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