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