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