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