]> The Tcpdump Group git mirrors - tcpdump/blob - tcpdump.1
verify/warn icmpv6 checksum. from jinmei@kame
[tcpdump] / tcpdump.1
1 .\" $NetBSD: tcpdump.8,v 1.9 2003/03/31 00:18:17 perry Exp $
2 .\"
3 .\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
4 .\" The Regents of the University of California. All rights reserved.
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that: (1) source code distributions
9 .\" retain the above copyright notice and this paragraph in its entirety, (2)
10 .\" distributions including binary code include the above copyright notice and
11 .\" this paragraph in its entirety in the documentation or other materials
12 .\" provided with the distribution, and (3) all advertising materials mentioning
13 .\" features or use of this software display the following acknowledgement:
14 .\" ``This product includes software developed by the University of California,
15 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 .\" the University nor the names of its contributors may be used to endorse
17 .\" or promote products derived from this software without specific prior
18 .\" written permission.
19 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 .\"
23 .TH TCPDUMP 1 "21 December 2002"
24 .SH NAME
25 tcpdump \- dump traffic on a network
26 .SH SYNOPSIS
27 .na
28 .B tcpdump
29 [
30 .B \-aAdDeflLnNOpqRStuUvxX
31 ] [
32 .B \-c
33 .I count
34 ]
35 .br
36 .ti +8
37 [
38 .B \-C
39 .I file_size
40 ] [
41 .B \-F
42 .I file
43 ]
44 .br
45 .ti +8
46 [
47 .B \-i
48 .I interface
49 ]
50 [
51 .B \-m
52 .I module
53 ]
54 [
55 .B \-r
56 .I file
57 ]
58 .br
59 .ti +8
60 [
61 .B \-s
62 .I snaplen
63 ]
64 [
65 .B \-T
66 .I type
67 ]
68 [
69 .B \-w
70 .I file
71 ]
72 .br
73 .ti +8
74 [
75 .B \-E
76 .I spi@ipaddr algo:secret,...
77 ]
78 .br
79 .ti +8
80 [
81 .B \-y
82 .I datalinktype
83 ]
84 .ti +8
85 [
86 .I expression
87 ]
88 .br
89 .ad
90 .SH DESCRIPTION
91 .LP
92 \fITcpdump\fP prints out the headers of packets on a network interface
93 that match the boolean \fIexpression\fP. It can also be run with the
94 .B \-w
95 flag, which causes it to save the packet data to a file for later
96 analysis, and/or with the
97 .B \-r
98 flag, which causes it to read from a saved packet file rather than to
99 read packets from a network interface. In all cases, only packets that
100 match
101 .I expression
102 will be processed by
103 .IR tcpdump .
104 .LP
105 .I Tcpdump
106 will, if not run with the
107 .B \-c
108 flag, continue capturing packets until it is interrupted by a SIGINT
109 signal (generated, for example, by typing your interrupt character,
110 typically control-C) or a SIGTERM signal (typically generated with the
111 .BR kill (1)
112 command); if run with the
113 .B \-c
114 flag, it will capture packets until it is interrupted by a SIGINT or
115 SIGTERM signal or the specified number of packets have been processed.
116 .LP
117 When
118 .I tcpdump
119 finishes capturing packets, it will report counts of:
120 .IP
121 packets ``received by filter'' (the meaning of this depends on the OS on
122 which you're running
123 .IR tcpdump ,
124 and possibly on the way the OS was configured - if a filter was
125 specified on the command line, on some OSes it counts packets regardless
126 of whether they were matched by the filter expression, and on other OSes
127 it counts only packets that were matched by the filter expression and
128 were processed by
129 .IR tcpdump );
130 .IP
131 packets ``dropped by kernel'' (this is the number of packets that were
132 dropped, due to a lack of buffer space, by the packet capture mechanism
133 in the OS on which
134 .I tcpdump
135 is running, if the OS reports that information to applications; if not,
136 it will be reported as 0).
137 .LP
138 On platforms that support the SIGINFO signal, such as most BSDs, it will
139 report those counts when it receives a SIGINFO signal (generated, for
140 example, by typing your ``status'' character, typically control-T) and
141 will continue capturing packets.
142 .LP
143 Reading packets from a network interface may require that you have
144 special privileges:
145 .TP
146 .B Under SunOS 3.x or 4.x with NIT or BPF:
147 You must have read access to
148 .I /dev/nit
149 or
150 .IR /dev/bpf* .
151 .TP
152 .B Under Solaris with DLPI:
153 You must have read/write access to the network pseudo device, e.g.
154 .IR /dev/le .
155 On at least some versions of Solaris, however, this is not sufficient to
156 allow
157 .I tcpdump
158 to capture in promiscuous mode; on those versions of Solaris, you must
159 be root, or
160 .I tcpdump
161 must be installed setuid to root, in order to capture in promiscuous
162 mode. Note that, on many (perhaps all) interfaces, if you don't capture
163 in promiscuous mode, you will not see any outgoing packets, so a capture
164 not done in promiscuous mode may not be very useful.
165 .TP
166 .B Under HP-UX with DLPI:
167 You must be root or
168 .I tcpdump
169 must be installed setuid to root.
170 .TP
171 .B Under IRIX with snoop:
172 You must be root or
173 .I tcpdump
174 must be installed setuid to root.
175 .TP
176 .B Under Linux:
177 You must be root or
178 .I tcpdump
179 must be installed setuid to root.
180 .TP
181 .B Under Ultrix and Digital UNIX/Tru64 UNIX:
182 Any user may capture network traffic with
183 .IR tcpdump .
184 However, no user (not even the super-user) can capture in promiscuous
185 mode on an interface unless the super-user has enabled promiscuous-mode
186 operation on that interface using
187 .IR pfconfig (8),
188 and no user (not even the super-user) can capture unicast traffic
189 received by or sent by the machine on an interface unless the super-user
190 has enabled copy-all-mode operation on that interface using
191 .IR pfconfig ,
192 so
193 .I useful
194 packet capture on an interface probably requires that either
195 promiscuous-mode or copy-all-mode operation, or both modes of
196 operation, be enabled on that interface.
197 .TP
198 .B Under BSD:
199 You must have read access to
200 .IR /dev/bpf* .
201 .LP
202 Reading a saved packet file doesn't require special privileges.
203 .SH OPTIONS
204 .TP
205 .B \-A
206 Print each packet (minus its link level header) in ASCII. Handy for
207 capturing web pages.
208 .TP
209 .B \-a
210 Attempt to convert network and broadcast addresses to names.
211 .TP
212 .B \-c
213 Exit after receiving \fIcount\fP packets.
214 .TP
215 .B \-C
216 Before writing a raw packet to a savefile, check whether the file is
217 currently larger than \fIfile_size\fP and, if so, close the current
218 savefile and open a new one. Savefiles after the first savefile will
219 have the name specified with the
220 .B \-w
221 flag, with a number after it, starting at 2 and continuing upward.
222 The units of \fIfile_size\fP are millions of bytes (1,000,000 bytes,
223 not 1,048,576 bytes).
224 .TP
225 .B \-d
226 Dump the compiled packet-matching code in a human readable form to
227 standard output and stop.
228 .TP
229 .B \-dd
230 Dump packet-matching code as a
231 .B C
232 program fragment.
233 .TP
234 .B \-ddd
235 Dump packet-matching code as decimal numbers (preceded with a count).
236 .TP
237 .B \-D
238 Print the list of the network interfaces available on the system and on
239 which
240 .I tcpdump
241 can capture packets. For each network interface, a number and an
242 interface name, possibly followed by a text description of the
243 interface, is printed. The interface name or the number can be supplied
244 to the
245 .B \-i
246 flag to specify an interface on which to capture.
247 .IP
248 This can be useful on systems that don't have a command to list them
249 (e.g., Windows systems, or UNIX systems lacking
250 .BR "ifconfig \-a" );
251 the number can be useful on Windows 2000 and later systems, where the
252 interface name is a somewhat complex string.
253 .IP
254 The
255 .B \-D
256 flag will not be supported if
257 .I tcpdump
258 was built with an older version of
259 .I libpcap
260 that lacks the
261 .B pcap_findalldevs()
262 function.
263 .TP
264 .B \-e
265 Print the link-level header on each dump line.
266 .TP
267 .B \-E
268 Use \fIspi@ipaddr algo:secret\fP for decrypting IPsec ESP packets that
269 are addressed to \fIaddr\fP and contain Security Parameter Index value
270 \fIspi\fP. This combination may be repeated with comma or newline seperation.
271 .IP
272 Note that setting the secret for IPv4 ESP packets is supported at this time.
273 .IP
274 Algorithms may be
275 \fBdes-cbc\fP,
276 \fB3des-cbc\fP,
277 \fBblowfish-cbc\fP,
278 \fBrc3-cbc\fP,
279 \fBcast128-cbc\fP, or
280 \fBnone\fP.
281 The default is \fBdes-cbc\fP.
282 The ability to decrypt packets is only present if \fItcpdump\fP was compiled
283 with cryptography enabled.
284 .IP
285 \fIsecret\fP is the ASCII text for ESP secret key.
286 If preceeded by 0x, then a hex value will be read.
287 .IP
288 The option assumes RFC2406 ESP, not RFC1827 ESP.
289 The option is only for debugging purposes, and
290 the use of this option with a true `secret' key is discouraged.
291 By presenting IPsec secret key onto command line
292 you make it visible to others, via
293 .IR ps (1)
294 and other occasions.
295 .IP
296 In addition to the above syntax, the syntax \fIfile name\fP may be used
297 to have tcpdump read the provided file in. The file is opened upon
298 receiving the first ESP packet, so any special permissions that tcpdump
299 may have been given should already have been given up.
300 .TP
301 .B \-f
302 Print `foreign' IPv4 addresses numerically rather than symbolically
303 (this option is intended to get around serious brain damage in
304 Sun's NIS server \(em usually it hangs forever translating non-local
305 internet numbers).
306 .IP
307 The test for `foreign' IPv4 addresses is done using the IPv4 address and
308 netmask of the interface on which capture is being done. If that
309 address or netmask are not available, available, either because the
310 interface on which capture is being done has no address or netmask or
311 because the capture is being done on the Linux "any" interface, which
312 can capture on more than one interface, this option will not work
313 correctly.
314 .TP
315 .B \-F
316 Use \fIfile\fP as input for the filter expression.
317 An additional expression given on the command line is ignored.
318 .TP
319 .B \-i
320 Listen on \fIinterface\fP.
321 If unspecified, \fItcpdump\fP searches the system interface list for the
322 lowest numbered, configured up interface (excluding loopback).
323 Ties are broken by choosing the earliest match.
324 .IP
325 On Linux systems with 2.2 or later kernels, an
326 .I interface
327 argument of ``any'' can be used to capture packets from all interfaces.
328 Note that captures on the ``any'' device will not be done in promiscuous
329 mode.
330 .IP
331 If the
332 .B \-D
333 flag is supported, an interface number as printed by that flag can be
334 used as the
335 .I interface
336 argument.
337 .TP
338 .B \-l
339 Make stdout line buffered.
340 Useful if you want to see the data
341 while capturing it.
342 E.g.,
343 .br
344 ``tcpdump\ \ \-l\ \ |\ \ tee dat'' or
345 ``tcpdump\ \ \-l \ \ > dat\ \ &\ \ tail\ \ \-f\ \ dat''.
346 .TP
347 .B \-L
348 List the known data link types for the interface and exit.
349 .TP
350 .B \-m
351 Load SMI MIB module definitions from file \fImodule\fR.
352 This option
353 can be used several times to load several MIB modules into \fItcpdump\fP.
354 .TP
355 .B \-n
356 Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.
357 .TP
358 .B \-N
359 Don't print domain name qualification of host names.
360 E.g.,
361 if you give this flag then \fItcpdump\fP will print ``nic''
362 instead of ``nic.ddn.mil''.
363 .TP
364 .B \-O
365 Do not run the packet-matching code optimizer.
366 This is useful only
367 if you suspect a bug in the optimizer.
368 .TP
369 .B \-p
370 \fIDon't\fP put the interface
371 into promiscuous mode.
372 Note that the interface might be in promiscuous
373 mode for some other reason; hence, `-p' cannot be used as an abbreviation for
374 `ether host {local-hw-addr} or ether broadcast'.
375 .TP
376 .B \-q
377 Quick (quiet?) output.
378 Print less protocol information so output
379 lines are shorter.
380 .TP
381 .B \-R
382 Assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829).
383 If specified, \fItcpdump\fP will not print replay prevention field.
384 Since there is no protocol version field in ESP/AH specification,
385 \fItcpdump\fP cannot deduce the version of ESP/AH protocol.
386 .TP
387 .B \-r
388 Read packets from \fIfile\fR (which was created with the
389 .B \-w
390 option).
391 Standard input is used if \fIfile\fR is ``-''.
392 .TP
393 .B \-S
394 Print absolute, rather than relative, TCP sequence numbers.
395 .TP
396 .B \-s
397 Snarf \fIsnaplen\fP bytes of data from each packet rather than the
398 default of 68 (with SunOS's NIT, the minimum is actually 96).
399 68 bytes is adequate for IP, ICMP, TCP
400 and UDP but may truncate protocol information from name server and NFS
401 packets (see below).
402 Packets truncated because of a limited snapshot
403 are indicated in the output with ``[|\fIproto\fP]'', where \fIproto\fP
404 is the name of the protocol level at which the truncation has occurred.
405 Note that taking larger snapshots both increases
406 the amount of time it takes to process packets and, effectively,
407 decreases the amount of packet buffering.
408 This may cause packets to be
409 lost.
410 You should limit \fIsnaplen\fP to the smallest number that will
411 capture the protocol information you're interested in.
412 Setting
413 \fIsnaplen\fP to 0 means use the required length to catch whole packets.
414 .TP
415 .B \-T
416 Force packets selected by "\fIexpression\fP" to be interpreted the
417 specified \fItype\fR.
418 Currently known types are
419 \fBcnfp\fR (Cisco NetFlow protocol),
420 \fBrpc\fR (Remote Procedure Call),
421 \fBrtp\fR (Real-Time Applications protocol),
422 \fBrtcp\fR (Real-Time Applications control protocol),
423 \fBsnmp\fR (Simple Network Management Protocol),
424 \fBvat\fR (Visual Audio Tool),
425 and
426 \fBwb\fR (distributed White Board).
427 .TP
428 .B \-t
429 \fIDon't\fP print a timestamp on each dump line.
430 .TP
431 .B \-tt
432 Print an unformatted timestamp on each dump line.
433 .TP
434 .B \-ttt
435 Print a delta (in micro-seconds) between current and previous line
436 on each dump line.
437 .TP
438 .B \-tttt
439 Print a timestamp in default format proceeded by date on each dump line.
440 .TP
441 .B \-u
442 Print undecoded NFS handles.
443 .TP
444 .B \-U
445 Make output saved via the
446 .B \-w
447 option ``packet-buffered''; i.e., as each packet is saved, it will be
448 written to the output file, rather than being written only when the
449 output buffer fills.
450 .IP
451 The
452 .B \-U
453 flag will not be supported if
454 .I tcpdump
455 was built with an older version of
456 .I libpcap
457 that lacks the
458 .B pcap_dump_flush()
459 function.
460 .TP
461 .B \-v
462 (Slightly more) verbose output.
463 For example, the time to live,
464 identification, total length and options in an IP packet are printed.
465 Also enables additional packet integrity checks such as verifying the
466 IP and ICMP header checksum.
467 .TP
468 .B \-vv
469 Even more verbose output.
470 For example, additional fields are
471 printed from NFS reply packets, and SMB packets are fully decoded.
472 .TP
473 .B \-vvv
474 Even more verbose output.
475 For example,
476 telnet \fBSB\fP ... \fBSE\fP options
477 are printed in full.
478 With
479 .B \-X
480 Telnet options are printed in hex as well.
481 .TP
482 .B \-w
483 Write the raw packets to \fIfile\fR rather than parsing and printing
484 them out.
485 They can later be printed with the \-r option.
486 Standard output is used if \fIfile\fR is ``-''.
487 .TP
488 .B \-x
489 Print each packet (minus its link level header) in hex.
490 The smaller of the entire packet or
491 .I snaplen
492 bytes will be printed. Note that this is the entire link-layer
493 packet, so for link layers that pad (e.g. Ethernet), the padding bytes
494 will also be printed when the higher layer packet is shorter than the
495 required padding.
496 .TP
497 .B \-xx
498 Print each packet,
499 .I including
500 its link level header, in hex.
501 .TP
502 .B \-X
503 Print each packet (minus its link level header) in hex and ASCII.
504 This is very handy for analysing new protocols.
505 .TP
506 .B \-XX
507 Print each packet,
508 .I including
509 its link level header, in hex and ASCII.
510 .TP
511 .B \-y
512 Set the data link type to use while capturing packets to \fIdatalinktype\fP.
513 .IP "\fI expression\fP"
514 .RS
515 selects which packets will be dumped.
516 If no \fIexpression\fP
517 is given, all packets on the net will be dumped.
518 Otherwise,
519 only packets for which \fIexpression\fP is `true' will be dumped.
520 .LP
521 The \fIexpression\fP consists of one or more
522 .I primitives.
523 Primitives usually consist of an
524 .I id
525 (name or number) preceded by one or more qualifiers.
526 There are three
527 different kinds of qualifier:
528 .IP \fItype\fP
529 qualifiers say what kind of thing the id name or number refers to.
530 Possible types are
531 .BR host ,
532 .B net
533 and
534 .BR port .
535 E.g., `host foo', `net 128.3', `port 20'.
536 If there is no type
537 qualifier,
538 .B host
539 is assumed.
540 .IP \fIdir\fP
541 qualifiers specify a particular transfer direction to and/or from
542 .IR id .
543 Possible directions are
544 .BR src ,
545 .BR dst ,
546 .B "src or dst"
547 and
548 .B "src and"
549 .BR dst .
550 E.g., `src foo', `dst net 128.3', `src or dst port ftp-data'.
551 If
552 there is no dir qualifier,
553 .B "src or dst"
554 is assumed.
555 For some link layers, such as SLIP and the ``cooked'' Linux capture mode
556 used for the ``any'' device and for some other device types, the
557 .B inbound
558 and
559 .B outbound
560 qualifiers can be used to specify a desired direction.
561 .IP \fIproto\fP
562 qualifiers restrict the match to a particular protocol.
563 Possible
564 protos are:
565 .BR ether ,
566 .BR fddi ,
567 .BR tr ,
568 .BR wlan ,
569 .BR ip ,
570 .BR ip6 ,
571 .BR arp ,
572 .BR rarp ,
573 .BR decnet ,
574 .B tcp
575 and
576 .BR udp .
577 E.g., `ether src foo', `arp net 128.3', `tcp port 21'.
578 If there is
579 no proto qualifier, all protocols consistent with the type are
580 assumed.
581 E.g., `src foo' means `(ip or arp or rarp) src foo'
582 (except the latter is not legal syntax), `net bar' means `(ip or
583 arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'.
584 .LP
585 [`fddi' is actually an alias for `ether'; the parser treats them
586 identically as meaning ``the data link level used on the specified
587 network interface.'' FDDI headers contain Ethernet-like source
588 and destination addresses, and often contain Ethernet-like packet
589 types, so you can filter on these FDDI fields just as with the
590 analogous Ethernet fields.
591 FDDI headers also contain other fields,
592 but you cannot name them explicitly in a filter expression.
593 .LP
594 Similarly, `tr' and `wlan' are aliases for `ether'; the previous
595 paragraph's statements about FDDI headers also apply to Token Ring
596 and 802.11 wireless LAN headers. For 802.11 headers, the destination
597 address is the DA field and the source address is the SA field; the
598 BSSID, RA, and TA fields aren't tested.]
599 .LP
600 In addition to the above, there are some special `primitive' keywords
601 that don't follow the pattern:
602 .BR gateway ,
603 .BR broadcast ,
604 .BR less ,
605 .B greater
606 and arithmetic expressions.
607 All of these are described below.
608 .LP
609 More complex filter expressions are built up by using the words
610 .BR and ,
611 .B or
612 and
613 .B not
614 to combine primitives.
615 E.g., `host foo and not port ftp and not port ftp-data'.
616 To save typing, identical qualifier lists can be omitted.
617 E.g.,
618 `tcp dst port ftp or ftp-data or domain' is exactly the same as
619 `tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'.
620 .LP
621 Allowable primitives are:
622 .IP "\fBdst host \fIhost\fR"
623 True if the IPv4/v6 destination field of the packet is \fIhost\fP,
624 which may be either an address or a name.
625 .IP "\fBsrc host \fIhost\fR"
626 True if the IPv4/v6 source field of the packet is \fIhost\fP.
627 .IP "\fBhost \fIhost\fP
628 True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
629 Any of the above host expressions can be prepended with the keywords,
630 \fBip\fP, \fBarp\fP, \fBrarp\fP, or \fBip6\fP as in:
631 .in +.5i
632 .nf
633 \fBip host \fIhost\fR
634 .fi
635 .in -.5i
636 which is equivalent to:
637 .in +.5i
638 .nf
639 \fBether proto \fI\\ip\fB and host \fIhost\fR
640 .fi
641 .in -.5i
642 If \fIhost\fR is a name with multiple IP addresses, each address will
643 be checked for a match.
644 .IP "\fBether dst \fIehost\fP
645 True if the ethernet destination address is \fIehost\fP.
646 \fIEhost\fP
647 may be either a name from /etc/ethers or a number (see
648 .IR ethers (3N)
649 for numeric format).
650 .IP "\fBether src \fIehost\fP
651 True if the ethernet source address is \fIehost\fP.
652 .IP "\fBether host \fIehost\fP
653 True if either the ethernet source or destination address is \fIehost\fP.
654 .IP "\fBgateway\fP \fIhost\fP
655 True if the packet used \fIhost\fP as a gateway.
656 I.e., the ethernet
657 source or destination address was \fIhost\fP but neither the IP source
658 nor the IP destination was \fIhost\fP.
659 \fIHost\fP must be a name and
660 must be found both by the machine's host-name-to-IP-address resolution
661 mechanisms (host name file, DNS, NIS, etc.) and by the machine's
662 host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
663 (An equivalent expression is
664 .in +.5i
665 .nf
666 \fBether host \fIehost \fBand not host \fIhost\fR
667 .fi
668 .in -.5i
669 which can be used with either names or numbers for \fIhost / ehost\fP.)
670 This syntax does not work in IPv6-enabled configuration at this moment.
671 .IP "\fBdst net \fInet\fR"
672 True if the IPv4/v6 destination address of the packet has a network
673 number of \fInet\fP.
674 \fINet\fP may be either a name from /etc/networks
675 or a network number (see \fInetworks(4)\fP for details).
676 .IP "\fBsrc net \fInet\fR"
677 True if the IPv4/v6 source address of the packet has a network
678 number of \fInet\fP.
679 .IP "\fBnet \fInet\fR"
680 True if either the IPv4/v6 source or destination address of the packet has a network
681 number of \fInet\fP.
682 .IP "\fBnet \fInet\fR \fBmask \fInetmask\fR"
683 True if the IP address matches \fInet\fR with the specific \fInetmask\fR.
684 May be qualified with \fBsrc\fR or \fBdst\fR.
685 Note that this syntax is not valid for IPv6 \fInet\fR.
686 .IP "\fBnet \fInet\fR/\fIlen\fR"
687 True if the IPv4/v6 address matches \fInet\fR with a netmask \fIlen\fR
688 bits wide.
689 May be qualified with \fBsrc\fR or \fBdst\fR.
690 .IP "\fBdst port \fIport\fR"
691 True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
692 destination port value of \fIport\fP.
693 The \fIport\fP can be a number or a name used in /etc/services (see
694 .IR tcp (4P)
695 and
696 .IR udp (4P)).
697 If a name is used, both the port
698 number and protocol are checked.
699 If a number or ambiguous name is used,
700 only the port number is checked (e.g., \fBdst port 513\fR will print both
701 tcp/login traffic and udp/who traffic, and \fBport domain\fR will print
702 both tcp/domain and udp/domain traffic).
703 .IP "\fBsrc port \fIport\fR"
704 True if the packet has a source port value of \fIport\fP.
705 .IP "\fBport \fIport\fR"
706 True if either the source or destination port of the packet is \fIport\fP.
707 Any of the above port expressions can be prepended with the keywords,
708 \fBtcp\fP or \fBudp\fP, as in:
709 .in +.5i
710 .nf
711 \fBtcp src port \fIport\fR
712 .fi
713 .in -.5i
714 which matches only tcp packets whose source port is \fIport\fP.
715 .IP "\fBless \fIlength\fR"
716 True if the packet has a length less than or equal to \fIlength\fP.
717 This is equivalent to:
718 .in +.5i
719 .nf
720 \fBlen <= \fIlength\fP.
721 .fi
722 .in -.5i
723 .IP "\fBgreater \fIlength\fR"
724 True if the packet has a length greater than or equal to \fIlength\fP.
725 This is equivalent to:
726 .in +.5i
727 .nf
728 \fBlen >= \fIlength\fP.
729 .fi
730 .in -.5i
731 .IP "\fBip proto \fIprotocol\fR"
732 True if the packet is an IP packet (see
733 .IR ip (4P))
734 of protocol type \fIprotocol\fP.
735 \fIProtocol\fP can be a number or one of the names
736 \fIicmp\fP, \fIicmp6\fP, \fIigmp\fP, \fIigrp\fP, \fIpim\fP, \fIah\fP,
737 \fIesp\fP, \fIvrrp\fP, \fIudp\fP, or \fItcp\fP.
738 Note that the identifiers \fItcp\fP, \fIudp\fP, and \fIicmp\fP are also
739 keywords and must be escaped via backslash (\\), which is \\\\ in the C-shell.
740 Note that this primitive does not chase the protocol header chain.
741 .IP "\fBip6 proto \fIprotocol\fR"
742 True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
743 Note that this primitive does not chase the protocol header chain.
744 .IP "\fBip6 protochain \fIprotocol\fR"
745 True if the packet is IPv6 packet,
746 and contains protocol header with type \fIprotocol\fR
747 in its protocol header chain.
748 For example,
749 .in +.5i
750 .nf
751 \fBip6 protochain 6\fR
752 .fi
753 .in -.5i
754 matches any IPv6 packet with TCP protocol header in the protocol header chain.
755 The packet may contain, for example,
756 authentication header, routing header, or hop-by-hop option header,
757 between IPv6 header and TCP header.
758 The BPF code emitted by this primitive is complex and
759 cannot be optimized by BPF optimizer code in \fItcpdump\fP,
760 so this can be somewhat slow.
761 .IP "\fBip protochain \fIprotocol\fR"
762 Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
763 .IP "\fBether broadcast\fR"
764 True if the packet is an ethernet broadcast packet.
765 The \fIether\fP
766 keyword is optional.
767 .IP "\fBip broadcast\fR"
768 True if the packet is an IPv4 broadcast packet.
769 It checks for both the all-zeroes and all-ones broadcast conventions,
770 and looks up the subnet mask on the interface on which the capture is
771 being done.
772 .IP
773 If the subnet mask of the interface on which the capture is being done
774 is not available, either because the interface on which capture is being
775 done has no netmask or because the capture is being done on the Linux
776 "any" interface, which can capture on more than one interface, this
777 check will not work correctly.
778 .IP "\fBether multicast\fR"
779 True if the packet is an ethernet multicast packet.
780 The \fIether\fP
781 keyword is optional.
782 This is shorthand for `\fBether[0] & 1 != 0\fP'.
783 .IP "\fBip multicast\fR"
784 True if the packet is an IP multicast packet.
785 .IP "\fBip6 multicast\fR"
786 True if the packet is an IPv6 multicast packet.
787 .IP "\fBether proto \fIprotocol\fR"
788 True if the packet is of ether type \fIprotocol\fR.
789 \fIProtocol\fP can be a number or one of the names
790 \fIip\fP, \fIip6\fP, \fIarp\fP, \fIrarp\fP, \fIatalk\fP, \fIaarp\fP,
791 \fIdecnet\fP, \fIsca\fP, \fIlat\fP, \fImopdl\fP, \fImoprc\fP,
792 \fIiso\fP, \fIstp\fP, \fIipx\fP, or \fInetbeui\fP.
793 Note these identifiers are also keywords
794 and must be escaped via backslash (\\).
795 .IP
796 [In the case of FDDI (e.g., `\fBfddi protocol arp\fR'), Token Ring
797 (e.g., `\fBtr protocol arp\fR'), and IEEE 802.11 wireless LANS (e.g.,
798 `\fBwlan protocol arp\fR'), for most of those protocols, the
799 protocol identification comes from the 802.2 Logical Link Control (LLC)
800 header, which is usually layered on top of the FDDI, Token Ring, or
801 802.11 header.
802 .IP
803 When filtering for most protocol identifiers on FDDI, Token Ring, or
804 802.11, \fItcpdump\fR checks only the protocol ID field of an LLC header
805 in so-called SNAP format with an Organizational Unit Identifier (OUI) of
806 0x000000, for encapsulated Ethernet; it doesn't check whether the packet
807 is in SNAP format with an OUI of 0x000000.
808 The exceptions are:
809 .RS
810 .TP
811 \fBiso\fP
812 \fItcpdump\fR checks the DSAP (Destination Service Access Point) and
813 SSAP (Source Service Access Point) fields of the LLC header;
814 .TP
815 \fBstp\fP and \fInetbeui\fP
816 \fItcpdump\fR checks the DSAP of the LLC header;
817 .TP
818 \fIatalk\fP
819 \fItcpdump\fR checks for a SNAP-format packet with an OUI of 0x080007
820 and the AppleTalk etype.
821 .RE
822 .IP
823 In the case of Ethernet, \fItcpdump\fR checks the Ethernet type field
824 for most of those protocols. The exceptions are:
825 .RS
826 .TP
827 \fBiso\fP, \fBsap\fP, and \fBnetbeui\fP
828 \fItcpdump\fR checks for an 802.3 frame and then checks the LLC header as
829 it does for FDDI, Token Ring, and 802.11;
830 .TP
831 \fBatalk\fP
832 \fItcpdump\fR checks both for the AppleTalk etype in an Ethernet frame and
833 for a SNAP-format packet as it does for FDDI, Token Ring, and 802.11;
834 .TP
835 \fBaarp\fP
836 \fItcpdump\fR checks for the AppleTalk ARP etype in either an Ethernet
837 frame or an 802.2 SNAP frame with an OUI of 0x000000;
838 .TP
839 \fBipx\fP
840 \fItcpdump\fR checks for the IPX etype in an Ethernet frame, the IPX
841 DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
842 IPX, and the IPX etype in a SNAP frame.
843 .RE
844 .IP "\fBdecnet src \fIhost\fR"
845 True if the DECNET source address is
846 .IR host ,
847 which may be an address of the form ``10.123'', or a DECNET host
848 name.
849 [DECNET host name support is only available on Ultrix systems
850 that are configured to run DECNET.]
851 .IP "\fBdecnet dst \fIhost\fR"
852 True if the DECNET destination address is
853 .IR host .
854 .IP "\fBdecnet host \fIhost\fR"
855 True if either the DECNET source or destination address is
856 .IR host .
857 .IP "\fBifname \fIinterface\fR"
858 True if the packet was logged as coming from the specified interface (applies
859 only to packets logged by OpenBSD's
860 .BR pf (4)).
861 .IP "\fBon \fIinterface\fR"
862 Synonymous with the
863 .B ifname
864 modifier.
865 .IP "\fBrnr \fInum\fR"
866 True if the packet was logged as matching the specified PF rule number
867 (applies only to packets logged by OpenBSD's
868 .BR pf (4)).
869 .IP "\fBrulenum \fInum\fR"
870 Synonomous with the
871 .B rnr
872 modifier.
873 .IP "\fBreason \fIcode\fR"
874 True if the packet was logged with the specified PF reason code. The known
875 codes are:
876 .BR match ,
877 .BR bad-offset ,
878 .BR fragment ,
879 .BR short ,
880 .BR normalize ,
881 and
882 .B memory
883 (applies only to packets logged by OpenBSD's
884 .BR pf (4)).
885 .IP "\fBaction \fIact\fR"
886 True if PF took the specified action when the packet was logged. Known actions
887 are:
888 .B pass
889 and
890 .B block
891 (applies only to packets logged by OpenBSD's
892 .BR pf(4)).
893 .IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fInetbeui\fP"
894 Abbreviations for:
895 .in +.5i
896 .nf
897 \fBether proto \fIp\fR
898 .fi
899 .in -.5i
900 where \fIp\fR is one of the above protocols.
901 .IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
902 Abbreviations for:
903 .in +.5i
904 .nf
905 \fBether proto \fIp\fR
906 .fi
907 .in -.5i
908 where \fIp\fR is one of the above protocols.
909 Note that
910 \fItcpdump\fP does not currently know how to parse these protocols.
911 .IP "\fBvlan \fI[vlan_id]\fR"
912 True if the packet is an IEEE 802.1Q VLAN packet.
913 If \fI[vlan_id]\fR is specified, only true is the packet has the specified
914 \fIvlan_id\fR.
915 Note that the first \fBvlan\fR keyword encountered in \fIexpression\fR
916 changes the decoding offsets for the remainder of \fIexpression\fR
917 on the assumption that the packet is a VLAN packet.
918 .IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
919 Abbreviations for:
920 .in +.5i
921 .nf
922 \fBip proto \fIp\fR\fB or ip6 proto \fIp\fR
923 .fi
924 .in -.5i
925 where \fIp\fR is one of the above protocols.
926 .IP "\fBiso proto \fIprotocol\fR"
927 True if the packet is an OSI packet of protocol type \fIprotocol\fP.
928 \fIProtocol\fP can be a number or one of the names
929 \fIclnp\fP, \fIesis\fP, or \fIisis\fP.
930 .IP "\fBclnp\fR, \fBesis\fR, \fBisis\fR"
931 Abbreviations for:
932 .in +.5i
933 .nf
934 \fBiso proto \fIp\fR
935 .fi
936 .in -.5i
937 where \fIp\fR is one of the above protocols.
938 .IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
939 Abbreviations for IS-IS PDU types.
940 .IP "\fBvpi\fP \fIn\fR
941 True if the packet is an ATM packet, for SunATM on Solaris, with a
942 virtual path identifier of
943 .IR n .
944 .IP "\fBvci\fP \fIn\fR
945 True if the packet is an ATM packet, for SunATM on Solaris, with a
946 virtual channel identifier of
947 .IR n .
948 .IP \fBlane\fP
949 True if the packet is an ATM packet, for SunATM on Solaris, and is
950 an ATM LANE packet.
951 Note that the first \fBlane\fR keyword encountered in \fIexpression\fR
952 changes the tests done in the remainder of \fIexpression\fR
953 on the assumption that the packet is either a LANE emulated Ethernet
954 packet or a LANE LE Control packet. If \fBlane\fR isn't specified, the
955 tests are done under the assumption that the packet is an
956 LLC-encapsulated packet.
957 .IP \fBllc\fP
958 True if the packet is an ATM packet, for SunATM on Solaris, and is
959 an LLC-encapsulated packet.
960 .IP \fBoamf4s\fP
961 True if the packet is an ATM packet, for SunATM on Solaris, and is
962 a segment OAM F4 flow cell (VPI=0 & VCI=3).
963 .IP \fBoamf4e\fP
964 True if the packet is an ATM packet, for SunATM on Solaris, and is
965 an end-to-end OAM F4 flow cell (VPI=0 & VCI=4).
966 .IP \fBoamf4\fP
967 True if the packet is an ATM packet, for SunATM on Solaris, and is
968 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
969 .IP \fBoam\fP
970 True if the packet is an ATM packet, for SunATM on Solaris, and is
971 a segment or end-to-end OAM F4 flow cell (VPI=0 & (VCI=3 | VCI=4)).
972 .IP \fBmetac\fP
973 True if the packet is an ATM packet, for SunATM on Solaris, and is
974 on a meta signaling circuit (VPI=0 & VCI=1).
975 .IP \fBbcc\fP
976 True if the packet is an ATM packet, for SunATM on Solaris, and is
977 on a broadcast signaling circuit (VPI=0 & VCI=2).
978 .IP \fBsc\fP
979 True if the packet is an ATM packet, for SunATM on Solaris, and is
980 on a signaling circuit (VPI=0 & VCI=5).
981 .IP \fBilmic\fP
982 True if the packet is an ATM packet, for SunATM on Solaris, and is
983 on an ILMI circuit (VPI=0 & VCI=16).
984 .IP \fBconnectmsg\fP
985 True if the packet is an ATM packet, for SunATM on Solaris, and is
986 on a signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
987 Connect Ack, Release, or Release Done message.
988 .IP \fBmetaconnect\fP
989 True if the packet is an ATM packet, for SunATM on Solaris, and is
990 on a meta signaling circuit and is a Q.2931 Setup, Call Proceeding, Connect,
991 Release, or Release Done message.
992 .IP "\fIexpr relop expr\fR"
993 True if the relation holds, where \fIrelop\fR is one of >, <, >=, <=, =, !=,
994 and \fIexpr\fR is an arithmetic expression composed of integer constants
995 (expressed in standard C syntax), the normal binary operators
996 [+, -, *, /, &, |], a length operator, and special packet data accessors.
997 To access
998 data inside the packet, use the following syntax:
999 .in +.5i
1000 .nf
1001 \fIproto\fB [ \fIexpr\fB : \fIsize\fB ]\fR
1002 .fi
1003 .in -.5i
1004 \fIProto\fR is one of \fBether, fddi, tr, wlan, ppp, slip, link,
1005 ip, arp, rarp, tcp, udp, icmp\fR or \fBip6\fR, and
1006 indicates the protocol layer for the index operation.
1007 (\fBether, fddi, wlan, tr, ppp, slip\fR and \fBlink\fR all refer to the
1008 link layer.)
1009 Note that \fItcp, udp\fR and other upper-layer protocol types only
1010 apply to IPv4, not IPv6 (this will be fixed in the future).
1011 The byte offset, relative to the indicated protocol layer, is
1012 given by \fIexpr\fR.
1013 \fISize\fR is optional and indicates the number of bytes in the
1014 field of interest; it can be either one, two, or four, and defaults to one.
1015 The length operator, indicated by the keyword \fBlen\fP, gives the
1016 length of the packet.
1017
1018 For example, `\fBether[0] & 1 != 0\fP' catches all multicast traffic.
1019 The expression `\fBip[0] & 0xf != 5\fP'
1020 catches all IP packets with options.
1021 The expression
1022 `\fBip[6:2] & 0x1fff = 0\fP'
1023 catches only unfragmented datagrams and frag zero of fragmented datagrams.
1024 This check is implicitly applied to the \fBtcp\fP and \fBudp\fP
1025 index operations.
1026 For instance, \fBtcp[0]\fP always means the first
1027 byte of the TCP \fIheader\fP, and never means the first byte of an
1028 intervening fragment.
1029
1030 Some offsets and field values may be expressed as names rather than
1031 as numeric values.
1032 The following protocol header field offsets are
1033 available: \fBicmptype\fP (ICMP type field), \fBicmpcode\fP (ICMP
1034 code field), and \fBtcpflags\fP (TCP flags field).
1035
1036 The following ICMP type field values are available: \fBicmp-echoreply\fP,
1037 \fBicmp-unreach\fP, \fBicmp-sourcequench\fP, \fBicmp-redirect\fP,
1038 \fBicmp-echo\fP, \fBicmp-routeradvert\fP, \fBicmp-routersolicit\fP,
1039 \fBicmp-timxceed\fP, \fBicmp-paramprob\fP, \fBicmp-tstamp\fP,
1040 \fBicmp-tstampreply\fP, \fBicmp-ireq\fP, \fBicmp-ireqreply\fP,
1041 \fBicmp-maskreq\fP, \fBicmp-maskreply\fP.
1042
1043 The following TCP flags field values are available: \fBtcp-fin\fP,
1044 \fBtcp-syn\fP, \fBtcp-rst\fP, \fBtcp-push\fP,
1045 \fBtcp-ack\fP, \fBtcp-urg\fP.
1046 .LP
1047 Primitives may be combined using:
1048 .IP
1049 A parenthesized group of primitives and operators
1050 (parentheses are special to the Shell and must be escaped).
1051 .IP
1052 Negation (`\fB!\fP' or `\fBnot\fP').
1053 .IP
1054 Concatenation (`\fB&&\fP' or `\fBand\fP').
1055 .IP
1056 Alternation (`\fB||\fP' or `\fBor\fP').
1057 .LP
1058 Negation has highest precedence.
1059 Alternation and concatenation have equal precedence and associate
1060 left to right.
1061 Note that explicit \fBand\fR tokens, not juxtaposition,
1062 are now required for concatenation.
1063 .LP
1064 If an identifier is given without a keyword, the most recent keyword
1065 is assumed.
1066 For example,
1067 .in +.5i
1068 .nf
1069 \fBnot host vs and ace\fR
1070 .fi
1071 .in -.5i
1072 is short for
1073 .in +.5i
1074 .nf
1075 \fBnot host vs and host ace\fR
1076 .fi
1077 .in -.5i
1078 which should not be confused with
1079 .in +.5i
1080 .nf
1081 \fBnot ( host vs or ace )\fR
1082 .fi
1083 .in -.5i
1084 .LP
1085 Expression arguments can be passed to \fItcpdump\fP as either a single
1086 argument or as multiple arguments, whichever is more convenient.
1087 Generally, if the expression contains Shell metacharacters, it is
1088 easier to pass it as a single, quoted argument.
1089 Multiple arguments are concatenated with spaces before being parsed.
1090 .SH EXAMPLES
1091 .LP
1092 To print all packets arriving at or departing from \fIsundown\fP:
1093 .RS
1094 .nf
1095 \fBtcpdump host sundown\fP
1096 .fi
1097 .RE
1098 .LP
1099 To print traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR:
1100 .RS
1101 .nf
1102 \fBtcpdump host helios and \\( hot or ace \\)\fP
1103 .fi
1104 .RE
1105 .LP
1106 To print all IP packets between \fIace\fR and any host except \fIhelios\fR:
1107 .RS
1108 .nf
1109 \fBtcpdump ip host ace and not helios\fP
1110 .fi
1111 .RE
1112 .LP
1113 To print all traffic between local hosts and hosts at Berkeley:
1114 .RS
1115 .nf
1116 .B
1117 tcpdump net ucb-ether
1118 .fi
1119 .RE
1120 .LP
1121 To print all ftp traffic through internet gateway \fIsnup\fP:
1122 (note that the expression is quoted to prevent the shell from
1123 (mis-)interpreting the parentheses):
1124 .RS
1125 .nf
1126 .B
1127 tcpdump 'gateway snup and (port ftp or ftp-data)'
1128 .fi
1129 .RE
1130 .LP
1131 To print traffic neither sourced from nor destined for local hosts
1132 (if you gateway to one other net, this stuff should never make it
1133 onto your local net).
1134 .RS
1135 .nf
1136 .B
1137 tcpdump ip and not net \fIlocalnet\fP
1138 .fi
1139 .RE
1140 .LP
1141 To print the start and end packets (the SYN and FIN packets) of each
1142 TCP conversation that involves a non-local host.
1143 .RS
1144 .nf
1145 .B
1146 tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP'
1147 .fi
1148 .RE
1149 .LP
1150 To print IP packets longer than 576 bytes sent through gateway \fIsnup\fP:
1151 .RS
1152 .nf
1153 .B
1154 tcpdump 'gateway snup and ip[2:2] > 576'
1155 .fi
1156 .RE
1157 .LP
1158 To print IP broadcast or multicast packets that were
1159 .I not
1160 sent via ethernet broadcast or multicast:
1161 .RS
1162 .nf
1163 .B
1164 tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'
1165 .fi
1166 .RE
1167 .LP
1168 To print all ICMP packets that are not echo requests/replies (i.e., not
1169 ping packets):
1170 .RS
1171 .nf
1172 .B
1173 tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'
1174 .fi
1175 .RE
1176 .SH OUTPUT FORMAT
1177 .LP
1178 The output of \fItcpdump\fP is protocol dependent.
1179 The following
1180 gives a brief description and examples of most of the formats.
1181 .de HD
1182 .sp 1.5
1183 .B
1184 ..
1185 .HD
1186 Link Level Headers
1187 .LP
1188 If the '-e' option is given, the link level header is printed out.
1189 On ethernets, the source and destination addresses, protocol,
1190 and packet length are printed.
1191 .LP
1192 On FDDI networks, the '-e' option causes \fItcpdump\fP to print
1193 the `frame control' field, the source and destination addresses,
1194 and the packet length.
1195 (The `frame control' field governs the
1196 interpretation of the rest of the packet.
1197 Normal packets (such
1198 as those containing IP datagrams) are `async' packets, with a priority
1199 value between 0 and 7; for example, `\fBasync4\fR'.
1200 Such packets
1201 are assumed to contain an 802.2 Logical Link Control (LLC) packet;
1202 the LLC header is printed if it is \fInot\fR an ISO datagram or a
1203 so-called SNAP packet.
1204 .LP
1205 On Token Ring networks, the '-e' option causes \fItcpdump\fP to print
1206 the `access control' and `frame control' fields, the source and
1207 destination addresses, and the packet length.
1208 As on FDDI networks,
1209 packets are assumed to contain an LLC packet.
1210 Regardless of whether
1211 the '-e' option is specified or not, the source routing information is
1212 printed for source-routed packets.
1213 .LP
1214 On 802.11 networks, the '-e' option causes \fItcpdump\fP to print
1215 the `frame control' fields, all of the addresses in the 802.11 header,
1216 and the packet length.
1217 As on FDDI networks,
1218 packets are assumed to contain an LLC packet.
1219 .LP
1220 \fI(N.B.: The following description assumes familiarity with
1221 the SLIP compression algorithm described in RFC-1144.)\fP
1222 .LP
1223 On SLIP links, a direction indicator (``I'' for inbound, ``O'' for outbound),
1224 packet type, and compression information are printed out.
1225 The packet type is printed first.
1226 The three types are \fIip\fP, \fIutcp\fP, and \fIctcp\fP.
1227 No further link information is printed for \fIip\fR packets.
1228 For TCP packets, the connection identifier is printed following the type.
1229 If the packet is compressed, its encoded header is printed out.
1230 The special cases are printed out as
1231 \fB*S+\fIn\fR and \fB*SA+\fIn\fR, where \fIn\fR is the amount by which
1232 the sequence number (or sequence number and ack) has changed.
1233 If it is not a special case,
1234 zero or more changes are printed.
1235 A change is indicated by U (urgent pointer), W (window), A (ack),
1236 S (sequence number), and I (packet ID), followed by a delta (+n or -n),
1237 or a new value (=n).
1238 Finally, the amount of data in the packet and compressed header length
1239 are printed.
1240 .LP
1241 For example, the following line shows an outbound compressed TCP packet,
1242 with an implicit connection identifier; the ack has changed by 6,
1243 the sequence number by 49, and the packet ID by 6; there are 3 bytes of
1244 data and 6 bytes of compressed header:
1245 .RS
1246 .nf
1247 \fBO ctcp * A+6 S+49 I+6 3 (6)\fP
1248 .fi
1249 .RE
1250 .HD
1251 ARP/RARP Packets
1252 .LP
1253 Arp/rarp output shows the type of request and its arguments.
1254 The
1255 format is intended to be self explanatory.
1256 Here is a short sample taken from the start of an `rlogin' from
1257 host \fIrtsg\fP to host \fIcsam\fP:
1258 .RS
1259 .nf
1260 .sp .5
1261 \f(CWarp who-has csam tell rtsg
1262 arp reply csam is-at CSAM\fR
1263 .sp .5
1264 .fi
1265 .RE
1266 The first line says that rtsg sent an arp packet asking
1267 for the ethernet address of internet host csam.
1268 Csam
1269 replies with its ethernet address (in this example, ethernet addresses
1270 are in caps and internet addresses in lower case).
1271 .LP
1272 This would look less redundant if we had done \fItcpdump \-n\fP:
1273 .RS
1274 .nf
1275 .sp .5
1276 \f(CWarp who-has 128.3.254.6 tell 128.3.254.68
1277 arp reply 128.3.254.6 is-at 02:07:01:00:01:c4\fP
1278 .fi
1279 .RE
1280 .LP
1281 If we had done \fItcpdump \-e\fP, the fact that the first packet is
1282 broadcast and the second is point-to-point would be visible:
1283 .RS
1284 .nf
1285 .sp .5
1286 \f(CWRTSG Broadcast 0806 64: arp who-has csam tell rtsg
1287 CSAM RTSG 0806 64: arp reply csam is-at CSAM\fR
1288 .sp .5
1289 .fi
1290 .RE
1291 For the first packet this says the ethernet source address is RTSG, the
1292 destination is the ethernet broadcast address, the type field
1293 contained hex 0806 (type ETHER_ARP) and the total length was 64 bytes.
1294 .HD
1295 TCP Packets
1296 .LP
1297 \fI(N.B.:The following description assumes familiarity with
1298 the TCP protocol described in RFC-793.
1299 If you are not familiar
1300 with the protocol, neither this description nor \fItcpdump\fP will
1301 be of much use to you.)\fP
1302 .LP
1303 The general format of a tcp protocol line is:
1304 .RS
1305 .nf
1306 .sp .5
1307 \fIsrc > dst: flags data-seqno ack window urgent options\fP
1308 .sp .5
1309 .fi
1310 .RE
1311 \fISrc\fP and \fIdst\fP are the source and destination IP
1312 addresses and ports.
1313 \fIFlags\fP are some combination of S (SYN),
1314 F (FIN), P (PUSH) or R (RST) or a single `.' (no flags).
1315 \fIData-seqno\fP describes the portion of sequence space covered
1316 by the data in this packet (see example below).
1317 \fIAck\fP is sequence number of the next data expected the other
1318 direction on this connection.
1319 \fIWindow\fP is the number of bytes of receive buffer space available
1320 the other direction on this connection.
1321 \fIUrg\fP indicates there is `urgent' data in the packet.
1322 \fIOptions\fP are tcp options enclosed in angle brackets (e.g., <mss 1024>).
1323 .LP
1324 \fISrc, dst\fP and \fIflags\fP are always present.
1325 The other fields
1326 depend on the contents of the packet's tcp protocol header and
1327 are output only if appropriate.
1328 .LP
1329 Here is the opening portion of an rlogin from host \fIrtsg\fP to
1330 host \fIcsam\fP.
1331 .RS
1332 .nf
1333 .sp .5
1334 \s-2\f(CWrtsg.1023 > csam.login: S 768512:768512(0) win 4096 <mss 1024>
1335 csam.login > rtsg.1023: S 947648:947648(0) ack 768513 win 4096 <mss 1024>
1336 rtsg.1023 > csam.login: . ack 1 win 4096
1337 rtsg.1023 > csam.login: P 1:2(1) ack 1 win 4096
1338 csam.login > rtsg.1023: . ack 2 win 4096
1339 rtsg.1023 > csam.login: P 2:21(19) ack 1 win 4096
1340 csam.login > rtsg.1023: P 1:2(1) ack 21 win 4077
1341 csam.login > rtsg.1023: P 2:3(1) ack 21 win 4077 urg 1
1342 csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1\fR\s+2
1343 .sp .5
1344 .fi
1345 .RE
1346 The first line says that tcp port 1023 on rtsg sent a packet
1347 to port \fIlogin\fP
1348 on csam.
1349 The \fBS\fP indicates that the \fISYN\fP flag was set.
1350 The packet sequence number was 768512 and it contained no data.
1351 (The notation is `first:last(nbytes)' which means `sequence
1352 numbers \fIfirst\fP
1353 up to but not including \fIlast\fP which is \fInbytes\fP bytes of user data'.)
1354 There was no piggy-backed ack, the available receive window was 4096
1355 bytes and there was a max-segment-size option requesting an mss of
1356 1024 bytes.
1357 .LP
1358 Csam replies with a similar packet except it includes a piggy-backed
1359 ack for rtsg's SYN.
1360 Rtsg then acks csam's SYN.
1361 The `.' means no
1362 flags were set.
1363 The packet contained no data so there is no data sequence number.
1364 Note that the ack sequence
1365 number is a small integer (1).
1366 The first time \fItcpdump\fP sees a
1367 tcp `conversation', it prints the sequence number from the packet.
1368 On subsequent packets of the conversation, the difference between
1369 the current packet's sequence number and this initial sequence number
1370 is printed.
1371 This means that sequence numbers after the
1372 first can be interpreted
1373 as relative byte positions in the conversation's data stream (with the
1374 first data byte each direction being `1').
1375 `-S' will override this
1376 feature, causing the original sequence numbers to be output.
1377 .LP
1378 On the 6th line, rtsg sends csam 19 bytes of data (bytes 2 through 20
1379 in the rtsg \(-> csam side of the conversation).
1380 The PUSH flag is set in the packet.
1381 On the 7th line, csam says it's received data sent by rtsg up to
1382 but not including byte 21.
1383 Most of this data is apparently sitting in the
1384 socket buffer since csam's receive window has gotten 19 bytes smaller.
1385 Csam also sends one byte of data to rtsg in this packet.
1386 On the 8th and 9th lines,
1387 csam sends two bytes of urgent, pushed data to rtsg.
1388 .LP
1389 If the snapshot was small enough that \fItcpdump\fP didn't capture
1390 the full TCP header, it interprets as much of the header as it can
1391 and then reports ``[|\fItcp\fP]'' to indicate the remainder could not
1392 be interpreted.
1393 If the header contains a bogus option (one with a length
1394 that's either too small or beyond the end of the header), \fItcpdump\fP
1395 reports it as ``[\fIbad opt\fP]'' and does not interpret any further
1396 options (since it's impossible to tell where they start).
1397 If the header
1398 length indicates options are present but the IP datagram length is not
1399 long enough for the options to actually be there, \fItcpdump\fP reports
1400 it as ``[\fIbad hdr length\fP]''.
1401 .HD
1402 .B Capturing TCP packets with particular flag combinations (SYN-ACK, URG-ACK, etc.)
1403 .PP
1404 There are 8 bits in the control bits section of the TCP header:
1405 .IP
1406 .I CWR | ECE | URG | ACK | PSH | RST | SYN | FIN
1407 .PP
1408 Let's assume that we want to watch packets used in establishing
1409 a TCP connection.
1410 Recall that TCP uses a 3-way handshake protocol
1411 when it initializes a new connection; the connection sequence with
1412 regard to the TCP control bits is
1413 .PP
1414 .RS
1415 1) Caller sends SYN
1416 .RE
1417 .RS
1418 2) Recipient responds with SYN, ACK
1419 .RE
1420 .RS
1421 3) Caller sends ACK
1422 .RE
1423 .PP
1424 Now we're interested in capturing packets that have only the
1425 SYN bit set (Step 1).
1426 Note that we don't want packets from step 2
1427 (SYN-ACK), just a plain initial SYN.
1428 What we need is a correct filter
1429 expression for \fItcpdump\fP.
1430 .PP
1431 Recall the structure of a TCP header without options:
1432 .PP
1433 .nf
1434 0 15 31
1435 -----------------------------------------------------------------
1436 | source port | destination port |
1437 -----------------------------------------------------------------
1438 | sequence number |
1439 -----------------------------------------------------------------
1440 | acknowledgment number |
1441 -----------------------------------------------------------------
1442 | HL | rsvd |C|E|U|A|P|R|S|F| window size |
1443 -----------------------------------------------------------------
1444 | TCP checksum | urgent pointer |
1445 -----------------------------------------------------------------
1446 .fi
1447 .PP
1448 A TCP header usually holds 20 octets of data, unless options are
1449 present.
1450 The first line of the graph contains octets 0 - 3, the
1451 second line shows octets 4 - 7 etc.
1452 .PP
1453 Starting to count with 0, the relevant TCP control bits are contained
1454 in octet 13:
1455 .PP
1456 .nf
1457 0 7| 15| 23| 31
1458 ----------------|---------------|---------------|----------------
1459 | HL | rsvd |C|E|U|A|P|R|S|F| window size |
1460 ----------------|---------------|---------------|----------------
1461 | | 13th octet | | |
1462 .fi
1463 .PP
1464 Let's have a closer look at octet no. 13:
1465 .PP
1466 .nf
1467 | |
1468 |---------------|
1469 |C|E|U|A|P|R|S|F|
1470 |---------------|
1471 |7 5 3 0|
1472 .fi
1473 .PP
1474 These are the TCP control bits we are interested
1475 in.
1476 We have numbered the bits in this octet from 0 to 7, right to
1477 left, so the PSH bit is bit number 3, while the URG bit is number 5.
1478 .PP
1479 Recall that we want to capture packets with only SYN set.
1480 Let's see what happens to octet 13 if a TCP datagram arrives
1481 with the SYN bit set in its header:
1482 .PP
1483 .nf
1484 |C|E|U|A|P|R|S|F|
1485 |---------------|
1486 |0 0 0 0 0 0 1 0|
1487 |---------------|
1488 |7 6 5 4 3 2 1 0|
1489 .fi
1490 .PP
1491 Looking at the
1492 control bits section we see that only bit number 1 (SYN) is set.
1493 .PP
1494 Assuming that octet number 13 is an 8-bit unsigned integer in
1495 network byte order, the binary value of this octet is
1496 .IP
1497 00000010
1498 .PP
1499 and its decimal representation is
1500 .PP
1501 .nf
1502 7 6 5 4 3 2 1 0
1503 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2 = 2
1504 .fi
1505 .PP
1506 We're almost done, because now we know that if only SYN is set,
1507 the value of the 13th octet in the TCP header, when interpreted
1508 as a 8-bit unsigned integer in network byte order, must be exactly 2.
1509 .PP
1510 This relationship can be expressed as
1511 .RS
1512 .B
1513 tcp[13] == 2
1514 .RE
1515 .PP
1516 We can use this expression as the filter for \fItcpdump\fP in order
1517 to watch packets which have only SYN set:
1518 .RS
1519 .B
1520 tcpdump -i xl0 tcp[13] == 2
1521 .RE
1522 .PP
1523 The expression says "let the 13th octet of a TCP datagram have
1524 the decimal value 2", which is exactly what we want.
1525 .PP
1526 Now, let's assume that we need to capture SYN packets, but we
1527 don't care if ACK or any other TCP control bit is set at the
1528 same time.
1529 Let's see what happens to octet 13 when a TCP datagram
1530 with SYN-ACK set arrives:
1531 .PP
1532 .nf
1533 |C|E|U|A|P|R|S|F|
1534 |---------------|
1535 |0 0 0 1 0 0 1 0|
1536 |---------------|
1537 |7 6 5 4 3 2 1 0|
1538 .fi
1539 .PP
1540 Now bits 1 and 4 are set in the 13th octet.
1541 The binary value of
1542 octet 13 is
1543 .IP
1544 00010010
1545 .PP
1546 which translates to decimal
1547 .PP
1548 .nf
1549 7 6 5 4 3 2 1 0
1550 0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2 = 18
1551 .fi
1552 .PP
1553 Now we can't just use 'tcp[13] == 18' in the \fItcpdump\fP filter
1554 expression, because that would select only those packets that have
1555 SYN-ACK set, but not those with only SYN set.
1556 Remember that we don't care
1557 if ACK or any other control bit is set as long as SYN is set.
1558 .PP
1559 In order to achieve our goal, we need to logically AND the
1560 binary value of octet 13 with some other value to preserve
1561 the SYN bit.
1562 We know that we want SYN to be set in any case,
1563 so we'll logically AND the value in the 13th octet with
1564 the binary value of a SYN:
1565 .PP
1566 .nf
1567
1568 00010010 SYN-ACK 00000010 SYN
1569 AND 00000010 (we want SYN) AND 00000010 (we want SYN)
1570 -------- --------
1571 = 00000010 = 00000010
1572 .fi
1573 .PP
1574 We see that this AND operation delivers the same result
1575 regardless whether ACK or another TCP control bit is set.
1576 The decimal representation of the AND value as well as
1577 the result of this operation is 2 (binary 00000010),
1578 so we know that for packets with SYN set the following
1579 relation must hold true:
1580 .IP
1581 ( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )
1582 .PP
1583 This points us to the \fItcpdump\fP filter expression
1584 .RS
1585 .B
1586 tcpdump -i xl0 'tcp[13] & 2 == 2'
1587 .RE
1588 .PP
1589 Note that you should use single quotes or a backslash
1590 in the expression to hide the AND ('&') special character
1591 from the shell.
1592 .HD
1593 .B
1594 UDP Packets
1595 .LP
1596 UDP format is illustrated by this rwho packet:
1597 .RS
1598 .nf
1599 .sp .5
1600 \f(CWactinide.who > broadcast.who: udp 84\fP
1601 .sp .5
1602 .fi
1603 .RE
1604 This says that port \fIwho\fP on host \fIactinide\fP sent a udp
1605 datagram to port \fIwho\fP on host \fIbroadcast\fP, the Internet
1606 broadcast address.
1607 The packet contained 84 bytes of user data.
1608 .LP
1609 Some UDP services are recognized (from the source or destination
1610 port number) and the higher level protocol information printed.
1611 In particular, Domain Name service requests (RFC-1034/1035) and Sun
1612 RPC calls (RFC-1050) to NFS.
1613 .HD
1614 UDP Name Server Requests
1615 .LP
1616 \fI(N.B.:The following description assumes familiarity with
1617 the Domain Service protocol described in RFC-1035.
1618 If you are not familiar
1619 with the protocol, the following description will appear to be written
1620 in greek.)\fP
1621 .LP
1622 Name server requests are formatted as
1623 .RS
1624 .nf
1625 .sp .5
1626 \fIsrc > dst: id op? flags qtype qclass name (len)\fP
1627 .sp .5
1628 \f(CWh2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)\fR
1629 .sp .5
1630 .fi
1631 .RE
1632 Host \fIh2opolo\fP asked the domain server on \fIhelios\fP for an
1633 address record (qtype=A) associated with the name \fIucbvax.berkeley.edu.\fP
1634 The query id was `3'.
1635 The `+' indicates the \fIrecursion desired\fP flag
1636 was set.
1637 The query length was 37 bytes, not including the UDP and
1638 IP protocol headers.
1639 The query operation was the normal one, \fIQuery\fP,
1640 so the op field was omitted.
1641 If the op had been anything else, it would
1642 have been printed between the `3' and the `+'.
1643 Similarly, the qclass was the normal one,
1644 \fIC_IN\fP, and omitted.
1645 Any other qclass would have been printed
1646 immediately after the `A'.
1647 .LP
1648 A few anomalies are checked and may result in extra fields enclosed in
1649 square brackets: If a query contains an answer, authority records or
1650 additional records section,
1651 .IR ancount ,
1652 .IR nscount ,
1653 or
1654 .I arcount
1655 are printed as `[\fIn\fPa]', `[\fIn\fPn]' or `[\fIn\fPau]' where \fIn\fP
1656 is the appropriate count.
1657 If any of the response bits are set (AA, RA or rcode) or any of the
1658 `must be zero' bits are set in bytes two and three, `[b2&3=\fIx\fP]'
1659 is printed, where \fIx\fP is the hex value of header bytes two and three.
1660 .HD
1661 UDP Name Server Responses
1662 .LP
1663 Name server responses are formatted as
1664 .RS
1665 .nf
1666 .sp .5
1667 \fIsrc > dst: id op rcode flags a/n/au type class data (len)\fP
1668 .sp .5
1669 \f(CWhelios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
1670 helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)\fR
1671 .sp .5
1672 .fi
1673 .RE
1674 In the first example, \fIhelios\fP responds to query id 3 from \fIh2opolo\fP
1675 with 3 answer records, 3 name server records and 7 additional records.
1676 The first answer record is type A (address) and its data is internet
1677 address 128.32.137.3.
1678 The total size of the response was 273 bytes,
1679 excluding UDP and IP headers.
1680 The op (Query) and response code
1681 (NoError) were omitted, as was the class (C_IN) of the A record.
1682 .LP
1683 In the second example, \fIhelios\fP responds to query 2 with a
1684 response code of non-existent domain (NXDomain) with no answers,
1685 one name server and no authority records.
1686 The `*' indicates that
1687 the \fIauthoritative answer\fP bit was set.
1688 Since there were no
1689 answers, no type, class or data were printed.
1690 .LP
1691 Other flag characters that might appear are `\-' (recursion available,
1692 RA, \fInot\fP set) and `|' (truncated message, TC, set).
1693 If the
1694 `question' section doesn't contain exactly one entry, `[\fIn\fPq]'
1695 is printed.
1696 .LP
1697 Note that name server requests and responses tend to be large and the
1698 default \fIsnaplen\fP of 68 bytes may not capture enough of the packet
1699 to print.
1700 Use the \fB\-s\fP flag to increase the snaplen if you
1701 need to seriously investigate name server traffic.
1702 `\fB\-s 128\fP'
1703 has worked well for me.
1704
1705 .HD
1706 SMB/CIFS decoding
1707 .LP
1708 \fItcpdump\fP now includes fairly extensive SMB/CIFS/NBT decoding for data
1709 on UDP/137, UDP/138 and TCP/139.
1710 Some primitive decoding of IPX and
1711 NetBEUI SMB data is also done.
1712
1713 By default a fairly minimal decode is done, with a much more detailed
1714 decode done if -v is used.
1715 Be warned that with -v a single SMB packet
1716 may take up a page or more, so only use -v if you really want all the
1717 gory details.
1718
1719 If you are decoding SMB sessions containing unicode strings then you
1720 may wish to set the environment variable USE_UNICODE to 1.
1721 A patch to
1722 auto-detect unicode strings would be welcome.
1723
1724 For information on SMB packet formats and what all te fields mean see
1725 www.cifs.org or the pub/samba/specs/ directory on your favorite
1726 samba.org mirror site.
1727 The SMB patches were written by Andrew Tridgell
1728 (tridge@samba.org).
1729
1730 .HD
1731 NFS Requests and Replies
1732 .LP
1733 Sun NFS (Network File System) requests and replies are printed as:
1734 .RS
1735 .nf
1736 .sp .5
1737 \fIsrc.xid > dst.nfs: len op args\fP
1738 \fIsrc.nfs > dst.xid: reply stat len op results\fP
1739 .sp .5
1740 \f(CW
1741 sushi.6709 > wrl.nfs: 112 readlink fh 21,24/10.73165
1742 wrl.nfs > sushi.6709: reply ok 40 readlink "../var"
1743 sushi.201b > wrl.nfs:
1744 144 lookup fh 9,74/4096.6878 "xcolors"
1745 wrl.nfs > sushi.201b:
1746 reply ok 128 lookup fh 9,74/4134.3150
1747 \fR
1748 .sp .5
1749 .fi
1750 .RE
1751 In the first line, host \fIsushi\fP sends a transaction with id \fI6709\fP
1752 to \fIwrl\fP (note that the number following the src host is a
1753 transaction id, \fInot\fP the source port).
1754 The request was 112 bytes,
1755 excluding the UDP and IP headers.
1756 The operation was a \fIreadlink\fP
1757 (read symbolic link) on file handle (\fIfh\fP) 21,24/10.731657119.
1758 (If one is lucky, as in this case, the file handle can be interpreted
1759 as a major,minor device number pair, followed by the inode number and
1760 generation number.)
1761 \fIWrl\fP replies `ok' with the contents of the link.
1762 .LP
1763 In the third line, \fIsushi\fP asks \fIwrl\fP to lookup the name
1764 `\fIxcolors\fP' in directory file 9,74/4096.6878.
1765 Note that the data printed
1766 depends on the operation type.
1767 The format is intended to be self
1768 explanatory if read in conjunction with
1769 an NFS protocol spec.
1770 .LP
1771 If the \-v (verbose) flag is given, additional information is printed.
1772 For example:
1773 .RS
1774 .nf
1775 .sp .5
1776 \f(CW
1777 sushi.1372a > wrl.nfs:
1778 148 read fh 21,11/12.195 8192 bytes @ 24576
1779 wrl.nfs > sushi.1372a:
1780 reply ok 1472 read REG 100664 ids 417/0 sz 29388
1781 \fP
1782 .sp .5
1783 .fi
1784 .RE
1785 (\-v also prints the IP header TTL, ID, length, and fragmentation fields,
1786 which have been omitted from this example.) In the first line,
1787 \fIsushi\fP asks \fIwrl\fP to read 8192 bytes from file 21,11/12.195,
1788 at byte offset 24576.
1789 \fIWrl\fP replies `ok'; the packet shown on the
1790 second line is the first fragment of the reply, and hence is only 1472
1791 bytes long (the other bytes will follow in subsequent fragments, but
1792 these fragments do not have NFS or even UDP headers and so might not be
1793 printed, depending on the filter expression used).
1794 Because the \-v flag
1795 is given, some of the file attributes (which are returned in addition
1796 to the file data) are printed: the file type (``REG'', for regular file),
1797 the file mode (in octal), the uid and gid, and the file size.
1798 .LP
1799 If the \-v flag is given more than once, even more details are printed.
1800 .LP
1801 Note that NFS requests are very large and much of the detail won't be printed
1802 unless \fIsnaplen\fP is increased.
1803 Try using `\fB\-s 192\fP' to watch
1804 NFS traffic.
1805 .LP
1806 NFS reply packets do not explicitly identify the RPC operation.
1807 Instead,
1808 \fItcpdump\fP keeps track of ``recent'' requests, and matches them to the
1809 replies using the transaction ID.
1810 If a reply does not closely follow the
1811 corresponding request, it might not be parsable.
1812 .HD
1813 AFS Requests and Replies
1814 .LP
1815 Transarc AFS (Andrew File System) requests and replies are printed
1816 as:
1817 .HD
1818 .RS
1819 .nf
1820 .sp .5
1821 \fIsrc.sport > dst.dport: rx packet-type\fP
1822 \fIsrc.sport > dst.dport: rx packet-type service call call-name args\fP
1823 \fIsrc.sport > dst.dport: rx packet-type service reply call-name args\fP
1824 .sp .5
1825 \f(CW
1826 elvis.7001 > pike.afsfs:
1827 rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
1828 new fid 536876964/1/1 ".newsrc"
1829 pike.afsfs > elvis.7001: rx data fs reply rename
1830 \fR
1831 .sp .5
1832 .fi
1833 .RE
1834 In the first line, host elvis sends a RX packet to pike.
1835 This was
1836 a RX data packet to the fs (fileserver) service, and is the start of
1837 an RPC call.
1838 The RPC call was a rename, with the old directory file id
1839 of 536876964/1/1 and an old filename of `.newsrc.new', and a new directory
1840 file id of 536876964/1/1 and a new filename of `.newsrc'.
1841 The host pike
1842 responds with a RPC reply to the rename call (which was successful, because
1843 it was a data packet and not an abort packet).
1844 .LP
1845 In general, all AFS RPCs are decoded at least by RPC call name.
1846 Most
1847 AFS RPCs have at least some of the arguments decoded (generally only
1848 the `interesting' arguments, for some definition of interesting).
1849 .LP
1850 The format is intended to be self-describing, but it will probably
1851 not be useful to people who are not familiar with the workings of
1852 AFS and RX.
1853 .LP
1854 If the -v (verbose) flag is given twice, acknowledgement packets and
1855 additional header information is printed, such as the the RX call ID,
1856 call number, sequence number, serial number, and the RX packet flags.
1857 .LP
1858 If the -v flag is given twice, additional information is printed,
1859 such as the the RX call ID, serial number, and the RX packet flags.
1860 The MTU negotiation information is also printed from RX ack packets.
1861 .LP
1862 If the -v flag is given three times, the security index and service id
1863 are printed.
1864 .LP
1865 Error codes are printed for abort packets, with the exception of Ubik
1866 beacon packets (because abort packets are used to signify a yes vote
1867 for the Ubik protocol).
1868 .LP
1869 Note that AFS requests are very large and many of the arguments won't
1870 be printed unless \fIsnaplen\fP is increased.
1871 Try using `\fB-s 256\fP'
1872 to watch AFS traffic.
1873 .LP
1874 AFS reply packets do not explicitly identify the RPC operation.
1875 Instead,
1876 \fItcpdump\fP keeps track of ``recent'' requests, and matches them to the
1877 replies using the call number and service ID.
1878 If a reply does not closely
1879 follow the
1880 corresponding request, it might not be parsable.
1881
1882 .HD
1883 KIP AppleTalk (DDP in UDP)
1884 .LP
1885 AppleTalk DDP packets encapsulated in UDP datagrams are de-encapsulated
1886 and dumped as DDP packets (i.e., all the UDP header information is
1887 discarded).
1888 The file
1889 .I /etc/atalk.names
1890 is used to translate appletalk net and node numbers to names.
1891 Lines in this file have the form
1892 .RS
1893 .nf
1894 .sp .5
1895 \fInumber name\fP
1896
1897 \f(CW1.254 ether
1898 16.1 icsd-net
1899 1.254.110 ace\fR
1900 .sp .5
1901 .fi
1902 .RE
1903 The first two lines give the names of appletalk networks.
1904 The third
1905 line gives the name of a particular host (a host is distinguished
1906 from a net by the 3rd octet in the number \-
1907 a net number \fImust\fP have two octets and a host number \fImust\fP
1908 have three octets.) The number and name should be separated by
1909 whitespace (blanks or tabs).
1910 The
1911 .I /etc/atalk.names
1912 file may contain blank lines or comment lines (lines starting with
1913 a `#').
1914 .LP
1915 AppleTalk addresses are printed in the form
1916 .RS
1917 .nf
1918 .sp .5
1919 \fInet.host.port\fP
1920
1921 \f(CW144.1.209.2 > icsd-net.112.220
1922 office.2 > icsd-net.112.220
1923 jssmag.149.235 > icsd-net.2\fR
1924 .sp .5
1925 .fi
1926 .RE
1927 (If the
1928 .I /etc/atalk.names
1929 doesn't exist or doesn't contain an entry for some appletalk
1930 host/net number, addresses are printed in numeric form.)
1931 In the first example, NBP (DDP port 2) on net 144.1 node 209
1932 is sending to whatever is listening on port 220 of net icsd node 112.
1933 The second line is the same except the full name of the source node
1934 is known (`office').
1935 The third line is a send from port 235 on
1936 net jssmag node 149 to broadcast on the icsd-net NBP port (note that
1937 the broadcast address (255) is indicated by a net name with no host
1938 number \- for this reason it's a good idea to keep node names and
1939 net names distinct in /etc/atalk.names).
1940 .LP
1941 NBP (name binding protocol) and ATP (AppleTalk transaction protocol)
1942 packets have their contents interpreted.
1943 Other protocols just dump
1944 the protocol name (or number if no name is registered for the
1945 protocol) and packet size.
1946
1947 \fBNBP packets\fP are formatted like the following examples:
1948 .RS
1949 .nf
1950 .sp .5
1951 \s-2\f(CWicsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
1952 jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
1953 techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186\fR\s+2
1954 .sp .5
1955 .fi
1956 .RE
1957 The first line is a name lookup request for laserwriters sent by net icsd host
1958 112 and broadcast on net jssmag.
1959 The nbp id for the lookup is 190.
1960 The second line shows a reply for this request (note that it has the
1961 same id) from host jssmag.209 saying that it has a laserwriter
1962 resource named "RM1140" registered on port 250.
1963 The third line is
1964 another reply to the same request saying host techpit has laserwriter
1965 "techpit" registered on port 186.
1966
1967 \fBATP packet\fP formatting is demonstrated by the following example:
1968 .RS
1969 .nf
1970 .sp .5
1971 \s-2\f(CWjssmag.209.165 > helios.132: atp-req 12266<0-7> 0xae030001
1972 helios.132 > jssmag.209.165: atp-resp 12266:0 (512) 0xae040000
1973 helios.132 > jssmag.209.165: atp-resp 12266:1 (512) 0xae040000
1974 helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000
1975 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1976 helios.132 > jssmag.209.165: atp-resp 12266:4 (512) 0xae040000
1977 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1978 helios.132 > jssmag.209.165: atp-resp 12266:6 (512) 0xae040000
1979 helios.132 > jssmag.209.165: atp-resp*12266:7 (512) 0xae040000
1980 jssmag.209.165 > helios.132: atp-req 12266<3,5> 0xae030001
1981 helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
1982 helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
1983 jssmag.209.165 > helios.132: atp-rel 12266<0-7> 0xae030001
1984 jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002\fR\s+2
1985 .sp .5
1986 .fi
1987 .RE
1988 Jssmag.209 initiates transaction id 12266 with host helios by requesting
1989 up to 8 packets (the `<0-7>').
1990 The hex number at the end of the line
1991 is the value of the `userdata' field in the request.
1992 .LP
1993 Helios responds with 8 512-byte packets.
1994 The `:digit' following the
1995 transaction id gives the packet sequence number in the transaction
1996 and the number in parens is the amount of data in the packet,
1997 excluding the atp header.
1998 The `*' on packet 7 indicates that the
1999 EOM bit was set.
2000 .LP
2001 Jssmag.209 then requests that packets 3 & 5 be retransmitted.
2002 Helios
2003 resends them then jssmag.209 releases the transaction.
2004 Finally,
2005 jssmag.209 initiates the next request.
2006 The `*' on the request
2007 indicates that XO (`exactly once') was \fInot\fP set.
2008
2009 .HD
2010 IP Fragmentation
2011 .LP
2012 Fragmented Internet datagrams are printed as
2013 .RS
2014 .nf
2015 .sp .5
2016 \fB(frag \fIid\fB:\fIsize\fB@\fIoffset\fB+)\fR
2017 \fB(frag \fIid\fB:\fIsize\fB@\fIoffset\fB)\fR
2018 .sp .5
2019 .fi
2020 .RE
2021 (The first form indicates there are more fragments.
2022 The second
2023 indicates this is the last fragment.)
2024 .LP
2025 \fIId\fP is the fragment id.
2026 \fISize\fP is the fragment
2027 size (in bytes) excluding the IP header.
2028 \fIOffset\fP is this
2029 fragment's offset (in bytes) in the original datagram.
2030 .LP
2031 The fragment information is output for each fragment.
2032 The first
2033 fragment contains the higher level protocol header and the frag
2034 info is printed after the protocol info.
2035 Fragments
2036 after the first contain no higher level protocol header and the
2037 frag info is printed after the source and destination addresses.
2038 For example, here is part of an ftp from arizona.edu to lbl-rtsg.arpa
2039 over a CSNET connection that doesn't appear to handle 576 byte datagrams:
2040 .RS
2041 .nf
2042 .sp .5
2043 \s-2\f(CWarizona.ftp-data > rtsg.1170: . 1024:1332(308) ack 1 win 4096 (frag 595a:328@0+)
2044 arizona > rtsg: (frag 595a:204@328)
2045 rtsg.1170 > arizona.ftp-data: . ack 1536 win 2560\fP\s+2
2046 .sp .5
2047 .fi
2048 .RE
2049 There are a couple of things to note here: First, addresses in the
2050 2nd line don't include port numbers.
2051 This is because the TCP
2052 protocol information is all in the first fragment and we have no idea
2053 what the port or sequence numbers are when we print the later fragments.
2054 Second, the tcp sequence information in the first line is printed as if there
2055 were 308 bytes of user data when, in fact, there are 512 bytes (308 in
2056 the first frag and 204 in the second).
2057 If you are looking for holes
2058 in the sequence space or trying to match up acks
2059 with packets, this can fool you.
2060 .LP
2061 A packet with the IP \fIdon't fragment\fP flag is marked with a
2062 trailing \fB(DF)\fP.
2063 .HD
2064 Timestamps
2065 .LP
2066 By default, all output lines are preceded by a timestamp.
2067 The timestamp
2068 is the current clock time in the form
2069 .RS
2070 .nf
2071 \fIhh:mm:ss.frac\fP
2072 .fi
2073 .RE
2074 and is as accurate as the kernel's clock.
2075 The timestamp reflects the time the kernel first saw the packet.
2076 No attempt
2077 is made to account for the time lag between when the
2078 ethernet interface removed the packet from the wire and when the kernel
2079 serviced the `new packet' interrupt.
2080 .SH "SEE ALSO"
2081 traffic(1C), nit(4P), bpf(4), pcap(3)
2082 .SH AUTHORS
2083 The original authors are:
2084 .LP
2085 Van Jacobson,
2086 Craig Leres and
2087 Steven McCanne, all of the
2088 Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
2089 .LP
2090 It is currently being maintained by tcpdump.org.
2091 .LP
2092 The current version is available via http:
2093 .LP
2094 .RS
2095 .I http://www.tcpdump.org/
2096 .RE
2097 .LP
2098 The original distribution is available via anonymous ftp:
2099 .LP
2100 .RS
2101 .I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
2102 .RE
2103 .LP
2104 IPv6/IPsec support is added by WIDE/KAME project.
2105 This program uses Eric Young's SSLeay library, under specific configuration.
2106 .SH BUGS
2107 Please send problems, bugs, questions, desirable enhancements, etc. to:
2108 .LP
2109 .RS
2110 tcpdump-workers@tcpdump.org
2111 .RE
2112 .LP
2113 Please send source code contributions, etc. to:
2114 .LP
2115 .RS
2116 patches@tcpdump.org
2117 .RE
2118 .LP
2119 NIT doesn't let you watch your own outbound traffic, BPF will.
2120 We recommend that you use the latter.
2121 .LP
2122 On Linux systems with 2.0[.x] kernels:
2123 .IP
2124 packets on the loopback device will be seen twice;
2125 .IP
2126 packet filtering cannot be done in the kernel, so that all packets must
2127 be copied from the kernel in order to be filtered in user mode;
2128 .IP
2129 all of a packet, not just the part that's within the snapshot length,
2130 will be copied from the kernel (the 2.0[.x] packet capture mechanism, if
2131 asked to copy only part of a packet to userland, will not report the
2132 true length of the packet; this would cause most IP packets to get an
2133 error from
2134 .BR tcpdump );
2135 .IP
2136 capturing on some PPP devices won't work correctly.
2137 .LP
2138 We recommend that you upgrade to a 2.2 or later kernel.
2139 .LP
2140 Some attempt should be made to reassemble IP fragments or, at least
2141 to compute the right length for the higher level protocol.
2142 .LP
2143 Name server inverse queries are not dumped correctly: the (empty)
2144 question section is printed rather than real query in the answer
2145 section.
2146 Some believe that inverse queries are themselves a bug and
2147 prefer to fix the program generating them rather than \fItcpdump\fP.
2148 .LP
2149 A packet trace that crosses a daylight savings time change will give
2150 skewed time stamps (the time change is ignored).
2151 .LP
2152 Filter expressions on fields other than those in Token Ring headers will
2153 not correctly handle source-routed Token Ring packets.
2154 .LP
2155 Filter expressions on fields other than those in 802.11 headers will not
2156 correctly handle 802.11 data packets with both To DS and From DS set.
2157 .LP
2158 .BR "ip6 proto"
2159 should chase header chain, but at this moment it does not.
2160 .BR "ip6 protochain"
2161 is supplied for this behavior.
2162 .LP
2163 Arithmetic expression against transport layer headers, like \fBtcp[0]\fP,
2164 does not work against IPv6 packets.
2165 It only looks at IPv4 packets.