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