from scapy.all import rdpcap, TCP, UDP, ICMP, ARP packets = rdpcap("ultimate.pcapng") protocols = {"TCP": TCP, "UDP": UDP, "ICMP": ICMP, "ARP": ARP} stats = {name: 0 for name in [*protocols, "Others"]} for packet in packets: for name, layer in protocols.items(): if packet.haslayer(layer): stats[name] += 1 break stats["Others"] += 1 print("Répartition par protocole") for proto, count in stats.items(): if count > 0: print(f"{proto:6} : {count} paquets.")