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