If you ever had to acquire packets from a network, you probably used tcpdump. Other tools (Wireshark, dumpcap, snort…) can do the same thing, but none is as widely used as tcpdump. tcpdump is simple to use, fast, and universally available (and free!).
So, let’s talk about speed and tcpdump. Everybody knows never to run tcpdump without the “-n” switch. But how do other command line switches affect performances? I did a bit of benchmarking to test different options.
I selected a 127 MByte pcap file (just something I had sitting around) collected on my Mac with tcpdump. Then, I used tcpdump with various command line options to measure the speed using the same system. I used this little test script:
for b in `seq 1 100`; do
tcpdump $arg /tmp/testfile > /dev/null
echo $arg $((end-start)) | tee -a tcpdump$arg.out
Note that I used “gdate” from homebrew. The default “date” command on MacOS does not have the “%N” option for fractional seconds. The output file was then analyzed with “datamash” (datamash -t ‘ ‘ mean 2 min 2 max 2). The data was a bit more noisy than I would have liked. I had to remove some outliers.
Command Line Options
In addition to the ‘n’ switch, both ‘q’ (Quiet) and ‘t’ (suppress timestamps) delivered nice performance gains. In particular, ‘t’ is an option you should consider if post-processing tcpdump files. When summarizing pcap files, the timestamp is often not needed. In particular, note the gain of using ‘q’ and ‘t’ simultaneously.
Adding verbosity is, of course, slowing things down. How much verbosity you add does not appear to affect the speed significantly.
(c) SANS Internet Storm Center. https://isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.