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.\" $Id: ping.8,v 1.3 1996/10/05 22:27:04 wosch 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 dfnqrvLRQ 46.Op Fl c Ar count 47.Op Fl i Ar wait 48.Op Fl I Ar interface 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 I Ar interface 106Source multicast packets with the given interface address. 107This flag only applies if the ping destination is a multicast address. 108.It Fl l Ar preload 109If 110.Ar preload 111is specified, 112.Nm ping 113sends that many packets as fast as possible before falling into its normal 114mode of behavior. 115.It Fl L 116Suppress loopback of multicast packets. 117This flag only applies if the ping destination is a multicast address. 118.It Fl n 119Numeric output only. 120No attempt will be made to lookup symbolic names for host addresses. 121.It Fl p Ar pattern 122You may specify up to 16 ``pad'' bytes to fill out the packet you send. 123This is useful for diagnosing data-dependent problems in a network. 124For example, 125.Dq Li \-p ff 126will cause the sent packet to be filled with all 127ones. 128.It Fl Q 129Somewhat quiet output. 130Don't display ICMP error messages that are in response to our query messages. 131Originally, the 132.Fl v 133flag was required to display such errors, but 134.Fl v 135displays all ICMP error messages. On a busy machine, this output can 136be overbearing. Without the 137.Fl Q 138flag, 139.Nm 140prints out any ICMP error messages caused by its own ECHO_REQUEST 141messages. 142.It Fl q 143Quiet output. 144Nothing is displayed except the summary lines at startup time and 145when finished. 146.It Fl R 147Record route. 148Includes the 149.Tn RECORD_ROUTE 150option in the 151.Tn ECHO_REQUEST 152packet and displays 153the route buffer on returned packets. 154Note that the IP header is only large enough for nine such routes. 155Many hosts ignore or discard this option. 156.It Fl r 157Bypass the normal routing tables and send directly to a host on an attached 158network. 159If the host is not on a directly-attached network, an error is returned. 160This option can be used to ping a local host through an interface 161that has no route through it (e.g., after the interface was dropped by 162.Xr routed 8 ) . 163.It Fl s Ar packetsize 164Specifies the number of data bytes to be sent. 165The default is 56, which translates into 64 166.Tn ICMP 167data bytes when combined 168with the 8 bytes of 169.Tn ICMP 170header data. 171.It Fl T Ar ttl 172Set the IP Time To Live for multicasted packets. 173This flag only applies if the ping destination is a multicast address. 174.It Fl v 175Verbose output. 176.Tn ICMP 177packets other than 178.Tn ECHO_RESPONSE 179that are received are listed. 180.El 181.Pp 182When using 183.Nm ping 184for fault isolation, it should first be run on the local host, to verify 185that the local network interface is up and running. 186Then, hosts and gateways further and further away should be ``pinged''. 187Round-trip times and packet loss statistics are computed. 188If duplicate packets are received, they are not included in the packet 189loss calculation, although the round trip time of these packets is used 190in calculating the minimum/average/maximum round-trip time numbers. 191When the specified number of packets have been sent (and received) or 192if the program is terminated with a 193.Dv SIGINT , 194a brief summary is displayed. 195.Pp 196This program is intended for use in network testing, measurement and 197management. 198Because of the load it can impose on the network, it is unwise to use 199.Nm ping 200during normal operations or from automated scripts. 201.Sh ICMP PACKET DETAILS 202An IP header without options is 20 bytes. 203An 204.Tn ICMP 205.Tn ECHO_REQUEST 206packet contains an additional 8 bytes worth 207of 208.Tn ICMP 209header followed by an arbitrary amount of data. 210When a 211.Ar packetsize 212is given, this indicated the size of this extra piece of data (the 213default is 56). 214Thus the amount of data received inside of an IP packet of type 215.Tn ICMP 216.Tn ECHO_REPLY 217will always be 8 bytes more than the requested data space 218(the 219.Tn ICMP 220header). 221.Pp 222If the data space is at least eight bytes large, 223.Nm ping 224uses the first eight bytes of this space to include a timestamp which 225it uses in the computation of round trip times. 226If less than eight bytes of pad are specified, no round trip times are 227given. 228.Sh DUPLICATE AND DAMAGED PACKETS 229.Nm Ping 230will report duplicate and damaged packets. 231Duplicate packets should never occur when pinging a unicast address, 232and seem to be caused by 233inappropriate link-level retransmissions. 234Duplicates may occur in many situations and are rarely (if ever) a 235good sign, although the presence of low levels of duplicates may not 236always be cause for alarm. 237Duplicates are expected when pinging a broadcast or multicast address, 238since they are not really duplicates but replies from different hosts 239to the same request. 240.Pp 241Damaged packets are obviously serious cause for alarm and often 242indicate broken hardware somewhere in the 243.Nm ping 244packet's path (in the network or in the hosts). 245.Sh TRYING DIFFERENT DATA PATTERNS 246The (inter)network layer should never treat packets differently depending 247on the data contained in the data portion. 248Unfortunately, data-dependent problems have been known to sneak into 249networks and remain undetected for long periods of time. 250In many cases the particular pattern that will have problems is something 251that doesn't have sufficient ``transitions'', such as all ones or all 252zeros, or a pattern right at the edge, such as almost all zeros. 253It isn't necessarily enough to specify a data pattern of all zeros (for 254example) on the command line because the pattern that is of interest is 255at the data link level, and the relationship between what you type and 256what the controllers transmit can be complicated. 257.Pp 258This means that if you have a data-dependent problem you will probably 259have to do a lot of testing to find it. 260If you are lucky, you may manage to find a file that either can't be sent 261across your network or that takes much longer to transfer than other 262similar length files. 263You can then examine this file for repeated patterns that you can test 264using the 265.Fl p 266option of 267.Nm ping . 268.Sh TTL DETAILS 269The 270.Tn TTL 271value of an IP packet represents the maximum number of IP routers 272that the packet can go through before being thrown away. 273In current practice you can expect each router in the Internet to decrement 274the 275.Tn TTL 276field by exactly one. 277.Pp 278The 279.Tn TCP/IP 280specification states that the 281.Tn TTL 282field for 283.Tn TCP 284packets should 285be set to 60, but many systems use smaller values (4.3 286.Tn BSD 287uses 30, 4.2 used 28815). 289.Pp 290The maximum possible value of this field is 255, and most Unix systems set 291the 292.Tn TTL 293field of 294.Tn ICMP ECHO_REQUEST 295packets to 255. 296This is why you will find you can ``ping'' some hosts, but not reach them 297with 298.Xr telnet 1 299or 300.Xr ftp 1 . 301.Pp 302In normal operation ping prints the ttl value from the packet it receives. 303When a remote system receives a ping packet, it can do one of three things 304with the 305.Tn TTL 306field in its response: 307.Bl -bullet 308.It 309Not change it; this is what Berkeley Unix systems did before the 310.Bx 4.3 tahoe 311release. 312In this case the 313.Tn TTL 314value in the received packet will be 255 minus the 315number of routers in the round-trip path. 316.It 317Set it to 255; this is what current Berkeley Unix systems do. 318In this case the 319.Tn TTL 320value in the received packet will be 255 minus the 321number of routers in the path 322.Xr from 323the remote system 324.Em to 325the 326.Nm ping Ns Em ing 327host. 328.It 329Set it to some other value. 330Some machines use the same value for 331.Tn ICMP 332packets that they use for 333.Tn TCP 334packets, for example either 30 or 60. 335Others may use completely wild values. 336.El 337.Sh BUGS 338Many Hosts and Gateways ignore the 339.Tn RECORD_ROUTE 340option. 341.Pp 342The maximum IP header length is too small for options like 343.Tn RECORD_ROUTE 344to 345be completely useful. 346There's not much that can be done about this, however. 347.Pp 348Flood pinging is not recommended in general, and flood pinging the 349broadcast address should only be done under very controlled conditions. 350.Pp 351The 352.Fl v 353option is not worth much on busy hosts. 354.Sh SEE ALSO 355.Xr netstat 1 , 356.Xr ifconfig 8 , 357.Xr routed 8 358.Sh HISTORY 359The 360.Nm 361command appeared in 362.Bx 4.3 . 363