I have program for extract PCAP ARP src_ip and Dest_IP and save in CSV file. i need code how to count Number of Times Src_IP is request to dest_ip (Example 192.168.0.1 src_IP try to connected 10 times with Dest_ip). so how to count duplicates IP in a Column. or how to count src to dest IP or any other idea for count duplicate IP in a Column pls.
below code I need to count number of times src to target
for ts, buf in pcap:
eth = dpkt.ethernet.Ethernet(buf)
# If the packet is not arp
if eth.type != 2054:
continue
try:
arp = eth.arp
except Exception as e:
continue
packet_time = datetime.datetime.utcfromtimestamp(ts).strftime("%m/%d/%Y,%H:%M:%S")
src = dpkt.socket.inet_ntoa(arp.spa)
tgt = dpkt.socket.inet_ntoa(arp.tpa)
collections.Counterclass: docs.python.org/3/library/collections.html#collections.Counter - Eric Fulmercsvmodule to read a CSV file! Python has quite a bit of useful functionality built into its standard library. docs.python.org/3/library/csv.html - Eric Fulmer