1<refentry id="ping"> 2 3<refmeta> 4<refentrytitle>ping</refentrytitle> 5<manvolnum>8</manvolnum> 6<refmiscinfo>iputils-&snapshot;</refmiscinfo> 7</refmeta> 8 9<refnamediv> 10<refname>ping, ping6</refname> 11<refpurpose>send ICMP ECHO_REQUEST to network hosts</refpurpose> 12</refnamediv> 13 14<refsynopsisdiv> 15<cmdsynopsis> 16<command>ping</command> 17<arg choice="opt"><option>-LRUbdfnqrvVaAB</option></arg> 18<arg choice="opt">-c <replaceable/count/</arg> 19<arg choice="opt">-i <replaceable/interval/</arg> 20<arg choice="opt">-l <replaceable/preload/</arg> 21<arg choice="opt">-p <replaceable/pattern/</arg> 22<arg choice="opt">-s <replaceable/packetsize/</arg> 23<arg choice="opt">-t <replaceable/ttl/</arg> 24<arg choice="opt">-w <replaceable/deadline/</arg> 25<arg choice="opt">-F <replaceable/flowlabel/</arg> 26<arg choice="opt">-I <replaceable/interface/</arg> 27<arg choice="opt">-M <replaceable/hint/</arg> 28<arg choice="opt">-P <replaceable/policy/</arg> 29<arg choice="opt">-Q <replaceable/tos/</arg> 30<arg choice="opt">-S <replaceable/sndbuf/</arg> 31<arg choice="opt">-T <replaceable/timestamp option/</arg> 32<arg choice="opt">-W <replaceable/timeout/</arg> 33<arg choice="opt" rep="repeat"><replaceable/hop/</arg> 34<arg choice="req"><replaceable/destination/</arg> 35</cmdsynopsis> 36</refsynopsisdiv> 37 38<refsect1><title>DESCRIPTION</title> 39<para> 40<command/ping/ uses the ICMP protocol's mandatory ECHO_REQUEST 41datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway. 42ECHO_REQUEST datagrams (``pings'') have an IP and ICMP 43header, followed by a <structname/struct timeval/ and then an arbitrary 44number of ``pad'' bytes used to fill out the packet. 45</para> 46</refsect1> 47 48<refsect1><title>OPTIONS</title> 49 50<variablelist> 51 <varlistentry> 52 <term><option/-a/</term> 53 <listitem><para> 54Audible ping. 55 </para></listitem> 56 </varlistentry> 57 <varlistentry> 58 <term><option/-A/</term> 59 <listitem><para> 60Adaptive ping. Interpacket interval adapts to round-trip time, so that 61effectively not more than one (or more, if preload is set) unanswered probes 62present in the network. Minimal interval is 200msec for not super-user. 63On networks with low rtt this mode is essentially equivalent to flood mode. 64 </para></listitem> 65 </varlistentry> 66 <varlistentry> 67 <term><option/-b/</term> 68 <listitem><para> 69Allow pinging a broadcast address. 70 </para></listitem> 71 </varlistentry> 72 <varlistentry> 73 <term><option/-B/</term> 74 <listitem><para> 75Do not allow <command/ping/ to change source address of probes. 76The address is bound to one selected when <command/ping/ starts. 77 </para></listitem> 78 </varlistentry> 79 <varlistentry> 80 <term><option><anchor id="ping.count">-c <replaceable/count/</option></term> 81 <listitem><para> 82Stop after sending <replaceable/count/ ECHO_REQUEST 83packets. With 84<link linkend="ping.deadline"><replaceable/deadline/</link> 85option, <command/ping/ waits for 86<replaceable/count/ ECHO_REPLY packets, until the timeout expires. 87 </para></listitem> 88 </varlistentry> 89 <varlistentry> 90 <term><option/-d/</term> 91 <listitem><para> 92Set the <constant/SO_DEBUG/ option on the socket being used. 93Essentially, this socket option is not used by Linux kernel. 94 </para></listitem> 95 </varlistentry> 96 <varlistentry> 97 <term><option>-F <replaceable/flow label/</option></term> 98 <listitem><para> 99Allocate and set 20 bit flow label on echo request packets. 100(Only <command/ping6/). If value is zero, kernel allocates random flow label. 101 </para></listitem> 102 </varlistentry> 103 <varlistentry> 104 <term><option/-f/</term> 105 <listitem><para> 106Flood ping. For every ECHO_REQUEST sent a period ``.'' is printed, 107while for ever ECHO_REPLY received a backspace is printed. 108This provides a rapid display of how many packets are being dropped. 109If interval is not given, it sets interval to zero and 110outputs packets as fast as they come back or one hundred times per second, 111whichever is more. 112Only the super-user may use this option with zero interval. 113 </para></listitem> 114 </varlistentry> 115 <varlistentry> 116 <term><option>-i <replaceable/interval/</option></term> 117 <listitem><para> 118Wait <replaceable/interval/ seconds between sending each packet. 119The default is to wait for one second between each packet normally, 120or not to wait in flood mode. Only super-user may set interval 121to values less 0.2 seconds. 122 </para></listitem> 123 </varlistentry> 124 <varlistentry> 125 <term><option>-I <replaceable/interface address/</option></term> 126 <listitem><para> 127Set source address to specified interface address. Argument 128may be numeric IP address or name of device. When pinging IPv6 129link-local address this option is required. 130 </para></listitem> 131 </varlistentry> 132 <varlistentry> 133 <term><option>-l <replaceable/preload/</option></term> 134 <listitem><para> 135If <replaceable/preload/ is specified, 136<command/ping/ sends that many packets not waiting for reply. 137Only the super-user may select preload more than 3. 138 </para></listitem> 139 </varlistentry> 140 <varlistentry> 141 <term><option/-L/</term> 142 <listitem><para> 143Suppress loopback of multicast packets. This flag only applies if the ping 144destination is a multicast address. 145 </para></listitem> 146 </varlistentry> 147 <varlistentry> 148 <term><option/-n/</term> 149 <listitem><para> 150Numeric output only. 151No attempt will be made to lookup symbolic names for host addresses. 152 </para></listitem> 153 </varlistentry> 154 <varlistentry> 155 <term><option>-P <replaceable/policy/</option></term> 156 <listitem><para> 157Override system-wide IPsec policy. Argument is a string of format described 158in ipsec_set_policy(3). Couple of examples: "out bypass" requests to bypass 159system-wide defaults, "out ipsec esp/transport//require" demands to send 160ping packets using ESP in transport mode. 161 </para></listitem> 162 </varlistentry> 163 <varlistentry> 164 <term><option>-p <replaceable/pattern/</option></term> 165 <listitem><para> 166You may specify up to 16 ``pad'' bytes to fill out the packet you send. 167This is useful for diagnosing data-dependent problems in a network. 168For example, <option>-p ff</option> will cause the sent packet 169to be filled with all ones. 170 </para></listitem> 171 </varlistentry> 172 <varlistentry> 173 <term><option>-Q <replaceable/tos/</option></term> 174 <listitem><para> 175Set Quality of Service -related bits in ICMP datagrams. 176<replaceable/tos/ can be either decimal or hex number. 177Traditionally (RFC1349), these have been interpreted as: 0 for reserved 178(currently being redefined as congestion control), 1-4 for Type of Service 179and 5-7 for Precedence. 180Possible settings for Type of Service are: minimal cost: 0x02, 181reliability: 0x04, throughput: 0x08, low delay: 0x10. Multiple TOS bits 182should not be set simultaneously. Possible settings for 183special Precedence range from priority (0x20) to net control (0xe0). You 184must be root (<constant/CAP_NET_ADMIN/ capability) to use Critical or 185higher precedence value. You cannot set 186bit 0x01 (reserved) unless ECN has been enabled in the kernel. 187In RFC2474, these fields has been redefined as 8-bit Differentiated 188Services (DS), consisting of: bits 0-1 of separate data (ECN will be used, 189here), and bits 2-7 of Differentiated Services Codepoint (DSCP). 190 </para></listitem> 191 </varlistentry> 192 <varlistentry> 193 <term><option/-q/</term> 194 <listitem><para> 195Quiet output. 196Nothing is displayed except the summary lines at startup time and 197when finished. 198 </para></listitem> 199 </varlistentry> 200 <varlistentry> 201 <term><option/-R/</term> 202 <listitem><para> 203Record route. 204Includes the RECORD_ROUTE option in the ECHO_REQUEST 205packet and displays the route buffer on returned packets. 206Note that the IP header is only large enough for nine such routes. 207Many hosts ignore or discard this option. 208 </para></listitem> 209 </varlistentry> 210 <varlistentry> 211 <term><option/-r/</term> 212 <listitem><para> 213Bypass the normal routing tables and send directly to a host on an attached 214interface. 215If the host is not on a directly-attached network, an error is returned. 216This option can be used to ping a local host through an interface 217that has no route through it provided the option <option/-I/ is also 218used. 219 </para></listitem> 220 </varlistentry> 221 <varlistentry> 222 <term><option>-s <replaceable/packetsize/</option></term> 223 <listitem><para> 224Specifies the number of data bytes to be sent. 225The default is 56, which translates into 64 ICMP 226data bytes when combined with the 8 bytes of ICMP header data. 227 </para></listitem> 228 </varlistentry> 229 <varlistentry> 230 <term><option>-S <replaceable/sndbuf/</option></term> 231 <listitem><para> 232Set socket sndbuf. If not specified, it is selected to buffer 233not more than one packet. 234 </para></listitem> 235 </varlistentry> 236 <varlistentry> 237 <term><option>-t <replaceable/ttl/</option></term> 238 <listitem><para> 239Set the IP Time to Live. 240 </para></listitem> 241 </varlistentry> 242 <varlistentry> 243 <term><option>-T <replaceable/timestamp option/</option></term> 244 <listitem><para> 245Set special IP timestamp options. 246<replaceable/timestamp option/ may be either 247<replaceable/tsonly/ (only timestamps), 248<replaceable/tsandaddr/ (timestamps and addresses) or 249<replaceable/tsprespec host1 [host2 [host3 [host4]]]/ 250(timestamp prespecified hops). 251 </para></listitem> 252 </varlistentry> 253 <varlistentry> 254 <term><option>-M <replaceable/hint/</option></term> 255 <listitem><para> 256Select Path MTU Discovery strategy. 257<replaceable/hint/ may be either <replaceable/do/ 258(prohibit fragmentation, even local one), 259<replaceable/want/ (do PMTU discovery, fragment locally when packet size 260is large), or <replaceable/dont/ (do not set DF flag). 261 </para></listitem> 262 </varlistentry> 263 <varlistentry> 264 <term><option/-U/</term> 265 <listitem><para> 266Print full user-to-user latency (the old behaviour). Normally 267<command/ping/ 268prints network round trip time, which can be different 269f.e. due to DNS failures. 270 </para></listitem> 271 </varlistentry> 272 <varlistentry> 273 <term><option/-v/</term> 274 <listitem><para> 275Verbose output. 276 </para></listitem> 277 </varlistentry> 278 <varlistentry> 279 <term><option/-V/</term> 280 <listitem><para> 281Show version and exit. 282 </para></listitem> 283 </varlistentry> 284 <varlistentry> 285 <term><option><anchor id="ping.deadline">-w <replaceable/deadline/</option></term> 286 <listitem><para> 287Specify a timeout, in seconds, before 288<command/ping/ 289exits regardless of how many 290packets have been sent or received. In this case 291<command/ping/ 292does not stop after 293<link linkend="ping.count"><replaceable/count/</link> 294packet are sent, it waits either for 295<link linkend="ping.deadline"><replaceable/deadline/</link> 296expire or until 297<link linkend="ping.count"><replaceable/count/</link> 298probes are answered or for some error notification from network. 299 </para></listitem> 300 </varlistentry> 301 <varlistentry> 302 <term><option>-W <replaceable/timeout/</option></term> 303 <listitem><para> 304Time to wait for a response, in seconds. The option affects only timeout 305in absense of any responses, otherwise <command/ping/ waits for two RTTs. 306 </para></listitem> 307 </varlistentry> 308</variablelist> 309 310<para> 311When using <command/ping/ for fault isolation, it should first be run 312on the local host, to verify that the local network interface is up 313and running. Then, hosts and gateways further and further away should be 314``pinged''. Round-trip times and packet loss statistics are computed. 315If duplicate packets are received, they are not included in the packet 316loss calculation, although the round trip time of these packets is used 317in calculating the minimum/average/maximum round-trip time numbers. 318When the specified number of packets have been sent (and received) or 319if the program is terminated with a 320<constant/SIGINT/, a brief summary is displayed. Shorter current statistics 321can be obtained without termination of process with signal 322<constant/SIGQUIT/. 323</para> 324 325<para> 326If <command/ping/ does not receive any reply packets at all it will 327exit with code 1. If a packet 328<link linkend="ping.count"><replaceable/count/</link> 329and 330<link linkend="ping.deadline"><replaceable/deadline/</link> 331are both specified, and fewer than 332<link linkend="ping.count"><replaceable/count/</link> 333packets are received by the time the 334<link linkend="ping.deadline"><replaceable/deadline/</link> 335has arrived, it will also exit with code 1. 336On other error it exits with code 2. Otherwise it exits with code 0. This 337makes it possible to use the exit code to see if a host is alive or 338not. 339</para> 340 341 342<para> 343This program is intended for use in network testing, measurement and 344management. 345Because of the load it can impose on the network, it is unwise to use 346<command/ping/ during normal operations or from automated scripts. 347</para> 348 349</refsect1> 350 351 352<refsect1><title>ICMP PACKET DETAILS</title> 353 354<para> 355An IP header without options is 20 bytes. 356An ICMP ECHO_REQUEST packet contains an additional 8 bytes worth 357of ICMP header followed by an arbitrary amount of data. 358When a <replaceable/packetsize/ is given, this indicated the size of this 359extra piece of data (the default is 56). Thus the amount of data received 360inside of an IP packet of type ICMP ECHO_REPLY will always be 8 bytes 361more than the requested data space (the ICMP header). 362</para> 363 364<para> 365If the data space is at least of size of <structname/struct timeval/ 366<command/ping/ uses the beginning bytes of this space to include 367a timestamp which it uses in the computation of round trip times. 368If the data space is shorter, no round trip times are given. 369</para> 370 371</refsect1> 372 373<refsect1><title>DUPLICATE AND DAMAGED PACKETS</title> 374 375<para> 376<command/ping/ will report duplicate and damaged packets. 377Duplicate packets should never occur, and seem to be caused by 378inappropriate link-level retransmissions. 379Duplicates may occur in many situations and are rarely (if ever) a 380good sign, although the presence of low levels of duplicates may not 381always be cause for alarm. 382</para> 383 384<para> 385Damaged packets are obviously serious cause for alarm and often 386indicate broken hardware somewhere in the 387<command/ping/ packet's path (in the network or in the hosts). 388</para> 389 390</refsect1> 391 392<refsect1><title>TRYING DIFFERENT DATA PATTERNS</title> 393 394<para> 395The (inter)network layer should never treat packets differently depending 396on the data contained in the data portion. 397Unfortunately, data-dependent problems have been known to sneak into 398networks and remain undetected for long periods of time. 399In many cases the particular pattern that will have problems is something 400that doesn't have sufficient ``transitions'', such as all ones or all 401zeros, or a pattern right at the edge, such as almost all zeros. 402It isn't necessarily enough to specify a data pattern of all zeros (for 403example) on the command line because the pattern that is of interest is 404at the data link level, and the relationship between what you type and 405what the controllers transmit can be complicated. 406</para> 407 408<para> 409This means that if you have a data-dependent problem you will probably 410have to do a lot of testing to find it. 411If you are lucky, you may manage to find a file that either can't be sent 412across your network or that takes much longer to transfer than other 413similar length files. 414You can then examine this file for repeated patterns that you can test 415using the <option/-p/ option of <command/ping/. 416</para> 417 418</refsect1> 419 420<refsect1><title>TTL DETAILS</title> 421 422<para> 423The TTL value of an IP packet represents the maximum number of IP routers 424that the packet can go through before being thrown away. 425In current practice you can expect each router in the Internet to decrement 426the TTL field by exactly one. 427</para> 428 429<para> 430The TCP/IP specification states that the TTL field for TCP 431packets should be set to 60, but many systems use smaller values 432(4.3 BSD uses 30, 4.2 used 15). 433</para> 434 435<para> 436The maximum possible value of this field is 255, and most Unix systems set 437the TTL field of ICMP ECHO_REQUEST packets to 255. 438This is why you will find you can ``ping'' some hosts, but not reach them 439with 440<citerefentry><refentrytitle/telnet/<manvolnum/1/</citerefentry> 441or 442<citerefentry><refentrytitle/ftp/<manvolnum/1/</citerefentry>. 443</para> 444 445<para> 446In normal operation ping prints the ttl value from the packet it receives. 447When a remote system receives a ping packet, it can do one of three things 448with the TTL field in its response: 449</para> 450 451<itemizedlist> 452 <listitem><para> 453Not change it; this is what Berkeley Unix systems did before the 4544.3BSD Tahoe release. In this case the TTL value in the received packet 455will be 255 minus the number of routers in the round-trip path. 456 </para></listitem> 457 <listitem><para> 458Set it to 255; this is what current Berkeley Unix systems do. 459In this case the TTL value in the received packet will be 255 minus the 460number of routers in the path <emphasis/from/ 461the remote system <emphasis/to/ the <command/ping/ing host. 462 </para></listitem> 463 <listitem><para> 464Set it to some other value. Some machines use the same value for 465ICMP packets that they use for TCP packets, for example either 30 or 60. 466Others may use completely wild values. 467 </para></listitem> 468</itemizedlist> 469 470</refsect1> 471 472<refsect1><title>BUGS</title> 473 474<itemizedlist> 475 <listitem><para> 476Many Hosts and Gateways ignore the RECORD_ROUTE option. 477 </para></listitem> 478 <listitem><para> 479The maximum IP header length is too small for options like 480RECORD_ROUTE to be completely useful. 481There's not much that that can be done about this, however. 482 </para></listitem> 483 <listitem><para> 484Flood pinging is not recommended in general, and flood pinging the 485broadcast address should only be done under very controlled conditions. 486 </para></listitem> 487</itemizedlist> 488 489</refsect1> 490 491<refsect1><title>SEE ALSO</title> 492<para> 493<citerefentry><refentrytitle/netstat/<manvolnum/1/</citerefentry>, 494<citerefentry><refentrytitle/ifconfig/<manvolnum/8/</citerefentry>. 495</para> 496</refsect1> 497 498<refsect1><title>HISTORY</title> 499<para> 500The <command/ping/ command appeared in 4.3BSD. 501</para> 502<para> 503The version described here is its descendant specific to Linux. 504</para> 505</refsect1> 506 507<refsect1><title>SECURITY</title> 508<para> 509<command/ping/ requires <constant/CAP_NET_RAWIO/ capability 510to be executed. It may be used as set-uid root. 511</para> 512</refsect1> 513 514<refsect1><title>AVAILABILITY</title> 515<para> 516<command/ping/ is part of <filename/iputils/ package 517and the latest versions are available in source form for anonymous ftp 518<ulink url="ftp://ftp.inr.ac.ru/ip-routing/iputils-current.tar.gz"> 519ftp://ftp.inr.ac.ru/ip-routing/iputils-current.tar.gz</ulink>. 520</para> 521</refsect1> 522 523<![IGNORE[ 524<refsect1><title>COPYING</title> 525<para> 526<literallayout> 527Copyright (c) 1989 The Regents of the University of California. 528All rights reserved. 529 530This code is derived from software contributed to Berkeley by 531Mike Muuss. 532 533Redistribution and use in source and binary forms, with or without 534modification, are permitted provided that the following conditions 535are met: 5361. Redistributions of source code must retain the above copyright 537 notice, this list of conditions and the following disclaimer. 5382. Redistributions in binary form must reproduce the above copyright 539 notice, this list of conditions and the following disclaimer in the 540 documentation and/or other materials provided with the distribution. 5413. All advertising materials mentioning features or use of this software 542 must display the following acknowledgement: 543 This product includes software developed by the University of 544 California, Berkeley and its contributors. 5454. Neither the name of the University nor the names of its contributors 546 may be used to endorse or promote products derived from this software 547 without specific prior written permission. 548 549THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 550ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 551IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 552ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 553FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 554DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 555OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 556HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 557LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 558OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 559SUCH DAMAGE. 560</literallayout> 561</para> 562</refsect1> 563]]> 564 565 566</refentry> 567 568