Capturing whole packet with tcpdump for analysis with wireshark
Capturing the hole packet on your NIC for later analysis with wireshark
$tcpdump -nnvvXSs 1514 -i em0 -w /tmp/em0.dumptcp
Will capture 1514 bytes of all packets on interface “em0” and dump it to the file “/tmp/em0.dumptcp”. You can then import the file into wireshark for analysis.
Explanation of Parameters
Text below is copied from tcpdump man page
Don’t convert protocol and port numbers etc. to names either.
Even more verbose output. For example, additional fields are printed from NFS reply packets, and SMB packets are fully decoded.
When printing hex, print ascii too. Thus if -x is also set, the packet is printed in hex/ascii. This is very handy for analysing new protocols. Even if -x is not also set, some parts of some packets may be printed in hex/ascii.
Print absolute, rather than relative, TCP sequence numbers.
Snarf snaplen bytes of data from each packet rather than the default of 68 (with SunOS’s NIT, the minimum is actually 96). 68 bytes is adequate for IP, ICMP, TCP and UDP but may truncate protocol information from name server and NFS packets (see below). Packets truncated because of a limited snapshot are indicated in the output with ``[|proto]“, where proto is the name of the protocol level at which the truncation has occurred. 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. Setting snaplen to 0 means use the required length to catch whole packets.
Listen on interface. If unspecified, tcpdump searches the system interface list for the lowest numbered, configured up interface (excluding loopback). Ties are broken by choosing the earliest match.
Write the raw packets to file rather than parsing and printing them out. They can later be printed with the
-r option. Standard output is used if file is