TCPDump – Lost Packets

fedoralinuxtcpdump

Running, either in promiscuous mode or not :

tcpdump -i "$INTERFACE" -vvv -n -XX -S -s0 -e

I got a bunch of lines and this conclusion when I stopped it :

601 packets captured
938 packets received by filter
230 packets dropped by kernel

Why the difference ? Where are the 107 packets missing ? And is it possible at all to get/capture 100% of the packets on the local network – it's just me behind a router ?

Best Answer

When tcpdump "drops" packets, is because it has not enough buffer space to keep up with the packets arriving from the network.

The difference between packets captured and received can be due to implementations of the OS or tcpdump, or more commonly due to aborting the process with ^C.

Setting the buffer size per packet with "s0" has the consequence of setting it as 64KB per man tcpdump; normally at most I set it up as 1500 if using -X to see the whole packet, and if only using tcpdump to watch headers even less than that is needed - 160 bytes which is the size of IPv4 headers.

Normally working with the screen is also slower, if needing speed I would direct the output to a file if you have no need to watch it in true realtime.

From man "tcpdump":

"Note that taking larger snapshots both increases the amount of time it takes to process packets and, effectively, decreases the amount of packet buffering. This may cause packets to be lost. You should limit snaplen to the smallest number that will capture the protocol information you're interested in."

Related Question