├── CS-5.py └── README.md /CS-5.py: -------------------------------------------------------------------------------- 1 | #Saving and Reading Packets 2 | from scapy.all import sniff, IP, wrpcap, rdpcap 3 | 4 | packets = sniff(count=10) 5 | wrpcap("packets.pcap", packets) 6 | 7 | # Read packets from a file 8 | saved_packets = rdpcap("packets.pcap") 9 | for packet in saved_packets: 10 | print(packet.summary()) 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A packet analyzer, also known as a packet sniffer, is a tool used to capture and analyze network traffic. It can be useful for network troubleshooting, performance analysis, security monitoring, and understanding network protocols. In Python, we can create a packet analyzer using libraries such as scapy, pyshark, and socket. Here, we'll use scapy to build a simple packet analyzer. 2 | 3 | We'll us Scapy to save captured packets to a file and read them later for analysis This code snippet captures 10 packets, saves them to a file named packets.pcap, and then reads the packets back from the file for processing. 4 | --------------------------------------------------------------------------------