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