### How many packets are?

using scapy
how to read a file named 'PCAP/ay2223_sasp_nmapcatured_1.pcap'
show the number of packet of the file ?



### What ports have been scanned?


using scapy
how to read a file named 'PCAP/ay2223_sasp_nmapcatured_1.pcap'
show the what ports have been scanned ?
classify them in source port and destination port
```python
from scapy.all import *

# Provide the path to your PCAP file
pcap_file = 'PCAP/ay2223_sasp_nmapcatured_1.pcap'

# Read the PCAP file
packets = rdpcap(pcap_file)

# Create an empty set to store unique destination ports
scanned_ports = set()

for packet in packets:
    # Check if it's a TCP packet with destination port information
    if TCP in packet and packet[TCP].dport not in scanned_ports:
        scanned_ports.add(packet[TCP].dport)

print("Ports that have been scanned:")
for port in sorted(scanned_ports):
    print(port)
```

### How many ports have been scanned?

using scapy
how to read a file named 'PCAP/ay2223_sasp_nmapcatured_1.pcap'
How many ports have been scanned ?

```python
from scapy.all import *

packets = rdpcap('PCAP/ay2223_sasp_nmapcatured_1.pcap')

scanned_ports = set()  # Set to store unique scanned ports

for pkt in packets:
    if pkt.haslayer(TCP):
        dst_port = pkt[TCP].dport  # Destination port
        scanned_ports.add(dst_port)

print("Number of ports scanned:", len(scanned_ports))

```

