This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

tcpdump - capture packets

0

When we use tcpdump, we see like the following at the end - is there any way to write only the packets captured to a file using the -w option (in this case save only 1310)? I want to do my analysis on the captured packets.

I am using this command

> sudo tcpdump -vv -s0 -i enp0s8 tcp and port 5201
1310 packets captured
133919 packets received by filter
132609 packets dropped by kernel

asked 14 May '17, 10:39

armodes's gravatar image

armodes
16181923
accept rate: 0%

edited 14 May '17, 13:13

grahamb's gravatar image

grahamb ♦
19.8k330206


One Answer:

0

That looks like your machine is simply too slow to write all packets to disk, or even get all of them from the network card into memory. You need a much much much faster capture machine :-)

answered 14 May '17, 11:27

Jasper's gravatar image

Jasper ♦♦
23.8k551284
accept rate: 18%

OK, in that case i will change a machine.

(14 May '17, 13:39) armodes

Note also that, in that example, tcpdump ''isn't'' writing packets to disk; the -w flag isn't being used, and the standard output isn't being redirected to a file. (Presumably it ''did'' print all 1310 packets before printing the captured/received/dropped message.)

Furthermore, tcpdump is dissecting the packets (because it's being run without -w), and that takes additional CPU time - and you're not running it with -n, so it's also trying to look up the source and destination IP addresses for the packets and report them as domain names, which can slow things down further.

(14 May '17, 19:18) Guy Harris ♦♦