string.h is ANSI C include file
[unix-history] / usr / src / sbin / ping / ping.8
CommitLineData
78288025
KB
1.\" Copyright (c) 1985 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms are permitted
5.\" provided that the above copyright notice and this paragraph are
6.\" duplicated in all such forms and that any documentation,
7.\" advertising materials, and other materials related to such
8.\" distribution and use acknowledge that the software was developed
9.\" by the University of California, Berkeley. The name of the
10.\" University may not be used to endorse or promote products derived
11.\" from this software without specific prior written permission.
12.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15.\"
16.\" @(#)ping.8 6.5 (Berkeley) %G%
17.\"
18.TH PING 8 ""
19.UC 6
9aecb40e
KM
20.SH NAME
21ping \- send ICMP ECHO_REQUEST packets to network hosts
22.SH SYNOPSIS
78288025 23.B ping
9aecb40e 24[
63ed9e52
KB
25.B -dfnqrvR
26][
27.B -c
28count][
29.B -i
30wait][
31.B -l
32preload][
33.B -p
34pattern][
35.B -s
36packetsize]
9aecb40e 37.SH DESCRIPTION
9aecb40e 38.I Ping
63ed9e52 39uses the
d53739b5
MK
40ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an
41ICMP ECHO_RESPONSE from a host or gateway.
9aecb40e 42ECHO_REQUEST datagrams (``pings'') have an IP and ICMP header,
78288025
KB
43followed by a
44.I struct timeval
45and then an arbitrary number of ``pad'' bytes used to fill out the
46packet.
47The options are as follows:
d53739b5
MK
48Other options are:
49.TP
78288025
KB
50.I "-c count"
51Stop after sending (and receiving)
52.I count
53ECHO_RESPONSE packets.
54.TP
55.I -d
63ed9e52
KB
56Set the SO_DEBUG option on the socket being used.
57.TP
78288025
KB
58.I -f
59Flood ping.
60Outputs packets as fast as they come back or one hundred times per second,
61whichever is more.
62For every ECHO_REQUEST sent a period ``.'' is printed, while for ever
63ECHO_REPLY received a backspace is printed.
63ed9e52 64This provides a rapid display of how many packets are being dropped.
78288025
KB
65Only the super-user may use this option.
66.I "This can be very hard on a network and should be used with caution."
63ed9e52 67.TP
78288025
KB
68.I "-i wait"
69Wait
70.I wait seconds between sending each packet.
63ed9e52 71The default is to wait for one second between each packet.
78288025
KB
72This option is incompatible with the
73.I -f
74option.
63ed9e52 75.TP
78288025 76.I -l preload
63ed9e52
KB
77If
78.I preload
78288025 79is specified,
63ed9e52 80.I ping
78288025
KB
81sends that many packets as fast as possible before falling into its normal
82mode of behavior.
63ed9e52 83.TP
78288025
KB
84.I -n
85Numeric output only.
86No attempt will be made to lookup symbolic names for host addresses.
87.TP
88.I "-p pattern"
89You may specify up to 16 ``pad'' bytes to fill out the packet you send.
63ed9e52 90This is useful for diagnosing data-dependent problems in a network.
78288025
KB
91For example, ``-p ff'' will cause the sent packet to be filled with all
92ones.
93.TP
94.I -q
95Quiet output.
96Nothing is displayed except the summary lines at startup time and
97when finished.
98.TP
99.B -R
100Record route.
101Includes the RECORD_ROUTE option in the ECHO_REQUEST packet and displays
102the route buffer on returned packets.
103Note that the IP header is only large enough for nine such routes.
104Many hosts ignore or discard this option.
105.TP
106.I -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.IR routed (8)).
63ed9e52 113.TP
78288025 114.I "-s packetsize"
63ed9e52
KB
115Specifies the number of data bytes to be sent.
116The default is 56, which translates into 64 ICMP data bytes when combined
117with the 8 bytes of ICMP header data.
78288025
KB
118.TP
119.I -v
120Verbose output.
121ICMP packets other than ECHO_RESPONSE that are received are listed.
9aecb40e 122.PP
78288025
KB
123When using
124.I ping
125for fault isolation, it should first be run on the local host, to verify
126that the local network interface is up and running.
127Then, hosts and gateways further and further away should be ``pinged''.
9aecb40e 128Round-trip times and packet loss statistics are computed.
78288025
KB
129If duplicate packets are received, they are not included in the packet
130loss calculation, although the round trip time of these packets is used
131in calculating the minimum/average/maximum round-trip time numbers.
132When the specified number of packets have been sent (and received) or
133if the program is terminated with a SIGINT, a brief summary is displayed.
d53739b5 134.PP
78288025
KB
135This program is intended for use in network testing, measurement and
136management.
137Because of the load it can impose on the network, it is unwise to use
d53739b5
MK
138.I ping
139during normal operations or from automated scripts.
78288025 140.SH ICMP PACKET DETAILS
63ed9e52
KB
141An IP header without options is 20 bytes.
142An ICMP ECHO_REQUEST packet contains an additional 8 bytes worth
78288025
KB
143of ICMP header followed by an arbitrary amount of data.
144When a
63ed9e52 145.I packetsize
78288025
KB
146is given, this indicated the size of this extra piece of data (the
147default is 56).
148Thus the amount of data received inside of an IP packet of type ICMP
149ECHO_REPLY will always be 8 bytes more than the requested data space
150(the ICMP header).
63ed9e52
KB
151.PP
152If the data space is at least eight bytes large,
153.I ping
154uses the first eight bytes of this space to include a timestamp which
78288025
KB
155it uses in the computation of round trip times.
156If less than eight bytes of pad are specified, no round trip times are
157given.
158.SH DUPLICATE AND DAMAGED PACKETS
159.I Ping
160will report duplicate and damaged packets.
63ed9e52
KB
161Duplicate packets should never occur, and seem to be caused by
162inappropriate link-level retransmissions.
78288025
KB
163Duplicates may occur in many situations and are rarely (if ever) a
164good sign, although the presence of low levels of duplicates may not
165always be cause for alarm.
63ed9e52 166.PP
78288025
KB
167Damaged packets are obviously serious cause for alarm and often
168indicate broken hardware somewhere in the
169.I ping
170packet's path (in the network or in the hosts).
171.SH TRYING DIFFERENT DATA PATTERNS
172The (inter)network layer should never treat packets differently depending
173on the data contained in the data portion.
63ed9e52
KB
174Unfortunately, data-dependent problems have been known to sneak into
175networks and remain undetected for long periods of time.
176In many cases the particular pattern that will have problems is something
78288025
KB
177that doesn't have sufficient ``transitions'', such as all ones or all
178zeros, or a pattern right at the edge, such as almost all zeros.
63ed9e52 179It isn't necessarily enough to specify a data pattern of all zeros (for
78288025
KB
180example) on the command line because the pattern that is of interest is
181at the data link level, and the relationship between what you type and
182what the controllers transmit can be complicated.
63ed9e52 183.PP
78288025
KB
184This means that if you have a data-dependent problem you will probably
185have to do a lot of testing to find it.
63ed9e52
KB
186If you are lucky, you may manage to find a file that either can't be sent
187across your network or that takes much longer to transfer than other
188similar length files.
189You can then examine this file for repeated patterns that you can test
190using the \fI-p\fR option of \fIping\fR.
78288025 191.SH TTL DETAILS
63ed9e52
KB
192The TTL value of an IP packet represents the maximum number of IP routers
193that the packet can go through before being thrown away.
78288025
KB
194In current practice you can expect each router in the Internet to decrement
195the TTL field by exactly one.
63ed9e52 196.PP
78288025 197The TCP/IP specification states that the TTL field for TCP packets should
63ed9e52
KB
198be set to 60, but many systems use smaller values (4.3 BSD uses 30, 4.2 used
19915).
200.PP
201The maximum possible value of this field is 255, and most Unix systems set
202the TTL field of ICMP ECHO_REQUEST packets to 255.
78288025
KB
203This is why you will find you can ``ping'' some hosts, but not reach them
204with
205.I telnet
206or
207.IR ftp .
63ed9e52
KB
208.PP
209In normal operation ping prints the ttl value from the packet it receives.
210When a remote system receives a ping packet, it can do one of three things
211with the TTL field in its response:
212.TP
78288025
KB
213--
214Not change it; this is what Berkeley Unix systems did before the 4.3BSD-tahoe
215release.
63ed9e52
KB
216In this case the TTL value in the received packet will be 255 minus the
217number of routers in the round-trip path.
218.TP
78288025
KB
219--
220Set it to 255; this is what current Berkeley Unix systems do.
221In this case the TTL value in the received packet will be 255 minus the
222number of routers in the path
223.I from
224the remote system
225.I to
226the
227.IR ping ing
228host.
229.TP
230--
63ed9e52
KB
231Set it to some other value.
232Some machines use the same value for ICMP packets that they use for
233TCP packets, for example either 30 or 60.
234Others may use completely wild values.
235.SH BUGS
236Many Hosts and Gateways ignore the RECORD_ROUTE option.
237.PP
78288025
KB
238The maximum IP header length is too small for options like RECORD_ROUTE to
239be completely useful.
240There's not much that that can be done about this, however.
63ed9e52 241.PP
78288025
KB
242Flood pinging is not recommended in general, and flood pinging the
243broadcast address should only be done under very controlled conditions.
9aecb40e 244.SH SEE ALSO
78288025 245netstat(1), ifconfig(8), routed(8)