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