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