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