xref: /original-bsd/sbin/ping/ping.8 (revision bd226a66)
1.\" Copyright (c) 1985, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)ping.8	6.7 (Berkeley) 03/16/91
7.\"
8.Dd
9.Dt PING 8
10.Os BSD 4.3
11.Sh NAME
12.Nm ping
13.Nd send
14.Tn ICMP ECHO_REQUEST
15packets to network hosts
16.Sh SYNOPSIS
17.Nm ping
18.Op Fl dfnqrvR
19.Op Fl c Ar count
20.Op Fl i Ar wait
21.Op Fl l Ar preload
22.Op Fl p Ar pattern
23.Op Fl s Ar packetsize
24.Sh DESCRIPTION
25.Nm Ping
26uses the
27.Tn ICMP
28protocol's mandatory
29.Tn ECHO_REQUEST
30datagram to elicit an
31.Tn ICMP ECHO_RESPONSE
32from a host or gateway.
33.Tn ECHO_REQUEST
34datagrams (``pings'') have an IP and
35.Tn ICMP
36header,
37followed by a
38.Dq struct timeval
39and then an arbitrary number of ``pad'' bytes used to fill out the
40packet.
41The options are as follows:
42Other options are:
43.Bl -tag -width Ds
44.It Fl c Ar count
45Stop after sending (and receiving)
46.Ar count
47.Tn ECHO_RESPONSE
48packets.
49.It Fl d
50Set the
51.Dv SO_DEBUG
52option on the socket being used.
53.It Fl f
54Flood ping.
55Outputs packets as fast as they come back or one hundred times per second,
56whichever is more.
57For every
58.Tn ECHO_REQUEST
59sent a period ``.'' is printed, while for ever
60.Tn ECHO_REPLY
61received a backspace is printed.
62This provides a rapid display of how many packets are being dropped.
63Only the super-user may use this option.
64.Bf -emphasis
65This can be very hard on a network and should be used with caution.
66.Ef
67.It Fl i Ar wait
68Wait
69.Ar wait
70seconds
71.Em between sending each packet .
72The default is to wait for one second between each packet.
73This option is incompatible with the
74.Fl f
75option.
76.It Fl l Ar preload
77If
78.Ar preload
79is specified,
80.Nm ping
81sends that many packets as fast as possible before falling into its normal
82mode of behavior.
83.It Fl n
84Numeric output only.
85No attempt will be made to lookup symbolic names for host addresses.
86.It Fl p Ar pattern
87You may specify up to 16 ``pad'' bytes to fill out the packet you send.
88This is useful for diagnosing data-dependent problems in a network.
89For example,
90.Dq Li \-p ff
91will cause the sent packet to be filled with all
92ones.
93.It Fl q
94Quiet output.
95Nothing is displayed except the summary lines at startup time and
96when finished.
97.It Fl R
98Record route.
99Includes the
100.Tn RECORD_ROUTE
101option in the
102.Tn ECHO_REQUEST
103packet and displays
104the route buffer on returned packets.
105Note that the IP header is only large enough for nine such routes.
106Many hosts ignore or discard this option.
107.It Fl r
108Bypass the normal routing tables and send directly to a host on an attached
109network.
110If the host is not on a directly-attached network, an error is returned.
111This option can be used to ping a local host through an interface
112that has no route through it (e.g., after the interface was dropped by
113.Xr routed 8 ) .
114.It Fl s Ar packetsize
115Specifies the number of data bytes to be sent.
116The default is 56, which translates into 64
117.Tn ICMP
118data bytes when combined
119with the 8 bytes of
120.Tn ICMP
121header data.
122.It Fl v
123Verbose output.
124.Tn ICMP
125packets other than
126.Tn ECHO_RESPONSE
127that are received are listed.
128.El
129.Pp
130When using
131.Nm ping
132for fault isolation, it should first be run on the local host, to verify
133that the local network interface is up and running.
134Then, hosts and gateways further and further away should be ``pinged''.
135Round-trip times and packet loss statistics are computed.
136If duplicate packets are received, they are not included in the packet
137loss calculation, although the round trip time of these packets is used
138in calculating the minimum/average/maximum round-trip time numbers.
139When the specified number of packets have been sent (and received) or
140if the program is terminated with a
141.Dv SIGINT ,
142a brief summary is displayed.
143.Pp
144This program is intended for use in network testing, measurement and
145management.
146Because of the load it can impose on the network, it is unwise to use
147.Nm ping
148during normal operations or from automated scripts.
149.Sh ICMP PACKET DETAILS
150An IP header without options is 20 bytes.
151An
152.Tn ICMP
153.Tn ECHO_REQUEST
154packet contains an additional 8 bytes worth
155of
156.Tn ICMP
157header followed by an arbitrary amount of data.
158When a
159.Ar packetsize
160is given, this indicated the size of this extra piece of data (the
161default is 56).
162Thus the amount of data received inside of an IP packet of type
163.Tn ICMP
164.Tn ECHO_REPLY
165will always be 8 bytes more than the requested data space
166(the
167.Tn ICMP
168header).
169.Pp
170If the data space is at least eight bytes large,
171.Nm ping
172uses the first eight bytes of this space to include a timestamp which
173it uses in the computation of round trip times.
174If less than eight bytes of pad are specified, no round trip times are
175given.
176.Sh DUPLICATE AND DAMAGED PACKETS
177.Nm Ping
178will report duplicate and damaged packets.
179Duplicate packets should never occur, and seem to be caused by
180inappropriate link-level retransmissions.
181Duplicates may occur in many situations and are rarely (if ever) a
182good sign, although the presence of low levels of duplicates may not
183always be cause for alarm.
184.Pp
185Damaged packets are obviously serious cause for alarm and often
186indicate broken hardware somewhere in the
187.Nm ping
188packet's path (in the network or in the hosts).
189.Sh TRYING DIFFERENT DATA PATTERNS
190The (inter)network layer should never treat packets differently depending
191on the data contained in the data portion.
192Unfortunately, data-dependent problems have been known to sneak into
193networks and remain undetected for long periods of time.
194In many cases the particular pattern that will have problems is something
195that doesn't have sufficient ``transitions'', such as all ones or all
196zeros, or a pattern right at the edge, such as almost all zeros.
197It isn't necessarily enough to specify a data pattern of all zeros (for
198example) on the command line because the pattern that is of interest is
199at the data link level, and the relationship between what you type and
200what the controllers transmit can be complicated.
201.Pp
202This means that if you have a data-dependent problem you will probably
203have to do a lot of testing to find it.
204If you are lucky, you may manage to find a file that either can't be sent
205across your network or that takes much longer to transfer than other
206similar length files.
207You can then examine this file for repeated patterns that you can test
208using the
209.Fl p
210option of
211.Nm ping .
212.Sh TTL DETAILS
213The
214.Tn TTL
215value of an IP packet represents the maximum number of IP routers
216that the packet can go through before being thrown away.
217In current practice you can expect each router in the Internet to decrement
218the
219.Tn TTL
220field by exactly one.
221.Pp
222The
223.Tn TCP/IP
224specification states that the
225.Tn TTL
226field for
227.Tn TCP
228packets should
229be set to 60, but many systems use smaller values (4.3
230.Tn BSD
231uses 30, 4.2 used
23215).
233.Pp
234The maximum possible value of this field is 255, and most Unix systems set
235the
236.Tn TTL
237field of
238.Tn ICMP ECHO_REQUEST
239packets to 255.
240This is why you will find you can ``ping'' some hosts, but not reach them
241with
242.Xr telnet 1
243or
244.Xr ftp 1 .
245.Pp
246In normal operation ping prints the ttl value from the packet it receives.
247When a remote system receives a ping packet, it can do one of three things
248with the
249.Tn TTL
250field in its response:
251.Bl -bullet
252.It
253Not change it; this is what Berkeley Unix systems did before the
254.Bx 4.3 tahoe
255release.
256In this case the
257.Tn TTL
258value in the received packet will be 255 minus the
259number of routers in the round-trip path.
260.It
261Set it to 255; this is what current Berkeley Unix systems do.
262In this case the
263.Tn TTL
264value in the received packet will be 255 minus the
265number of routers in the path
266.Xr from
267the remote system
268.Em to
269the
270.Nm ping Ns Em ing
271host.
272.It
273Set it to some other value.
274Some machines use the same value for
275.Tn ICMP
276packets that they use for
277.Tn TCP
278packets, for example either 30 or 60.
279Others may use completely wild values.
280.El
281.Sh BUGS
282Many Hosts and Gateways ignore the
283.Tn RECORD_ROUTE
284option.
285.Pp
286The maximum IP header length is too small for options like
287.Tn RECORD_ROUTE
288to
289be completely useful.
290There's not much that that can be done about this, however.
291.Pp
292Flood pinging is not recommended in general, and flood pinging the
293broadcast address should only be done under very controlled conditions.
294.Sh SEE ALSO
295.Xr netstat 1 ,
296.Xr ifconfig 8 ,
297.Xr routed 8
298.Sh HISTORY
299The
300.Nm
301command appeared in
302.Bx 4.3 .
303