How do I get a specific range of packets from a large pcap file with tcpdump?

growse picture growse · Oct 28, 2013 · Viewed 14.6k times · Source

I've got a huge pcap file (100GB) and I'm interested in a small number of packets which I know are numbers 5,000,000 to 5,000,020.

How can I use tcpdump to read a pcap file, filter out packets by packet number (or range), and then write them out to a new pcap file?

Answer

pdp picture pdp · Nov 29, 2016

It is quite simple using editcap that comes along with Wireshark (at least on CentOS and Debian). For the 5,000,000 to 5,000,020 packet numbers, you can do:

editcap -r <big_pcap_file> <new_pcap_file> 5000000-5000020