]> The Tcpdump Group git mirrors - tcpdump/blob - tcpdump.1.in
remove tcpdump's own CVS keywords
[tcpdump] / tcpdump.1.in
1 .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
2 .\"
3 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
4 .\" The Regents of the University of California. All rights reserved.
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that: (1) source code distributions
9 .\" retain the above copyright notice and this paragraph in its entirety, (2)
10 .\" distributions including binary code include the above copyright notice and
11 .\" this paragraph in its entirety in the documentation or other materials
12 .\" provided with the distribution, and (3) all advertising materials mentioning
13 .\" features or use of this software display the following acknowledgement:
14 .\" ``This product includes software developed by the University of California,
15 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 .\" the University nor the names of its contributors may be used to endorse
17 .\" or promote products derived from this software without specific prior
18 .\" written permission.
19 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 .\"
23 .TH TCPDUMP 1 "13 December 2013"
24 .SH NAME
25 tcpdump \- dump traffic on a network
26 .SH SYNOPSIS
27 .na
28 .B tcpdump
29 [
30 .B \-AbdDefhHIJKlLnNOpqRStuUvxX
31 ] [
32 .B \-B
33 .I buffer_size
34 ] [
35 .B \-c
36 .I count
37 ]
38 .br
39 .ti +8
40 [
41 .B \-C
42 .I file_size
43 ] [
44 .B \-G
45 .I rotate_seconds
46 ] [
47 .B \-F
48 .I file
49 ]
50 .br
51 .ti +8
52 [
53 .B \-i
54 .I interface
55 ]
56 [
57 .B \-j
58 .I tstamp_type
59 ]
60 [
61 .B \-m
62 .I module
63 ]
64 [
65 .B \-M
66 .I secret
67 ]
68 .br
69 .ti +8
70 [
71 .B \-Q
72 .I in|out|inout
73 ]
74 .ti +8
75 [
76 .B \-r
77 .I file
78 ]
79 [
80 .B \-V
81 .I file
82 ]
83 [
84 .B \-s
85 .I snaplen
86 ]
87 [
88 .B \-T
89 .I type
90 ]
91 [
92 .B \-w
93 .I file
94 ]
95 .br
96 .ti +8
97 [
98 .B \-W
99 .I filecount
100 ]
101 .br
102 .ti +8
103 [
104 .B \-E
105 .I spi@ipaddr algo:secret,...
106 ]
107 .br
108 .ti +8
109 [
110 .B \-y
111 .I datalinktype
112 ]
113 [
114 .B \-z
115 .I postrotate-command
116 ]
117 [
118 .B \-Z
119 .I user
120 ]
121 .ti +8
122 [
123 .I expression
124 ]
125 .br
126 .ad
127 .SH DESCRIPTION
128 .LP
129 \fITcpdump\fP prints out a description of the contents of packets on a
130 network interface that match the boolean \fIexpression\fP. It can also
131 be run with the
132 .B \-w
133 flag, which causes it to save the packet data to a file for later
134 analysis, and/or with the
135 .B \-r
136 flag, which causes it to read from a saved packet file rather than to
137 read packets from a network interface. It can also be run with the
138 .B \-V
139 flag, which causes it to read a list of saved packet files. In all cases,
140 only packets that match
141 .I expression
142 will be processed by
143 .IR tcpdump .
144 .LP
145 .I Tcpdump
146 will, if not run with the
147 .B \-c
148 flag, continue capturing packets until it is interrupted by a SIGINT
149 signal (generated, for example, by typing your interrupt character,
150 typically control-C) or a SIGTERM signal (typically generated with the
151 .BR kill (1)
152 command); if run with the
153 .B \-c
154 flag, it will capture packets until it is interrupted by a SIGINT or
155 SIGTERM signal or the specified number of packets have been processed.
156 .LP
157 When
158 .I tcpdump
159 finishes capturing packets, it will report counts of:
160 .IP
161 packets ``captured'' (this is the number of packets that
162 .I tcpdump
163 has received and processed);
164 .IP
165 packets ``received by filter'' (the meaning of this depends on the OS on
166 which you're running
167 .IR tcpdump ,
168 and possibly on the way the OS was configured - if a filter was
169 specified on the command line, on some OSes it counts packets regardless
170 of whether they were matched by the filter expression and, even if they
171 were matched by the filter expression, regardless of whether
172 .I tcpdump
173 has read and processed them yet, on other OSes it counts only packets that were
174 matched by the filter expression regardless of whether
175 .I tcpdump
176 has read and processed them yet, and on other OSes it counts only
177 packets that were matched by the filter expression and were processed by
178 .IR tcpdump );
179 .IP
180 packets ``dropped by kernel'' (this is the number of packets that were
181 dropped, due to a lack of buffer space, by the packet capture mechanism
182 in the OS on which
183 .I tcpdump
184 is running, if the OS reports that information to applications; if not,
185 it will be reported as 0).
186 .LP
187 On platforms that support the SIGINFO signal, such as most BSDs
188 (including Mac OS X) and Digital/Tru64 UNIX, it will report those counts
189 when it receives a SIGINFO signal (generated, for example, by typing
190 your ``status'' character, typically control-T, although on some
191 platforms, such as Mac OS X, the ``status'' character is not set by
192 default, so you must set it with
193 .BR stty (1)
194 in order to use it) and will continue capturing packets.
195 .LP
196 Reading packets from a network interface may require that you have
197 special privileges; see the
198 .B pcap (3PCAP)
199 man page for details. Reading a saved packet file doesn't require
200 special privileges.
201 .SH OPTIONS
202 .TP
203 .B \-A
204 Print each packet (minus its link level header) in ASCII. Handy for
205 capturing web pages.
206 .TP
207 .B \-b
208 Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN
209 notation.
210 .TP
211 .B \-B
212 Set the operating system capture buffer size to \fIbuffer_size\fP, in
213 units of KiB (1024 bytes).
214 .TP
215 .B \-c
216 Exit after receiving \fIcount\fP packets.
217 .TP
218 .B \-C
219 Before writing a raw packet to a savefile, check whether the file is
220 currently larger than \fIfile_size\fP and, if so, close the current
221 savefile and open a new one. Savefiles after the first savefile will
222 have the name specified with the
223 .B \-w
224 flag, with a number after it, starting at 1 and continuing upward.
225 The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes,
226 not 1,048,576 bytes).
227 .TP
228 .B \-d
229 Dump the compiled packet-matching code in a human readable form to
230 standard output and stop.
231 .TP
232 .B \-dd
233 Dump packet-matching code as a
234 .B C
235 program fragment.
236 .TP
237 .B \-ddd
238 Dump packet-matching code as decimal numbers (preceded with a count).
239 .TP
240 .B \-D
241 Print the list of the network interfaces available on the system and on
242 which
243 .I tcpdump
244 can capture packets. For each network interface, a number and an
245 interface name, possibly followed by a text description of the
246 interface, is printed. The interface name or the number can be supplied
247 to the
248 .B \-i
249 flag to specify an interface on which to capture.
250 .IP
251 This can be useful on systems that don't have a command to list them
252 (e.g., Windows systems, or UNIX systems lacking
253 .BR "ifconfig \-a" );
254 the number can be useful on Windows 2000 and later systems, where the
255 interface name is a somewhat complex string.
256 .IP
257 The
258 .B \-D
259 flag will not be supported if
260 .I tcpdump
261 was built with an older version of
262 .I libpcap
263 that lacks the
264 .B pcap_findalldevs()
265 function.
266 .TP
267 .B \-e
268 Print the link-level header on each dump line. This can be used, for
269 example, to print MAC layer addresses for protocols such as Ethernet and
270 IEEE 802.11.
271 .TP
272 .B \-E
273 Use \fIspi@ipaddr algo:secret\fP for decrypting IPsec ESP packets that
274 are addressed to \fIaddr\fP and contain Security Parameter Index value
275 \fIspi\fP. This combination may be repeated with comma or newline separation.
276 .IP
277 Note that setting the secret for IPv4 ESP packets is supported at this time.
278 .IP
279 Algorithms may be
280 \fBdes-cbc\fP,
281 \fB3des-cbc\fP,
282 \fBblowfish-cbc\fP,
283 \fBrc3-cbc\fP,
284 \fBcast128-cbc\fP, or
285 \fBnone\fP.
286 The default is \fBdes-cbc\fP.
287 The ability to decrypt packets is only present if \fItcpdump\fP was compiled
288 with cryptography enabled.
289 .IP
290 \fIsecret\fP is the ASCII text for ESP secret key.
291 If preceded by 0x, then a hex value will be read.
292 .IP
293 The option assumes RFC2406 ESP, not RFC1827 ESP.
294 The option is only for debugging purposes, and
295 the use of this option with a true `secret' key is discouraged.
296 By presenting IPsec secret key onto command line
297 you make it visible to others, via
298 .IR ps (1)
299 and other occasions.
300 .IP
301 In addition to the above syntax, the syntax \fIfile name\fP may be used
302 to have tcpdump read the provided file in. The file is opened upon
303 receiving the first ESP packet, so any special permissions that tcpdump
304 may have been given should already have been given up.
305 .TP
306 .B \-f
307 Print `foreign' IPv4 addresses numerically rather than symbolically
308 (this option is intended to get around serious brain damage in
309 Sun's NIS server \(em usually it hangs forever translating non-local
310 internet numbers).
311 .IP
312 The test for `foreign' IPv4 addresses is done using the IPv4 address and
313 netmask of the interface on which capture is being done. If that
314 address or netmask are not available, available, either because the
315 interface on which capture is being done has no address or netmask or
316 because the capture is being done on the Linux "any" interface, which
317 can capture on more than one interface, this option will not work
318 correctly.
319 .TP
320 .B \-F
321 Use \fIfile\fP as input for the filter expression.
322 An additional expression given on the command line is ignored.
323 .TP
324 .B \-G
325 If specified, rotates the dump file specified with the
326 .B \-w
327 option every \fIrotate_seconds\fP seconds.
328 Savefiles will have the name specified by
329 .B \-w
330 which should include a time format as defined by
331 .BR strftime (3).
332 If no time format is specified, each new file will overwrite the previous.
333 .IP
334 If used in conjunction with the
335 .B \-C
336 option, filenames will take the form of `\fIfile\fP<count>'.
337 .TP
338 .B \-h
339 Print the tcpdump and libpcap version strings, print a usage message,
340 and exit.
341 .TP
342 .B \-H
343 Attempt to detect 802.11s draft mesh headers.
344 .TP
345 .B \-i
346 Listen on \fIinterface\fP.
347 If unspecified, \fItcpdump\fP searches the system interface list for the
348 lowest numbered, configured up interface (excluding loopback), which may turn
349 out to be, for example, ``eth0''.
350 .IP
351 On Linux systems with 2.2 or later kernels, an
352 .I interface
353 argument of ``any'' can be used to capture packets from all interfaces.
354 Note that captures on the ``any'' device will not be done in promiscuous
355 mode.
356 .IP
357 If the
358 .B \-D
359 flag is supported, an interface number as printed by that flag can be
360 used as the
361 .I interface
362 argument.
363 .TP
364 .B \-I
365 Put the interface in "monitor mode"; this is supported only on IEEE
366 802.11 Wi-Fi interfaces, and supported only on some operating systems.
367 .IP
368 Note that in monitor mode the adapter might disassociate from the
369 network with which it's associated, so that you will not be able to use
370 any wireless networks with that adapter. This could prevent accessing
371 files on a network server, or resolving host names or network addresses,
372 if you are capturing in monitor mode and are not connected to another
373 network with another adapter.
374 .IP
375 This flag will affect the output of the
376 .B \-L
377 flag. If
378 .B \-I
379 isn't specified, only those link-layer types available when not in
380 monitor mode will be shown; if
381 .B \-I
382 is specified, only those link-layer types available when in monitor mode
383 will be shown.
384 .TP
385 .B \-j
386 Set the time stamp type for the capture to \fItstamp_type\fP. The names
387 to use for the time stamp types are given in
388 .BR pcap-tstamp (@MAN_MISC_INFO@);
389 not all the types listed there will necessarily be valid for any given
390 interface.
391 .TP
392 .B \-J
393 List the supported time stamp types for the interface and exit. If the
394 time stamp type cannot be set for the interface, no time stamp types are
395 listed.
396 .TP
397 .B \-K
398 Don't attempt to verify IP, TCP, or UDP checksums. This is useful for
399 interfaces that perform some or all of those checksum calculation in
400 hardware; otherwise, all outgoing TCP checksums will be flagged as bad.
401 .TP
402 .B \-l
403 Make stdout line buffered.
404 Useful if you want to see the data
405 while capturing it.
406 E.g.,
407 .IP
408 .RS
409 .RS
410 .nf
411 \fBtcpdump \-l | tee dat\fP
412 .fi
413 .RE
414 .RE
415 .IP
416 or
417 .IP
418 .RS
419 .RS
420 .nf
421 \fBtcpdump \-l > dat & tail \-f dat\fP
422 .fi
423 .RE
424 .RE
425 .IP
426 Note that on Windows,``line buffered'' means ``unbuffered'', so that
427 WinDump will write each character individually if
428 .B \-l
429 is specified.
430 .IP
431 .B \-U
432 is similar to
433 .B \-l
434 in its behavior, but it will cause output to be ``packet-buffered'', so
435 that the output is written to stdout at the end of each packet rather
436 than at the end of each line; this is buffered on all platforms,
437 including Windows.
438 .TP
439 .B \-L
440 List the known data link types for the interface, in the specified mode,
441 and exit. The list of known data link types may be dependent on the
442 specified mode; for example, on some platforms, a Wi-Fi interface might
443 support one set of data link types when not in monitor mode (for
444 example, it might support only fake Ethernet headers, or might support
445 802.11 headers but not support 802.11 headers with radio information)
446 and another set of data link types when in monitor mode (for example, it
447 might support 802.11 headers, or 802.11 headers with radio information,
448 only in monitor mode).
449 .TP
450 .B \-m
451 Load SMI MIB module definitions from file \fImodule\fR.
452 This option
453 can be used several times to load several MIB modules into \fItcpdump\fP.
454 .TP
455 .B \-M
456 Use \fIsecret\fP as a shared secret for validating the digests found in
457 TCP segments with the TCP-MD5 option (RFC 2385), if present.
458 .TP
459 .B \-n
460 Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.
461 .TP
462 .B \-N
463 Don't print domain name qualification of host names.
464 E.g.,
465 if you give this flag then \fItcpdump\fP will print ``nic''
466 instead of ``nic.ddn.mil''.
467 .TP
468 .B \-O
469 Do not run the packet-matching code optimizer.
470 This is useful only
471 if you suspect a bug in the optimizer.
472 .TP
473 .B \-p
474 \fIDon't\fP put the interface
475 into promiscuous mode.
476 Note that the interface might be in promiscuous
477 mode for some other reason; hence, `-p' cannot be used as an abbreviation for
478 `ether host {local-hw-addr} or ether broadcast'.
479 .TP
480 .B \-Q
481 Choose send/receive direction \fIdirection\fR for which packets should be
482 captured. Possible values are `in', `out' and `inout'. Not available
483 on all platforms.
484 .TP
485 .B \-q
486 Quick (quiet?) output.
487 Print less protocol information so output
488 lines are shorter.
489 .TP
490 .B \-R
491 Assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829).
492 If specified, \fItcpdump\fP will not print replay prevention field.
493 Since there is no protocol version field in ESP/AH specification,
494 \fItcpdump\fP cannot deduce the version of ESP/AH protocol.
495 .TP
496 .B \-r
497 Read packets from \fIfile\fR (which was created with the
498 .B \-w
499 option).
500 Standard input is used if \fIfile\fR is ``-''.
501 .TP
502 .B \-S
503 Print absolute, rather than relative, TCP sequence numbers.
504 .TP
505 .B \-s
506 Snarf \fIsnaplen\fP bytes of data from each packet rather than the
507 default of 65535 bytes.
508 Packets truncated because of a limited snapshot
509 are indicated in the output with ``[|\fIproto\fP]'', where \fIproto\fP
510 is the name of the protocol level at which the truncation has occurred.
511 Note that taking larger snapshots both increases
512 the amount of time it takes to process packets and, effectively,
513 decreases the amount of packet buffering.
514 This may cause packets to be
515 lost.
516 You should limit \fIsnaplen\fP to the smallest number that will
517 capture the protocol information you're interested in.
518 Setting
519 \fIsnaplen\fP to 0 sets it to the default of 65535,
520 for backwards compatibility with recent older versions of
521 .IR tcpdump .
522 .TP
523 .B \-T
524 Force packets selected by "\fIexpression\fP" to be interpreted the
525 specified \fItype\fR.
526 Currently known types are
527 \fBaodv\fR (Ad-hoc On-demand Distance Vector protocol),
528 \fBcarp\fR (Common Address Redundancy Protocol),
529 \fBcnfp\fR (Cisco NetFlow protocol),
530 \fBlmp\fR (Link Management Protocol),
531 \fBpgm\fR (Pragmatic General Multicast),
532 \fBpgm_zmtp1\fR (ZMTP/1.0 inside PGM/EPGM),
533 \fBradius\fR (RADIUS),
534 \fBrpc\fR (Remote Procedure Call),
535 \fBrtp\fR (Real-Time Applications protocol),
536 \fBrtcp\fR (Real-Time Applications control protocol),
537 \fBsnmp\fR (Simple Network Management Protocol),
538 \fBtftp\fR (Trivial File Transfer Protocol),
539 \fBvat\fR (Visual Audio Tool),
540 \fBwb\fR (distributed White Board),
541 \fBzmtp1\fR (ZeroMQ Message Transport Protocol 1.0)
542 and
543 \fBvxlan\fR (Virtual eXtensible Local Area Network).
544 .IP
545 Note that the \fBpgm\fR type above affects UDP interpretation only, the native
546 PGM is always recognised as IP protocol 113 regardless. UDP-encapsulated PGM is
547 often called "EPGM" or "PGM/UDP".
548 .IP
549 Note that the \fBpgm_zmtp1\fR type above affects interpretation of both native
550 PGM and UDP at once. During the native PGM decoding the application data of an
551 ODATA/RDATA packet would be decoded as a ZeroMQ datagram with ZMTP/1.0 frames.
552 During the UDP decoding in addition to that any UDP packet would be treated as
553 an encapsulated PGM packet.
554 .TP
555 .B \-t
556 \fIDon't\fP print a timestamp on each dump line.
557 .TP
558 .B \-tt
559 Print an unformatted timestamp on each dump line.
560 .TP
561 .B \-ttt
562 Print a delta (micro-second resolution) between current and previous line
563 on each dump line.
564 .TP
565 .B \-tttt
566 Print a timestamp in default format proceeded by date on each dump line.
567 .TP
568 .B \-ttttt
569 Print a delta (micro-second resolution) between current and first line
570 on each dump line.
571 .TP
572 .B \-u
573 Print undecoded NFS handles.
574 .TP
575 .B \-U
576 If the
577 .B \-w
578 option is not specified, make the printed packet output
579 ``packet-buffered''; i.e., as the description of the contents of each
580 packet is printed, it will be written to the standard output, rather
581 than, when not writing to a terminal, being written only when the output
582 buffer fills.
583 .IP
584 If the
585 .B \-w
586 option is specified, make the saved raw packet output
587 ``packet-buffered''; i.e., as each packet is saved, it will be written
588 to the output file, rather than being written only when the output
589 buffer fills.
590 .IP
591 The
592 .B \-U
593 flag will not be supported if
594 .I tcpdump
595 was built with an older version of
596 .I libpcap
597 that lacks the
598 .B pcap_dump_flush()
599 function.
600 .TP
601 .B \-v
602 When parsing and printing, produce (slightly more) verbose output.
603 For example, the time to live,
604 identification, total length and options in an IP packet are printed.
605 Also enables additional packet integrity checks such as verifying the
606 IP and ICMP header checksum.
607 .IP
608 When writing to a file with the
609 .B \-w
610 option, report, every 10 seconds, the number of packets captured.
611 .TP
612 .B \-vv
613 Even more verbose output.
614 For example, additional fields are
615 printed from NFS reply packets, and SMB packets are fully decoded.
616 .TP
617 .B \-vvv
618 Even more verbose output.
619 For example,
620 telnet \fBSB\fP ... \fBSE\fP options
621 are printed in full.
622 With
623 .B \-X
624 Telnet options are printed in hex as well.
625 .TP
626 .B \-V
627 Read a list of filenames from \fIfile\fR. Standard input is used
628 if \fIfile\fR is ``-''.
629 .TP
630 .B \-w
631 Write the raw packets to \fIfile\fR rather than parsing and printing
632 them out.
633 They can later be printed with the \-r option.
634 Standard output is used if \fIfile\fR is ``-''.
635 .IP
636 This output will be buffered if written to a file or pipe, so a program
637 reading from the file or pipe may not see packets for an arbitrary
638 amount of time after they are received. Use the
639 .B \-U
640 flag to cause packets to be written as soon as they are received.
641 .IP
642 The MIME type \fIapplication/vnd.tcpdump.pcap\fP has been registered
643 with IANA for \fIpcap\fP files. The filename extension \fI.pcap\fP
644 appears to be the most commonly used along with \fI.cap\fP and
645 \fI.dmp\fP. \fITcpdump\fP itself doesn't check the extension when
646 reading capture files and doesn't add an extension when writing them
647 (it uses magic numbers in the file header instead). However, many
648 operating systems and applications will use the extension if it is
649 present and adding one (e.g. .pcap) is recommended.
650 .IP
651 See
652 .BR pcap-savefile (@MAN_FILE_FORMATS@)
653 for a description of the file format.
654 .TP
655 .B \-W
656 Used in conjunction with the
657 .B \-C
658 option, this will limit the number
659 of files created to the specified number, and begin overwriting files
660 from the beginning, thus creating a 'rotating' buffer.
661 In addition, it will name
662 the files with enough leading 0s to support the maximum number of
663 files, allowing them to sort correctly.
664 .IP
665 Used in conjunction with the
666 .B \-G
667 option, this will limit the number of rotated dump files that get
668 created, exiting with status 0 when reaching the limit. If used with
669 .B \-C
670 as well, the behavior will result in cyclical files per timeslice.
671 .TP
672 .B \-x
673 When parsing and printing,
674 in addition to printing the headers of each packet, print the data of
675 each packet (minus its link level header) in hex.
676 The smaller of the entire packet or
677 .I snaplen
678 bytes will be printed. Note that this is the entire link-layer
679 packet, so for link layers that pad (e.g. Ethernet), the padding bytes
680 will also be printed when the higher layer packet is shorter than the
681 required padding.
682 .TP
683 .B \-xx
684 When parsing and printing,
685 in addition to printing the headers of each packet, print the data of
686 each packet,
687 .I including
688 its link level header, in hex.
689 .TP
690 .B \-X
691 When parsing and printing,
692 in addition to printing the headers of each packet, print the data of
693 each packet (minus its link level header) in hex and ASCII.
694 This is very handy for analysing new protocols.
695 .TP
696 .B \-XX
697 When parsing and printing,
698 in addition to printing the headers of each packet, print the data of
699 each packet,
700 .I including
701 its link level header, in hex and ASCII.
702 .TP
703 .B \-y
704 Set the data link type to use while capturing packets to \fIdatalinktype\fP.
705 .TP
706 .B \-z
707 Used in conjunction with the
708 .B -C
709 or
710 .B -G
711 options, this will make
712 .I tcpdump
713 run "
714 .I command file
715 " where
716 .I file
717 is the savefile being closed after each rotation. For example, specifying
718 .B \-z gzip
719 or
720 .B \-z bzip2
721 will compress each savefile using gzip or bzip2.
722 .IP
723 Note that tcpdump will run the command in parallel to the capture, using
724 the lowest priority so that this doesn't disturb the capture process.
725 .IP
726 And in case you would like to use a command that itself takes flags or
727 different arguments, you can always write a shell script that will take the
728 savefile name as the only argument, make the flags & arguments arrangements
729 and execute the command that you want.
730 .TP
731 .B \-Z
732 If
733 .I tcpdump
734 is running as root, after opening the capture device or input savefile,
735 but before opening any savefiles for output, change the user ID to
736 .I user
737 and the group ID to the primary group of
738 .IR user .
739 .IP
740 This behavior can also be enabled by default at compile time.
741 .IP "\fI expression\fP"
742 .RS
743 selects which packets will be dumped.
744 If no \fIexpression\fP
745 is given, all packets on the net will be dumped.
746 Otherwise,
747 only packets for which \fIexpression\fP is `true' will be dumped.
748 .LP
749 For the \fIexpression\fP syntax, see
750 .BR pcap-filter (@MAN_MISC_INFO@).
751 .LP
752 The \fIexpression\fP argument can be passed to \fItcpdump\fP as either a single
753 Shell argument, or as multiple Shell arguments, whichever is more convenient.
754 Generally, if the expression contains Shell metacharacters, such as
755 backslashes used to escape protocol names, it is easier to pass it as
756 a single, quoted argument rather than to escape the Shell
757 metacharacters.
758 Multiple arguments are concatenated with spaces before being parsed.
759 .SH EXAMPLES
760 .LP
761 To print all packets arriving at or departing from \fIsundown\fP:
762 .RS
763 .nf
764 \fBtcpdump host sundown\fP
765 .fi
766 .RE
767 .LP
768 To print traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR:
769 .RS
770 .nf
771 \fBtcpdump host helios and \\( hot or ace \\)\fP
772 .fi
773 .RE
774 .LP
775 To print all IP packets between \fIace\fR and any host except \fIhelios\fR:
776 .RS
777 .nf
778 \fBtcpdump ip host ace and not helios\fP
779 .fi
780 .RE
781 .LP
782 To print all traffic between local hosts and hosts at Berkeley:
783 .RS
784 .nf
785 .B
786 tcpdump net ucb-ether
787 .fi
788 .RE
789 .LP
790 To print all ftp traffic through internet gateway \fIsnup\fP:
791 (note that the expression is quoted to prevent the shell from
792 (mis-)interpreting the parentheses):
793 .RS
794 .nf
795 .B
796 tcpdump 'gateway snup and (port ftp or ftp-data)'
797 .fi
798 .RE
799 .LP
800 To print traffic neither sourced from nor destined for local hosts
801 (if you gateway to one other net, this stuff should never make it
802 onto your local net).
803 .RS
804 .nf
805 .B
806 tcpdump ip and not net \fIlocalnet\fP
807 .fi
808 .RE
809 .LP
810 To print the start and end packets (the SYN and FIN packets) of each
811 TCP conversation that involves a non-local host.
812 .RS
813 .nf
814 .B
815 tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP'
816 .fi
817 .RE
818 .LP
819 To print all IPv4 HTTP packets to and from port 80, i.e. print only
820 packets that contain data, not, for example, SYN and FIN packets and
821 ACK-only packets. (IPv6 is left as an exercise for the reader.)
822 .RS
823 .nf
824 .B
825 tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
826 .fi
827 .RE
828 .LP
829 To print IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
830 .RS
831 .nf
832 .B
833 tcpdump 'gateway snup and ip[2:2] > 576'
834 .fi
835 .RE
836 .LP
837 To print IP broadcast or multicast packets that were
838 .I not
839 sent via Ethernet broadcast or multicast:
840 .RS
841 .nf
842 .B
843 tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'
844 .fi
845 .RE
846 .LP
847 To print all ICMP packets that are not echo requests/replies (i.e., not
848 ping packets):
849 .RS
850 .nf
851 .B
852 tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'
853 .fi
854 .RE
855 .SH OUTPUT FORMAT
856 .LP
857 The output of \fItcpdump\fP is protocol dependent.
858 The following
859 gives a brief description and examples of most of the formats.
860 .de HD
861 .sp 1.5
862 .B
863 ..
864 .HD
865 Link Level Headers
866 .LP
867 If the '-e' option is given, the link level header is printed out.
868 On Ethernets, the source and destination addresses, protocol,
869 and packet length are printed.
870 .LP
871 On FDDI networks, the '-e' option causes \fItcpdump\fP to print
872 the `frame control' field, the source and destination addresses,
873 and the packet length.
874 (The `frame control' field governs the
875 interpretation of the rest of the packet.
876 Normal packets (such
877 as those containing IP datagrams) are `async' packets, with a priority
878 value between 0 and 7; for example, `\fBasync4\fR'.
879 Such packets
880 are assumed to contain an 802.2 Logical Link Control (LLC) packet;
881 the LLC header is printed if it is \fInot\fR an ISO datagram or a
882 so-called SNAP packet.
883 .LP
884 On Token Ring networks, the '-e' option causes \fItcpdump\fP to print
885 the `access control' and `frame control' fields, the source and
886 destination addresses, and the packet length.
887 As on FDDI networks,
888 packets are assumed to contain an LLC packet.
889 Regardless of whether
890 the '-e' option is specified or not, the source routing information is
891 printed for source-routed packets.
892 .LP
893 On 802.11 networks, the '-e' option causes \fItcpdump\fP to print
894 the `frame control' fields, all of the addresses in the 802.11 header,
895 and the packet length.
896 As on FDDI networks,
897 packets are assumed to contain an LLC packet.
898 .LP
899 \fI(N.B.: The following description assumes familiarity with
900 the SLIP compression algorithm described in RFC-1144.)\fP
901 .LP
902 On SLIP links, a direction indicator (``I'' for inbound, ``O'' for outbound),
903 packet type, and compression information are printed out.
904 The packet type is printed first.
905 The three types are \fIip\fP, \fIutcp\fP, and \fIctcp\fP.
906 No further link information is printed for \fIip\fR packets.
907 For TCP packets, the connection identifier is printed following the type.
908 If the packet is compressed, its encoded header is printed out.
909 The special cases are printed out as
910 \fB*S+\fIn\fR and \fB*SA+\fIn\fR, where \fIn\fR is the amount by which
911 the sequence number (or sequence number and ack) has changed.
912 If it is not a special case,
913 zero or more changes are printed.
914 A change is indicated by U (urgent pointer), W (window), A (ack),
915 S (sequence number), and I (packet ID), followed by a delta (+n or -n),
916 or a new value (=n).
917 Finally, the amount of data in the packet and compressed header length
918 are printed.
919 .LP
920 For example, the following line shows an outbound compressed TCP packet,
921 with an implicit connection identifier; the ack has changed by 6,
922 the sequence number by 49, and the packet ID by 6; there are 3 bytes of
923 data and 6 bytes of compressed header:
924 .RS
925 .nf
926 \fBO ctcp * A+6 S+49 I+6 3 (6)\fP
927 .fi
928 .RE
929 .HD
930 ARP/RARP Packets
931 .LP
932 Arp/rarp output shows the type of request and its arguments.
933 The
934 format is intended to be self explanatory.
935 Here is a short sample taken from the start of an `rlogin' from
936 host \fIrtsg\fP to host \fIcsam\fP:
937 .RS
938 .nf
939 .sp .5
940 \f(CWarp who-has csam tell rtsg
941 arp reply csam is-at CSAM\fR
942 .sp .5
943 .fi
944 .RE
945 The first line says that rtsg sent an arp packet asking
946 for the Ethernet address of internet host csam.
947 Csam
948 replies with its Ethernet address (in this example, Ethernet addresses
949 are in caps and internet addresses in lower case).
950 .LP
951 This would look less redundant if we had done \fItcpdump \-n\fP:
952 .RS
953 .nf
954 .sp .5
955 \f(CWarp who-has 128.3.254.6 tell 128.3.254.68
956 arp reply 128.3.254.6 is-at 02:07:01:00:01:c4\fP
957 .fi
958 .RE
959 .LP
960 If we had done \fItcpdump \-e\fP, the fact that the first packet is
961 broadcast and the second is point-to-point would be visible:
962 .RS
963 .nf
964 .sp .5
965 \f(CWRTSG Broadcast 0806 64: arp who-has csam tell rtsg
966 CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR
967 .sp .5
968 .fi
969 .RE
970 For the first packet this says the Ethernet source address is RTSG, the
971 destination is the Ethernet broadcast address, the type field
972 contained hex 0806 (type ETHER_ARP) and the total length was 64 bytes.
973 .HD
974 TCP Packets
975 .LP
976 \fI(N.B.:The following description assumes familiarity with
977 the TCP protocol described in RFC-793.
978 If you are not familiar
979 with the protocol, neither this description nor \fItcpdump\fP will
980 be of much use to you.)\fP
981 .LP
982 The general format of a tcp protocol line is:
983 .RS
984 .nf
985 .sp .5
986 \fIsrc > dst: flags data-seqno ack window urgent options\fP
987 .sp .5
988 .fi
989 .RE
990 \fISrc\fP and \fIdst\fP are the source and destination IP
991 addresses and ports.
992 \fIFlags\fP are some combination of S (SYN),
993 F (FIN), P (PUSH), R (RST), U (URG), W (ECN CWR), E (ECN-Echo) or
994 `.' (ACK), or `none' if no flags are set.
995 \fIData-seqno\fP describes the portion of sequence space covered
996 by the data in this packet (see example below).
997 \fIAck\fP is sequence number of the next data expected the other
998 direction on this connection.
999 \fIWindow\fP is the number of bytes of receive buffer space available
1000 the other direction on this connection.
1001 \fIUrg\fP indicates there is `urgent' data in the packet.
1002 \fIOptions\fP are tcp options enclosed in angle brackets (e.g., <mss 1024>).
1003 .LP
1004 \fISrc, dst\fP and \fIflags\fP are always present.
1005 The other fields
1006 depend on the contents of the packet's tcp protocol header and
1007 are output only if appropriate.
1008 .LP
1009 Here is the opening portion of an rlogin from host \fIrtsg\fP to
1010 host \fIcsam\fP.
1011 .RS
1012 .nf
1013 .sp .5
1014 \s-2\f(CWrtsg.1023 > csam.login: S 768512:768512(0) win 4096 <mss 1024>
1015 csam.login > rtsg.1023: S 947648:947648(0) ack 768513 win 4096 <mss 1024>
1016 rtsg.1023 > csam.login: . ack 1 win 4096
1017 rtsg.1023 > csam.login: P 1:2(1) ack 1 win 4096
1018 csam.login > rtsg.1023: . ack 2 win 4096
1019 rtsg.1023 > csam.login: P 2:21(19) ack 1 win 4096
1020 csam.login > rtsg.1023: P 1:2(1) ack 21 win 4077
1021 csam.login > rtsg.1023: P 2:3(1) ack 21 win 4077 urg 1
1022 csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1\fR\s+2
1023 .sp .5
1024 .fi
1025 .RE
1026 The first line says that tcp port 1023 on rtsg sent a packet
1027 to port \fIlogin\fP
1028 on csam.
1029 The \fBS\fP indicates that the \fISYN\fP flag was set.
1030 The packet sequence number was 768512 and it contained no data.
1031 (The notation is `first:last(nbytes)' which means `sequence
1032 numbers \fIfirst\fP
1033 up to but not including \fIlast\fP which is \fInbytes\fP bytes of user data'.)
1034 There was no piggy-backed ack, the available receive window was 4096
1035 bytes and there was a max-segment-size option requesting an mss of
1036 1024 bytes.
1037 .LP
1038 Csam replies with a similar packet except it includes a piggy-backed
1039 ack for rtsg's SYN.
1040 Rtsg then acks csam's SYN.
1041 The `.' means the ACK flag was set.
1042 The packet contained no data so there is no data sequence number.
1043 Note that the ack sequence
1044 number is a small integer (1).
1045 The first time \fItcpdump\fP sees a
1046 tcp `conversation', it prints the sequence number from the packet.
1047 On subsequent packets of the conversation, the difference between
1048 the current packet's sequence number and this initial sequence number
1049 is printed.
1050 This means that sequence numbers after the
1051 first can be interpreted
1052 as relative byte positions in the conversation's data stream (with the
1053 first data byte each direction being `1').
1054 `-S' will override this
1055 feature, causing the original sequence numbers to be output.
1056 .LP
1057 On the 6th line, rtsg sends csam 19 bytes of data (bytes 2 through 20
1058 in the rtsg \(-> csam side of the conversation).
1059 The PUSH flag is set in the packet.
1060 On the 7th line, csam says it's received data sent by rtsg up to
1061 but not including byte 21.
1062 Most of this data is apparently sitting in the
1063 socket buffer since csam's receive window has gotten 19 bytes smaller.
1064 Csam also sends one byte of data to rtsg in this packet.
1065 On the 8th and 9th lines,
1066 csam sends two bytes of urgent, pushed data to rtsg.
1067 .LP
1068 If the snapshot was small enough that \fItcpdump\fP didn't capture
1069 the full TCP header, it interprets as much of the header as it can
1070 and then reports ``[|\fItcp\fP]'' to indicate the remainder could not
1071 be interpreted.
1072 If the header contains a bogus option (one with a length
1073 that's either too small or beyond the end of the header), \fItcpdump\fP
1074 reports it as ``[\fIbad opt\fP]'' and does not interpret any further
1075 options (since it's impossible to tell where they start).
1076 If the header
1077 length indicates options are present but the IP datagram length is not
1078 long enough for the options to actually be there, \fItcpdump\fP reports
1079 it as ``[\fIbad hdr length\fP]''.
1080 .HD
1081 .B Capturing TCP packets with particular flag combinations (SYN-ACK, URG-ACK, etc.)
1082 .PP
1083 There are 8 bits in the control bits section of the TCP header:
1084 .IP
1085 .I CWR | ECE | URG | ACK | PSH | RST | SYN | FIN
1086 .PP
1087 Let's assume that we want to watch packets used in establishing
1088 a TCP connection.
1089 Recall that TCP uses a 3-way handshake protocol
1090 when it initializes a new connection; the connection sequence with
1091 regard to the TCP control bits is
1092 .PP
1093 .RS
1094 1) Caller sends SYN
1095 .RE
1096 .RS
1097 2) Recipient responds with SYN, ACK
1098 .RE
1099 .RS
1100 3) Caller sends ACK
1101 .RE
1102 .PP
1103 Now we're interested in capturing packets that have only the
1104 SYN bit set (Step 1).
1105 Note that we don't want packets from step 2
1106 (SYN-ACK), just a plain initial SYN.
1107 What we need is a correct filter
1108 expression for \fItcpdump\fP.
1109 .PP
1110 Recall the structure of a TCP header without options:
1111 .PP
1112 .nf
1113 0 15 31
1114 -----------------------------------------------------------------
1115 | source port | destination port |
1116 -----------------------------------------------------------------
1117 | sequence number |
1118 -----------------------------------------------------------------
1119 | acknowledgment number |
1120 -----------------------------------------------------------------
1121 | HL | rsvd |C|E|U|A|P|R|S|F| window size |
1122 -----------------------------------------------------------------
1123 | TCP checksum | urgent pointer |
1124 -----------------------------------------------------------------
1125 .fi
1126 .PP
1127 A TCP header usually holds 20 octets of data, unless options are
1128 present.
1129 The first line of the graph contains octets 0 - 3, the
1130 second line shows octets 4 - 7 etc.
1131 .PP
1132 Starting to count with 0, the relevant TCP control bits are contained
1133 in octet 13:
1134 .PP
1135 .nf
1136 0 7| 15| 23| 31
1137 ----------------|---------------|---------------|----------------
1138 | HL | rsvd |C|E|U|A|P|R|S|F| window size |
1139 ----------------|---------------|---------------|----------------
1140 | | 13th octet | | |
1141 .fi
1142 .PP
1143 Let's have a closer look at octet no. 13:
1144 .PP
1145 .nf
1146 | |
1147 |---------------|
1148 |C|E|U|A|P|R|S|F|
1149 |---------------|
1150 |7 5 3 0|
1151 .fi
1152 .PP
1153 These are the TCP control bits we are interested
1154 in.
1155 We have numbered the bits in this octet from 0 to 7, right to
1156 left, so the PSH bit is bit number 3, while the URG bit is number 5.
1157 .PP
1158 Recall that we want to capture packets with only SYN set.
1159 Let's see what happens to octet 13 if a TCP datagram arrives
1160 with the SYN bit set in its header:
1161 .PP
1162 .nf
1163 |C|E|U|A|P|R|S|F|
1164 |---------------|
1165 |0 0 0 0 0 0 1 0|
1166 |---------------|
1167 |7 6 5 4 3 2 1 0|
1168 .fi
1169 .PP
1170 Looking at the
1171 control bits section we see that only bit number 1 (SYN) is set.
1172 .PP
1173 Assuming that octet number 13 is an 8-bit unsigned integer in
1174 network byte order, the binary value of this octet is
1175 .IP
1176 00000010
1177 .PP
1178 and its decimal representation is
1179 .PP
1180 .nf
1181 7 6 5 4 3 2 1 0
1182 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2 = 2
1183 .fi
1184 .PP
1185 We're almost done, because now we know that if only SYN is set,
1186 the value of the 13th octet in the TCP header, when interpreted
1187 as a 8-bit unsigned integer in network byte order, must be exactly 2.
1188 .PP
1189 This relationship can be expressed as
1190 .RS
1191 .B
1192 tcp[13] == 2
1193 .RE
1194 .PP
1195 We can use this expression as the filter for \fItcpdump\fP in order
1196 to watch packets which have only SYN set:
1197 .RS
1198 .B
1199 tcpdump -i xl0 tcp[13] == 2
1200 .RE
1201 .PP
1202 The expression says "let the 13th octet of a TCP datagram have
1203 the decimal value 2", which is exactly what we want.
1204 .PP
1205 Now, let's assume that we need to capture SYN packets, but we
1206 don't care if ACK or any other TCP control bit is set at the
1207 same time.
1208 Let's see what happens to octet 13 when a TCP datagram
1209 with SYN-ACK set arrives:
1210 .PP
1211 .nf
1212 |C|E|U|A|P|R|S|F|
1213 |---------------|
1214 |0 0 0 1 0 0 1 0|
1215 |---------------|
1216 |7 6 5 4 3 2 1 0|
1217 .fi
1218 .PP
1219 Now bits 1 and 4 are set in the 13th octet.
1220 The binary value of
1221 octet 13 is
1222 .IP
1223 00010010
1224 .PP
1225 which translates to decimal
1226 .PP
1227 .nf
1228 7 6 5 4 3 2 1 0
1229 0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2 = 18
1230 .fi
1231 .PP
1232 Now we can't just use 'tcp[13] == 18' in the \fItcpdump\fP filter
1233 expression, because that would select only those packets that have
1234 SYN-ACK set, but not those with only SYN set.
1235 Remember that we don't care
1236 if ACK or any other control bit is set as long as SYN is set.
1237 .PP
1238 In order to achieve our goal, we need to logically AND the
1239 binary value of octet 13 with some other value to preserve
1240 the SYN bit.
1241 We know that we want SYN to be set in any case,
1242 so we'll logically AND the value in the 13th octet with
1243 the binary value of a SYN:
1244 .PP
1245 .nf
1246
1247 00010010 SYN-ACK 00000010 SYN
1248 AND 00000010 (we want SYN) AND 00000010 (we want SYN)
1249 -------- --------
1250 = 00000010 = 00000010
1251 .fi
1252 .PP
1253 We see that this AND operation delivers the same result
1254 regardless whether ACK or another TCP control bit is set.
1255 The decimal representation of the AND value as well as
1256 the result of this operation is 2 (binary 00000010),
1257 so we know that for packets with SYN set the following
1258 relation must hold true:
1259 .IP
1260 ( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )
1261 .PP
1262 This points us to the \fItcpdump\fP filter expression
1263 .RS
1264 .B
1265 tcpdump -i xl0 'tcp[13] & 2 == 2'
1266 .RE
1267 .PP
1268 Some offsets and field values may be expressed as names
1269 rather than as numeric values. For example tcp[13] may
1270 be replaced with tcp[tcpflags]. The following TCP flag
1271 field values are also available: tcp-fin, tcp-syn, tcp-rst,
1272 tcp-push, tcp-act, tcp-urg.
1273 .PP
1274 This can be demonstrated as:
1275 .RS
1276 .B
1277 tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'
1278 .RE
1279 .PP
1280 Note that you should use single quotes or a backslash
1281 in the expression to hide the AND ('&') special character
1282 from the shell.
1283 .HD
1284 .B
1285 UDP Packets
1286 .LP
1287 UDP format is illustrated by this rwho packet:
1288 .RS
1289 .nf
1290 .sp .5
1291 \f(CWactinide.who > broadcast.who: udp 84\fP
1292 .sp .5
1293 .fi
1294 .RE
1295 This says that port \fIwho\fP on host \fIactinide\fP sent a udp
1296 datagram to port \fIwho\fP on host \fIbroadcast\fP, the Internet
1297 broadcast address.
1298 The packet contained 84 bytes of user data.
1299 .LP
1300 Some UDP services are recognized (from the source or destination
1301 port number) and the higher level protocol information printed.
1302 In particular, Domain Name service requests (RFC-1034/1035) and Sun
1303 RPC calls (RFC-1050) to NFS.
1304 .HD
1305 UDP Name Server Requests
1306 .LP
1307 \fI(N.B.:The following description assumes familiarity with
1308 the Domain Service protocol described in RFC-1035.
1309 If you are not familiar
1310 with the protocol, the following description will appear to be written
1311 in greek.)\fP
1312 .LP
1313 Name server requests are formatted as
1314 .RS
1315 .nf
1316 .sp .5
1317 \fIsrc > dst: id op? flags qtype qclass name (len)\fP
1318 .sp .5
1319 \f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fR
1320 .sp .5
1321 .fi
1322 .RE
1323 Host \fIh2opolo\fP asked the domain server on \fIhelios\fP for an
1324 address record (qtype=A) associated with the name \fIucbvax.berkeley.edu.\fP
1325 The query id was `3'.
1326 The `+' indicates the \fIrecursion desired\fP flag
1327 was set.
1328 The query length was 37 bytes, not including the UDP and
1329 IP protocol headers.
1330 The query operation was the normal one, \fIQuery\fP,
1331 so the op field was omitted.
1332 If the op had been anything else, it would
1333 have been printed between the `3' and the `+'.
1334 Similarly, the qclass was the normal one,
1335 \fIC_IN\fP, and omitted.
1336 Any other qclass would have been printed
1337 immediately after the `A'.
1338 .LP
1339 A few anomalies are checked and may result in extra fields enclosed in
1340 square brackets: If a query contains an answer, authority records or
1341 additional records section,
1342 .IR ancount ,
1343 .IR nscount ,
1344 or
1345 .I arcount
1346 are printed as `[\fIn\fPa]', `[\fIn\fPn]' or `[\fIn\fPau]' where \fIn\fP
1347 is the appropriate count.
1348 If any of the response bits are set (AA, RA or rcode) or any of the
1349 `must be zero' bits are set in bytes two and three, `[b2&3=\fIx\fP]'
1350 is printed, where \fIx\fP is the hex value of header bytes two and three.
1351 .HD
1352 UDP Name Server Responses
1353 .LP
1354 Name server responses are formatted as
1355 .RS
1356 .nf
1357 .sp .5
1358 \fIsrc > dst: id op rcode flags a/n/au type class data (len)\fP
1359 .sp .5
1360 \f(CWhelios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
1361 helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fR
1362 .sp .5
1363 .fi
1364 .RE
1365 In the first example, \fIhelios\fP responds to query id 3 from \fIh2opolo\fP
1366 with 3 answer records, 3 name server records and 7 additional records.
1367 The first answer record is type A (address) and its data is internet
1368 address 128.32.137.3.
1369 The total size of the response was 273 bytes,
1370 excluding UDP and IP headers.
1371 The op (Query) and response code
1372 (NoError) were omitted, as was the class (C_IN) of the A record.
1373 .LP
1374 In the second example, \fIhelios\fP responds to query 2 with a
1375 response code of non-existent domain (NXDomain) with no answers,
1376 one name server and no authority records.
1377 The `*' indicates that
1378 the \fIauthoritative answer\fP bit was set.
1379 Since there were no
1380 answers, no type, class or data were printed.
1381 .LP
1382 Other flag characters that might appear are `\-' (recursion available,
1383 RA, \fInot\fP set) and `|' (truncated message, TC, set).
1384 If the
1385 `question' section doesn't contain exactly one entry, `[\fIn\fPq]'
1386 is printed.
1387 .HD
1388 SMB/CIFS decoding
1389 .LP
1390 \fItcpdump\fP now includes fairly extensive SMB/CIFS/NBT decoding for data
1391 on UDP/137, UDP/138 and TCP/139.
1392 Some primitive decoding of IPX and
1393 NetBEUI SMB data is also done.
1394 .LP
1395 By default a fairly minimal decode is done, with a much more detailed
1396 decode done if -v is used.
1397 Be warned that with -v a single SMB packet
1398 may take up a page or more, so only use -v if you really want all the
1399 gory details.
1400 .LP
1401 For information on SMB packet formats and what all the fields mean see
1402 www.cifs.org or the pub/samba/specs/ directory on your favorite
1403 samba.org mirror site.
1404 The SMB patches were written by Andrew Tridgell
1405 (tridge@samba.org).
1406 .HD
1407 NFS Requests and Replies
1408 .LP
1409 Sun NFS (Network File System) requests and replies are printed as:
1410 .RS
1411 .nf
1412 .sp .5
1413 \fIsrc.xid > dst.nfs: len op args\fP
1414 \fIsrc.nfs > dst.xid: reply stat len op results\fP
1415 .sp .5
1416 \f(CW
1417 sushi.6709 > wrl.nfs: 112 readlink fh 21,24/10.73165
1418 wrl.nfs > sushi.6709: reply ok 40 readlink "../var"
1419 sushi.201b > wrl.nfs:
1420 144 lookup fh 9,74/4096.6878 "xcolors"
1421 wrl.nfs > sushi.201b:
1422 reply ok 128 lookup fh 9,74/4134.3150
1423 \fR
1424 .sp .5
1425 .fi
1426 .RE
1427 In the first line, host \fIsushi\fP sends a transaction with id \fI6709\fP
1428 to \fIwrl\fP.
1429 (Note that for UDP NFS packets the standard UDP header isn't printed and the
1430 number following the src host is a transaction id, \fInot\fP the source port.
1431 The example above represents UDP NFS traffic.
1432 For TCP NFS packets port numbers are printed as part of the standard TCP header
1433 and the transaction id is printed separately as "xid" field of the packet.)
1434 The request was 112 bytes,
1435 excluding the UDP and IP headers.
1436 The operation was a \fIreadlink\fP
1437 (read symbolic link) on file handle (\fIfh\fP) 21,24/10.731657119.
1438 (If one is lucky, as in this case, the file handle can be interpreted
1439 as a major,minor device number pair, followed by the inode number and
1440 generation number.)
1441 \fIWrl\fP replies `ok' with the contents of the link.
1442 .LP
1443 In the third line, \fIsushi\fP asks \fIwrl\fP to lookup the name
1444 `\fIxcolors\fP' in directory file 9,74/4096.6878.
1445 Note that the data printed
1446 depends on the operation type.
1447 The format is intended to be self
1448 explanatory if read in conjunction with
1449 an NFS protocol spec.
1450 .LP
1451 If the \-v (verbose) flag is given, additional information is printed.
1452 For example:
1453 .RS
1454 .nf
1455 .sp .5
1456 \f(CW
1457 sushi.1372a > wrl.nfs:
1458 148 read fh 21,11/12.195 8192 bytes @ 24576
1459 wrl.nfs > sushi.1372a:
1460 reply ok 1472 read REG 100664 ids 417/0 sz 29388
1461 \fP
1462 .sp .5
1463 .fi
1464 .RE
1465 (\-v also prints the IP header TTL, ID, length, and fragmentation fields,
1466 which have been omitted from this example.) In the first line,
1467 \fIsushi\fP asks \fIwrl\fP to read 8192 bytes from file 21,11/12.195,
1468 at byte offset 24576.
1469 \fIWrl\fP replies `ok'; the packet shown on the
1470 second line is the first fragment of the reply, and hence is only 1472
1471 bytes long (the other bytes will follow in subsequent fragments, but
1472 these fragments do not have NFS or even UDP headers and so might not be
1473 printed, depending on the filter expression used).
1474 Because the \-v flag
1475 is given, some of the file attributes (which are returned in addition
1476 to the file data) are printed: the file type (``REG'', for regular file),
1477 the file mode (in octal), the uid and gid, and the file size.
1478 .LP
1479 If the \-v flag is given more than once, even more details are printed.
1480 .LP
1481 Note that NFS requests are very large and much of the detail won't be printed
1482 unless \fIsnaplen\fP is increased.
1483 Try using `\fB\-s 192\fP' to watch
1484 NFS traffic.
1485 .LP
1486 NFS reply packets do not explicitly identify the RPC operation.
1487 Instead,
1488 \fItcpdump\fP keeps track of ``recent'' requests, and matches them to the
1489 replies using the transaction ID.
1490 If a reply does not closely follow the
1491 corresponding request, it might not be parsable.
1492 .HD
1493 AFS Requests and Replies
1494 .LP
1495 Transarc AFS (Andrew File System) requests and replies are printed
1496 as:
1497 .HD
1498 .RS
1499 .nf
1500 .sp .5
1501 \fIsrc.sport > dst.dport: rx packet-type\fP
1502 \fIsrc.sport > dst.dport: rx packet-type service call call-name args\fP
1503 \fIsrc.sport > dst.dport: rx packet-type service reply call-name args\fP
1504 .sp .5
1505 \f(CW
1506 elvis.7001 > pike.afsfs:
1507 rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
1508 new fid 536876964/1/1 ".newsrc"
1509 pike.afsfs > elvis.7001: rx data fs reply rename
1510 \fR
1511 .sp .5
1512 .fi
1513 .RE
1514 In the first line, host elvis sends a RX packet to pike.
1515 This was
1516 a RX data packet to the fs (fileserver) service, and is the start of
1517 an RPC call.
1518 The RPC call was a rename, with the old directory file id
1519 of 536876964/1/1 and an old filename of `.newsrc.new', and a new directory
1520 file id of 536876964/1/1 and a new filename of `.newsrc'.
1521 The host pike
1522 responds with a RPC reply to the rename call (which was successful, because
1523 it was a data packet and not an abort packet).
1524 .LP
1525 In general, all AFS RPCs are decoded at least by RPC call name.
1526 Most
1527 AFS RPCs have at least some of the arguments decoded (generally only
1528 the `interesting' arguments, for some definition of interesting).
1529 .LP
1530 The format is intended to be self-describing, but it will probably
1531 not be useful to people who are not familiar with the workings of
1532 AFS and RX.
1533 .LP
1534 If the -v (verbose) flag is given twice, acknowledgement packets and
1535 additional header information is printed, such as the RX call ID,
1536 call number, sequence number, serial number, and the RX packet flags.
1537 .LP
1538 If the -v flag is given twice, additional information is printed,
1539 such as the RX call ID, serial number, and the RX packet flags.
1540 The MTU negotiation information is also printed from RX ack packets.
1541 .LP
1542 If the -v flag is given three times, the security index and service id
1543 are printed.
1544 .LP
1545 Error codes are printed for abort packets, with the exception of Ubik
1546 beacon packets (because abort packets are used to signify a yes vote
1547 for the Ubik protocol).
1548 .LP
1549 Note that AFS requests are very large and many of the arguments won't
1550 be printed unless \fIsnaplen\fP is increased.
1551 Try using `\fB-s 256\fP'
1552 to watch AFS traffic.
1553 .LP
1554 AFS reply packets do not explicitly identify the RPC operation.
1555 Instead,
1556 \fItcpdump\fP keeps track of ``recent'' requests, and matches them to the
1557 replies using the call number and service ID.
1558 If a reply does not closely
1559 follow the
1560 corresponding request, it might not be parsable.
1561
1562 .HD
1563 KIP AppleTalk (DDP in UDP)
1564 .LP
1565 AppleTalk DDP packets encapsulated in UDP datagrams are de-encapsulated
1566 and dumped as DDP packets (i.e., all the UDP header information is
1567 discarded).
1568 The file
1569 .I /etc/atalk.names
1570 is used to translate AppleTalk net and node numbers to names.
1571 Lines in this file have the form
1572 .RS
1573 .nf
1574 .sp .5
1575 \fInumber name\fP
1576
1577 \f(CW1.254 ether
1578 16.1 icsd-net
1579 1.254.110 ace\fR
1580 .sp .5
1581 .fi
1582 .RE
1583 The first two lines give the names of AppleTalk networks.
1584 The third
1585 line gives the name of a particular host (a host is distinguished
1586 from a net by the 3rd octet in the number \-
1587 a net number \fImust\fP have two octets and a host number \fImust\fP
1588 have three octets.) The number and name should be separated by
1589 whitespace (blanks or tabs).
1590 The
1591 .I /etc/atalk.names
1592 file may contain blank lines or comment lines (lines starting with
1593 a `#').
1594 .LP
1595 AppleTalk addresses are printed in the form
1596 .RS
1597 .nf
1598 .sp .5
1599 \fInet.host.port\fP
1600
1601 \f(CW144.1.209.2 > icsd-net.112.220
1602 office.2 > icsd-net.112.220
1603 jssmag.149.235 > icsd-net.2\fR
1604 .sp .5
1605 .fi
1606 .RE
1607 (If the
1608 .I /etc/atalk.names
1609 doesn't exist or doesn't contain an entry for some AppleTalk
1610 host/net number, addresses are printed in numeric form.)
1611 In the first example, NBP (DDP port 2) on net 144.1 node 209
1612 is sending to whatever is listening on port 220 of net icsd node 112.
1613 The second line is the same except the full name of the source node
1614 is known (`office').
1615 The third line is a send from port 235 on
1616 net jssmag node 149 to broadcast on the icsd-net NBP port (note that
1617 the broadcast address (255) is indicated by a net name with no host
1618 number \- for this reason it's a good idea to keep node names and
1619 net names distinct in /etc/atalk.names).
1620 .LP
1621 NBP (name binding protocol) and ATP (AppleTalk transaction protocol)
1622 packets have their contents interpreted.
1623 Other protocols just dump
1624 the protocol name (or number if no name is registered for the
1625 protocol) and packet size.
1626
1627 \fBNBP packets\fP are formatted like the following examples:
1628 .RS
1629 .nf
1630 .sp .5
1631 \s-2\f(CWicsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
1632 jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
1633 techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fR\s+2
1634 .sp .5
1635 .fi
1636 .RE
1637 The first line is a name lookup request for laserwriters sent by net icsd host
1638 112 and broadcast on net jssmag.
1639 The nbp id for the lookup is 190.
1640 The second line shows a reply for this request (note that it has the
1641 same id) from host jssmag.209 saying that it has a laserwriter
1642 resource named "RM1140" registered on port 250.
1643 The third line is
1644 another reply to the same request saying host techpit has laserwriter
1645 "techpit" registered on port 186.
1646
1647 \fBATP packet\fP formatting is demonstrated by the following example:
1648 .RS
1649 .nf
1650 .sp .5
1651 \s-2\f(CWjssmag.209.165 > helios.132: atp-req 12266<0-7> 0xae030001
1652 helios.132 > jssmag.209.165: atp-resp 12266:0 (512) 0xae040000
1653 helios.132 > jssmag.209.165: atp-resp 12266:1 (512) 0xae040000
1654 helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000
1655 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1656 helios.132 > jssmag.209.165: atp-resp 12266:4 (512) 0xae040000
1657 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1658 helios.132 > jssmag.209.165: atp-resp 12266:6 (512) 0xae040000
1659 helios.132 > jssmag.209.165: atp-resp*12266:7 (512) 0xae040000
1660 jssmag.209.165 > helios.132: atp-req 12266<3,5> 0xae030001
1661 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1662 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1663 jssmag.209.165 > helios.132: atp-rel 12266<0-7> 0xae030001
1664 jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fR\s+2
1665 .sp .5
1666 .fi
1667 .RE
1668 Jssmag.209 initiates transaction id 12266 with host helios by requesting
1669 up to 8 packets (the `<0-7>').
1670 The hex number at the end of the line
1671 is the value of the `userdata' field in the request.
1672 .LP
1673 Helios responds with 8 512-byte packets.
1674 The `:digit' following the
1675 transaction id gives the packet sequence number in the transaction
1676 and the number in parens is the amount of data in the packet,
1677 excluding the atp header.
1678 The `*' on packet 7 indicates that the
1679 EOM bit was set.
1680 .LP
1681 Jssmag.209 then requests that packets 3 & 5 be retransmitted.
1682 Helios
1683 resends them then jssmag.209 releases the transaction.
1684 Finally,
1685 jssmag.209 initiates the next request.
1686 The `*' on the request
1687 indicates that XO (`exactly once') was \fInot\fP set.
1688
1689 .HD
1690 IP Fragmentation
1691 .LP
1692 Fragmented Internet datagrams are printed as
1693 .RS
1694 .nf
1695 .sp .5
1696 \fB(frag \fIid\fB:\fIsize\fB@\fIoffset\fB+)\fR
1697 \fB(frag \fIid\fB:\fIsize\fB@\fIoffset\fB)\fR
1698 .sp .5
1699 .fi
1700 .RE
1701 (The first form indicates there are more fragments.
1702 The second
1703 indicates this is the last fragment.)
1704 .LP
1705 \fIId\fP is the fragment id.
1706 \fISize\fP is the fragment
1707 size (in bytes) excluding the IP header.
1708 \fIOffset\fP is this
1709 fragment's offset (in bytes) in the original datagram.
1710 .LP
1711 The fragment information is output for each fragment.
1712 The first
1713 fragment contains the higher level protocol header and the frag
1714 info is printed after the protocol info.
1715 Fragments
1716 after the first contain no higher level protocol header and the
1717 frag info is printed after the source and destination addresses.
1718 For example, here is part of an ftp from arizona.edu to lbl-rtsg.arpa
1719 over a CSNET connection that doesn't appear to handle 576 byte datagrams:
1720 .RS
1721 .nf
1722 .sp .5
1723 \s-2\f(CWarizona.ftp-data > rtsg.1170: . 1024:1332(308) ack 1 win 4096 (frag 595a:328@0+)
1724 arizona > rtsg: (frag 595a:204@328)
1725 rtsg.1170 > arizona.ftp-data: . ack 1536 win 2560\fP\s+2
1726 .sp .5
1727 .fi
1728 .RE
1729 There are a couple of things to note here: First, addresses in the
1730 2nd line don't include port numbers.
1731 This is because the TCP
1732 protocol information is all in the first fragment and we have no idea
1733 what the port or sequence numbers are when we print the later fragments.
1734 Second, the tcp sequence information in the first line is printed as if there
1735 were 308 bytes of user data when, in fact, there are 512 bytes (308 in
1736 the first frag and 204 in the second).
1737 If you are looking for holes
1738 in the sequence space or trying to match up acks
1739 with packets, this can fool you.
1740 .LP
1741 A packet with the IP \fIdon't fragment\fP flag is marked with a
1742 trailing \fB(DF)\fP.
1743 .HD
1744 Timestamps
1745 .LP
1746 By default, all output lines are preceded by a timestamp.
1747 The timestamp
1748 is the current clock time in the form
1749 .RS
1750 .nf
1751 \fIhh:mm:ss.frac\fP
1752 .fi
1753 .RE
1754 and is as accurate as the kernel's clock.
1755 The timestamp reflects the time the kernel first saw the packet.
1756 No attempt
1757 is made to account for the time lag between when the
1758 Ethernet interface removed the packet from the wire and when the kernel
1759 serviced the `new packet' interrupt.
1760 .SH "SEE ALSO"
1761 stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@),
1762 pcap-filter(@MAN_MISC_INFO@), pcap-tstamp(@MAN_MISC_INFO@)
1763 .LP
1764 .RS
1765 .I http://www.iana.org/assignments/media-types/application/vnd.tcpdump.pcap
1766 .RE
1767 .LP
1768 .SH AUTHORS
1769 The original authors are:
1770 .LP
1771 Van Jacobson,
1772 Craig Leres and
1773 Steven McCanne, all of the
1774 Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
1775 .LP
1776 It is currently being maintained by tcpdump.org.
1777 .LP
1778 The current version is available via http:
1779 .LP
1780 .RS
1781 .I http://www.tcpdump.org/
1782 .RE
1783 .LP
1784 The original distribution is available via anonymous ftp:
1785 .LP
1786 .RS
1787 .I ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z
1788 .RE
1789 .LP
1790 IPv6/IPsec support is added by WIDE/KAME project.
1791 This program uses Eric Young's SSLeay library, under specific configurations.
1792 .SH BUGS
1793 Please send problems, bugs, questions, desirable enhancements, patches
1794 etc. to:
1795 .LP
1796 .RS
1797 tcpdump-workers@lists.tcpdump.org
1798 .RE
1799 .LP
1800 NIT doesn't let you watch your own outbound traffic, BPF will.
1801 We recommend that you use the latter.
1802 .LP
1803 On Linux systems with 2.0[.x] kernels:
1804 .IP
1805 packets on the loopback device will be seen twice;
1806 .IP
1807 packet filtering cannot be done in the kernel, so that all packets must
1808 be copied from the kernel in order to be filtered in user mode;
1809 .IP
1810 all of a packet, not just the part that's within the snapshot length,
1811 will be copied from the kernel (the 2.0[.x] packet capture mechanism, if
1812 asked to copy only part of a packet to userland, will not report the
1813 true length of the packet; this would cause most IP packets to get an
1814 error from
1815 .BR tcpdump );
1816 .IP
1817 capturing on some PPP devices won't work correctly.
1818 .LP
1819 We recommend that you upgrade to a 2.2 or later kernel.
1820 .LP
1821 Some attempt should be made to reassemble IP fragments or, at least
1822 to compute the right length for the higher level protocol.
1823 .LP
1824 Name server inverse queries are not dumped correctly: the (empty)
1825 question section is printed rather than real query in the answer
1826 section.
1827 Some believe that inverse queries are themselves a bug and
1828 prefer to fix the program generating them rather than \fItcpdump\fP.
1829 .LP
1830 A packet trace that crosses a daylight savings time change will give
1831 skewed time stamps (the time change is ignored).
1832 .LP
1833 Filter expressions on fields other than those in Token Ring headers will
1834 not correctly handle source-routed Token Ring packets.
1835 .LP
1836 Filter expressions on fields other than those in 802.11 headers will not
1837 correctly handle 802.11 data packets with both To DS and From DS set.
1838 .LP
1839 .BR "ip6 proto"
1840 should chase header chain, but at this moment it does not.
1841 .BR "ip6 protochain"
1842 is supplied for this behavior.
1843 .LP
1844 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
1845 does not work against IPv6 packets.
1846 It only looks at IPv4 packets.