xref: /freebsd/sbin/ping/ping.8 (revision bcd92649c9952c9c9e8845dbd34276a60dd16664)
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$
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 dfnqrvRQ
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.Sh DESCRIPTION
52.Nm Ping
53uses the
54.Tn ICMP
55protocol's mandatory
56.Tn ECHO_REQUEST
57datagram to elicit an
58.Tn ICMP ECHO_RESPONSE
59from a host or gateway.
60.Tn ECHO_REQUEST
61datagrams (``pings'') have an IP and
62.Tn ICMP
63header,
64followed by a
65.Dq struct timeval
66and then an arbitrary number of ``pad'' bytes used to fill out the
67packet.
68The options are as follows:
69.Bl -tag -width Ds
70.It Fl c Ar count
71Stop after sending (and receiving)
72.Ar count
73.Tn ECHO_RESPONSE
74packets.
75.It Fl d
76Set the
77.Dv SO_DEBUG
78option on the socket being used.
79.It Fl f
80Flood ping.
81Outputs packets as fast as they come back or one hundred times per second,
82whichever is more.
83For every
84.Tn ECHO_REQUEST
85sent a period ``.'' is printed, while for every
86.Tn ECHO_REPLY
87received a backspace is printed.
88This provides a rapid display of how many packets are being dropped.
89Only the super-user may use this option.
90.Bf -emphasis
91This can be very hard on a network and should be used with caution.
92.Ef
93.It Fl i Ar wait
94Wait
95.Ar wait
96seconds
97.Em between sending each packet .
98The default is to wait for one second between each packet.
99This option is incompatible with the
100.Fl f
101option.
102.It Fl l Ar preload
103If
104.Ar preload
105is specified,
106.Nm ping
107sends that many packets as fast as possible before falling into its normal
108mode of behavior.
109.It Fl n
110Numeric output only.
111No attempt will be made to lookup symbolic names for host addresses.
112.It Fl p Ar pattern
113You may specify up to 16 ``pad'' bytes to fill out the packet you send.
114This is useful for diagnosing data-dependent problems in a network.
115For example,
116.Dq Li \-p ff
117will cause the sent packet to be filled with all
118ones.
119.It Fl Q
120Somewhat quiet output.
121Don't display ICMP error messages that are in response to our query messages.
122Originally, the
123.Fl v
124flag was required to display such errors, but
125.Fl v
126displays all ICMP error messages.  On a busy machine, this output can
127be overbearing.  Without the
128.Fl Q
129flag,
130.Nm
131prints out any ICMP error messages caused by its own ECHO_REQUEST
132messages.
133.It Fl q
134Quiet output.
135Nothing is displayed except the summary lines at startup time and
136when finished.
137.It Fl R
138Record route.
139Includes the
140.Tn RECORD_ROUTE
141option in the
142.Tn ECHO_REQUEST
143packet and displays
144the route buffer on returned packets.
145Note that the IP header is only large enough for nine such routes.
146Many hosts ignore or discard this option.
147.It Fl r
148Bypass the normal routing tables and send directly to a host on an attached
149network.
150If the host is not on a directly-attached network, an error is returned.
151This option can be used to ping a local host through an interface
152that has no route through it (e.g., after the interface was dropped by
153.Xr routed 8 ) .
154.It Fl s Ar packetsize
155Specifies the number of data bytes to be sent.
156The default is 56, which translates into 64
157.Tn ICMP
158data bytes when combined
159with the 8 bytes of
160.Tn ICMP
161header data.
162.It Fl v
163Verbose output.
164.Tn ICMP
165packets other than
166.Tn ECHO_RESPONSE
167that are received are listed.
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 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.Pp
335The
336.Fl v
337option is not worth much on busy hosts.
338.Sh SEE ALSO
339.Xr netstat 1 ,
340.Xr ifconfig 8 ,
341.Xr routed 8
342.Sh HISTORY
343The
344.Nm
345command appeared in
346.Bx 4.3 .
347