from collections import Counter
from scapy.all import rdpcap, IP
packets = rdpcap('traffic_50.pcap')
src_ips = []
for pac in packets:
if IP in pac:
src_ips.append(pac[IP].src)
top3 = Counter(src_ips).most_common(3)
for ip, count in top3:
print(ip, count)