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