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