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