xref: /freebsd/sbin/ping/ping.8 (revision 8fae3551ec46402adf7ab034cf9e02bcbc7ca8ee)
18fae3551SRodney W. Grimes.\" Copyright (c) 1985, 1991, 1993
28fae3551SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
38fae3551SRodney W. Grimes.\"
48fae3551SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
58fae3551SRodney W. Grimes.\" modification, are permitted provided that the following conditions
68fae3551SRodney W. Grimes.\" are met:
78fae3551SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
88fae3551SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
98fae3551SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
108fae3551SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
118fae3551SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
128fae3551SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
138fae3551SRodney W. Grimes.\"    must display the following acknowledgement:
148fae3551SRodney W. Grimes.\"	This product includes software developed by the University of
158fae3551SRodney W. Grimes.\"	California, Berkeley and its contributors.
168fae3551SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
178fae3551SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
188fae3551SRodney W. Grimes.\"    without specific prior written permission.
198fae3551SRodney W. Grimes.\"
208fae3551SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
218fae3551SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
228fae3551SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
238fae3551SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
248fae3551SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
258fae3551SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
268fae3551SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
278fae3551SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
288fae3551SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
298fae3551SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
308fae3551SRodney W. Grimes.\" SUCH DAMAGE.
318fae3551SRodney W. Grimes.\"
328fae3551SRodney W. Grimes.\"     @(#)ping.8	8.2 (Berkeley) 12/11/93
338fae3551SRodney W. Grimes.\"
348fae3551SRodney W. Grimes.Dd December 11, 1993
358fae3551SRodney W. Grimes.Dt PING 8
368fae3551SRodney W. Grimes.Os BSD 4.3
378fae3551SRodney W. Grimes.Sh NAME
388fae3551SRodney W. Grimes.Nm ping
398fae3551SRodney W. Grimes.Nd send
408fae3551SRodney W. Grimes.Tn ICMP ECHO_REQUEST
418fae3551SRodney W. Grimespackets to network hosts
428fae3551SRodney W. Grimes.Sh SYNOPSIS
438fae3551SRodney W. Grimes.Nm ping
448fae3551SRodney W. Grimes.Op Fl dfnqrvR
458fae3551SRodney W. Grimes.Op Fl c Ar count
468fae3551SRodney W. Grimes.Op Fl i Ar wait
478fae3551SRodney W. Grimes.Op Fl l Ar preload
488fae3551SRodney W. Grimes.Op Fl p Ar pattern
498fae3551SRodney W. Grimes.Op Fl s Ar packetsize
508fae3551SRodney W. Grimes.Sh DESCRIPTION
518fae3551SRodney W. Grimes.Nm Ping
528fae3551SRodney W. Grimesuses the
538fae3551SRodney W. Grimes.Tn ICMP
548fae3551SRodney W. Grimesprotocol's mandatory
558fae3551SRodney W. Grimes.Tn ECHO_REQUEST
568fae3551SRodney W. Grimesdatagram to elicit an
578fae3551SRodney W. Grimes.Tn ICMP ECHO_RESPONSE
588fae3551SRodney W. Grimesfrom a host or gateway.
598fae3551SRodney W. Grimes.Tn ECHO_REQUEST
608fae3551SRodney W. Grimesdatagrams (``pings'') have an IP and
618fae3551SRodney W. Grimes.Tn ICMP
628fae3551SRodney W. Grimesheader,
638fae3551SRodney W. Grimesfollowed by a
648fae3551SRodney W. Grimes.Dq struct timeval
658fae3551SRodney W. Grimesand then an arbitrary number of ``pad'' bytes used to fill out the
668fae3551SRodney W. Grimespacket.
678fae3551SRodney W. GrimesThe options are as follows:
688fae3551SRodney W. Grimes.Bl -tag -width Ds
698fae3551SRodney W. Grimes.It Fl c Ar count
708fae3551SRodney W. GrimesStop after sending (and receiving)
718fae3551SRodney W. Grimes.Ar count
728fae3551SRodney W. Grimes.Tn ECHO_RESPONSE
738fae3551SRodney W. Grimespackets.
748fae3551SRodney W. Grimes.It Fl d
758fae3551SRodney W. GrimesSet the
768fae3551SRodney W. Grimes.Dv SO_DEBUG
778fae3551SRodney W. Grimesoption on the socket being used.
788fae3551SRodney W. Grimes.It Fl f
798fae3551SRodney W. GrimesFlood ping.
808fae3551SRodney W. GrimesOutputs packets as fast as they come back or one hundred times per second,
818fae3551SRodney W. Grimeswhichever is more.
828fae3551SRodney W. GrimesFor every
838fae3551SRodney W. Grimes.Tn ECHO_REQUEST
848fae3551SRodney W. Grimessent a period ``.'' is printed, while for every
858fae3551SRodney W. Grimes.Tn ECHO_REPLY
868fae3551SRodney W. Grimesreceived a backspace is printed.
878fae3551SRodney W. GrimesThis provides a rapid display of how many packets are being dropped.
888fae3551SRodney W. GrimesOnly the super-user may use this option.
898fae3551SRodney W. Grimes.Bf -emphasis
908fae3551SRodney W. GrimesThis can be very hard on a network and should be used with caution.
918fae3551SRodney W. Grimes.Ef
928fae3551SRodney W. Grimes.It Fl i Ar wait
938fae3551SRodney W. GrimesWait
948fae3551SRodney W. Grimes.Ar wait
958fae3551SRodney W. Grimesseconds
968fae3551SRodney W. Grimes.Em between sending each packet .
978fae3551SRodney W. GrimesThe default is to wait for one second between each packet.
988fae3551SRodney W. GrimesThis option is incompatible with the
998fae3551SRodney W. Grimes.Fl f
1008fae3551SRodney W. Grimesoption.
1018fae3551SRodney W. Grimes.It Fl l Ar preload
1028fae3551SRodney W. GrimesIf
1038fae3551SRodney W. Grimes.Ar preload
1048fae3551SRodney W. Grimesis specified,
1058fae3551SRodney W. Grimes.Nm ping
1068fae3551SRodney W. Grimessends that many packets as fast as possible before falling into its normal
1078fae3551SRodney W. Grimesmode of behavior.
1088fae3551SRodney W. Grimes.It Fl n
1098fae3551SRodney W. GrimesNumeric output only.
1108fae3551SRodney W. GrimesNo attempt will be made to lookup symbolic names for host addresses.
1118fae3551SRodney W. Grimes.It Fl p Ar pattern
1128fae3551SRodney W. GrimesYou may specify up to 16 ``pad'' bytes to fill out the packet you send.
1138fae3551SRodney W. GrimesThis is useful for diagnosing data-dependent problems in a network.
1148fae3551SRodney W. GrimesFor example,
1158fae3551SRodney W. Grimes.Dq Li \-p ff
1168fae3551SRodney W. Grimeswill cause the sent packet to be filled with all
1178fae3551SRodney W. Grimesones.
1188fae3551SRodney W. Grimes.It Fl q
1198fae3551SRodney W. GrimesQuiet output.
1208fae3551SRodney W. GrimesNothing is displayed except the summary lines at startup time and
1218fae3551SRodney W. Grimeswhen finished.
1228fae3551SRodney W. Grimes.It Fl R
1238fae3551SRodney W. GrimesRecord route.
1248fae3551SRodney W. GrimesIncludes the
1258fae3551SRodney W. Grimes.Tn RECORD_ROUTE
1268fae3551SRodney W. Grimesoption in the
1278fae3551SRodney W. Grimes.Tn ECHO_REQUEST
1288fae3551SRodney W. Grimespacket and displays
1298fae3551SRodney W. Grimesthe route buffer on returned packets.
1308fae3551SRodney W. GrimesNote that the IP header is only large enough for nine such routes.
1318fae3551SRodney W. GrimesMany hosts ignore or discard this option.
1328fae3551SRodney W. Grimes.It Fl r
1338fae3551SRodney W. GrimesBypass the normal routing tables and send directly to a host on an attached
1348fae3551SRodney W. Grimesnetwork.
1358fae3551SRodney W. GrimesIf the host is not on a directly-attached network, an error is returned.
1368fae3551SRodney W. GrimesThis option can be used to ping a local host through an interface
1378fae3551SRodney W. Grimesthat has no route through it (e.g., after the interface was dropped by
1388fae3551SRodney W. Grimes.Xr routed 8 ) .
1398fae3551SRodney W. Grimes.It Fl s Ar packetsize
1408fae3551SRodney W. GrimesSpecifies the number of data bytes to be sent.
1418fae3551SRodney W. GrimesThe default is 56, which translates into 64
1428fae3551SRodney W. Grimes.Tn ICMP
1438fae3551SRodney W. Grimesdata bytes when combined
1448fae3551SRodney W. Grimeswith the 8 bytes of
1458fae3551SRodney W. Grimes.Tn ICMP
1468fae3551SRodney W. Grimesheader data.
1478fae3551SRodney W. Grimes.It Fl v
1488fae3551SRodney W. GrimesVerbose output.
1498fae3551SRodney W. Grimes.Tn ICMP
1508fae3551SRodney W. Grimespackets other than
1518fae3551SRodney W. Grimes.Tn ECHO_RESPONSE
1528fae3551SRodney W. Grimesthat are received are listed.
1538fae3551SRodney W. Grimes.El
1548fae3551SRodney W. Grimes.Pp
1558fae3551SRodney W. GrimesWhen using
1568fae3551SRodney W. Grimes.Nm ping
1578fae3551SRodney W. Grimesfor fault isolation, it should first be run on the local host, to verify
1588fae3551SRodney W. Grimesthat the local network interface is up and running.
1598fae3551SRodney W. GrimesThen, hosts and gateways further and further away should be ``pinged''.
1608fae3551SRodney W. GrimesRound-trip times and packet loss statistics are computed.
1618fae3551SRodney W. GrimesIf duplicate packets are received, they are not included in the packet
1628fae3551SRodney W. Grimesloss calculation, although the round trip time of these packets is used
1638fae3551SRodney W. Grimesin calculating the minimum/average/maximum round-trip time numbers.
1648fae3551SRodney W. GrimesWhen the specified number of packets have been sent (and received) or
1658fae3551SRodney W. Grimesif the program is terminated with a
1668fae3551SRodney W. Grimes.Dv SIGINT ,
1678fae3551SRodney W. Grimesa brief summary is displayed.
1688fae3551SRodney W. Grimes.Pp
1698fae3551SRodney W. GrimesThis program is intended for use in network testing, measurement and
1708fae3551SRodney W. Grimesmanagement.
1718fae3551SRodney W. GrimesBecause of the load it can impose on the network, it is unwise to use
1728fae3551SRodney W. Grimes.Nm ping
1738fae3551SRodney W. Grimesduring normal operations or from automated scripts.
1748fae3551SRodney W. Grimes.Sh ICMP PACKET DETAILS
1758fae3551SRodney W. GrimesAn IP header without options is 20 bytes.
1768fae3551SRodney W. GrimesAn
1778fae3551SRodney W. Grimes.Tn ICMP
1788fae3551SRodney W. Grimes.Tn ECHO_REQUEST
1798fae3551SRodney W. Grimespacket contains an additional 8 bytes worth
1808fae3551SRodney W. Grimesof
1818fae3551SRodney W. Grimes.Tn ICMP
1828fae3551SRodney W. Grimesheader followed by an arbitrary amount of data.
1838fae3551SRodney W. GrimesWhen a
1848fae3551SRodney W. Grimes.Ar packetsize
1858fae3551SRodney W. Grimesis given, this indicated the size of this extra piece of data (the
1868fae3551SRodney W. Grimesdefault is 56).
1878fae3551SRodney W. GrimesThus the amount of data received inside of an IP packet of type
1888fae3551SRodney W. Grimes.Tn ICMP
1898fae3551SRodney W. Grimes.Tn ECHO_REPLY
1908fae3551SRodney W. Grimeswill always be 8 bytes more than the requested data space
1918fae3551SRodney W. Grimes(the
1928fae3551SRodney W. Grimes.Tn ICMP
1938fae3551SRodney W. Grimesheader).
1948fae3551SRodney W. Grimes.Pp
1958fae3551SRodney W. GrimesIf the data space is at least eight bytes large,
1968fae3551SRodney W. Grimes.Nm ping
1978fae3551SRodney W. Grimesuses the first eight bytes of this space to include a timestamp which
1988fae3551SRodney W. Grimesit uses in the computation of round trip times.
1998fae3551SRodney W. GrimesIf less than eight bytes of pad are specified, no round trip times are
2008fae3551SRodney W. Grimesgiven.
2018fae3551SRodney W. Grimes.Sh DUPLICATE AND DAMAGED PACKETS
2028fae3551SRodney W. Grimes.Nm Ping
2038fae3551SRodney W. Grimeswill report duplicate and damaged packets.
2048fae3551SRodney W. GrimesDuplicate packets should never occur, and seem to be caused by
2058fae3551SRodney W. Grimesinappropriate link-level retransmissions.
2068fae3551SRodney W. GrimesDuplicates may occur in many situations and are rarely (if ever) a
2078fae3551SRodney W. Grimesgood sign, although the presence of low levels of duplicates may not
2088fae3551SRodney W. Grimesalways be cause for alarm.
2098fae3551SRodney W. Grimes.Pp
2108fae3551SRodney W. GrimesDamaged packets are obviously serious cause for alarm and often
2118fae3551SRodney W. Grimesindicate broken hardware somewhere in the
2128fae3551SRodney W. Grimes.Nm ping
2138fae3551SRodney W. Grimespacket's path (in the network or in the hosts).
2148fae3551SRodney W. Grimes.Sh TRYING DIFFERENT DATA PATTERNS
2158fae3551SRodney W. GrimesThe (inter)network layer should never treat packets differently depending
2168fae3551SRodney W. Grimeson the data contained in the data portion.
2178fae3551SRodney W. GrimesUnfortunately, data-dependent problems have been known to sneak into
2188fae3551SRodney W. Grimesnetworks and remain undetected for long periods of time.
2198fae3551SRodney W. GrimesIn many cases the particular pattern that will have problems is something
2208fae3551SRodney W. Grimesthat doesn't have sufficient ``transitions'', such as all ones or all
2218fae3551SRodney W. Grimeszeros, or a pattern right at the edge, such as almost all zeros.
2228fae3551SRodney W. GrimesIt isn't necessarily enough to specify a data pattern of all zeros (for
2238fae3551SRodney W. Grimesexample) on the command line because the pattern that is of interest is
2248fae3551SRodney W. Grimesat the data link level, and the relationship between what you type and
2258fae3551SRodney W. Grimeswhat the controllers transmit can be complicated.
2268fae3551SRodney W. Grimes.Pp
2278fae3551SRodney W. GrimesThis means that if you have a data-dependent problem you will probably
2288fae3551SRodney W. Grimeshave to do a lot of testing to find it.
2298fae3551SRodney W. GrimesIf you are lucky, you may manage to find a file that either can't be sent
2308fae3551SRodney W. Grimesacross your network or that takes much longer to transfer than other
2318fae3551SRodney W. Grimessimilar length files.
2328fae3551SRodney W. GrimesYou can then examine this file for repeated patterns that you can test
2338fae3551SRodney W. Grimesusing the
2348fae3551SRodney W. Grimes.Fl p
2358fae3551SRodney W. Grimesoption of
2368fae3551SRodney W. Grimes.Nm ping .
2378fae3551SRodney W. Grimes.Sh TTL DETAILS
2388fae3551SRodney W. GrimesThe
2398fae3551SRodney W. Grimes.Tn TTL
2408fae3551SRodney W. Grimesvalue of an IP packet represents the maximum number of IP routers
2418fae3551SRodney W. Grimesthat the packet can go through before being thrown away.
2428fae3551SRodney W. GrimesIn current practice you can expect each router in the Internet to decrement
2438fae3551SRodney W. Grimesthe
2448fae3551SRodney W. Grimes.Tn TTL
2458fae3551SRodney W. Grimesfield by exactly one.
2468fae3551SRodney W. Grimes.Pp
2478fae3551SRodney W. GrimesThe
2488fae3551SRodney W. Grimes.Tn TCP/IP
2498fae3551SRodney W. Grimesspecification states that the
2508fae3551SRodney W. Grimes.Tn TTL
2518fae3551SRodney W. Grimesfield for
2528fae3551SRodney W. Grimes.Tn TCP
2538fae3551SRodney W. Grimespackets should
2548fae3551SRodney W. Grimesbe set to 60, but many systems use smaller values (4.3
2558fae3551SRodney W. Grimes.Tn BSD
2568fae3551SRodney W. Grimesuses 30, 4.2 used
2578fae3551SRodney W. Grimes15).
2588fae3551SRodney W. Grimes.Pp
2598fae3551SRodney W. GrimesThe maximum possible value of this field is 255, and most Unix systems set
2608fae3551SRodney W. Grimesthe
2618fae3551SRodney W. Grimes.Tn TTL
2628fae3551SRodney W. Grimesfield of
2638fae3551SRodney W. Grimes.Tn ICMP ECHO_REQUEST
2648fae3551SRodney W. Grimespackets to 255.
2658fae3551SRodney W. GrimesThis is why you will find you can ``ping'' some hosts, but not reach them
2668fae3551SRodney W. Grimeswith
2678fae3551SRodney W. Grimes.Xr telnet 1
2688fae3551SRodney W. Grimesor
2698fae3551SRodney W. Grimes.Xr ftp 1 .
2708fae3551SRodney W. Grimes.Pp
2718fae3551SRodney W. GrimesIn normal operation ping prints the ttl value from the packet it receives.
2728fae3551SRodney W. GrimesWhen a remote system receives a ping packet, it can do one of three things
2738fae3551SRodney W. Grimeswith the
2748fae3551SRodney W. Grimes.Tn TTL
2758fae3551SRodney W. Grimesfield in its response:
2768fae3551SRodney W. Grimes.Bl -bullet
2778fae3551SRodney W. Grimes.It
2788fae3551SRodney W. GrimesNot change it; this is what Berkeley Unix systems did before the
2798fae3551SRodney W. Grimes.Bx 4.3 tahoe
2808fae3551SRodney W. Grimesrelease.
2818fae3551SRodney W. GrimesIn this case the
2828fae3551SRodney W. Grimes.Tn TTL
2838fae3551SRodney W. Grimesvalue in the received packet will be 255 minus the
2848fae3551SRodney W. Grimesnumber of routers in the round-trip path.
2858fae3551SRodney W. Grimes.It
2868fae3551SRodney W. GrimesSet it to 255; this is what current Berkeley Unix systems do.
2878fae3551SRodney W. GrimesIn this case the
2888fae3551SRodney W. Grimes.Tn TTL
2898fae3551SRodney W. Grimesvalue in the received packet will be 255 minus the
2908fae3551SRodney W. Grimesnumber of routers in the path
2918fae3551SRodney W. Grimes.Xr from
2928fae3551SRodney W. Grimesthe remote system
2938fae3551SRodney W. Grimes.Em to
2948fae3551SRodney W. Grimesthe
2958fae3551SRodney W. Grimes.Nm ping Ns Em ing
2968fae3551SRodney W. Grimeshost.
2978fae3551SRodney W. Grimes.It
2988fae3551SRodney W. GrimesSet it to some other value.
2998fae3551SRodney W. GrimesSome machines use the same value for
3008fae3551SRodney W. Grimes.Tn ICMP
3018fae3551SRodney W. Grimespackets that they use for
3028fae3551SRodney W. Grimes.Tn TCP
3038fae3551SRodney W. Grimespackets, for example either 30 or 60.
3048fae3551SRodney W. GrimesOthers may use completely wild values.
3058fae3551SRodney W. Grimes.El
3068fae3551SRodney W. Grimes.Sh BUGS
3078fae3551SRodney W. GrimesMany Hosts and Gateways ignore the
3088fae3551SRodney W. Grimes.Tn RECORD_ROUTE
3098fae3551SRodney W. Grimesoption.
3108fae3551SRodney W. Grimes.Pp
3118fae3551SRodney W. GrimesThe maximum IP header length is too small for options like
3128fae3551SRodney W. Grimes.Tn RECORD_ROUTE
3138fae3551SRodney W. Grimesto
3148fae3551SRodney W. Grimesbe completely useful.
3158fae3551SRodney W. GrimesThere's not much that that can be done about this, however.
3168fae3551SRodney W. Grimes.Pp
3178fae3551SRodney W. GrimesFlood pinging is not recommended in general, and flood pinging the
3188fae3551SRodney W. Grimesbroadcast address should only be done under very controlled conditions.
3198fae3551SRodney W. Grimes.Sh SEE ALSO
3208fae3551SRodney W. Grimes.Xr netstat 1 ,
3218fae3551SRodney W. Grimes.Xr ifconfig 8 ,
3228fae3551SRodney W. Grimes.Xr routed 8
3238fae3551SRodney W. Grimes.Sh HISTORY
3248fae3551SRodney W. GrimesThe
3258fae3551SRodney W. Grimes.Nm
3268fae3551SRodney W. Grimescommand appeared in
3278fae3551SRodney W. Grimes.Bx 4.3 .
328