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.11 1997/03/02 23:38:05 jmg Exp $ 34.\" 35.Dd March 1, 1997 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 45.Op Fl QRadfnqrv 46.Op Fl c Ar count 47.Op Fl i Ar wait 48.Op Fl l Ar preload 49.Op Fl p Ar pattern 50.Op Fl s Ar packetsize 51.Bo 52.Ar host | 53.Op Fl L 54.Op Fl I Ar interface 55.Op Fl T Ar ttl 56.Ar mcast-group 57.Bc 58.Sh DESCRIPTION 59.Nm Ping 60uses the 61.Tn ICMP 62.No protocol Ap s mandatory 63.Tn ECHO_REQUEST 64datagram to elicit an 65.Tn ICMP ECHO_RESPONSE 66from a host or gateway. 67.Tn ECHO_REQUEST 68datagrams 69.Pq Dq pings 70have an IP and 71.Tn ICMP 72header, followed by a 73.Dq struct timeval 74and then an arbitrary number of 75.Dq pad 76bytes used to fill out the packet. The options are as follows: 77.Bl -tag -width Ds 78.It Fl a 79Audible. Include a bell 80.Pq ASCII 0x07 81character in the output when any packet is received. This option is ignored 82if other format options are present. 83.It Fl c Ar count 84Stop after sending 85.Pq and receiving 86.Ar count 87.Tn ECHO_RESPONSE 88packets. 89.It Fl d 90Set the 91.Dv SO_DEBUG 92option on the socket being used. 93.It Fl f 94Flood ping. 95Outputs packets as fast as they come back or one hundred times per second, 96whichever is more. 97For every 98.Tn ECHO_REQUEST 99sent a period 100.Dq \&. 101is printed, while for every 102.Tn ECHO_REPLY 103received a backspace is printed. 104This provides a rapid display of how many packets are being dropped. 105Only the super-user may use this option. 106.Bf -emphasis 107This can be very hard on a network and should be used with caution. 108.Ef 109.It Fl i Ar wait 110Wait 111.Ar wait 112seconds 113.Em between sending each packet . 114The default is to wait for one second between each packet. 115This option is incompatible with the 116.Fl f 117option. 118.It Fl I Ar interface 119Source multicast packets with the given interface address. 120This flag only applies if the ping destination is a multicast address. 121.It Fl l Ar preload 122If 123.Ar preload 124is specified, 125.Nm ping 126sends that many packets as fast as possible before falling into its normal 127mode of behavior. 128Only the super-user may use this option. 129.It Fl L 130Suppress loopback of multicast packets. 131This flag only applies if the ping destination is a multicast address. 132.It Fl n 133Numeric output only. 134No attempt will be made to lookup symbolic names for host addresses. 135.It Fl p Ar pattern 136You may specify up to 16 137.Dq pad 138bytes to fill out the packet you send. 139This is useful for diagnosing data-dependent problems in a network. 140For example, 141.Dq Li \-p ff 142will cause the sent packet to be filled with all 143ones. 144.It Fl Q 145Somewhat quiet output. 146.No Don Ap t 147display ICMP error messages that are in response to our query messages. 148Originally, the 149.Fl v 150flag was required to display such errors, but 151.Fl v 152displays all ICMP error messages. On a busy machine, this output can 153be overbearing. Without the 154.Fl Q 155flag, 156.Nm 157prints out any ICMP error messages caused by its own ECHO_REQUEST 158messages. 159.It Fl q 160Quiet output. 161Nothing is displayed except the summary lines at startup time and 162when finished. 163.It Fl R 164Record route. 165Includes the 166.Tn RECORD_ROUTE 167option in the 168.Tn ECHO_REQUEST 169packet and displays 170the route buffer on returned packets. 171Note that the IP header is only large enough for nine such routes; 172the 173.Xr traceroute 8 174command is usually better at determining the route packets take to a 175particular destination. 176Many hosts ignore or discard the 177.Tn RECORD_ROUTE 178option. 179.It Fl r 180Bypass the normal routing tables and send directly to a host on an attached 181network. 182If the host is not on a directly-attached network, an error is returned. 183This option can be used to ping a local host through an interface 184that has no route through it 185.Po 186e.g., after the interface was dropped by 187.Xr routed 8 188.Pc . 189.It Fl s Ar packetsize 190Specifies the number of data bytes to be sent. 191The default is 56, which translates into 64 192.Tn ICMP 193data bytes when combined 194with the 8 bytes of 195.Tn ICMP 196header data. 197.It Fl T Ar ttl 198Set the IP Time To Live for multicasted packets. 199This flag only applies if the ping destination is a multicast address. 200.It Fl v 201Verbose output. 202.Tn ICMP 203packets other than 204.Tn ECHO_RESPONSE 205that are received are listed. 206.El 207.Pp 208When using 209.Nm 210for fault isolation, it should first be run on the local host, to verify 211that the local network interface is up and running. 212Then, hosts and gateways further and further away should be 213.Dq pinged . 214Round-trip times and packet loss statistics are computed. 215If duplicate packets are received, they are not included in the packet 216loss calculation, although the round trip time of these packets is used 217in calculating the round-trip time statistics. 218When the specified number of packets have been sent 219.Pq and received 220or if the program is terminated with a 221.Dv SIGINT , 222a brief summary is displayed, showing the number of packets sent and 223received, and the minimum, maximum, mean, and standard deviation of 224the round-trip times. 225.Pp 226This program is intended for use in network testing, measurement and 227management. 228Because of the load it can impose on the network, it is unwise to use 229.Nm 230during normal operations or from automated scripts. 231.Sh ICMP PACKET DETAILS 232An IP header without options is 20 bytes. 233An 234.Tn ICMP 235.Tn ECHO_REQUEST 236packet contains an additional 8 bytes worth of 237.Tn ICMP 238header followed by an arbitrary amount of data. 239When a 240.Ar packetsize 241is given, this indicated the size of this extra piece of data 242.Pq the default is 56 . 243Thus the amount of data received inside of an IP packet of type 244.Tn ICMP 245.Tn ECHO_REPLY 246will always be 8 bytes more than the requested data space 247.Pq the Tn ICMP header . 248.Pp 249If the data space is at least eight bytes large, 250.Nm 251uses the first eight bytes of this space to include a timestamp which 252it uses in the computation of round trip times. 253If less than eight bytes of pad are specified, no round trip times are 254given. 255.Sh DUPLICATE AND DAMAGED PACKETS 256.Nm Ping 257will report duplicate and damaged packets. 258Duplicate packets should never occur when pinging a unicast address, 259and seem to be caused by 260inappropriate link-level retransmissions. 261Duplicates may occur in many situations and are rarely 262.Pq if ever 263a good sign, although the presence of low levels of duplicates may not 264always be cause for alarm. 265Duplicates are expected when pinging a broadcast or multicast address, 266since they are not really duplicates but replies from different hosts 267to the same request. 268.Pp 269Damaged packets are obviously serious cause for alarm and often 270indicate broken hardware somewhere in the 271.Nm ping 272packet's path (in the network or in the hosts). 273.Sh TRYING DIFFERENT DATA PATTERNS 274The 275(inter)network 276layer should never treat packets differently depending on the data 277contained in the data portion. 278Unfortunately, data-dependent problems have been known to sneak into 279networks and remain undetected for long periods of time. 280In many cases the particular pattern that will have problems is something 281that does not have sufficient 282.Dq transitions , 283such as all ones or all zeros, or a pattern right at the edge, such as 284almost all zeros. 285It is not 286necessarily enough to specify a data pattern of all zeros (for example) 287on the command line because the pattern that is of interest is 288at the data link level, and the relationship between what you type and 289what the controllers transmit can be complicated. 290.Pp 291This means that if you have a data-dependent problem you will probably 292have to do a lot of testing to find it. 293If you are lucky, you may manage to find a file that either 294cannot 295be sent across your network or that takes much longer to transfer than 296other similar length files. 297You can then examine this file for repeated patterns that you can test 298using the 299.Fl p 300option of 301.Nm Ns . 302.Sh TTL DETAILS 303The 304.Tn TTL 305value of an IP packet represents the maximum number of IP routers 306that the packet can go through before being thrown away. 307In current practice you can expect each router in the Internet to decrement 308the 309.Tn TTL 310field by exactly one. 311.Pp 312The 313.Tn TCP/IP 314specification states that the 315.Tn TTL 316field for 317.Tn TCP 318packets should be set to 60, but many systems use smaller values 319.Po 320.Bx 4.3 321uses 30, 322.Bx 4.2 323used 15 324.Pc . 325.Pp 326The maximum possible value of this field is 255, and most Unix systems set 327the 328.Tn TTL 329field of 330.Tn ICMP ECHO_REQUEST 331packets to 255. 332This is why you will find you can 333.Dq ping 334some hosts, but not reach them with 335.Xr telnet 1 336or 337.Xr ftp 1 . 338.Pp 339In normal operation ping prints the ttl value from the packet it receives. 340When a remote system receives a ping packet, it can do one of three things 341with the 342.Tn TTL 343field in its response: 344.Bl -bullet 345.It 346Not change it; this is what Berkeley Unix systems did before the 347.Bx 4.3 tahoe 348release. 349In this case the 350.Tn TTL 351value in the received packet will be 255 minus the 352number of routers in the round-trip path. 353.It 354Set it to 255; this is what current 355.Tn BSD 356systems do. 357In this case the 358.Tn TTL 359value in the received packet will be 255 minus the 360number of routers in the path 361.Em from 362the remote system 363.Em to 364the 365.Nm Ns Em ing 366host. 367.It 368Set it to some other value. 369Some machines use the same value for 370.Tn ICMP 371packets that they use for 372.Tn TCP 373packets, for example either 30 or 60. 374Others may use completely wild values. 375.El 376.Sh RETURN VALUES 377The 378.Nm 379command returns an exit status of zero if at least one response was 380heard from the specified 381.Ar host ; 382a status of two if the transmission was successful but no responses 383were received; or another value 384.Pq from Aq Pa sysexits.h 385if an error occurred. 386.Sh SEE ALSO 387.Xr netstat 1 , 388.Xr ifconfig 8 , 389.Xr routed 8 , 390.Xr traceroute 8 391.Sh HISTORY 392The 393.Nm 394command appeared in 395.Bx 4.3 . 396.Sh AUTHORS 397The original 398.Nm 399command was written by Mike Muuss while at the US Army Ballistics 400Research Laboratory. 401.Sh BUGS 402Many Hosts and Gateways ignore the 403.Tn RECORD_ROUTE 404option. 405.Pp 406The maximum IP header length is too small for options like 407.Tn RECORD_ROUTE 408to be completely useful. 409.No There Ap s 410not much that can be done about this, however. 411.Pp 412Flood pinging is not recommended in general, and flood pinging the 413broadcast address should only be done under very controlled conditions. 414.Pp 415The 416.Fl v 417option is not worth much on busy hosts. 418