1.\" Copyright (c) 1985, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. All advertising materials mentioning features or use of this software 13.\" must display the following acknowledgement: 14.\" This product includes software developed by the University of 15.\" California, Berkeley and its contributors. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)ping.8 8.2 (Berkeley) 12/11/93 33.\" 34.Dd December 11, 1993 35.Dt PING 8 36.Os BSD 4.3 37.Sh NAME 38.Nm ping 39.Nd send 40.Tn ICMP ECHO_REQUEST 41packets to network hosts 42.Sh SYNOPSIS 43.Nm ping 44.Op Fl dfnqrvR 45.Op Fl c Ar count 46.Op Fl i Ar wait 47.Op Fl l Ar preload 48.Op Fl p Ar pattern 49.Op Fl s Ar packetsize 50.Sh DESCRIPTION 51.Nm Ping 52uses the 53.Tn ICMP 54protocol's mandatory 55.Tn ECHO_REQUEST 56datagram to elicit an 57.Tn ICMP ECHO_RESPONSE 58from a host or gateway. 59.Tn ECHO_REQUEST 60datagrams (``pings'') have an IP and 61.Tn ICMP 62header, 63followed by a 64.Dq struct timeval 65and then an arbitrary number of ``pad'' bytes used to fill out the 66packet. 67The options are as follows: 68.Bl -tag -width Ds 69.It Fl c Ar count 70Stop after sending (and receiving) 71.Ar count 72.Tn ECHO_RESPONSE 73packets. 74.It Fl d 75Set the 76.Dv SO_DEBUG 77option on the socket being used. 78.It Fl f 79Flood ping. 80Outputs packets as fast as they come back or one hundred times per second, 81whichever is more. 82For every 83.Tn ECHO_REQUEST 84sent a period ``.'' is printed, while for every 85.Tn ECHO_REPLY 86received a backspace is printed. 87This provides a rapid display of how many packets are being dropped. 88Only the super-user may use this option. 89.Bf -emphasis 90This can be very hard on a network and should be used with caution. 91.Ef 92.It Fl i Ar wait 93Wait 94.Ar wait 95seconds 96.Em between sending each packet . 97The default is to wait for one second between each packet. 98This option is incompatible with the 99.Fl f 100option. 101.It Fl l Ar preload 102If 103.Ar preload 104is specified, 105.Nm ping 106sends that many packets as fast as possible before falling into its normal 107mode of behavior. 108.It Fl n 109Numeric output only. 110No attempt will be made to lookup symbolic names for host addresses. 111.It Fl p Ar pattern 112You may specify up to 16 ``pad'' bytes to fill out the packet you send. 113This is useful for diagnosing data-dependent problems in a network. 114For example, 115.Dq Li \-p ff 116will cause the sent packet to be filled with all 117ones. 118.It Fl q 119Quiet output. 120Nothing is displayed except the summary lines at startup time and 121when finished. 122.It Fl R 123Record route. 124Includes the 125.Tn RECORD_ROUTE 126option in the 127.Tn ECHO_REQUEST 128packet and displays 129the route buffer on returned packets. 130Note that the IP header is only large enough for nine such routes. 131Many hosts ignore or discard this option. 132.It Fl r 133Bypass the normal routing tables and send directly to a host on an attached 134network. 135If the host is not on a directly-attached network, an error is returned. 136This option can be used to ping a local host through an interface 137that has no route through it (e.g., after the interface was dropped by 138.Xr routed 8 ) . 139.It Fl s Ar packetsize 140Specifies the number of data bytes to be sent. 141The default is 56, which translates into 64 142.Tn ICMP 143data bytes when combined 144with the 8 bytes of 145.Tn ICMP 146header data. 147.It Fl v 148Verbose output. 149.Tn ICMP 150packets other than 151.Tn ECHO_RESPONSE 152that are received are listed. 153.El 154.Pp 155When using 156.Nm ping 157for fault isolation, it should first be run on the local host, to verify 158that the local network interface is up and running. 159Then, hosts and gateways further and further away should be ``pinged''. 160Round-trip times and packet loss statistics are computed. 161If duplicate packets are received, they are not included in the packet 162loss calculation, although the round trip time of these packets is used 163in calculating the minimum/average/maximum round-trip time numbers. 164When the specified number of packets have been sent (and received) or 165if the program is terminated with a 166.Dv SIGINT , 167a brief summary is displayed. 168.Pp 169This program is intended for use in network testing, measurement and 170management. 171Because of the load it can impose on the network, it is unwise to use 172.Nm ping 173during normal operations or from automated scripts. 174.Sh ICMP PACKET DETAILS 175An IP header without options is 20 bytes. 176An 177.Tn ICMP 178.Tn ECHO_REQUEST 179packet contains an additional 8 bytes worth 180of 181.Tn ICMP 182header followed by an arbitrary amount of data. 183When a 184.Ar packetsize 185is given, this indicated the size of this extra piece of data (the 186default is 56). 187Thus the amount of data received inside of an IP packet of type 188.Tn ICMP 189.Tn ECHO_REPLY 190will always be 8 bytes more than the requested data space 191(the 192.Tn ICMP 193header). 194.Pp 195If the data space is at least eight bytes large, 196.Nm ping 197uses the first eight bytes of this space to include a timestamp which 198it uses in the computation of round trip times. 199If less than eight bytes of pad are specified, no round trip times are 200given. 201.Sh DUPLICATE AND DAMAGED PACKETS 202.Nm Ping 203will report duplicate and damaged packets. 204Duplicate packets should never occur, and seem to be caused by 205inappropriate link-level retransmissions. 206Duplicates may occur in many situations and are rarely (if ever) a 207good sign, although the presence of low levels of duplicates may not 208always be cause for alarm. 209.Pp 210Damaged packets are obviously serious cause for alarm and often 211indicate broken hardware somewhere in the 212.Nm ping 213packet's path (in the network or in the hosts). 214.Sh TRYING DIFFERENT DATA PATTERNS 215The (inter)network layer should never treat packets differently depending 216on the data contained in the data portion. 217Unfortunately, data-dependent problems have been known to sneak into 218networks and remain undetected for long periods of time. 219In many cases the particular pattern that will have problems is something 220that doesn't have sufficient ``transitions'', such as all ones or all 221zeros, or a pattern right at the edge, such as almost all zeros. 222It isn't necessarily enough to specify a data pattern of all zeros (for 223example) on the command line because the pattern that is of interest is 224at the data link level, and the relationship between what you type and 225what the controllers transmit can be complicated. 226.Pp 227This means that if you have a data-dependent problem you will probably 228have to do a lot of testing to find it. 229If you are lucky, you may manage to find a file that either can't be sent 230across your network or that takes much longer to transfer than other 231similar length files. 232You can then examine this file for repeated patterns that you can test 233using the 234.Fl p 235option of 236.Nm ping . 237.Sh TTL DETAILS 238The 239.Tn TTL 240value of an IP packet represents the maximum number of IP routers 241that the packet can go through before being thrown away. 242In current practice you can expect each router in the Internet to decrement 243the 244.Tn TTL 245field by exactly one. 246.Pp 247The 248.Tn TCP/IP 249specification states that the 250.Tn TTL 251field for 252.Tn TCP 253packets should 254be set to 60, but many systems use smaller values (4.3 255.Tn BSD 256uses 30, 4.2 used 25715). 258.Pp 259The maximum possible value of this field is 255, and most Unix systems set 260the 261.Tn TTL 262field of 263.Tn ICMP ECHO_REQUEST 264packets to 255. 265This is why you will find you can ``ping'' some hosts, but not reach them 266with 267.Xr telnet 1 268or 269.Xr ftp 1 . 270.Pp 271In normal operation ping prints the ttl value from the packet it receives. 272When a remote system receives a ping packet, it can do one of three things 273with the 274.Tn TTL 275field in its response: 276.Bl -bullet 277.It 278Not change it; this is what Berkeley Unix systems did before the 279.Bx 4.3 tahoe 280release. 281In this case the 282.Tn TTL 283value in the received packet will be 255 minus the 284number of routers in the round-trip path. 285.It 286Set it to 255; this is what current Berkeley Unix systems do. 287In this case the 288.Tn TTL 289value in the received packet will be 255 minus the 290number of routers in the path 291.Xr from 292the remote system 293.Em to 294the 295.Nm ping Ns Em ing 296host. 297.It 298Set it to some other value. 299Some machines use the same value for 300.Tn ICMP 301packets that they use for 302.Tn TCP 303packets, for example either 30 or 60. 304Others may use completely wild values. 305.El 306.Sh BUGS 307Many Hosts and Gateways ignore the 308.Tn RECORD_ROUTE 309option. 310.Pp 311The maximum IP header length is too small for options like 312.Tn RECORD_ROUTE 313to 314be completely useful. 315There's not much that that can be done about this, however. 316.Pp 317Flood pinging is not recommended in general, and flood pinging the 318broadcast address should only be done under very controlled conditions. 319.Sh SEE ALSO 320.Xr netstat 1 , 321.Xr ifconfig 8 , 322.Xr routed 8 323.Sh HISTORY 324The 325.Nm 326command appeared in 327.Bx 4.3 . 328