Tcpdump only showing output after stopping it

tcpdump

I am trying to see if I get ping packets through one interface but tcpdump shows nothing. However, as soon as I stop it (Ctrl + C), all the packets appear and the summary looks good.

For example:

11:49:45.486887 IP 11.0.0.1 > 11.0.0.9: ICMP echo reply, id 13532, seq 1, length 64

And here the summary:

10 packets captured
10 packets received by filter
0 packets dropped by kernel

I normally see the traffic "live" but I don't understand why now it is hidden until I stop tcpdump. Can somebody point me to what might be happening?

Best Answer

You probably want the -l or -U option. See the info in man page ...

   -l     Make  stdout  line buffered.  Useful if you want to see the data
          while capturing it.
          ...
          -U is similar to -l in its behavior, but it will cause output to
          be  ``packet-buffered'', so that the output is written to stdout
          at the end of each packet rather than at the end of  each  line;