1

I have assignment to Read packets from a file and output the details of those packets having. Do not fragment(DF) flag set for IP header and SYN and ACK flags set (together) for TCP header (all the three flags should be set). For packets qualifying the above condition print the following:

  • Packet number
  • Source IP address and Source port number
  • Destination IP address and Destination port number

I have done packet capture but not able to print values matching condition of all 3 flag set from that PCAP file

Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55

1 Answers1

0
print("Starting ")
for packet in PcapReader(filename):
   if packet[IP].flags == 'DF' and packet[TCP].flags == 'S' and packet[TCP].flags == 'A':
       print("Source IP address = {} , source port number = {} , destination IP addr = {} , destination port number = {} ".format(packet[IP].src,packet[TCP].sport,packet[IP].dst,packet[TCP].dport))
else:
   print("Finishing. ")
Nagmat
  • 373
  • 4
  • 14