1TCPDUMP(8) System Manager's Manual TCPDUMP(8)
2
3
4
6 tcpdump - dump traffic on a network
7
9 tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
10 [ -c count ] [ --count ] [ -C file_size ]
11 [ -E spi@ipaddr algo:secret,... ]
12 [ -F file ] [ -G rotate_seconds ] [ -i interface ]
13 [ --immediate-mode ] [ -j tstamp_type ] [ -m module ]
14 [ -M secret ] [ --number ] [ --print ] [ -Q in|out|inout ]
15 [ -r file ] [ -s snaplen ] [ -T type ] [ --version ]
16 [ -V file ] [ -w file ] [ -W filecount ] [ -y datalinktype ]
17 [ -z postrotate-command ] [ -Z user ]
18 [ --time-stamp-precision=tstamp_precision ]
19 [ --micro ] [ --nano ]
20 [ expression ]
21
23 Tcpdump prints out a description of the contents of packets on a net‐
24 work interface that match the Boolean expression; the description is
25 preceded by a time stamp, printed, by default, as hours, minutes, sec‐
26 onds, and fractions of a second since midnight. It can also be run
27 with the -w flag, which causes it to save the packet data to a file for
28 later analysis, and/or with the -r flag, which causes it to read from a
29 saved packet file rather than to read packets from a network interface.
30 It can also be run with the -V flag, which causes it to read a list of
31 saved packet files. In all cases, only packets that match expression
32 will be processed by tcpdump.
33
34 Tcpdump will, if not run with the -c flag, continue capturing packets
35 until it is interrupted by a SIGINT signal (generated, for example, by
36 typing your interrupt character, typically control-C) or a SIGTERM sig‐
37 nal (typically generated with the kill(1) command); if run with the -c
38 flag, it will capture packets until it is interrupted by a SIGINT or
39 SIGTERM signal or the specified number of packets have been processed.
40
41 When tcpdump finishes capturing packets, it will report counts of:
42
43 packets ``captured'' (this is the number of packets that tcpdump
44 has received and processed);
45
46 packets ``received by filter'' (the meaning of this depends on
47 the OS on which you're running tcpdump, and possibly on the way
48 the OS was configured - if a filter was specified on the command
49 line, on some OSes it counts packets regardless of whether they
50 were matched by the filter expression and, even if they were
51 matched by the filter expression, regardless of whether tcpdump
52 has read and processed them yet, on other OSes it counts only
53 packets that were matched by the filter expression regardless of
54 whether tcpdump has read and processed them yet, and on other
55 OSes it counts only packets that were matched by the filter
56 expression and were processed by tcpdump);
57
58 packets ``dropped by kernel'' (this is the number of packets
59 that were dropped, due to a lack of buffer space, by the packet
60 capture mechanism in the OS on which tcpdump is running, if the
61 OS reports that information to applications; if not, it will be
62 reported as 0).
63
64 On platforms that support the SIGINFO signal, such as most BSDs
65 (including macOS) and Digital/Tru64 UNIX, it will report those counts
66 when it receives a SIGINFO signal (generated, for example, by typing
67 your ``status'' character, typically control-T, although on some plat‐
68 forms, such as macOS, the ``status'' character is not set by default,
69 so you must set it with stty(1) in order to use it) and will continue
70 capturing packets. On platforms that do not support the SIGINFO signal,
71 the same can be achieved by using the SIGUSR1 signal.
72
73 Using the SIGUSR2 signal along with the -w flag will forcibly flush the
74 packet buffer into the output file.
75
76 Reading packets from a network interface may require that you have spe‐
77 cial privileges; see the pcap(3PCAP) man page for details. Reading a
78 saved packet file doesn't require special privileges.
79
81 -A Print each packet (minus its link level header) in ASCII. Handy
82 for capturing web pages.
83
84 -b Print the AS number in BGP packets in ASDOT notation rather than
85 ASPLAIN notation.
86
87 -B buffer_size
88 --buffer-size=buffer_size
89 Set the operating system capture buffer size to buffer_size, in
90 units of KiB (1024 bytes).
91
92 -c count
93 Exit after receiving count packets.
94
95 --count
96 Print only on stderr the packet count when reading capture
97 file(s) instead of parsing/printing the packets. If a filter is
98 specified on the command line, tcpdump counts only packets that
99 were matched by the filter expression.
100
101 -C file_size
102 Before writing a raw packet to a savefile, check whether the
103 file is currently larger than file_size and, if so, close the
104 current savefile and open a new one. Savefiles after the first
105 savefile will have the name specified with the -w flag, with a
106 number after it, starting at 1 and continuing upward. The units
107 of file_size are millions of bytes (1,000,000 bytes, not
108 1,048,576 bytes).
109
110 Note that when used with -Z option (enabled by default), privi‐
111 leges are dropped before opening the first savefile.
112
113 -d Dump the compiled packet-matching code in a human readable form
114 to standard output and stop.
115
116 Please mind that although code compilation is always DLT-spe‐
117 cific, typically it is impossible (and unnecessary) to specify
118 which DLT to use for the dump because tcpdump uses either the
119 DLT of the input pcap file specified with -r, or the default DLT
120 of the network interface specified with -i, or the particular
121 DLT of the network interface specified with -y and -i respec‐
122 tively. In these cases the dump shows the same exact code that
123 would filter the input file or the network interface without -d.
124
125 However, when neither -r nor -i is specified, specifying -d pre‐
126 vents tcpdump from guessing a suitable network interface (see
127 -i). In this case the DLT defaults to EN10MB and can be set to
128 another valid value manually with -y.
129
130 -dd Dump packet-matching code as a C program fragment.
131
132 -ddd Dump packet-matching code as decimal numbers (preceded with a
133 count).
134
135 -D
136 --list-interfaces
137 Print the list of the network interfaces available on the system
138 and on which tcpdump can capture packets. For each network
139 interface, a number and an interface name, possibly followed by
140 a text description of the interface, are printed. The interface
141 name or the number can be supplied to the -i flag to specify an
142 interface on which to capture.
143
144 This can be useful on systems that don't have a command to list
145 them (e.g., Windows systems, or UNIX systems lacking ifconfig
146 -a); the number can be useful on Windows 2000 and later systems,
147 where the interface name is a somewhat complex string.
148
149 The -D flag will not be supported if tcpdump was built with an
150 older version of libpcap that lacks the pcap_findalldevs(3PCAP)
151 function.
152
153 -e Print the link-level header on each dump line. This can be
154 used, for example, to print MAC layer addresses for protocols
155 such as Ethernet and IEEE 802.11.
156
157 -E Use spi@ipaddr algo:secret for decrypting IPsec ESP packets that
158 are addressed to addr and contain Security Parameter Index value
159 spi. This combination may be repeated with comma or newline sep‐
160 aration.
161
162 Note that setting the secret for IPv4 ESP packets is supported
163 at this time.
164
165 Algorithms may be des-cbc, 3des-cbc, blowfish-cbc, rc3-cbc,
166 cast128-cbc, or none. The default is des-cbc. The ability to
167 decrypt packets is only present if tcpdump was compiled with
168 cryptography enabled.
169
170 secret is the ASCII text for ESP secret key. If preceded by 0x,
171 then a hex value will be read.
172
173 The option assumes RFC2406 ESP, not RFC1827 ESP. The option is
174 only for debugging purposes, and the use of this option with a
175 true `secret' key is discouraged. By presenting IPsec secret
176 key onto command line you make it visible to others, via ps(1)
177 and other occasions.
178
179 In addition to the above syntax, the syntax file name may be
180 used to have tcpdump read the provided file in. The file is
181 opened upon receiving the first ESP packet, so any special per‐
182 missions that tcpdump may have been given should already have
183 been given up.
184
185 -f Print `foreign' IPv4 addresses numerically rather than symboli‐
186 cally (this option is intended to get around serious brain dam‐
187 age in Sun's NIS server — usually it hangs forever translating
188 non-local internet numbers).
189
190 The test for `foreign' IPv4 addresses is done using the IPv4
191 address and netmask of the interface on which capture is being
192 done. If that address or netmask are not available, available,
193 either because the interface on which capture is being done has
194 no address or netmask or because the capture is being done on
195 the Linux "any" interface, which can capture on more than one
196 interface, this option will not work correctly.
197
198 -F file
199 Use file as input for the filter expression. An additional
200 expression given on the command line is ignored.
201
202 -G rotate_seconds
203 If specified, rotates the dump file specified with the -w option
204 every rotate_seconds seconds. Savefiles will have the name
205 specified by -w which should include a time format as defined by
206 strftime(3). If no time format is specified, each new file will
207 overwrite the previous. Whenever a generated filename is not
208 unique, tcpdump will overwrite the pre-existing data; providing
209 a time specification that is coarser than the capture period is
210 therefore not advised.
211
212 If used in conjunction with the -C option, filenames will take
213 the form of `file<count>'.
214
215 Note that when used with -Z option (enabled by default), privi‐
216 leges are dropped before opening the first savefile.
217
218 -h
219 --help Print the tcpdump and libpcap version strings, print a usage
220 message, and exit.
221
222 --version
223 Print the tcpdump and libpcap version strings and exit.
224
225 -H Attempt to detect 802.11s draft mesh headers.
226
227 -i interface
228 --interface=interface
229 Listen, report the list of link-layer types, report the list of
230 time stamp types, or report the results of compiling a filter
231 expression on interface. If unspecified and if the -d flag is
232 not given, tcpdump searches the system interface list for the
233 lowest numbered, configured up interface (excluding loopback),
234 which may turn out to be, for example, ``eth0''.
235
236 On Linux systems with 2.2 or later kernels, an interface argu‐
237 ment of ``any'' can be used to capture packets from all inter‐
238 faces. Note that captures on the ``any'' device will not be
239 done in promiscuous mode.
240
241 If the -D flag is supported, an interface number as printed by
242 that flag can be used as the interface argument, if no interface
243 on the system has that number as a name.
244
245 -I
246 --monitor-mode
247 Put the interface in "monitor mode"; this is supported only on
248 IEEE 802.11 Wi-Fi interfaces, and supported only on some operat‐
249 ing systems.
250
251 Note that in monitor mode the adapter might disassociate from
252 the network with which it's associated, so that you will not be
253 able to use any wireless networks with that adapter. This could
254 prevent accessing files on a network server, or resolving host
255 names or network addresses, if you are capturing in monitor mode
256 and are not connected to another network with another adapter.
257
258 This flag will affect the output of the -L flag. If -I isn't
259 specified, only those link-layer types available when not in
260 monitor mode will be shown; if -I is specified, only those link-
261 layer types available when in monitor mode will be shown.
262
263 --immediate-mode
264 Capture in "immediate mode". In this mode, packets are deliv‐
265 ered to tcpdump as soon as they arrive, rather than being
266 buffered for efficiency. This is the default when printing
267 packets rather than saving packets to a ``savefile'' if the
268 packets are being printed to a terminal rather than to a file or
269 pipe.
270
271 -j tstamp_type
272 --time-stamp-type=tstamp_type
273 Set the time stamp type for the capture to tstamp_type. The
274 names to use for the time stamp types are given in
275 pcap-tstamp(7); not all the types listed there will necessarily
276 be valid for any given interface.
277
278 -J
279 --list-time-stamp-types
280 List the supported time stamp types for the interface and exit.
281 If the time stamp type cannot be set for the interface, no time
282 stamp types are listed.
283
284 --time-stamp-precision=tstamp_precision
285 When capturing, set the time stamp precision for the capture to
286 tstamp_precision. Note that availability of high precision time
287 stamps (nanoseconds) and their actual accuracy is platform and
288 hardware dependent. Also note that when writing captures made
289 with nanosecond accuracy to a savefile, the time stamps are
290 written with nanosecond resolution, and the file is written with
291 a different magic number, to indicate that the time stamps are
292 in seconds and nanoseconds; not all programs that read pcap
293 savefiles will be able to read those captures.
294
295 When reading a savefile, convert time stamps to the precision
296 specified by timestamp_precision, and display them with that
297 resolution. If the precision specified is less than the preci‐
298 sion of time stamps in the file, the conversion will lose preci‐
299 sion.
300
301 The supported values for timestamp_precision are micro for
302 microsecond resolution and nano for nanosecond resolution. The
303 default is microsecond resolution.
304
305 --micro
306 --nano Shorthands for --time-stamp-precision=micro or --time-stamp-pre‐
307 cision=nano, adjusting the time stamp precision accordingly.
308 When reading packets from a savefile, using --micro truncates
309 time stamps if the savefile was created with nanosecond preci‐
310 sion. In contrast, a savefile created with microsecond preci‐
311 sion will have trailing zeroes added to the time stamp when
312 --nano is used.
313
314 -K
315 --dont-verify-checksums
316 Don't attempt to verify IP, TCP, or UDP checksums. This is use‐
317 ful for interfaces that perform some or all of those checksum
318 calculation in hardware; otherwise, all outgoing TCP checksums
319 will be flagged as bad.
320
321 -l Make stdout line buffered. Useful if you want to see the data
322 while capturing it. E.g.,
323
324 tcpdump -l | tee dat
325
326 or
327
328 tcpdump -l > dat & tail -f dat
329
330 Note that on Windows,``line buffered'' means ``unbuffered'', so
331 that WinDump will write each character individually if -l is
332 specified.
333
334 -U is similar to -l in its behavior, but it will cause output to
335 be ``packet-buffered'', so that the output is written to stdout
336 at the end of each packet rather than at the end of each line;
337 this is buffered on all platforms, including Windows.
338
339 -L
340 --list-data-link-types
341 List the known data link types for the interface, in the speci‐
342 fied mode, and exit. The list of known data link types may be
343 dependent on the specified mode; for example, on some platforms,
344 a Wi-Fi interface might support one set of data link types when
345 not in monitor mode (for example, it might support only fake
346 Ethernet headers, or might support 802.11 headers but not sup‐
347 port 802.11 headers with radio information) and another set of
348 data link types when in monitor mode (for example, it might sup‐
349 port 802.11 headers, or 802.11 headers with radio information,
350 only in monitor mode).
351
352 -m module
353 Load SMI MIB module definitions from file module. This option
354 can be used several times to load several MIB modules into tcp‐
355 dump.
356
357 -M secret
358 Use secret as a shared secret for validating the digests found
359 in TCP segments with the TCP-MD5 option (RFC 2385), if present.
360
361 -n Don't convert host addresses to names. This can be used to
362 avoid DNS lookups.
363
364 -nn Don't convert protocol and port numbers etc. to names either.
365
366 -N Don't print domain name qualification of host names. E.g., if
367 you give this flag then tcpdump will print ``nic'' instead of
368 ``nic.ddn.mil''.
369
370 -#
371 --number
372 Print an optional packet number at the beginning of the line.
373
374 -O
375 --no-optimize
376 Do not run the packet-matching code optimizer. This is useful
377 only if you suspect a bug in the optimizer.
378
379 -p
380 --no-promiscuous-mode
381 Don't put the interface into promiscuous mode. Note that the
382 interface might be in promiscuous mode for some other reason;
383 hence, `-p' cannot be used as an abbreviation for `ether host
384 {local-hw-addr} or ether broadcast'.
385
386 --print
387 Print parsed packet output, even if the raw packets are being
388 saved to a file with the -w flag.
389
390 -Q direction
391 --direction=direction
392 Choose send/receive direction direction for which packets should
393 be captured. Possible values are `in', `out' and `inout'. Not
394 available on all platforms.
395
396 -q Quick (quiet?) output. Print less protocol information so out‐
397 put lines are shorter.
398
399 -r file
400 Read packets from file (which was created with the -w option or
401 by other tools that write pcap or pcapng files). Standard input
402 is used if file is ``-''.
403
404 -S
405 --absolute-tcp-sequence-numbers
406 Print absolute, rather than relative, TCP sequence numbers.
407
408 -s snaplen
409 --snapshot-length=snaplen
410 Snarf snaplen bytes of data from each packet rather than the
411 default of 262144 bytes. Packets truncated because of a limited
412 snapshot are indicated in the output with ``[|proto]'', where
413 proto is the name of the protocol level at which the truncation
414 has occurred.
415
416 Note that taking larger snapshots both increases the amount of
417 time it takes to process packets and, effectively, decreases the
418 amount of packet buffering. This may cause packets to be lost.
419 Note also that taking smaller snapshots will discard data from
420 protocols above the transport layer, which loses information
421 that may be important. NFS and AFS requests and replies, for
422 example, are very large, and much of the detail won't be avail‐
423 able if a too-short snapshot length is selected.
424
425 If you need to reduce the snapshot size below the default, you
426 should limit snaplen to the smallest number that will capture
427 the protocol information you're interested in. Setting snaplen
428 to 0 sets it to the default of 262144, for backwards compatibil‐
429 ity with recent older versions of tcpdump.
430
431 -T type
432 Force packets selected by "expression" to be interpreted the
433 specified type. Currently known types are aodv (Ad-hoc On-
434 demand Distance Vector protocol), carp (Common Address Redun‐
435 dancy Protocol), cnfp (Cisco NetFlow protocol), domain (Domain
436 Name System), lmp (Link Management Protocol), pgm (Pragmatic
437 General Multicast), pgm_zmtp1 (ZMTP/1.0 inside PGM/EPGM), ptp
438 (Precision Time Protocol), radius (RADIUS), resp (REdis Serial‐
439 ization Protocol), rpc (Remote Procedure Call), rtcp (Real-Time
440 Applications control protocol), rtp (Real-Time Applications pro‐
441 tocol), snmp (Simple Network Management Protocol), someip
442 (SOME/IP), tftp (Trivial File Transfer Protocol), vat (Visual
443 Audio Tool), vxlan (Virtual eXtensible Local Area Network), wb
444 (distributed White Board) and zmtp1 (ZeroMQ Message Transport
445 Protocol 1.0).
446
447 Note that the pgm type above affects UDP interpretation only,
448 the native PGM is always recognised as IP protocol 113 regard‐
449 less. UDP-encapsulated PGM is often called "EPGM" or "PGM/UDP".
450
451 Note that the pgm_zmtp1 type above affects interpretation of
452 both native PGM and UDP at once. During the native PGM decoding
453 the application data of an ODATA/RDATA packet would be decoded
454 as a ZeroMQ datagram with ZMTP/1.0 frames. During the UDP
455 decoding in addition to that any UDP packet would be treated as
456 an encapsulated PGM packet.
457
458 -t Don't print a timestamp on each dump line.
459
460 -tt Print the timestamp, as seconds since January 1, 1970, 00:00:00,
461 UTC, and fractions of a second since that time, on each dump
462 line.
463
464 -ttt Print a delta (microsecond or nanosecond resolution depending on
465 the --time-stamp-precision option) between current and previous
466 line on each dump line. The default is microsecond resolution.
467
468 -tttt Print a timestamp, as hours, minutes, seconds, and fractions of
469 a second since midnight, preceded by the date, on each dump
470 line.
471
472 -ttttt Print a delta (microsecond or nanosecond resolution depending on
473 the --time-stamp-precision option) between current and first
474 line on each dump line. The default is microsecond resolution.
475
476 -u Print undecoded NFS handles.
477
478 -U
479 --packet-buffered
480 If the -w option is not specified, or if it is specified but the
481 --print flag is also specified, make the printed packet output
482 ``packet-buffered''; i.e., as the description of the contents of
483 each packet is printed, it will be written to the standard out‐
484 put, rather than, when not writing to a terminal, being written
485 only when the output buffer fills.
486
487 If the -w option is specified, make the saved raw packet output
488 ``packet-buffered''; i.e., as each packet is saved, it will be
489 written to the output file, rather than being written only when
490 the output buffer fills.
491
492 The -U flag will not be supported if tcpdump was built with an
493 older version of libpcap that lacks the pcap_dump_flush(3PCAP)
494 function.
495
496 -v When parsing and printing, produce (slightly more) verbose out‐
497 put. For example, the time to live, identification, total
498 length and options in an IP packet are printed. Also enables
499 additional packet integrity checks such as verifying the IP and
500 ICMP header checksum.
501
502 When writing to a file with the -w option and at the same time
503 not reading from a file with the -r option, report to stderr,
504 once per second, the number of packets captured. In Solaris,
505 FreeBSD and possibly other operating systems this periodic
506 update currently can cause loss of captured packets on their way
507 from the kernel to tcpdump.
508
509 -vv Even more verbose output. For example, additional fields are
510 printed from NFS reply packets, and SMB packets are fully
511 decoded.
512
513 -vvv Even more verbose output. For example, telnet SB ... SE options
514 are printed in full. With -X Telnet options are printed in hex
515 as well.
516
517 -V file
518 Read a list of filenames from file. Standard input is used if
519 file is ``-''.
520
521 -w file
522 Write the raw packets to file rather than parsing and printing
523 them out. They can later be printed with the -r option. Stan‐
524 dard output is used if file is ``-''.
525
526 This output will be buffered if written to a file or pipe, so a
527 program reading from the file or pipe may not see packets for an
528 arbitrary amount of time after they are received. Use the -U
529 flag to cause packets to be written as soon as they are
530 received.
531
532 The MIME type application/vnd.tcpdump.pcap has been registered
533 with IANA for pcap files. The filename extension .pcap appears
534 to be the most commonly used along with .cap and .dmp. Tcpdump
535 itself doesn't check the extension when reading capture files
536 and doesn't add an extension when writing them (it uses magic
537 numbers in the file header instead). However, many operating
538 systems and applications will use the extension if it is present
539 and adding one (e.g. .pcap) is recommended.
540
541 See pcap-savefile(5) for a description of the file format.
542
543 -W filecount
544 Used in conjunction with the -C option, this will limit the num‐
545 ber of files created to the specified number, and begin over‐
546 writing files from the beginning, thus creating a 'rotating'
547 buffer. In addition, it will name the files with enough leading
548 0s to support the maximum number of files, allowing them to sort
549 correctly.
550
551 Used in conjunction with the -G option, this will limit the num‐
552 ber of rotated dump files that get created, exiting with status
553 0 when reaching the limit.
554
555 If used in conjunction with both -C and -G, the -W option will
556 currently be ignored, and will only affect the file name.
557
558 -x When parsing and printing, in addition to printing the headers
559 of each packet, print the data of each packet (minus its link
560 level header) in hex. The smaller of the entire packet or
561 snaplen bytes will be printed. Note that this is the entire
562 link-layer packet, so for link layers that pad (e.g. Ethernet),
563 the padding bytes will also be printed when the higher layer
564 packet is shorter than the required padding. In the current
565 implementation this flag may have the same effect as -xx if the
566 packet is truncated.
567
568 -xx When parsing and printing, in addition to printing the headers
569 of each packet, print the data of each packet, including its
570 link level header, in hex.
571
572 -X When parsing and printing, in addition to printing the headers
573 of each packet, print the data of each packet (minus its link
574 level header) in hex and ASCII. This is very handy for
575 analysing new protocols. In the current implementation this
576 flag may have the same effect as -XX if the packet is truncated.
577
578 -XX When parsing and printing, in addition to printing the headers
579 of each packet, print the data of each packet, including its
580 link level header, in hex and ASCII.
581
582 -y datalinktype
583 --linktype=datalinktype
584 Set the data link type to use while capturing packets (see -L)
585 or just compiling and dumping packet-matching code (see -d) to
586 datalinktype.
587
588 -z postrotate-command
589 Used in conjunction with the -C or -G options, this will make
590 tcpdump run " postrotate-command file " where file is the save‐
591 file being closed after each rotation. For example, specifying
592 -z gzip or -z bzip2 will compress each savefile using gzip or
593 bzip2.
594
595 Note that tcpdump will run the command in parallel to the cap‐
596 ture, using the lowest priority so that this doesn't disturb the
597 capture process.
598
599 And in case you would like to use a command that itself takes
600 flags or different arguments, you can always write a shell
601 script that will take the savefile name as the only argument,
602 make the flags & arguments arrangements and execute the command
603 that you want.
604
605 -Z user
606 --relinquish-privileges=user
607 If tcpdump is running as root, after opening the capture device
608 or input savefile, but before opening any savefiles for output,
609 change the user ID to user and the group ID to the primary group
610 of user.
611
612 This behavior is enabled by default (-Z tcpdump), and can be
613 disabled by -Z root.
614
615
616 expression
617 selects which packets will be dumped. If no expression is
618 given, all packets on the net will be dumped. Otherwise, only
619 packets for which expression is `true' will be dumped.
620
621 For the expression syntax, see pcap-filter(7).
622
623 The expression argument can be passed to tcpdump as either a
624 single Shell argument, or as multiple Shell arguments, whichever
625 is more convenient. Generally, if the expression contains Shell
626 metacharacters, such as backslashes used to escape protocol
627 names, it is easier to pass it as a single, quoted argument
628 rather than to escape the Shell metacharacters. Multiple argu‐
629 ments are concatenated with spaces before being parsed.
630
632 To print all packets arriving at or departing from sundown:
633 tcpdump host sundown
634
635 To print traffic between helios and either hot or ace:
636 tcpdump host helios and \( hot or ace \)
637
638 To print all IP packets between ace and any host except helios:
639 tcpdump ip host ace and not helios
640
641 To print all traffic between local hosts and hosts at Berkeley:
642 tcpdump net ucb-ether
643
644 To print all ftp traffic through internet gateway snup: (note that the
645 expression is quoted to prevent the shell from (mis-)interpreting the
646 parentheses):
647 tcpdump 'gateway snup and (port ftp or ftp-data)'
648
649 To print traffic neither sourced from nor destined for local hosts (if
650 you gateway to one other net, this stuff should never make it onto your
651 local net).
652 tcpdump ip and not net localnet
653
654 To print the start and end packets (the SYN and FIN packets) of each
655 TCP conversation that involves a non-local host.
656 tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet'
657
658 To print the TCP packets with flags RST and ACK both set. (i.e. select
659 only the RST and ACK flags in the flags field, and if the result is
660 "RST and ACK both set", match)
661 tcpdump 'tcp[tcpflags] & (tcp-rst|tcp-ack) == (tcp-rst|tcp-ack)'
662
663 To print all IPv4 HTTP packets to and from port 80, i.e. print only
664 packets that contain data, not, for example, SYN and FIN packets and
665 ACK-only packets. (IPv6 is left as an exercise for the reader.)
666 tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
667
668 To print IP packets longer than 576 bytes sent through gateway snup:
669 tcpdump 'gateway snup and ip[2:2] > 576'
670
671 To print IP broadcast or multicast packets that were not sent via Eth‐
672 ernet broadcast or multicast:
673 tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'
674
675 To print all ICMP packets that are not echo requests/replies (i.e., not
676 ping packets):
677 tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'
678
680 The output of tcpdump is protocol dependent. The following gives a
681 brief description and examples of most of the formats.
682
683 Timestamps
684
685 By default, all output lines are preceded by a timestamp. The time‐
686 stamp is the current clock time in the form
687 hh:mm:ss.frac
688 and is as accurate as the kernel's clock. The timestamp reflects the
689 time the kernel applied a time stamp to the packet. No attempt is made
690 to account for the time lag between when the network interface finished
691 receiving the packet from the network and when the kernel applied a
692 time stamp to the packet; that time lag could include a delay between
693 the time when the network interface finished receiving a packet from
694 the network and the time when an interrupt was delivered to the kernel
695 to get it to read the packet and a delay between the time when the ker‐
696 nel serviced the `new packet' interrupt and the time when it applied a
697 time stamp to the packet.
698
699 Link Level Headers
700
701 If the '-e' option is given, the link level header is printed out. On
702 Ethernets, the source and destination addresses, protocol, and packet
703 length are printed.
704
705 On FDDI networks, the '-e' option causes tcpdump to print the `frame
706 control' field, the source and destination addresses, and the packet
707 length. (The `frame control' field governs the interpretation of the
708 rest of the packet. Normal packets (such as those containing IP data‐
709 grams) are `async' packets, with a priority value between 0 and 7; for
710 example, `async4'. Such packets are assumed to contain an 802.2 Logi‐
711 cal Link Control (LLC) packet; the LLC header is printed if it is not
712 an ISO datagram or a so-called SNAP packet.
713
714 On Token Ring networks, the '-e' option causes tcpdump to print the
715 `access control' and `frame control' fields, the source and destination
716 addresses, and the packet length. As on FDDI networks, packets are
717 assumed to contain an LLC packet. Regardless of whether the '-e'
718 option is specified or not, the source routing information is printed
719 for source-routed packets.
720
721 On 802.11 networks, the '-e' option causes tcpdump to print the `frame
722 control' fields, all of the addresses in the 802.11 header, and the
723 packet length. As on FDDI networks, packets are assumed to contain an
724 LLC packet.
725
726 (N.B.: The following description assumes familiarity with the SLIP com‐
727 pression algorithm described in RFC-1144.)
728
729 On SLIP links, a direction indicator (``I'' for inbound, ``O'' for out‐
730 bound), packet type, and compression information are printed out. The
731 packet type is printed first. The three types are ip, utcp, and ctcp.
732 No further link information is printed for ip packets. For TCP pack‐
733 ets, the connection identifier is printed following the type. If the
734 packet is compressed, its encoded header is printed out. The special
735 cases are printed out as *S+n and *SA+n, where n is the amount by which
736 the sequence number (or sequence number and ack) has changed. If it is
737 not a special case, zero or more changes are printed. A change is
738 indicated by U (urgent pointer), W (window), A (ack), S (sequence num‐
739 ber), and I (packet ID), followed by a delta (+n or -n), or a new value
740 (=n). Finally, the amount of data in the packet and compressed header
741 length are printed.
742
743 For example, the following line shows an outbound compressed TCP
744 packet, with an implicit connection identifier; the ack has changed by
745 6, the sequence number by 49, and the packet ID by 6; there are 3 bytes
746 of data and 6 bytes of compressed header:
747 O ctcp * A+6 S+49 I+6 3 (6)
748
749 ARP/RARP Packets
750
751 ARP/RARP output shows the type of request and its arguments. The for‐
752 mat is intended to be self explanatory. Here is a short sample taken
753 from the start of an `rlogin' from host rtsg to host csam:
754 arp who-has csam tell rtsg
755 arp reply csam is-at CSAM
756 The first line says that rtsg sent an ARP packet asking for the Ether‐
757 net address of internet host csam. Csam replies with its Ethernet
758 address (in this example, Ethernet addresses are in caps and internet
759 addresses in lower case).
760
761 This would look less redundant if we had done tcpdump -n:
762 arp who-has 128.3.254.6 tell 128.3.254.68
763 arp reply 128.3.254.6 is-at 02:07:01:00:01:c4
764
765 If we had done tcpdump -e, the fact that the first packet is broadcast
766 and the second is point-to-point would be visible:
767 RTSG Broadcast 0806 64: arp who-has csam tell rtsg
768 CSAM RTSG 0806 64: arp reply csam is-at CSAM
769 For the first packet this says the Ethernet source address is RTSG, the
770 destination is the Ethernet broadcast address, the type field contained
771 hex 0806 (type ETHER_ARP) and the total length was 64 bytes.
772
773 IPv4 Packets
774
775 If the link-layer header is not being printed, for IPv4 packets, IP is
776 printed after the time stamp.
777
778 If the -v flag is specified, information from the IPv4 header is shown
779 in parentheses after the IP or the link-layer header. The general for‐
780 mat of this information is:
781 tos tos, ttl ttl, id id, offset offset, flags [flags], proto proto, length length, options (options)
782 tos is the type of service field; if the ECN bits are non-zero, those
783 are reported as ECT(1), ECT(0), or CE. ttl is the time-to-live; it is
784 not reported if it is zero. id is the IP identification field. offset
785 is the fragment offset field; it is printed whether this is part of a
786 fragmented datagram or not. flags are the MF and DF flags; + is
787 reported if MF is set, and DF is reported if F is set. If neither are
788 set, . is reported. proto is the protocol ID field. length is the
789 total length field. options are the IP options, if any.
790
791 Next, for TCP and UDP packets, the source and destination IP addresses
792 and TCP or UDP ports, with a dot between each IP address and its corre‐
793 sponding port, will be printed, with a > separating the source and des‐
794 tination. For other protocols, the addresses will be printed, with a >
795 separating the source and destination. Higher level protocol informa‐
796 tion, if any, will be printed after that.
797
798 For fragmented IP datagrams, the first fragment contains the higher
799 level protocol header; fragments after the first contain no higher
800 level protocol header. Fragmentation information will be printed only
801 with the -v flag, in the IP header information, as described above.
802
803 TCP Packets
804
805 (N.B.:The following description assumes familiarity with the TCP proto‐
806 col described in RFC-793. If you are not familiar with the protocol,
807 this description will not be of much use to you.)
808
809 The general format of a TCP protocol line is:
810 src > dst: Flags [tcpflags], seq data-seqno, ack ackno, win window, urg urgent, options [opts], length len
811 Src and dst are the source and destination IP addresses and ports.
812 Tcpflags are some combination of S (SYN), F (FIN), P (PUSH), R (RST), U
813 (URG), W (ECN CWR), E (ECN-Echo) or `.' (ACK), or `none' if no flags
814 are set. Data-seqno describes the portion of sequence space covered by
815 the data in this packet (see example below). Ackno is sequence number
816 of the next data expected the other direction on this connection. Win‐
817 dow is the number of bytes of receive buffer space available the other
818 direction on this connection. Urg indicates there is `urgent' data in
819 the packet. Opts are TCP options (e.g., mss 1024). Len is the length
820 of payload data.
821
822 Iptype, Src, dst, and flags are always present. The other fields
823 depend on the contents of the packet's TCP protocol header and are out‐
824 put only if appropriate.
825
826 Here is the opening portion of an rlogin from host rtsg to host csam.
827 IP rtsg.1023 > csam.login: Flags [S], seq 768512:768512, win 4096, opts [mss 1024]
828 IP csam.login > rtsg.1023: Flags [S.], seq, 947648:947648, ack 768513, win 4096, opts [mss 1024]
829 IP rtsg.1023 > csam.login: Flags [.], ack 1, win 4096
830 IP rtsg.1023 > csam.login: Flags [P.], seq 1:2, ack 1, win 4096, length 1
831 IP csam.login > rtsg.1023: Flags [.], ack 2, win 4096
832 IP rtsg.1023 > csam.login: Flags [P.], seq 2:21, ack 1, win 4096, length 19
833 IP csam.login > rtsg.1023: Flags [P.], seq 1:2, ack 21, win 4077, length 1
834 IP csam.login > rtsg.1023: Flags [P.], seq 2:3, ack 21, win 4077, urg 1, length 1
835 IP csam.login > rtsg.1023: Flags [P.], seq 3:4, ack 21, win 4077, urg 1, length 1
836 The first line says that TCP port 1023 on rtsg sent a packet to port
837 login on csam. The S indicates that the SYN flag was set. The packet
838 sequence number was 768512 and it contained no data. (The notation is
839 `first:last' which means `sequence numbers first up to but not includ‐
840 ing last'.) There was no piggy-backed ACK, the available receive win‐
841 dow was 4096 bytes and there was a max-segment-size option requesting
842 an MSS of 1024 bytes.
843
844 Csam replies with a similar packet except it includes a piggy-backed
845 ACK for rtsg's SYN. Rtsg then ACKs csam's SYN. The `.' means the ACK
846 flag was set. The packet contained no data so there is no data
847 sequence number or length. Note that the ACK sequence number is a
848 small integer (1). The first time tcpdump sees a TCP `conversation',
849 it prints the sequence number from the packet. On subsequent packets
850 of the conversation, the difference between the current packet's
851 sequence number and this initial sequence number is printed. This
852 means that sequence numbers after the first can be interpreted as rela‐
853 tive byte positions in the conversation's data stream (with the first
854 data byte each direction being `1'). `-S' will override this feature,
855 causing the original sequence numbers to be output.
856
857 On the 6th line, rtsg sends csam 19 bytes of data (bytes 2 through 20
858 in the rtsg → csam side of the conversation). The PUSH flag is set in
859 the packet. On the 7th line, csam says it's received data sent by rtsg
860 up to but not including byte 21. Most of this data is apparently sit‐
861 ting in the socket buffer since csam's receive window has gotten 19
862 bytes smaller. Csam also sends one byte of data to rtsg in this
863 packet. On the 8th and 9th lines, csam sends two bytes of urgent,
864 pushed data to rtsg.
865
866 If the snapshot was small enough that tcpdump didn't capture the full
867 TCP header, it interprets as much of the header as it can and then
868 reports ``[|tcp]'' to indicate the remainder could not be interpreted.
869 If the header contains a bogus option (one with a length that's either
870 too small or beyond the end of the header), tcpdump reports it as
871 ``[bad opt]'' and does not interpret any further options (since it's
872 impossible to tell where they start). If the header length indicates
873 options are present but the IP datagram length is not long enough for
874 the options to actually be there, tcpdump reports it as ``[bad hdr
875 length]''.
876
877 Capturing TCP packets with particular flag combinations (SYN-ACK, URG-
878 ACK, etc.)
879
880 There are 8 bits in the control bits section of the TCP header:
881
882 CWR | ECE | URG | ACK | PSH | RST | SYN | FIN
883
884 Let's assume that we want to watch packets used in establishing a TCP
885 connection. Recall that TCP uses a 3-way handshake protocol when it
886 initializes a new connection; the connection sequence with regard to
887 the TCP control bits is
888
889 1) Caller sends SYN
890 2) Recipient responds with SYN, ACK
891 3) Caller sends ACK
892
893 Now we're interested in capturing packets that have only the SYN bit
894 set (Step 1). Note that we don't want packets from step 2 (SYN-ACK),
895 just a plain initial SYN. What we need is a correct filter expression
896 for tcpdump.
897
898 Recall the structure of a TCP header without options:
899
900 0 15 31
901 -----------------------------------------------------------------
902 | source port | destination port |
903 -----------------------------------------------------------------
904 | sequence number |
905 -----------------------------------------------------------------
906 | acknowledgment number |
907 -----------------------------------------------------------------
908 | HL | rsvd |C|E|U|A|P|R|S|F| window size |
909 -----------------------------------------------------------------
910 | TCP checksum | urgent pointer |
911 -----------------------------------------------------------------
912
913 A TCP header usually holds 20 octets of data, unless options are
914 present. The first line of the graph contains octets 0 - 3, the second
915 line shows octets 4 - 7 etc.
916
917 Starting to count with 0, the relevant TCP control bits are contained
918 in octet 13:
919
920 0 7| 15| 23| 31
921 ----------------|---------------|---------------|----------------
922 | HL | rsvd |C|E|U|A|P|R|S|F| window size |
923 ----------------|---------------|---------------|----------------
924 | | 13th octet | | |
925
926 Let's have a closer look at octet no. 13:
927
928 | |
929 |---------------|
930 |C|E|U|A|P|R|S|F|
931 |---------------|
932 |7 5 3 0|
933
934 These are the TCP control bits we are interested in. We have numbered
935 the bits in this octet from 0 to 7, right to left, so the PSH bit is
936 bit number 3, while the URG bit is number 5.
937
938 Recall that we want to capture packets with only SYN set. Let's see
939 what happens to octet 13 if a TCP datagram arrives with the SYN bit set
940 in its header:
941
942 |C|E|U|A|P|R|S|F|
943 |---------------|
944 |0 0 0 0 0 0 1 0|
945 |---------------|
946 |7 6 5 4 3 2 1 0|
947
948 Looking at the control bits section we see that only bit number 1 (SYN)
949 is set.
950
951 Assuming that octet number 13 is an 8-bit unsigned integer in network
952 byte order, the binary value of this octet is
953
954 00000010
955
956 and its decimal representation is
957
958 7 6 5 4 3 2 1 0
959 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2 = 2
960
961 We're almost done, because now we know that if only SYN is set, the
962 value of the 13th octet in the TCP header, when interpreted as a 8-bit
963 unsigned integer in network byte order, must be exactly 2.
964
965 This relationship can be expressed as
966 tcp[13] == 2
967
968 We can use this expression as the filter for tcpdump in order to watch
969 packets which have only SYN set:
970 tcpdump -i xl0 tcp[13] == 2
971
972 The expression says "let the 13th octet of a TCP datagram have the dec‐
973 imal value 2", which is exactly what we want.
974
975 Now, let's assume that we need to capture SYN packets, but we don't
976 care if ACK or any other TCP control bit is set at the same time.
977 Let's see what happens to octet 13 when a TCP datagram with SYN-ACK set
978 arrives:
979
980 |C|E|U|A|P|R|S|F|
981 |---------------|
982 |0 0 0 1 0 0 1 0|
983 |---------------|
984 |7 6 5 4 3 2 1 0|
985
986 Now bits 1 and 4 are set in the 13th octet. The binary value of octet
987 13 is
988
989 00010010
990
991 which translates to decimal
992
993 7 6 5 4 3 2 1 0
994 0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2 = 18
995
996 Now we can't just use 'tcp[13] == 18' in the tcpdump filter expression,
997 because that would select only those packets that have SYN-ACK set, but
998 not those with only SYN set. Remember that we don't care if ACK or any
999 other control bit is set as long as SYN is set.
1000
1001 In order to achieve our goal, we need to logically AND the binary value
1002 of octet 13 with some other value to preserve the SYN bit. We know
1003 that we want SYN to be set in any case, so we'll logically AND the
1004 value in the 13th octet with the binary value of a SYN:
1005
1006 00010010 SYN-ACK 00000010 SYN
1007 AND 00000010 (we want SYN) AND 00000010 (we want SYN)
1008 -------- --------
1009 = 00000010 = 00000010
1010
1011 We see that this AND operation delivers the same result regardless
1012 whether ACK or another TCP control bit is set. The decimal representa‐
1013 tion of the AND value as well as the result of this operation is 2
1014 (binary 00000010), so we know that for packets with SYN set the follow‐
1015 ing relation must hold true:
1016
1017 ( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )
1018
1019 This points us to the tcpdump filter expression
1020 tcpdump -i xl0 'tcp[13] & 2 == 2'
1021
1022 Some offsets and field values may be expressed as names rather than as
1023 numeric values. For example tcp[13] may be replaced with tcp[tcpflags].
1024 The following TCP flag field values are also available: tcp-fin, tcp-
1025 syn, tcp-rst, tcp-push, tcp-ack, tcp-urg.
1026
1027 This can be demonstrated as:
1028 tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'
1029
1030 Note that you should use single quotes or a backslash in the expression
1031 to hide the AND ('&') special character from the shell.
1032
1033 UDP Packets
1034
1035 UDP format is illustrated by this rwho packet:
1036 actinide.who > broadcast.who: udp 84
1037 This says that port who on host actinide sent a UDP datagram to port
1038 who on host broadcast, the Internet broadcast address. The packet con‐
1039 tained 84 bytes of user data.
1040
1041 Some UDP services are recognized (from the source or destination port
1042 number) and the higher level protocol information printed. In particu‐
1043 lar, Domain Name service requests (RFC-1034/1035) and Sun RPC calls
1044 (RFC-1050) to NFS.
1045
1046 UDP Name Server Requests
1047
1048 (N.B.:The following description assumes familiarity with the Domain
1049 Service protocol described in RFC-1035. If you are not familiar with
1050 the protocol, the following description will appear to be written in
1051 Greek.)
1052
1053 Name server requests are formatted as
1054 src > dst: id op? flags qtype qclass name (len)
1055 h2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)
1056 Host h2opolo asked the domain server on helios for an address record
1057 (qtype=A) associated with the name ucbvax.berkeley.edu. The query id
1058 was `3'. The `+' indicates the recursion desired flag was set. The
1059 query length was 37 bytes, not including the UDP and IP protocol head‐
1060 ers. The query operation was the normal one, Query, so the op field
1061 was omitted. If the op had been anything else, it would have been
1062 printed between the `3' and the `+'. Similarly, the qclass was the
1063 normal one, C_IN, and omitted. Any other qclass would have been
1064 printed immediately after the `A'.
1065
1066 A few anomalies are checked and may result in extra fields enclosed in
1067 square brackets: If a query contains an answer, authority records or
1068 additional records section, ancount, nscount, or arcount are printed as
1069 `[na]', `[nn]' or `[nau]' where n is the appropriate count. If any of
1070 the response bits are set (AA, RA or rcode) or any of the `must be
1071 zero' bits are set in bytes two and three, `[b2&3=x]' is printed, where
1072 x is the hex value of header bytes two and three.
1073
1074 UDP Name Server Responses
1075
1076 Name server responses are formatted as
1077 src > dst: id op rcode flags a/n/au type class data (len)
1078 helios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
1079 helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)
1080 In the first example, helios responds to query id 3 from h2opolo with 3
1081 answer records, 3 name server records and 7 additional records. The
1082 first answer record is type A (address) and its data is internet
1083 address 128.32.137.3. The total size of the response was 273 bytes,
1084 excluding UDP and IP headers. The op (Query) and response code (NoEr‐
1085 ror) were omitted, as was the class (C_IN) of the A record.
1086
1087 In the second example, helios responds to query 2 with a response code
1088 of non-existent domain (NXDomain) with no answers, one name server and
1089 no authority records. The `*' indicates that the authoritative answer
1090 bit was set. Since there were no answers, no type, class or data were
1091 printed.
1092
1093 Other flag characters that might appear are `-' (recursion available,
1094 RA, not set) and `|' (truncated message, TC, set). If the `question'
1095 section doesn't contain exactly one entry, `[nq]' is printed.
1096
1097 SMB/CIFS decoding
1098
1099 tcpdump now includes fairly extensive SMB/CIFS/NBT decoding for data on
1100 UDP/137, UDP/138 and TCP/139. Some primitive decoding of IPX and Net‐
1101 BEUI SMB data is also done.
1102
1103 By default a fairly minimal decode is done, with a much more detailed
1104 decode done if -v is used. Be warned that with -v a single SMB packet
1105 may take up a page or more, so only use -v if you really want all the
1106 gory details.
1107
1108 For information on SMB packet formats and what all the fields mean see
1109 www.cifs.org or the pub/samba/specs/ directory on your favorite
1110 samba.org mirror site. The SMB patches were written by Andrew Tridgell
1111 (tridge@samba.org).
1112
1113 NFS Requests and Replies
1114
1115 Sun NFS (Network File System) requests and replies are printed as:
1116 src.sport > dst.nfs: NFS request xid xid len op args
1117 src.nfs > dst.dport: NFS reply xid xid reply stat len op results
1118 sushi.1023 > wrl.nfs: NFS request xid 26377
1119 112 readlink fh 21,24/10.73165
1120 wrl.nfs > sushi.1023: NFS reply xid 26377
1121 reply ok 40 readlink "../var"
1122 sushi.1022 > wrl.nfs: NFS request xid 8219
1123 144 lookup fh 9,74/4096.6878 "xcolors"
1124 wrl.nfs > sushi.1022: NFS reply xid 8219
1125 reply ok 128 lookup fh 9,74/4134.3150
1126 In the first line, host sushi sends a transaction with id 26377 to wrl.
1127 The request was 112 bytes, excluding the UDP and IP headers. The oper‐
1128 ation was a readlink (read symbolic link) on file handle (fh)
1129 21,24/10.731657119. (If one is lucky, as in this case, the file handle
1130 can be interpreted as a major,minor device number pair, followed by the
1131 inode number and generation number.) In the second line, wrl replies
1132 `ok' with the same transaction id and the contents of the link.
1133
1134 In the third line, sushi asks (using a new transaction id) wrl to
1135 lookup the name `xcolors' in directory file 9,74/4096.6878. In the
1136 fourth line, wrl sends a reply with the respective transaction id.
1137
1138 Note that the data printed depends on the operation type. The format
1139 is intended to be self explanatory if read in conjunction with an NFS
1140 protocol spec. Also note that older versions of tcpdump printed NFS
1141 packets in a slightly different format: the transaction id (xid) would
1142 be printed instead of the non-NFS port number of the packet.
1143
1144 If the -v (verbose) flag is given, additional information is printed.
1145 For example:
1146 sushi.1023 > wrl.nfs: NFS request xid 79658
1147 148 read fh 21,11/12.195 8192 bytes @ 24576
1148 wrl.nfs > sushi.1023: NFS reply xid 79658
1149 reply ok 1472 read REG 100664 ids 417/0 sz 29388
1150 (-v also prints the IP header TTL, ID, length, and fragmentation
1151 fields, which have been omitted from this example.) In the first line,
1152 sushi asks wrl to read 8192 bytes from file 21,11/12.195, at byte off‐
1153 set 24576. Wrl replies `ok'; the packet shown on the second line is
1154 the first fragment of the reply, and hence is only 1472 bytes long (the
1155 other bytes will follow in subsequent fragments, but these fragments do
1156 not have NFS or even UDP headers and so might not be printed, depending
1157 on the filter expression used). Because the -v flag is given, some of
1158 the file attributes (which are returned in addition to the file data)
1159 are printed: the file type (``REG'', for regular file), the file mode
1160 (in octal), the UID and GID, and the file size.
1161
1162 If the -v flag is given more than once, even more details are printed.
1163
1164 NFS reply packets do not explicitly identify the RPC operation.
1165 Instead, tcpdump keeps track of ``recent'' requests, and matches them
1166 to the replies using the transaction ID. If a reply does not closely
1167 follow the corresponding request, it might not be parsable.
1168
1169 AFS Requests and Replies
1170
1171 Transarc AFS (Andrew File System) requests and replies are printed as:
1172
1173 src.sport > dst.dport: rx packet-type
1174 src.sport > dst.dport: rx packet-type service call call-name args
1175 src.sport > dst.dport: rx packet-type service reply call-name args
1176 elvis.7001 > pike.afsfs:
1177 rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
1178 new fid 536876964/1/1 ".newsrc"
1179 pike.afsfs > elvis.7001: rx data fs reply rename
1180 In the first line, host elvis sends a RX packet to pike. This was a RX
1181 data packet to the fs (fileserver) service, and is the start of an RPC
1182 call. The RPC call was a rename, with the old directory file id of
1183 536876964/1/1 and an old filename of `.newsrc.new', and a new directory
1184 file id of 536876964/1/1 and a new filename of `.newsrc'. The host
1185 pike responds with a RPC reply to the rename call (which was success‐
1186 ful, because it was a data packet and not an abort packet).
1187
1188 In general, all AFS RPCs are decoded at least by RPC call name. Most
1189 AFS RPCs have at least some of the arguments decoded (generally only
1190 the `interesting' arguments, for some definition of interesting).
1191
1192 The format is intended to be self-describing, but it will probably not
1193 be useful to people who are not familiar with the workings of AFS and
1194 RX.
1195
1196 If the -v (verbose) flag is given twice, acknowledgement packets and
1197 additional header information is printed, such as the RX call ID, call
1198 number, sequence number, serial number, and the RX packet flags.
1199
1200 If the -v flag is given twice, additional information is printed, such
1201 as the RX call ID, serial number, and the RX packet flags. The MTU
1202 negotiation information is also printed from RX ack packets.
1203
1204 If the -v flag is given three times, the security index and service id
1205 are printed.
1206
1207 Error codes are printed for abort packets, with the exception of Ubik
1208 beacon packets (because abort packets are used to signify a yes vote
1209 for the Ubik protocol).
1210
1211 AFS reply packets do not explicitly identify the RPC operation.
1212 Instead, tcpdump keeps track of ``recent'' requests, and matches them
1213 to the replies using the call number and service ID. If a reply does
1214 not closely follow the corresponding request, it might not be parsable.
1215
1216
1217 KIP AppleTalk (DDP in UDP)
1218
1219 AppleTalk DDP packets encapsulated in UDP datagrams are de-encapsulated
1220 and dumped as DDP packets (i.e., all the UDP header information is dis‐
1221 carded). The file /etc/atalk.names is used to translate AppleTalk net
1222 and node numbers to names. Lines in this file have the form
1223 number name
1224
1225 1.254 ether
1226 16.1 icsd-net
1227 1.254.110 ace
1228 The first two lines give the names of AppleTalk networks. The third
1229 line gives the name of a particular host (a host is distinguished from
1230 a net by the 3rd octet in the number - a net number must have two
1231 octets and a host number must have three octets.) The number and name
1232 should be separated by whitespace (blanks or tabs). The
1233 /etc/atalk.names file may contain blank lines or comment lines (lines
1234 starting with a `#').
1235
1236 AppleTalk addresses are printed in the form
1237 net.host.port
1238
1239 144.1.209.2 > icsd-net.112.220
1240 office.2 > icsd-net.112.220
1241 jssmag.149.235 > icsd-net.2
1242 (If the /etc/atalk.names doesn't exist or doesn't contain an entry for
1243 some AppleTalk host/net number, addresses are printed in numeric form.)
1244 In the first example, NBP (DDP port 2) on net 144.1 node 209 is sending
1245 to whatever is listening on port 220 of net icsd node 112. The second
1246 line is the same except the full name of the source node is known
1247 (`office'). The third line is a send from port 235 on net jssmag node
1248 149 to broadcast on the icsd-net NBP port (note that the broadcast
1249 address (255) is indicated by a net name with no host number - for this
1250 reason it's a good idea to keep node names and net names distinct in
1251 /etc/atalk.names).
1252
1253 NBP (name binding protocol) and ATP (AppleTalk transaction protocol)
1254 packets have their contents interpreted. Other protocols just dump the
1255 protocol name (or number if no name is registered for the protocol) and
1256 packet size.
1257
1258 NBP packets are formatted like the following examples:
1259 icsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
1260 jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
1261 techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186
1262 The first line is a name lookup request for laserwriters sent by net
1263 icsd host 112 and broadcast on net jssmag. The nbp id for the lookup
1264 is 190. The second line shows a reply for this request (note that it
1265 has the same id) from host jssmag.209 saying that it has a laserwriter
1266 resource named "RM1140" registered on port 250. The third line is
1267 another reply to the same request saying host techpit has laserwriter
1268 "techpit" registered on port 186.
1269
1270 ATP packet formatting is demonstrated by the following example:
1271 jssmag.209.165 > helios.132: atp-req 12266<0-7> 0xae030001
1272 helios.132 > jssmag.209.165: atp-resp 12266:0 (512) 0xae040000
1273 helios.132 > jssmag.209.165: atp-resp 12266:1 (512) 0xae040000
1274 helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000
1275 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1276 helios.132 > jssmag.209.165: atp-resp 12266:4 (512) 0xae040000
1277 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1278 helios.132 > jssmag.209.165: atp-resp 12266:6 (512) 0xae040000
1279 helios.132 > jssmag.209.165: atp-resp*12266:7 (512) 0xae040000
1280 jssmag.209.165 > helios.132: atp-req 12266<3,5> 0xae030001
1281 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1282 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1283 jssmag.209.165 > helios.132: atp-rel 12266<0-7> 0xae030001
1284 jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002
1285 Jssmag.209 initiates transaction id 12266 with host helios by request‐
1286 ing up to 8 packets (the `<0-7>'). The hex number at the end of the
1287 line is the value of the `userdata' field in the request.
1288
1289 Helios responds with 8 512-byte packets. The `:digit' following the
1290 transaction id gives the packet sequence number in the transaction and
1291 the number in parens is the amount of data in the packet, excluding the
1292 ATP header. The `*' on packet 7 indicates that the EOM bit was set.
1293
1294 Jssmag.209 then requests that packets 3 & 5 be retransmitted. Helios
1295 resends them then jssmag.209 releases the transaction. Finally, jss‐
1296 mag.209 initiates the next request. The `*' on the request indicates
1297 that XO (`exactly once') was not set.
1298
1299
1301 stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(5),
1302 pcap-filter(7), pcap-tstamp(7)
1303
1304 https://www.iana.org/assignments/media-types/applica‐
1305 tion/vnd.tcpdump.pcap
1306
1308 The original authors are:
1309
1310 Van Jacobson, Craig Leres and Steven McCanne, all of the Lawrence
1311 Berkeley National Laboratory, University of California, Berkeley, CA.
1312
1313 It is currently being maintained by tcpdump.org.
1314
1315 The current version is available via HTTPS:
1316
1317 https://www.tcpdump.org/
1318
1319 The original distribution is available via anonymous ftp:
1320
1321 ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z
1322
1323 IPv6/IPsec support is added by WIDE/KAME project. This program uses
1324 OpenSSL/LibreSSL, under specific configurations.
1325
1327 To report a security issue please send an e-mail to
1328 security@tcpdump.org.
1329
1330 To report bugs and other problems, contribute patches, request a fea‐
1331 ture, provide generic feedback etc. please see the file CONTRIBUTING in
1332 the tcpdump source tree root.
1333
1334 NIT doesn't let you watch your own outbound traffic, BPF will. We rec‐
1335 ommend that you use the latter.
1336
1337 On Linux systems with 2.0[.x] kernels:
1338
1339 packets on the loopback device will be seen twice;
1340
1341 packet filtering cannot be done in the kernel, so that all pack‐
1342 ets must be copied from the kernel in order to be filtered in
1343 user mode;
1344
1345 all of a packet, not just the part that's within the snapshot
1346 length, will be copied from the kernel (the 2.0[.x] packet cap‐
1347 ture mechanism, if asked to copy only part of a packet to
1348 userspace, will not report the true length of the packet; this
1349 would cause most IP packets to get an error from tcpdump);
1350
1351 capturing on some PPP devices won't work correctly.
1352
1353 We recommend that you upgrade to a 2.2 or later kernel.
1354
1355 Some attempt should be made to reassemble IP fragments or, at least to
1356 compute the right length for the higher level protocol.
1357
1358 Name server inverse queries are not dumped correctly: the (empty) ques‐
1359 tion section is printed rather than real query in the answer section.
1360 Some believe that inverse queries are themselves a bug and prefer to
1361 fix the program generating them rather than tcpdump.
1362
1363 A packet trace that crosses a daylight savings time change will give
1364 skewed time stamps (the time change is ignored).
1365
1366 Filter expressions on fields other than those in Token Ring headers
1367 will not correctly handle source-routed Token Ring packets.
1368
1369 Filter expressions on fields other than those in 802.11 headers will
1370 not correctly handle 802.11 data packets with both To DS and From DS
1371 set.
1372
1373 ip6 proto should chase header chain, but at this moment it does not.
1374 ip6 protochain is supplied for this behavior.
1375
1376 Arithmetic expression against transport layer headers, like tcp[0],
1377 does not work against IPv6 packets. It only looks at IPv4 packets.
1378
1379
1380
1381 21 December 2020 TCPDUMP(8)