copyediting for Usenix manuals
[unix-history] / usr / src / sbin / ping / ping.8
CommitLineData
e91396ee
KB
1.\" Copyright (c) 1985, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
78288025 3.\"
ef2a224d 4.\" %sccs.include.redist.man%
78288025 5.\"
653ba8b6 6.\" @(#)ping.8 8.2 (Berkeley) %G%
78288025 7.\"
70567b1c
CL
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
63ed9e52 26uses the
70567b1c
CL
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,
78288025 37followed by a
70567b1c 38.Dq struct timeval
78288025
KB
39and then an arbitrary number of ``pad'' bytes used to fill out the
40packet.
41The options are as follows:
70567b1c
CL
42.Bl -tag -width Ds
43.It Fl c Ar count
78288025 44Stop after sending (and receiving)
70567b1c
CL
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
78288025
KB
53Flood ping.
54Outputs packets as fast as they come back or one hundred times per second,
55whichever is more.
70567b1c
CL
56For every
57.Tn ECHO_REQUEST
653ba8b6 58sent a period ``.'' is printed, while for every
70567b1c
CL
59.Tn ECHO_REPLY
60received a backspace is printed.
63ed9e52 61This provides a rapid display of how many packets are being dropped.
78288025 62Only the super-user may use this option.
70567b1c
CL
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
78288025 67Wait
70567b1c
CL
68.Ar wait
69seconds
70.Em between sending each packet .
63ed9e52 71The default is to wait for one second between each packet.
78288025 72This option is incompatible with the
70567b1c 73.Fl f
78288025 74option.
70567b1c 75.It Fl l Ar preload
63ed9e52 76If
70567b1c 77.Ar preload
78288025 78is specified,
70567b1c 79.Nm ping
78288025
KB
80sends that many packets as fast as possible before falling into its normal
81mode of behavior.
70567b1c 82.It Fl n
78288025
KB
83Numeric output only.
84No attempt will be made to lookup symbolic names for host addresses.
70567b1c 85.It Fl p Ar pattern
78288025 86You may specify up to 16 ``pad'' bytes to fill out the packet you send.
63ed9e52 87This is useful for diagnosing data-dependent problems in a network.
70567b1c
CL
88For example,
89.Dq Li \-p ff
90will cause the sent packet to be filled with all
78288025 91ones.
70567b1c 92.It Fl q
78288025
KB
93Quiet output.
94Nothing is displayed except the summary lines at startup time and
95when finished.
70567b1c 96.It Fl R
78288025 97Record route.
70567b1c
CL
98Includes the
99.Tn RECORD_ROUTE
100option in the
101.Tn ECHO_REQUEST
102packet and displays
78288025
KB
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.
70567b1c 106.It Fl r
78288025
KB
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
70567b1c
CL
112.Xr routed 8 ) .
113.It Fl s Ar packetsize
63ed9e52 114Specifies the number of data bytes to be sent.
70567b1c
CL
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
78288025 122Verbose output.
70567b1c
CL
123.Tn ICMP
124packets other than
125.Tn ECHO_RESPONSE
126that are received are listed.
127.El
128.Pp
78288025 129When using
70567b1c 130.Nm ping
78288025
KB
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''.
9aecb40e 134Round-trip times and packet loss statistics are computed.
78288025
KB
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
70567b1c
CL
139if the program is terminated with a
140.Dv SIGINT ,
141a brief summary is displayed.
142.Pp
78288025
KB
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
70567b1c 146.Nm ping
d53739b5 147during normal operations or from automated scripts.
70567b1c 148.Sh ICMP PACKET DETAILS
63ed9e52 149An IP header without options is 20 bytes.
70567b1c
CL
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.
78288025 157When a
70567b1c 158.Ar packetsize
78288025
KB
159is given, this indicated the size of this extra piece of data (the
160default is 56).
70567b1c
CL
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
63ed9e52 169If the data space is at least eight bytes large,
70567b1c 170.Nm ping
63ed9e52 171uses the first eight bytes of this space to include a timestamp which
78288025
KB
172it uses in the computation of round trip times.
173If less than eight bytes of pad are specified, no round trip times are
174given.
70567b1c
CL
175.Sh DUPLICATE AND DAMAGED PACKETS
176.Nm Ping
78288025 177will report duplicate and damaged packets.
63ed9e52
KB
178Duplicate packets should never occur, and seem to be caused by
179inappropriate link-level retransmissions.
78288025
KB
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.
70567b1c 183.Pp
78288025
KB
184Damaged packets are obviously serious cause for alarm and often
185indicate broken hardware somewhere in the
70567b1c 186.Nm ping
78288025 187packet's path (in the network or in the hosts).
70567b1c 188.Sh TRYING DIFFERENT DATA PATTERNS
78288025
KB
189The (inter)network layer should never treat packets differently depending
190on the data contained in the data portion.
63ed9e52
KB
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
78288025
KB
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.
63ed9e52 196It isn't necessarily enough to specify a data pattern of all zeros (for
78288025
KB
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.
70567b1c 200.Pp
78288025
KB
201This means that if you have a data-dependent problem you will probably
202have to do a lot of testing to find it.
63ed9e52
KB
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
70567b1c
CL
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
63ed9e52 215that the packet can go through before being thrown away.
78288025 216In current practice you can expect each router in the Internet to decrement
70567b1c
CL
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
63ed9e52 23115).
70567b1c 232.Pp
63ed9e52 233The maximum possible value of this field is 255, and most Unix systems set
70567b1c
CL
234the
235.Tn TTL
236field of
237.Tn ICMP ECHO_REQUEST
238packets to 255.
78288025
KB
239This is why you will find you can ``ping'' some hosts, but not reach them
240with
70567b1c 241.Xr telnet 1
78288025 242or
70567b1c
CL
243.Xr ftp 1 .
244.Pp
63ed9e52
KB
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
70567b1c
CL
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
78288025 254release.
70567b1c
CL
255In this case the
256.Tn TTL
257value in the received packet will be 255 minus the
63ed9e52 258number of routers in the round-trip path.
70567b1c 259.It
78288025 260Set it to 255; this is what current Berkeley Unix systems do.
70567b1c
CL
261In this case the
262.Tn TTL
263value in the received packet will be 255 minus the
78288025 264number of routers in the path
70567b1c 265.Xr from
78288025 266the remote system
70567b1c 267.Em to
78288025 268the
70567b1c 269.Nm ping Ns Em ing
78288025 270host.
70567b1c 271.It
63ed9e52 272Set it to some other value.
70567b1c
CL
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.
63ed9e52 278Others may use completely wild values.
70567b1c
CL
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
78288025
KB
288be completely useful.
289There's not much that that can be done about this, however.
70567b1c 290.Pp
78288025
KB
291Flood pinging is not recommended in general, and flood pinging the
292broadcast address should only be done under very controlled conditions.
70567b1c
CL
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 .