tcpdump -i eth0 -X -nn -s0 udp port 12345 -w /tmp/hoge.cap
tcpdumpでこう書いたとき、ファイルに保存されないことがある。
ある程度溜まると、まとめて4096バイトずつ保存される。
つまり、これはバッファリングされてるやつ
liebestraumtomo.hatenablog.com
-U --packet-buffered If the -w option is not specified, or if it is specified but the --print flag is also specified, make the printed packet output ``packet-buffered''; i.e., as the description of the contents of each packet is printed, it will be written to the standard out- put, rather than, when not writing to a terminal, being written only when the output buffer fills. If the -w option is specified, make the saved raw packet output ``packet-buffered''; i.e., as each packet is saved, it will be written to the output file, rather than being written only when the output buffer fills. The -U flag will not be supported if tcpdump was built with an older version of libpcap that lacks the pcap_dump_flush(3PCAP) function.
-U をつけると、パケット単位でバッファリングになる。 つまり受信したらすぐ出力することになるので 実質バッファリングしない指定になる
tcpdump -i eth0 -X -nn -s0 udp port 12345 -U -w /tmp/hoge.cap
やったぜ