161530Sbostic.\" Copyright (c) 1985, 1991, 1993 261530Sbostic.\" The Regents of the University of California. All rights reserved. 338645Sbostic.\" 443795Strent.\" %sccs.include.redist.man% 538645Sbostic.\" 6*69058Sbostic.\" @(#)ping.8 8.3 (Berkeley) 04/28/95 738645Sbostic.\" 847463Scael.Dd 947463Scael.Dt PING 8 1047463Scael.Os BSD 4.3 1147463Scael.Sh NAME 1247463Scael.Nm ping 1347463Scael.Nd send 1447463Scael.Tn ICMP ECHO_REQUEST 1547463Scaelpackets to network hosts 1647463Scael.Sh SYNOPSIS 1747463Scael.Nm ping 18*69058Sbostic.Op Fl Rdfnqrv 1947463Scael.Op Fl c Ar count 2047463Scael.Op Fl i Ar wait 2147463Scael.Op Fl l Ar preload 2247463Scael.Op Fl p Ar pattern 2347463Scael.Op Fl s Ar packetsize 24*69058Sbostic.Ar host 2547463Scael.Sh DESCRIPTION 2647463Scael.Nm Ping 2738643Sbosticuses the 2847463Scael.Tn ICMP 2947463Scaelprotocol's mandatory 3047463Scael.Tn ECHO_REQUEST 3147463Scaeldatagram to elicit an 3247463Scael.Tn ICMP ECHO_RESPONSE 3347463Scaelfrom a host or gateway. 3447463Scael.Tn ECHO_REQUEST 3547463Scaeldatagrams (``pings'') have an IP and 3647463Scael.Tn ICMP 3747463Scaelheader, 3838645Sbosticfollowed by a 3947463Scael.Dq struct timeval 4038645Sbosticand then an arbitrary number of ``pad'' bytes used to fill out the 4138645Sbosticpacket. 4238645SbosticThe options are as follows: 4347463Scael.Bl -tag -width Ds 4447463Scael.It Fl c Ar count 4538645SbosticStop after sending (and receiving) 4647463Scael.Ar count 4747463Scael.Tn ECHO_RESPONSE 4847463Scaelpackets. 4947463Scael.It Fl d 5047463ScaelSet the 5147463Scael.Dv SO_DEBUG 5247463Scaeloption on the socket being used. 5347463Scael.It Fl f 5438645SbosticFlood ping. 5538645SbosticOutputs packets as fast as they come back or one hundred times per second, 5638645Sbosticwhichever is more. 5747463ScaelFor every 5847463Scael.Tn ECHO_REQUEST 5965103Smckusicksent a period ``.'' is printed, while for every 6047463Scael.Tn ECHO_REPLY 6147463Scaelreceived a backspace is printed. 6238643SbosticThis provides a rapid display of how many packets are being dropped. 6338645SbosticOnly the super-user may use this option. 6447463Scael.Bf -emphasis 6547463ScaelThis can be very hard on a network and should be used with caution. 6647463Scael.Ef 6747463Scael.It Fl i Ar wait 6838645SbosticWait 6947463Scael.Ar wait 7047463Scaelseconds 7147463Scael.Em between sending each packet . 7238645SbosticThe default is to wait for one second between each packet. 7338645SbosticThis option is incompatible with the 7447463Scael.Fl f 7538645Sbosticoption. 7647463Scael.It Fl l Ar preload 7738645SbosticIf 7847463Scael.Ar preload 7938645Sbosticis specified, 8047463Scael.Nm ping 8138645Sbosticsends that many packets as fast as possible before falling into its normal 8238645Sbosticmode of behavior. 8347463Scael.It Fl n 8438645SbosticNumeric output only. 8538645SbosticNo attempt will be made to lookup symbolic names for host addresses. 8647463Scael.It Fl p Ar pattern 8738645SbosticYou may specify up to 16 ``pad'' bytes to fill out the packet you send. 8838645SbosticThis is useful for diagnosing data-dependent problems in a network. 8947463ScaelFor example, 9047463Scael.Dq Li \-p ff 9147463Scaelwill cause the sent packet to be filled with all 9238645Sbosticones. 9347463Scael.It Fl q 9438645SbosticQuiet output. 9538645SbosticNothing is displayed except the summary lines at startup time and 9638645Sbosticwhen finished. 9747463Scael.It Fl R 9838645SbosticRecord route. 9947463ScaelIncludes the 10047463Scael.Tn RECORD_ROUTE 10147463Scaeloption in the 10247463Scael.Tn ECHO_REQUEST 10347463Scaelpacket and displays 10438645Sbosticthe route buffer on returned packets. 10538645SbosticNote that the IP header is only large enough for nine such routes. 10638645SbosticMany hosts ignore or discard this option. 10747463Scael.It Fl r 10828707SkarelsBypass the normal routing tables and send directly to a host on an attached 10928707Skarelsnetwork. 11038645SbosticIf the host is not on a directly-attached network, an error is returned. 11128707SkarelsThis option can be used to ping a local host through an interface 11228707Skarelsthat has no route through it (e.g., after the interface was dropped by 11347463Scael.Xr routed 8 ) . 11447463Scael.It Fl s Ar packetsize 11538643SbosticSpecifies the number of data bytes to be sent. 11647463ScaelThe default is 56, which translates into 64 11747463Scael.Tn ICMP 11847463Scaeldata bytes when combined 11947463Scaelwith the 8 bytes of 12047463Scael.Tn ICMP 12147463Scaelheader data. 12247463Scael.It Fl v 12338645SbosticVerbose output. 12447463Scael.Tn ICMP 12547463Scaelpackets other than 12647463Scael.Tn ECHO_RESPONSE 12747463Scaelthat are received are listed. 12847463Scael.El 12947463Scael.Pp 13038645SbosticWhen using 13147463Scael.Nm ping 13238645Sbosticfor fault isolation, it should first be run on the local host, to verify 13338645Sbosticthat the local network interface is up and running. 13438645SbosticThen, hosts and gateways further and further away should be ``pinged''. 13525229SmckusickRound-trip times and packet loss statistics are computed. 13638645SbosticIf duplicate packets are received, they are not included in the packet 13738645Sbosticloss calculation, although the round trip time of these packets is used 13838645Sbosticin calculating the minimum/average/maximum round-trip time numbers. 13938645SbosticWhen the specified number of packets have been sent (and received) or 14047463Scaelif the program is terminated with a 14147463Scael.Dv SIGINT , 14247463Scaela brief summary is displayed. 14347463Scael.Pp 14438645SbosticThis program is intended for use in network testing, measurement and 14538645Sbosticmanagement. 14638645SbosticBecause of the load it can impose on the network, it is unwise to use 14747463Scael.Nm ping 14828707Skarelsduring normal operations or from automated scripts. 14947463Scael.Sh ICMP PACKET DETAILS 15038643SbosticAn IP header without options is 20 bytes. 15147463ScaelAn 15247463Scael.Tn ICMP 15347463Scael.Tn ECHO_REQUEST 15447463Scaelpacket contains an additional 8 bytes worth 15547463Scaelof 15647463Scael.Tn ICMP 15747463Scaelheader followed by an arbitrary amount of data. 15838645SbosticWhen a 15947463Scael.Ar packetsize 16038645Sbosticis given, this indicated the size of this extra piece of data (the 16138645Sbosticdefault is 56). 16247463ScaelThus the amount of data received inside of an IP packet of type 16347463Scael.Tn ICMP 16447463Scael.Tn ECHO_REPLY 16547463Scaelwill always be 8 bytes more than the requested data space 16647463Scael(the 16747463Scael.Tn ICMP 16847463Scaelheader). 16947463Scael.Pp 17038643SbosticIf the data space is at least eight bytes large, 17147463Scael.Nm ping 17238643Sbosticuses the first eight bytes of this space to include a timestamp which 17338645Sbosticit uses in the computation of round trip times. 17438645SbosticIf less than eight bytes of pad are specified, no round trip times are 17538645Sbosticgiven. 17647463Scael.Sh DUPLICATE AND DAMAGED PACKETS 17747463Scael.Nm Ping 17838645Sbosticwill report duplicate and damaged packets. 17938643SbosticDuplicate packets should never occur, and seem to be caused by 18038643Sbosticinappropriate link-level retransmissions. 18138645SbosticDuplicates may occur in many situations and are rarely (if ever) a 18238645Sbosticgood sign, although the presence of low levels of duplicates may not 18338645Sbosticalways be cause for alarm. 18447463Scael.Pp 18538645SbosticDamaged packets are obviously serious cause for alarm and often 18638645Sbosticindicate broken hardware somewhere in the 18747463Scael.Nm ping 18838645Sbosticpacket's path (in the network or in the hosts). 18947463Scael.Sh TRYING DIFFERENT DATA PATTERNS 19038645SbosticThe (inter)network layer should never treat packets differently depending 19138645Sbosticon the data contained in the data portion. 19238643SbosticUnfortunately, data-dependent problems have been known to sneak into 19338643Sbosticnetworks and remain undetected for long periods of time. 19438643SbosticIn many cases the particular pattern that will have problems is something 19538645Sbosticthat doesn't have sufficient ``transitions'', such as all ones or all 19638645Sbosticzeros, or a pattern right at the edge, such as almost all zeros. 19738643SbosticIt isn't necessarily enough to specify a data pattern of all zeros (for 19838645Sbosticexample) on the command line because the pattern that is of interest is 19938645Sbosticat the data link level, and the relationship between what you type and 20038645Sbosticwhat the controllers transmit can be complicated. 20147463Scael.Pp 20238645SbosticThis means that if you have a data-dependent problem you will probably 20338645Sbostichave to do a lot of testing to find it. 20438643SbosticIf you are lucky, you may manage to find a file that either can't be sent 20538643Sbosticacross your network or that takes much longer to transfer than other 20638643Sbosticsimilar length files. 20738643SbosticYou can then examine this file for repeated patterns that you can test 20847463Scaelusing the 20947463Scael.Fl p 21047463Scaeloption of 21147463Scael.Nm ping . 21247463Scael.Sh TTL DETAILS 21347463ScaelThe 21447463Scael.Tn TTL 21547463Scaelvalue of an IP packet represents the maximum number of IP routers 21638643Sbosticthat the packet can go through before being thrown away. 21738645SbosticIn current practice you can expect each router in the Internet to decrement 21847463Scaelthe 21947463Scael.Tn TTL 22047463Scaelfield by exactly one. 22147463Scael.Pp 22247463ScaelThe 22347463Scael.Tn TCP/IP 22447463Scaelspecification states that the 22547463Scael.Tn TTL 22647463Scaelfield for 22747463Scael.Tn TCP 22847463Scaelpackets should 22947463Scaelbe set to 60, but many systems use smaller values (4.3 23047463Scael.Tn BSD 23147463Scaeluses 30, 4.2 used 23238643Sbostic15). 23347463Scael.Pp 23438643SbosticThe maximum possible value of this field is 255, and most Unix systems set 23547463Scaelthe 23647463Scael.Tn TTL 23747463Scaelfield of 23847463Scael.Tn ICMP ECHO_REQUEST 23947463Scaelpackets to 255. 24038645SbosticThis is why you will find you can ``ping'' some hosts, but not reach them 24138645Sbosticwith 24247463Scael.Xr telnet 1 24338645Sbosticor 24447463Scael.Xr ftp 1 . 24547463Scael.Pp 24638643SbosticIn normal operation ping prints the ttl value from the packet it receives. 24738643SbosticWhen a remote system receives a ping packet, it can do one of three things 24847463Scaelwith the 24947463Scael.Tn TTL 25047463Scaelfield in its response: 25147463Scael.Bl -bullet 25247463Scael.It 25347463ScaelNot change it; this is what Berkeley Unix systems did before the 25447463Scael.Bx 4.3 tahoe 25538645Sbosticrelease. 25647463ScaelIn this case the 25747463Scael.Tn TTL 25847463Scaelvalue in the received packet will be 255 minus the 25938643Sbosticnumber of routers in the round-trip path. 26047463Scael.It 26138645SbosticSet it to 255; this is what current Berkeley Unix systems do. 26247463ScaelIn this case the 26347463Scael.Tn TTL 26447463Scaelvalue in the received packet will be 255 minus the 26538645Sbosticnumber of routers in the path 26647463Scael.Xr from 26738645Sbosticthe remote system 26847463Scael.Em to 26938645Sbosticthe 27047463Scael.Nm ping Ns Em ing 27138645Sbostichost. 27247463Scael.It 27338643SbosticSet it to some other value. 27447463ScaelSome machines use the same value for 27547463Scael.Tn ICMP 27647463Scaelpackets that they use for 27747463Scael.Tn TCP 27847463Scaelpackets, for example either 30 or 60. 27938643SbosticOthers may use completely wild values. 28047463Scael.El 28147463Scael.Sh BUGS 28247463ScaelMany Hosts and Gateways ignore the 28347463Scael.Tn RECORD_ROUTE 28447463Scaeloption. 28547463Scael.Pp 28647463ScaelThe maximum IP header length is too small for options like 28747463Scael.Tn RECORD_ROUTE 28847463Scaelto 28938645Sbosticbe completely useful. 29038645SbosticThere's not much that that can be done about this, however. 29147463Scael.Pp 29238645SbosticFlood pinging is not recommended in general, and flood pinging the 29338645Sbosticbroadcast address should only be done under very controlled conditions. 29447463Scael.Sh SEE ALSO 29547463Scael.Xr netstat 1 , 29647463Scael.Xr ifconfig 8 , 29747463Scael.Xr routed 8 29847463Scael.Sh HISTORY 29947463ScaelThe 30047463Scael.Nm 30147463Scaelcommand appeared in 30247463Scael.Bx 4.3 . 303