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