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