xref: /openbsd-src/usr.sbin/tcpdump/tcpdump.8 (revision 6396a31b28c13abcc71f05292f11b42abbafd7d3)
1.\"	$OpenBSD: tcpdump.8,v 1.102 2019/05/26 22:42:42 dlg Exp $
2.\"
3.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that: (1) source code distributions
8.\" retain the above copyright notice and this paragraph in its entirety, (2)
9.\" distributions including binary code include the above copyright notice and
10.\" this paragraph in its entirety in the documentation or other materials
11.\" provided with the distribution, and (3) all advertising materials mentioning
12.\" features or use of this software display the following acknowledgement:
13.\" ``This product includes software developed by the University of California,
14.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15.\" the University nor the names of its contributors may be used to endorse
16.\" or promote products derived from this software without specific prior
17.\" written permission.
18.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21.\"
22.Dd $Mdocdate: May 26 2019 $
23.Dt TCPDUMP 8
24.Os
25.Sh NAME
26.Nm tcpdump
27.Nd dump traffic on a network
28.Sh SYNOPSIS
29.Nm tcpdump
30.Op Fl AadefILlNnOopqStvXx
31.Op Fl B Ar fildrop
32.Op Fl c Ar count
33.Op Fl D Ar direction
34.Op Fl E Oo Ar espalg : Oc Ns Ar espkey
35.Op Fl F Ar file
36.Op Fl i Ar interface
37.Op Fl r Ar file
38.Op Fl s Ar snaplen
39.Op Fl T Ar type
40.Op Fl w Ar file
41.Op Fl y Ar datalinktype
42.Op Ar expression
43.Sh DESCRIPTION
44.Nm
45prints out the headers of packets on a network interface that match the boolean
46.Ar expression .
47You must have read access to
48.Pa /dev/bpf .
49.Pp
50The options are as follows:
51.Bl -tag -width "-c count"
52.It Fl A
53Print each packet in ASCII.
54If the
55.Fl e
56option is also specified, the link-level header will be included.
57The smaller of the entire packet or
58.Ar snaplen
59bytes will be printed.
60.It Fl a
61Attempt to convert network and broadcast addresses to names.
62.It Fl B Ar fildrop
63Configure the drop action specified by
64.Ar fildrop
65to be used when the filter expression matches a packet.
66The actions are:
67.Pp
68.Bl -tag -width "capture" -offset indent -compact
69.It Cm pass
70Matching packets are accepted and captured.
71.It Cm capture
72Matching packets are dropped and captured.
73.It Cm drop
74Matching packets are dropped but not captured.
75.El
76.Pp
77The default action is
78.Cm pass .
79.It Fl c Ar count
80Exit after receiving
81.Ar count
82packets.
83.It Fl D Ar direction
84Select packets flowing in the specified
85.Ar direction .
86Valid directions are:
87.Cm in
88and
89.Cm out .
90The default is to accept packets flowing in any direction.
91.It Fl d
92Dump the compiled packet-matching code in a human readable form to
93standard output and stop.
94.It Fl dd
95Dump packet-matching code as a C program fragment.
96.It Fl ddd
97Dump packet-matching code as decimal numbers
98preceded with a count.
99.It Fl E Oo Ar espalg : Oc Ns Ar espkey
100Try to decrypt RFC 4835 ESP
101.Pq Encapsulating Security Payload
102traffic using the specified hex key
103.Ar espkey .
104Supported algorithms for
105.Ar espalg
106are:
107.Cm aes128 ,
108.Cm aes128-hmac96 ,
109.Cm blowfish ,
110.Cm blowfish-hmac96 ,
111.Cm cast ,
112.Cm cast-hmac96 ,
113.Cm des3 ,
114.Cm des3-hmac96 ,
115.Cm des
116and
117.Cm des-hmac96 .
118The algorithm defaults to
119.Cm aes128-hmac96 .
120This option should be used for debugging only, since the key will show up in
121.Xr ps 1
122output.
123.It Fl e
124Print the link-level header on each dump line.
125.It Fl F Ar file
126Use
127.Ar file
128as input for the filter expression.
129Any additional expressions given on the command line are ignored.
130.It Fl f
131Print
132.Dq foreign
133internet addresses numerically rather than symbolically.
134This option is intended to get around serious brain damage in
135Sun's yp server \(em usually it hangs forever translating non-local
136internet numbers.
137.It Fl I
138Print the interface on each dump line.
139.It Fl i Ar interface
140Listen on
141.Ar interface .
142If unspecified,
143.Nm
144searches the system interface list for the lowest numbered, configured
145.Dq up
146interface
147.Pq excluding loopback .
148Ties are broken by choosing the earliest match.
149.It Fl L
150List the supported data link types for the interface and exit.
151.It Fl l
152Make stdout line buffered.
153Useful if you want to see the data while capturing it.
154For example:
155.Pp
156.Dl # tcpdump -l | tee dat
157or
158.Dl # tcpdump -l > dat & tail -f dat
159.It Fl N
160Do not print domain name qualification of host names.
161For example, if you specify this flag then
162.Nm
163will print
164.Dq nic
165instead of
166.Dq nic.ddn.mil .
167.It Fl n
168Do not convert addresses
169.Pq host addresses, port numbers, etc.
170to names.
171.It Fl O
172Do not run the packet-matching code optimizer.
173This is useful only if you suspect a bug in the optimizer.
174.It Fl o
175Print a guess of the possible operating system(s) of hosts that sent
176TCP SYN packets.
177See
178.Xr pf.os 5
179for a description of the passive operating system fingerprints.
180.It Fl p
181Do not put the interface into promiscuous mode.
182The interface might be in promiscuous mode for some other reason; hence,
183.Fl p
184cannot be used as an abbreviation for
185.Dq ether host \&"{local-hw-addr}\&"
186or
187.Dq ether broadcast .
188.It Fl q
189Quick
190.Pq quiet?
191output.
192Print less protocol information so output lines are shorter.
193.It Fl r Ar file
194Read packets from a
195.Ar file
196which was created with the
197.Fl w
198option.
199Standard input is used if
200.Ar file
201is
202.Ql - .
203.It Fl S
204Print absolute, rather than relative, TCP sequence numbers.
205.It Fl s Ar snaplen
206Analyze at most the first
207.Ar snaplen
208bytes of data from each packet rather than the default of 116.
209116 bytes is adequate for IPv6, ICMP, TCP, and UDP,
210but may truncate protocol information from name server and NFS packets
211.Pq see below .
212Packets truncated because of a limited
213.Ar snaplen
214are indicated in the output with
215.Dq Op | Ns Em proto ,
216where
217.Em proto
218is the name of the protocol level at which the truncation has occurred.
219Taking larger snapshots both increases the amount of time it takes
220to process packets and, effectively, decreases the amount of packet buffering.
221This may cause packets to be lost.
222You should limit
223.Ar snaplen
224to the smallest number that will capture the protocol information
225you're interested in.
226.It Fl T Ar type
227Force packets selected by
228.Ar expression
229to be interpreted as the specified
230.Ar type .
231Currently known types are:
232.Pp
233.Bl -tag -width "erspan" -offset indent -compact
234.It Cm cnfp
235Cisco NetFlow protocol
236.It Cm erspan
237Cisco Encapsulated Remote Switch Port Analyzer (ERSPAN) over GRE
238.It Cm gre
239Generic Routing Encapsulation over UDP
240.It Cm mpls
241Multiprocol Label Switching over UDP
242.It Cm rpc
243Remote Procedure Call
244.It Cm rtcp
245Real-Time Applications control protocol
246.It Cm rtp
247Real-Time Applications protocol
248.It Cm sack
249RFC 2018 TCP Selective Acknowledgements Options
250.It Cm tcp
251Transmission Control Protocol
252.It Cm tftp
253Trivial File Transfer Protocol
254.It Cm vat
255Visual Audio Tool
256.It Cm vrrp
257Virtual Router Redundancy protocol
258.It Cm vxlan
259Virtual eXtensible Local Area Network
260.It Cm wb
261distributed White Board
262.El
263.It Fl t
264Do not print a timestamp on each dump line.
265.It Fl tt
266Print an unformatted timestamp on each dump line.
267.It Fl ttt
268Print day and month in timestamp.
269.It Fl tttt
270Print timestamp difference between packets.
271.It Fl ttttt
272Print timestamp difference since the first packet.
273.It Fl v
274.Pq Slightly more
275verbose output.
276For example, the time to live
277.Pq TTL
278and type of service
279.Pq ToS
280information in an IP packet are printed.
281.It Fl vv
282Even more verbose output.
283For example, additional fields are printed from NFS reply packets.
284.It Fl w Ar file
285Write the raw packets to
286.Ar file
287rather than parsing and printing them out.
288They can be analyzed later with the
289.Fl r
290option.
291Standard output is used if
292.Ar file
293is
294.Ql - .
295.It Fl X
296Print each packet in hex and ASCII.
297If the
298.Fl e
299option is also specified, the link-level header will be included.
300The smaller of the entire packet or
301.Ar snaplen
302bytes will be printed.
303.It Fl x
304Print each packet in hex.
305If the
306.Fl e
307option is also specified, the link-level header will be included.
308The smaller of the entire packet or
309.Ar snaplen
310bytes will be printed.
311.It Fl y Ar datalinktype
312Set the data link type to use while capturing to
313.Ar datalinktype .
314Commonly used types include
315.Cm EN10MB ,
316.Cm IEEE802_11 ,
317and
318.Cm IEEE802_11_RADIO .
319The choices applicable to a particular device can be listed using
320.Fl L .
321.El
322.Pp
323.Ar expression
324selects which packets will be dumped.
325If no
326.Ar expression
327is given, all packets on the net will be dumped.
328Otherwise, only packets satisfying
329.Ar expression
330will be dumped.
331.Pp
332The
333.Ar expression
334consists of one or more primitives.
335Primitives usually consist of an
336.Ar id
337.Pq name or number
338preceded by one or more qualifiers.
339There are three different kinds of qualifiers:
340.Bl -tag -width "proto"
341.It Ar type
342Specify which kind of address component the
343.Ar id
344name or number refers to.
345Possible types are
346.Cm host ,
347.Cm net
348and
349.Cm port .
350E.g.,
351.Dq host foo ,
352.Dq net 128.3 ,
353.Dq port 20 .
354If there is no type qualifier,
355.Cm host
356is assumed.
357.It Ar dir
358Specify a particular transfer direction to and/or from
359.Ar id .
360Possible directions are
361.Cm src ,
362.Cm dst ,
363.Cm src or dst ,
364.Cm src and dst ,
365.Cm addr1 ,
366.Cm addr2 ,
367.Cm addr3 ,
368and
369.Cm addr4 .
370E.g.,
371.Dq src foo ,
372.Dq dst net 128.3 ,
373.Dq src or dst port ftp-data .
374If there is no
375.Ar dir
376qualifier,
377.Cm src or dst
378is assumed.
379The
380.Cm addr1 ,
381.Cm addr2 ,
382.Cm addr3 ,
383and
384.Cm addr4
385qualifiers are only valid for IEEE 802.11 Wireless LAN link layers.
386For null link layers (i.e., point-to-point protocols such as SLIP
387.Pq Serial Line Internet Protocol
388or the
389.Xr pflog 4
390header), the
391.Cm inbound
392and
393.Cm outbound
394qualifiers can be used to specify a desired direction.
395.It Ar proto
396Restrict the match to a particular protocol.
397Possible protocols are:
398.Cm ah ,
399.Cm arp ,
400.Cm atalk ,
401.Cm decnet ,
402.Cm esp ,
403.Cm ether ,
404.Cm fddi ,
405.Cm icmp ,
406.Cm icmp6 ,
407.Cm igmp ,
408.Cm igrp ,
409.Cm ip ,
410.Cm ip6 ,
411.Cm lat ,
412.Cm mopdl ,
413.Cm moprc ,
414.Cm pim ,
415.Cm rarp ,
416.Cm sca ,
417.Cm stp ,
418.Cm tcp ,
419.Cm udp ,
420and
421.Cm wlan .
422E.g.,
423.Dq ether src foo ,
424.Dq arp net 128.3 ,
425.Dq tcp port 21 ,
426.Dq wlan addr1 0:2:3:4:5:6 .
427If there is no protocol qualifier,
428all protocols consistent with the type are assumed.
429E.g.,
430.Dq src foo
431means
432.Do
433.Pq ip or arp or rarp
434src foo
435.Dc
436.Pq except the latter is not legal syntax ;
437.Dq net bar
438means
439.Do
440.Pq ip or arp or rarp
441net bar
442.Dc ;
443and
444.Dq port 53
445means
446.Do
447.Pq TCP or UDP
448port 53
449.Dc .
450.Pp
451.Cm fddi
452is actually an alias for
453.Cm ether ;
454the parser treats them identically as meaning
455.Qo
456the data link level used on the specified network interface
457.Qc .
458FDDI
459.Pq Fiber Distributed Data Interface
460headers contain Ethernet-like source and destination addresses,
461and often contain Ethernet-like packet types,
462so you can filter on these FDDI fields just as with the analogous
463Ethernet fields.
464FDDI headers also contain other fields,
465but you cannot name them explicitly in a filter expression.
466.El
467.Pp
468In addition to the above, there are some special primitive
469keywords that don't follow the pattern:
470.Cm gateway ,
471.Cm broadcast ,
472.Cm less ,
473.Cm greater ,
474and arithmetic expressions.
475All of these are described below.
476.Pp
477More complex filter expressions are built up by using the words
478.Cm and ,
479.Cm or ,
480and
481.Cm not
482to combine primitives
483e.g.,
484.Do
485host foo and not port ftp and not port ftp-data
486.Dc .
487To save typing, identical qualifier lists can be omitted
488e.g.,
489.Dq tcp dst port ftp or ftp-data or domain
490is exactly the same as
491.Do
492tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain
493.Dc .
494.Pp
495Allowable primitives are:
496.Bl -tag -width "ether proto proto"
497.It Cm dst host Ar host
498True if the IP destination field of the packet is
499.Ar host ,
500which may be either an address or a name.
501.It Cm src host Ar host
502True if the IP source field of the packet is
503.Ar host .
504.It Cm host Ar host
505True if either the IP source or destination of the packet is
506.Ar host .
507.Pp
508Any of the above
509.Ar host
510expressions can be prepended with the keywords,
511.Cm ip ,
512.Cm arp ,
513or
514.Cm rarp
515as in:
516.Pp
517.D1 Cm ip host Ar host
518.Pp
519which is equivalent to:
520.Bd -ragged -offset indent
521.Cm ether proto
522.Ar ip
523.Cm and host
524.Ar host
525.Ed
526.Pp
527If
528.Ar host
529is a name with multiple IP addresses, each address will be checked for a match.
530.It Cm ether dst Ar ehost
531True if the Ethernet destination address is
532.Ar ehost .
533.Ar ehost
534may be either a name from
535.Pa /etc/ethers
536or a number (see
537.Xr ethers 3
538for a numeric format).
539.It Cm ether src Ar ehost
540True if the Ethernet source address is
541.Ar ehost .
542.It Cm ether host Ar ehost
543True if either the Ethernet source or destination address is
544.Ar ehost .
545.It Cm gateway Ar host
546True if the packet used
547.Ar host
548as a gateway; i.e., the Ethernet source or destination address was
549.Ar host
550but neither the IP source nor the IP destination was
551.Ar host .
552.Ar host
553must be a name and must be found in both
554.Pa /etc/hosts
555and
556.Pa /etc/ethers .
557An equivalent expression is
558.Bd -ragged -offset indent
559.Cm ether host
560.Ar ehost
561.Cm and not host
562.Ar host
563.Ed
564.Pp
565which can be used with either names or numbers for
566.Ar host Ns / Ns Ar ehost .
567.It Cm dst net Ar net
568True if the IP destination address of the packet has a network number of
569.Ar net .
570.Ar net
571may be either a name from
572.Pa /etc/hosts
573or a network number (see
574.Xr hosts 5
575for details).
576.It Cm src net Ar net
577True if the IP source address of the packet has a network number of
578.Ar net .
579.It Cm net Ar net
580True if either the IP source or destination address of the packet
581has a network number of
582.Ar net .
583.It Cm dst port Ar port
584True if the packet is IP/TCP or IP/UDP and has a destination port value of
585.Ar port .
586The
587.Ar port
588can be a number or name from
589.Xr services 5
590(see
591.Xr tcp 4
592and
593.Xr udp 4 ) .
594If a name is used, both the port number and protocol are checked.
595If a number or ambiguous name is used, only the port number is checked;
596e.g.,
597.Dq Cm dst port No 513
598will print both TCP/login traffic and UDP/who traffic, and
599.Dq Cm dst port No domain
600will print both TCP/domain and UDP/domain traffic.
601.It Cm src port Ar port
602True if the packet has a source port value of
603.Ar port .
604.It Cm port Ar port
605True if either the source or destination port of the packet is
606.Ar port .
607.Pp
608Any of the above port expressions can be prepended with the keywords
609.Cm tcp
610or
611.Cm udp ,
612as in:
613.Pp
614.D1 Cm tcp src port Ar port
615.Pp
616which matches only TCP packets whose source port is
617.Ar port .
618.It Cm less Ar length
619True if the packet has a length less than or equal to
620.Ar length .
621This is equivalent to:
622.Pp
623.D1 Cm len <= Ar length
624.It Cm greater Ar length
625True if the packet has a length greater than or equal to
626.Ar length .
627This is equivalent to:
628.Pp
629.D1 Cm len >= Ar length
630.It Cm ip proto Ar proto
631True if the packet is an IP packet (see
632.Xr ip 4 )
633of protocol type
634.Ar proto .
635.Ar proto
636can be a number or name from
637.Xr protocols 5 ,
638such as
639.Cm icmp ,
640.Cm udp ,
641or
642.Cm tcp .
643These identifiers are also keywords and must be escaped
644using a backslash character
645.Pq Sq \e .
646.It Cm ether broadcast
647True if the packet is an Ethernet broadcast packet.
648The
649.Cm ether
650keyword is optional.
651.It Cm ip broadcast
652True if the packet is an IP broadcast packet.
653It checks for both the all-zeroes and all-ones broadcast conventions
654and looks up the local subnet mask.
655.It Cm ether multicast
656True if the packet is an Ethernet multicast packet.
657The
658.Cm ether
659keyword is optional.
660This is shorthand for
661.Do
662.Cm ether Ns [0] & 1 != 0
663.Dc .
664.It Cm ip multicast
665True if the packet is an IP multicast packet.
666.It Cm ether proto Ar proto
667True if the packet is of ether type
668.Ar proto .
669.Ar proto
670can be a number or one of the names
671.Cm ip ,
672.Cm ip6 ,
673.Cm arp ,
674.Cm rarp ,
675.Cm atalk ,
676.Cm atalkarp ,
677.Cm decnet ,
678.Cm decdts ,
679.Cm decdns ,
680.Cm lanbridge ,
681.Cm lat ,
682.Cm mopdl ,
683.Cm moprc ,
684.Cm pup ,
685.Cm sca ,
686.Cm sprite ,
687.Cm stp ,
688.Cm vexp ,
689.Cm vprod ,
690or
691.Cm xns .
692These identifiers are also keywords and must be escaped
693using a backslash character
694.Pq Sq \e .
695In the case of FDDI (e.g.,
696.Dq Cm fddi protocol arp ) ,
697the protocol identification comes from the 802.2 Logical Link Control
698.Pq LLC
699header, which is usually layered on top of the FDDI header.
700.Nm
701assumes, when filtering on the protocol identifier, that all FDDI packets
702include an LLC header, and that the LLC header is in so-called SNAP format.
703.It Cm decnet src Ar host
704True if the DECNET source address is
705.Ar host ,
706which may be an address of the form
707.Dq 10.123 ,
708or a DECNET host name.
709DECNET host name support is only available on systems that are
710configured to run DECNET.
711.It Cm decnet dst Ar host
712True if the DECNET destination address is
713.Ar host .
714.It Cm decnet host Ar host
715True if either the DECNET source or destination address is
716.Ar host .
717.It Cm ifname Ar interface
718True if the packet was logged as coming from the specified interface
719(applies only to packets logged by
720.Xr pf 4 ) .
721.It Cm on Ar interface
722Synonymous with the
723.Ar ifname
724modifier.
725.It Cm rnr Ar num
726True if the packet was logged as matching the specified PF rule number
727in the main ruleset (applies only to packets logged by
728.Xr pf 4 ) .
729.It Cm rulenum Ar num
730Synonymous with the
731.Ar rnr
732modifier.
733.It Cm reason Ar code
734True if the packet was logged with the specified PF reason code.
735The known codes are:
736.Ar match ,
737.Ar bad-offset ,
738.Ar fragment ,
739.Ar short ,
740.Ar normalize ,
741.Ar memory ,
742.Ar bad-timestamp ,
743.Ar congestion ,
744.Ar ip-option ,
745.Ar proto-cksum ,
746.Ar state-mismatch ,
747.Ar state-insert ,
748.Ar state-limit ,
749.Ar src-limit ,
750and
751.Ar synproxy
752(applies only to packets logged by
753.Xr pf 4 ) .
754.It Cm rset Ar name
755True if the packet was logged as matching the specified PF ruleset
756name of an anchored ruleset (applies only to packets logged by
757.Xr pf 4 ) .
758.It Cm ruleset Ar name
759Synonymous with the
760.Ar rset
761modifier.
762.It Cm srnr Ar num
763True if the packet was logged as matching the specified PF rule number
764of an anchored ruleset (applies only to packets logged by
765.Xr pf 4 ) .
766.It Cm subrulenum Ar num
767Synonymous with the
768.Ar srnr
769modifier.
770.It Cm action Ar act
771True if PF took the specified action when the packet was logged.
772Valid actions are:
773.Ar pass ,
774.Ar block ,
775and
776.Ar match
777(applies only to packets logged by
778.Xr pf 4 ) .
779.It Cm wlan addr1 Ar ehost
780True if the first IEEE 802.11 address is
781.Ar ehost .
782.It Cm wlan addr2 Ar ehost
783True if the second IEEE 802.11 address is
784.Ar ehost .
785.It Cm wlan addr3 Ar ehost
786True if the third IEEE 802.11 address is
787.Ar ehost .
788.It Cm wlan addr4 Ar ehost
789True if the fourth IEEE 802.11 address is
790.Ar ehost .
791The fourth address field is only used for
792WDS (Wireless Distribution System) frames.
793.It Cm wlan host Ar ehost
794True if either the first, second, third, or fourth
795IEEE 802.11 address is
796.Ar ehost .
797.It Cm type Ar type
798True if the IEEE 802.11 frame type matches the specified
799.Ar type .
800Valid types are:
801.Ar data ,
802.Ar mgt ,
803.Ar ctl ,
804or a numeric value.
805.It Cm subtype Ar subtype
806True if the IEEE 802.11 frame subtype matches the specified
807.Ar subtype .
808Valid subtypes are:
809.Ar assocreq ,
810.Ar assocresp ,
811.Ar reassocreq ,
812.Ar reassocresp ,
813.Ar probereq ,
814.Ar proberesp ,
815.Ar beacon ,
816.Ar atim ,
817.Ar disassoc ,
818.Ar auth ,
819.Ar deauth ,
820.Ar data ,
821or a numeric value.
822.It Cm dir Ar dir
823True if the IEEE 802.11 frame direction matches the specified
824.Ar dir .
825Valid directions are:
826.Ar nods ,
827.Ar tods ,
828.Ar fromds ,
829.Ar dstods ,
830or a numeric value.
831.It Xo
832.Cm atalk ,
833.Cm ip ,
834.Cm ip6 ,
835.Cm arp ,
836.Cm decnet ,
837.Cm lat ,
838.Cm moprc ,
839.Cm mopdl ,
840.Cm rarp ,
841.Cm sca
842.Xc
843Abbreviations for:
844.Cm ether proto Ar p
845where
846.Ar p
847is one of the above protocols.
848.Nm
849does not currently know how to parse
850.Cm lat ,
851.Cm moprc ,
852or
853.Cm mopdl .
854.It Xo
855.Cm ah ,
856.Cm esp ,
857.Cm icmp ,
858.Cm icmp6 ,
859.Cm igmp ,
860.Cm igrp ,
861.Cm pim ,
862.Cm tcp ,
863.Cm udp
864.Xc
865Abbreviations for:
866.Cm ip proto Ar p
867where
868.Ar p
869is one of the above protocols.
870.It Ar expr relop expr
871True if the relation holds, where
872.Ar relop
873is one of
874.Ql > ,
875.Ql < ,
876.Ql >= ,
877.Ql <= ,
878.Ql = ,
879.Ql != ,
880and
881.Ar expr
882is an arithmetic expression composed of integer constants
883.Pq expressed in standard C syntax ,
884the normal binary operators
885.Ql ( + ,
886.Ql - ,
887.Ql * ,
888.Ql / ,
889.Ql & ,
890.Ql | ) ,
891a length operator, and special packet data accessors.
892To access data inside the packet, use the following syntax:
893.Sm off
894.Bd -ragged -offset indent
895.Ar proto Op Ar expr : Ar size
896.Ed
897.Sm on
898.Pp
899.Ar proto
900is one of
901.Cm ether ,
902.Cm fddi ,
903.Cm ip ,
904.Cm arp ,
905.Cm rarp ,
906.Cm tcp ,
907.Cm udp ,
908or
909.Cm icmp ,
910and indicates the protocol layer for the index operation.
911The byte offset, relative to the indicated protocol layer, is given by
912.Ar expr .
913.Ar size
914is optional and indicates the number of bytes in the field of interest;
915it can be either one, two, or four, and defaults to one.
916The length operator, indicated by the keyword
917.Cm len ,
918gives the length of the packet.
919.Pp
920For example,
921.Dq Cm ether Ns [0] & 1 != 0
922catches all multicast traffic.
923The expression
924.Dq Cm ip Ns [0] & 0xf != 5
925catches all IP packets with options.
926The expression
927.Dq Cm ip Ns [6:2] & 0x1fff = 0
928catches only unfragmented datagrams and frag zero of fragmented datagrams.
929This check is implicitly applied to the
930.Cm tcp
931and
932.Cm udp
933index operations.
934For instance,
935.Dq Cm tcp Ns [0]
936always means the first byte of the TCP header,
937and never means the first byte of an intervening fragment.
938.El
939.Pp
940Primitives may be combined using a parenthesized group of primitives and
941operators.
942Parentheses are special to the shell and must be escaped.
943Allowable primitives and operators are:
944.Bd -ragged -offset indent
945Negation
946.Po
947.Dq Cm \&!
948or
949.Dq Cm not
950.Pc
951.Pp
952Concatenation
953.Po
954.Dq Cm &&
955or
956.Dq Cm and
957.Pc
958.Pp
959Alternation
960.Po
961.Dq Cm ||
962or
963.Dq Cm or
964.Pc
965.Ed
966.Pp
967Negation has highest precedence.
968Alternation and concatenation have equal precedence and associate left to right.
969Explicit
970.Cm and
971tokens, not juxtaposition,
972are now required for concatenation.
973.Pp
974If an identifier is given without a keyword, the most recent keyword is assumed.
975For example,
976.Bd -ragged -offset indent
977.Cm not host
978vs
979.Cm and
980ace
981.Ed
982.Pp
983is short for
984.Bd -ragged -offset indent
985.Cm not host
986vs
987.Cm and host
988ace
989.Ed
990.Pp
991which should not be confused with
992.Bd -ragged -offset indent
993.Cm not
994.Pq Cm host No vs Cm or No ace
995.Ed
996.Pp
997Expression arguments can be passed to
998.Nm
999as either a single argument or as multiple arguments,
1000whichever is more convenient.
1001Generally, if the expression contains shell metacharacters,
1002it is easier to pass it as a single, quoted argument.
1003Multiple arguments are concatenated with spaces before being parsed.
1004.Sh EXAMPLES
1005To print all packets arriving at or departing from sundown:
1006.Pp
1007.Dl # tcpdump host sundown
1008.Pp
1009To print traffic between helios and either hot or ace
1010(the expression is quoted to prevent the shell from misinterpreting
1011the parentheses):
1012.Pp
1013.Dl # tcpdump 'host helios and (hot or ace)'
1014.Pp
1015To print all IP packets between ace and any host except helios:
1016.Pp
1017.Dl # tcpdump ip host ace and not helios
1018.Pp
1019To print all traffic between local hosts and hosts at Berkeley:
1020.Pp
1021.Dl # tcpdump net ucb-ether
1022.Pp
1023To print all FTP traffic through internet gateway snup:
1024.Pp
1025.Dl # tcpdump 'gateway snup and (port ftp or ftp-data)'
1026.Pp
1027To print traffic neither sourced from nor destined for local network
1028192.168.7.0/24 (if you gateway to one other net, this stuff should
1029never make it onto your local network):
1030.Pp
1031.Dl # tcpdump ip and not net 192.168.7.0/24
1032.Pp
1033To print the start and end packets
1034.Pq the SYN and FIN packets
1035of each TCP connection that involves a host that is not in local
1036network 192.168.7.0/24:
1037.Bd -literal -offset indent
1038# tcpdump 'tcp[13] & 3 != 0 and not src and dst net 192.168.7.0/24'
1039.Ed
1040.Pp
1041To print only the SYN packets of HTTP connections:
1042.Pp
1043.Dl # tcpdump 'tcp[tcpflags] = tcp-syn and port http'
1044.Pp
1045To print IP packets longer than 576 bytes sent through gateway snup:
1046.Pp
1047.Dl # tcpdump 'gateway snup and ip[2:2] > 576'
1048.Pp
1049To print IP broadcast or multicast packets that were
1050.Em not
1051sent via Ethernet broadcast or multicast:
1052.Bd -literal -offset indent
1053# tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'
1054.Ed
1055.Pp
1056To print all ICMP packets that are not echo requests/replies
1057.Pq i.e., not ping packets :
1058.Pp
1059.Dl # tcpdump 'icmp[0] != 8 and icmp[0] != 0'
1060.Pp
1061To print only echo request ICMP packets:
1062.Pp
1063.Dl # tcpdump 'icmp[icmptype] = icmp-echo'
1064.Pp
1065To print and decrypt all ESP packets with SPI 0x00001234:
1066.Pp
1067.Dl # tcpdump -E des3-hmac96:ab...def 'ip[20:4] = 0x00001234'
1068.Pp
1069To print raw wireless frames passing the iwn0 interface:
1070.Dl # tcpdump -i iwn0 -y IEEE802_11_RADIO -v
1071.Sh OUTPUT FORMAT
1072The output of
1073.Nm
1074is protocol dependent.
1075The following gives a brief description and examples of most of the formats.
1076.Ss Link Level Headers
1077If the
1078.Fl e
1079option is given, the link level header is printed out.
1080On Ethernets, the source and destination addresses, protocol,
1081and packet length are printed.
1082.Pp
1083On the packet filter logging interface
1084.Xr pflog 4 ,
1085logging reason
1086.Pq rule match, bad-offset, fragment, bad-timestamp, short, normalize, memory ,
1087action taken
1088.Pq pass/block ,
1089direction
1090.Pq in/out
1091and interface information are printed out for each packet.
1092.Pp
1093On FDDI networks, the
1094.Fl e
1095option causes
1096.Nm
1097to print the frame control field, the source and destination addresses,
1098and the packet length.
1099The frame control field governs the interpretation of the rest of the packet.
1100Normal packets
1101.Pq such as those containing IP datagrams
1102are
1103.Dq async
1104packets, with a priority value between 0 and 7; for example,
1105.Sy async4 .
1106Such packets are assumed to contain an 802.2 Logical Link Control
1107.Pq LLC
1108packet; the LLC header is printed if it is
1109.Em not
1110an ISO datagram or a so-called SNAP packet.
1111.Pp
1112The following description assumes familiarity with the
1113SLIP compression algorithm described in RFC 1144.
1114.Pp
1115On SLIP links, a direction indicator
1116.Po
1117.Ql I
1118for inbound,
1119.Ql O
1120for outbound
1121.Pc ,
1122packet type, and compression information are printed out.
1123The packet type is printed first.
1124The three types are
1125.Cm ip ,
1126.Cm utcp ,
1127and
1128.Cm ctcp .
1129No further link information is printed for IP packets.
1130For TCP packets, the connection identifier is printed following the type.
1131If the packet is compressed, its encoded header is printed out.
1132The special cases are printed out as
1133.Cm *S+ Ns Ar n
1134and
1135.Cm *SA+ Ns Ar n ,
1136where
1137.Ar n
1138is the amount by which the sequence number
1139.Pq or sequence number and ack
1140has changed.
1141If it is not a special case, zero or more changes are printed.
1142A change is indicated by
1143.Sq U
1144.Pq urgent pointer ,
1145.Sq W
1146.Pq window ,
1147.Sq A
1148.Pq ack ,
1149.Sq S
1150.Pq sequence number ,
1151and
1152.Sq I
1153.Pq packet ID ,
1154followed by a delta
1155.Pq +n or -n ,
1156or a new value
1157.Pq =n .
1158Finally, the amount of data in the packet and compressed header length
1159are printed.
1160.Pp
1161For example, the following line shows an outbound compressed TCP packet,
1162with an implicit connection identifier; the ack has changed by 6,
1163the sequence number by 49, and the packet ID by 6;
1164there are 3 bytes of data and 6 bytes of compressed header:
1165.Bd -ragged -offset indent
1166O
1167.Cm ctcp No *
1168.Cm A No +6
1169.Cm S No +49
1170.Cm I No +6 3
1171.Pq 6
1172.Ed
1173.Ss ARP/RARP Packets
1174arp/rarp output shows the type of request and its arguments.
1175The format is intended to be self-explanatory.
1176Here is a short sample taken from the start of an rlogin
1177from host rtsg to host csam:
1178.Bd -literal -offset indent
1179arp who-has csam tell rtsg
1180arp reply csam is-at CSAM
1181.Ed
1182.Pp
1183In this example, Ethernet addresses are in caps and internet addresses
1184in lower case.
1185The first line says that rtsg sent an arp packet asking for
1186the Ethernet address of internet host csam.
1187csam replies with its Ethernet address CSAM.
1188.Pp
1189This would look less redundant if we had done
1190.Nm
1191.Fl n :
1192.Bd -literal -offset indent
1193arp who-has 128.3.254.6 tell 128.3.254.68
1194arp reply 128.3.254.6 is-at 02:07:01:00:01:c4
1195.Ed
1196.Pp
1197If we had done
1198.Nm
1199.Fl e ,
1200the fact that the first packet is
1201broadcast and the second is point-to-point would be visible:
1202.Bd -literal -offset indent
1203RTSG Broadcast 0806 64: arp who-has csam tell rtsg
1204CSAM RTSG 0806 64: arp reply csam is-at CSAM
1205.Ed
1206.Pp
1207For the first packet this says the Ethernet source address is RTSG,
1208the destination is the Ethernet broadcast address,
1209the type field contained hex 0806 (type
1210.Dv ETHER_ARP )
1211and the total length was 64 bytes.
1212.Ss TCP Packets
1213The following description assumes familiarity with the TCP protocol
1214described in RFC 793.
1215If you are not familiar with the protocol, neither this description nor
1216.Nm
1217will be of much use to you.
1218.Pp
1219The general format of a TCP protocol line is:
1220.Bd -ragged -offset indent
1221.Ar src No > Ar dst :
1222.Ar flags src-os data-seqno ack window urgent options
1223.Ed
1224.Pp
1225.Ar src
1226and
1227.Ar dst
1228are the source and destination IP addresses and ports.
1229.Ar flags
1230is some combination of
1231.Sq S
1232.Pq SYN ,
1233.Sq F
1234.Pq FIN ,
1235.Sq P
1236.Pq PUSH ,
1237or
1238.Sq R
1239.Pq RST ,
1240.Sq W
1241.Pq congestion Window reduced ,
1242.Sq E
1243.Pq ecn ECHO
1244or a single
1245.Ql \&.
1246.Pq no flags .
1247.Ar src-os
1248will list a guess of the source host's operating system if the
1249.Fl o
1250command line flag was passed to
1251.Nm tcpdump .
1252.Ar data-seqno
1253describes the portion of sequence space covered
1254by the data in this packet
1255.Pq see example below .
1256.Ar ack
1257is the sequence number of the next data expected by the other
1258end of this connection.
1259.Ar window
1260is the number of bytes of receive buffer space available
1261at the other end of this connection.
1262.Ar urg
1263indicates there is urgent data in the packet.
1264.Ar options
1265are TCP options enclosed in angle brackets e.g.,
1266<mss 1024>.
1267.Pp
1268.Ar src , dst
1269and
1270.Ar flags
1271are always present.
1272The other fields depend on the contents of the packet's TCP protocol header and
1273are output only if appropriate.
1274.Pp
1275Here is the opening portion of an rlogin from host rtsg to host csam.
1276.Bd -unfilled -offset 2n
1277rtsg.1023 > csam.login: S 768512:768512(0) win 4096 <mss 1024>
1278csam.login > rtsg.1023: S 947648:947648(0) ack 768513 win 4096 <mss 1024>
1279rtsg.1023 > csam.login: . ack 1 win 4096
1280rtsg.1023 > csam.login: P 1:2(1) ack 1 win 4096
1281csam.login > rtsg.1023: . ack 2 win 4096
1282rtsg.1023 > csam.login: P 2:21(19) ack 1 win 4096
1283csam.login > rtsg.1023: P 1:2(1) ack 21 win 4077
1284csam.login > rtsg.1023: P 2:3(1) ack 21 win 4077 urg 1
1285csam.login > rtsg.1023: P 3:4(1) ack 21 win 4077 urg 1
1286.Ed
1287.Pp
1288The first line says that TCP port 1023 on rtsg sent a packet
1289to port login on host csam.
1290The
1291.Ql S
1292indicates that the SYN flag was set.
1293The packet sequence number was 768512 and it contained no data.
1294The notation is
1295.Sm off
1296.So
1297.Ar first : last
1298.Po Ar nbytes
1299.Pc
1300.Sc
1301.Sm on
1302which means sequence numbers
1303.Ar first
1304up to but not including
1305.Ar last
1306which is
1307.Ar nbytes
1308bytes of user data.
1309There was no piggy-backed ack, the available receive window was 4096
1310bytes and there was a max-segment-size option requesting an mss of 1024 bytes.
1311.Pp
1312Csam replies with a similar packet except it includes a piggy-backed
1313ack for rtsg's SYN.
1314Rtsg then acks csam's SYN.
1315The
1316.Ql \&.
1317means no flags were set.
1318The packet contained no data so there is no data sequence number.
1319The ack sequence number is a 32-bit integer.
1320The first time
1321.Nm
1322sees a TCP connection, it prints the sequence number from the packet.
1323On subsequent packets of the connection, the difference between
1324the current packet's sequence number and this initial sequence number
1325is printed.
1326This means that sequence numbers after the first can be interpreted
1327as relative byte positions in the connection's data stream
1328.Po
1329with the first data byte each direction being 1
1330.Pc .
1331.Fl S
1332will override this
1333feature, causing the original sequence numbers to be output.
1334.Pp
1335On the 6th line, rtsg sends csam 19 bytes of data
1336.Po
1337bytes 2 through 20
1338in the rtsg -> csam side of the connection
1339.Pc .
1340The PUSH flag is set in the packet.
1341On the 7th line, csam says it's received data sent by rtsg up to
1342but not including byte 21.
1343Most of this data is apparently sitting in the socket buffer
1344since csam's receive window has gotten 19 bytes smaller.
1345Csam also sends one byte of data to rtsg in this packet.
1346On the 8th and 9th lines,
1347csam sends two bytes of urgent, pushed data to rtsg.
1348.Ss UDP Packets
1349UDP format is illustrated by this rwho packet:
1350.Pp
1351.D1 actinide.who > broadcast.who: udp 84
1352.Pp
1353This says that port who on host actinide sent a UDP datagram to port
1354who on host broadcast, the Internet broadcast address.
1355The packet contained 84 bytes of user data.
1356.Pp
1357Some UDP services are recognized
1358.Pq from the source or destination port number
1359and the higher level protocol information printed.
1360In particular, Domain Name service requests
1361.Pq RFC 1034/1035
1362and Sun RPC calls
1363.Pq RFC 1050
1364to NFS.
1365.Ss UDP Name Server Requests
1366The following description assumes familiarity with
1367the Domain Service protocol described in RFC 1035.
1368If you are not familiar with the protocol,
1369the following description will appear to be written in Greek.
1370.Pp
1371Name server requests are formatted as
1372.Bd -ragged -offset indent
1373.Ar src
1374>
1375.Ar dst :
1376.Ar id op Ns ?\&
1377.Ar flags qtype qclass name
1378.Pq Ar len
1379.Ed
1380.Pp
1381For example:
1382.Pp
1383.D1 h2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)
1384.Pp
1385Host h2opolo asked the domain server on helios for an address record
1386.Pq Ar qtype Ns =A
1387associated with the name
1388ucbvax.berkeley.edu.
1389The query
1390.Ar id
1391was 3.
1392The
1393.Ql +
1394indicates the recursion desired flag was set.
1395The query length was 37 bytes, not including the UDP and IP protocol headers.
1396The query operation was the normal one
1397.Pq Query
1398so the
1399.Ar op
1400field was omitted.
1401If
1402.Ar op
1403had been anything else, it would have been printed between the 3 and the
1404.Ql + .
1405Similarly, the
1406.Ar qclass
1407was the normal one
1408.Pq C_IN
1409and was omitted.
1410Any other
1411.Ar qclass
1412would have been printed immediately after the A.
1413.Pp
1414A few anomalies are checked and may result in extra fields enclosed in
1415square brackets: if a query contains an answer, name server or
1416authority section,
1417.Ar ancount ,
1418.Ar nscount ,
1419or
1420.Ar arcount
1421are printed as
1422.Dq Bq Ar n Ns a ,
1423.Dq Bq Ar n Ns n ,
1424or
1425.Dq Bq Ar n Ns au
1426where
1427.Ar n
1428is the appropriate count.
1429If any of the response bits are set
1430.Po
1431AA, RA or rcode
1432.Pc
1433or any of the
1434.Dq must be zero
1435bits are set in bytes two and three,
1436.Dq Bq b2&3= Ns Ar x
1437is printed, where
1438.Ar x
1439is the hex value of header bytes two and three.
1440.Ss UDP Name Server Responses
1441Name server responses are formatted as
1442.Bd -ragged -offset indent
1443.Ar src No > Ar dst :
1444.Ar id op rcode flags
1445.Ar a
1446/
1447.Ar n
1448/
1449.Ar au
1450.Ar type class data
1451.Pq Ar len
1452.Ed
1453.Pp
1454For example:
1455.Bd -unfilled -offset indent
1456helios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
1457helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)
1458.Ed
1459.Pp
1460In the first example, helios responds to query
1461.Ar id
14623 from h2opolo
1463with 3 answer records, 3 name server records and 7 authority records.
1464The first answer record is type A
1465.Pq address and its data is internet
1466address 128.32.137.3.
1467The total size of the response was 273 bytes, excluding UDP and IP headers.
1468The
1469.Ar op
1470.Pq Query
1471and
1472.Ar rcode
1473.Pq NoError
1474were omitted, as was the
1475.Ar class
1476.Pq C_IN
1477of the A record.
1478.Pp
1479In the second example, helios responds to query
1480.Ar op
14812 with an
1482.Ar rcode
1483of non-existent domain
1484.Pq NXDomain
1485with no answers,
1486one name server and no authority records.
1487The
1488.Ql *
1489indicates that the authoritative answer bit was set.
1490Since there were no answers, no
1491.Ar type ,
1492.Ar class
1493or
1494.Ar data
1495were printed.
1496.Pp
1497Other flag characters that might appear are
1498.Sq -
1499(recursion available, RA,
1500.Em not
1501set)
1502and
1503.Sq |
1504.Pq truncated message, TC, set .
1505If the question section doesn't contain exactly one entry,
1506.Dq Bq Ar n Ns q
1507is printed.
1508.Pp
1509Name server requests and responses tend to be large and the default
1510.Ar snaplen
1511of 96 bytes may not capture enough of the packet to print.
1512Use the
1513.Fl s
1514flag to increase the
1515.Ar snaplen
1516if you need to seriously investigate name server traffic.
1517.Dq Fl s No 128
1518has worked well for me.
1519.Ss NFS Requests and Replies
1520Sun NFS
1521.Pq Network File System
1522requests and replies are printed as:
1523.Bd -ragged -offset indent
1524.Ar src . Ns Ar xid
1525>
1526.Ar dst . Ns nfs :
1527.Ar len op args
1528.Pp
1529.Ar src . Ns nfs
1530>
1531.Ar dst . Ns Ar xid :
1532reply
1533.Ar stat len op results
1534.Ed
1535.Bd -unfilled -offset indent
1536sushi.6709 > wrl.nfs: 112 readlink fh 21,24/10.73165
1537wrl.nfs > sushi.6709: reply ok 40 readlink "../var"
1538sushi.201b > wrl.nfs:
1539	144 lookup fh 9,74/4096.6878 "xcolors"
1540wrl.nfs > sushi.201b:
1541	reply ok 128 lookup fh 9,74/4134.3150
1542.Ed
1543.Pp
1544In the first line, host sushi sends a transaction with ID 6709 to wrl.
1545The number following the src host is a transaction ID,
1546.Em not
1547the source port.
1548The request was 112 bytes, excluding the UDP and IP headers.
1549The
1550.Ar op
1551was a readlink
1552.Pq read symbolic link
1553on fh
1554.Pq Dq file handle
155521,24/10.731657119.
1556If one is lucky, as in this case, the file handle can be interpreted
1557as a major,minor device number pair, followed by the inode number and
1558generation number.
1559Wrl replies with a
1560.Ar stat
1561of ok and the contents of the link.
1562.Pp
1563In the third line, sushi asks wrl to look up the name
1564.Dq xcolors
1565in directory file 9,74/4096.6878.
1566The data printed depends on the operation type.
1567The format is intended to be self-explanatory
1568if read in conjunction with an NFS protocol spec.
1569.Pp
1570If the
1571.Fl v
1572.Pq verbose
1573flag is given, additional information is printed.
1574For example:
1575.Bd -unfilled -offset indent
1576sushi.1372a > wrl.nfs:
1577	148 read fh 21,11/12.195 8192 bytes @ 24576
1578wrl.nfs > sushi.1372a:
1579	reply ok 1472 read REG 100664 ids 417/0 sz 29388
1580.Ed
1581.Pp
1582.Fl v
1583also prints the IP header TTL, ID, and fragmentation fields,
1584which have been omitted from this example.
1585In the first line, sushi asks wrl to read 8192 bytes from file 21,11/12.195,
1586at byte offset 24576.
1587Wrl replies with a
1588.Ar stat of
1589ok;
1590the packet shown on the second line is the first fragment of the reply,
1591and hence is only 1472 bytes long.
1592The other bytes will follow in subsequent fragments,
1593but these fragments do not have NFS or even UDP headers and so might not be
1594printed, depending on the filter expression used.
1595Because the
1596.Fl v
1597flag is given, some of the file attributes
1598.Po
1599which are returned in addition to the file data
1600.Pc
1601are printed: the file type
1602.Pq So REG Sc , No for regular file ,
1603the file mode
1604.Pq in octal ,
1605the UID and GID, and the file size.
1606.Pp
1607If the
1608.Fl v
1609flag is given more than once, even more details are printed.
1610.Pp
1611NFS requests are very large and much of the detail won't be printed unless
1612.Ar snaplen
1613is increased.
1614Try using
1615.Dq Fl s No 192
1616to watch NFS traffic.
1617.Pp
1618NFS reply packets do not explicitly identify the RPC operation.
1619Instead,
1620.Nm
1621keeps track of
1622.Dq recent
1623requests, and matches them to the replies using the
1624.Ar xid
1625.Pq transaction ID .
1626If a reply does not closely follow the corresponding request,
1627it might not be parsable.
1628.Ss IP Fragmentation
1629Fragmented Internet datagrams are printed as
1630.Bd -ragged -offset indent
1631.Po
1632.Cm frag Ar id
1633:
1634.Ar size
1635@
1636.Ar offset
1637.Op +
1638.Pc
1639.Ed
1640.Pp
1641A
1642.Ql +
1643indicates there are more fragments.
1644The last fragment will have no
1645.Ql + .
1646.Pp
1647.Ar id
1648is the fragment ID.
1649.Ar size
1650is the fragment size
1651.Pq in bytes
1652excluding the IP header.
1653.Ar offset
1654is this fragment's offset
1655.Pq in bytes
1656in the original datagram.
1657.Pp
1658The fragment information is output for each fragment.
1659The first fragment contains the higher level protocol header and the fragment
1660info is printed after the protocol info.
1661Fragments after the first contain no higher level protocol header and the
1662fragment info is printed after the source and destination addresses.
1663For example, here is part of an FTP from arizona.edu to lbl-rtsg.arpa
1664over a CSNET connection that doesn't appear to handle 576 byte datagrams:
1665.Bd -unfilled -offset indent
1666arizona.ftp-data > rtsg.1170: . 1024:1332(308) ack 1 win 4096 (frag 595a:328@0+)
1667arizona > rtsg: (frag 595a:204@328)
1668rtsg.1170 > arizona.ftp-data: . ack 1536 win 2560
1669.Ed
1670.Pp
1671There are a couple of things to note here: first, addresses in the
16722nd line don't include port numbers.
1673This is because the TCP protocol information is all in the first fragment
1674and we have no idea what the port or sequence numbers are when we print
1675the later fragments.
1676Second, the TCP sequence information in the first line is printed as if there
1677were 308 bytes of user data when, in fact, there are 512 bytes
1678.Po
1679308 in the first frag and 204 in the second
1680.Pc .
1681If you are looking for holes in the sequence space or trying to match up acks
1682with packets, this can fool you.
1683.Pp
1684A packet with the IP
1685.Sy don't fragment
1686flag is marked with a trailing
1687.Dq Pq DF .
1688.Ss Timestamps
1689By default, all output lines are preceded by a timestamp.
1690The timestamp is the current clock time in the form
1691.Sm off
1692.Ar hh : mm : ss . frac
1693.Sm on
1694and is as accurate as the kernel's clock.
1695The timestamp reflects the time the kernel first saw the packet.
1696No attempt is made to account for the time lag between when the
1697Ethernet interface removed the packet from the wire and when the kernel
1698serviced the
1699.Dq new packet
1700interrupt.
1701.Ss IP and Protocol Checksum Offload
1702Some network cards support IP and/or protocol checksum offload.
1703Packet headers for such interfaces erroneously indicate a bad checksum,
1704since the checksum is not calculated until after
1705.Nm
1706sees the packet.
1707.Sh SEE ALSO
1708.\" traffic(1C), nit(4P),
1709.Xr ethers 3 ,
1710.Xr pcap 3 ,
1711.Xr pcap-filter 3 ,
1712.Xr bpf 4 ,
1713.Xr ip 4 ,
1714.Xr pf 4 ,
1715.Xr pflog 4 ,
1716.Xr tcp 4 ,
1717.Xr udp 4 ,
1718.Xr hosts 5 ,
1719.Xr pf.os 5 ,
1720.Xr protocols 5 ,
1721.Xr services 5
1722.Sh STANDARDS
1723.Rs
1724.%D September 1981
1725.%R RFC 793
1726.%T Transmission Control Protocol
1727.Re
1728.Pp
1729.Rs
1730.%A P. Mockapetris
1731.%D November 1987
1732.%R RFC 1034
1733.%T Domain Names \(en Concepts and Facilities
1734.Re
1735.Pp
1736.Rs
1737.%A P. Mockapetris
1738.%D November 1987
1739.%R RFC 1035
1740.%T Domain Names \(en Implementation and Specification
1741.Re
1742.Pp
1743.Rs
1744.%D April 1988
1745.%R RFC 1050
1746.%T RPC: Remote Procedure Call Protocol Specification
1747.Re
1748.Pp
1749.Rs
1750.%A V. Jacobson
1751.%D February 1990
1752.%R RFC 1144
1753.%T Compressing TCP/IP Headers for Low-Speed Serial Links
1754.Re
1755.Pp
1756.Rs
1757.%A M. Mathis
1758.%A J. Mahdavi
1759.%A S. Floyd
1760.%A A. Romanow
1761.%D October 1996
1762.%R RFC 2018
1763.%T TCP Selective Acknowledgement Options
1764.Re
1765.Pp
1766.Rs
1767.%A V. Manral
1768.%D April 2007
1769.%R RFC 4835
1770.%T Cryptographic Algorithm Implementation Requirements for Encapsulating Security Payload (ESP) and Authentication Header (AH)
1771.Re
1772.Sh AUTHORS
1773.An -nosplit
1774.An Van Jacobson Aq Mt van@ee.lbl.gov ,
1775.An Craig Leres Aq Mt leres@ee.lbl.gov ,
1776and
1777.An Steven McCanne Aq Mt mccanne@ee.lbl.gov ,
1778all of the Lawrence Berkeley Laboratory, University of California, Berkeley, CA.
1779.Sh BUGS
1780Some attempt should be made to reassemble IP fragments,
1781or at least to compute the right length for the higher level protocol.
1782.Pp
1783Name server inverse queries are not dumped correctly: The
1784.Pq empty
1785question section is printed rather than the real query in the answer section.
1786Some believe that inverse queries are themselves a bug and
1787prefer to fix the program generating them rather than
1788.Nm tcpdump .
1789.Pp
1790A packet trace that crosses a daylight saving time change will give
1791skewed time stamps
1792.Pq the time change is ignored .
1793.Pp
1794Filter expressions that manipulate FDDI headers assume that all FDDI packets
1795are encapsulated Ethernet packets.
1796This is true for IP, ARP, and DECNET Phase IV,
1797but is not true for protocols such as ISO CLNS.
1798Therefore, the filter may inadvertently accept certain packets that
1799do not properly match the filter expression.
1800