update NEWS
[manpages-zh.git] / raw / man8 / ping.8
blob8558de4356ff23df967b9cdcd8265861830b4846
1 .\" This manpage has been automatically generated by docbook2man 
2 .\" from a DocBook document.  This tool can be found at:
3 .\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
4 .\" Please send any bug reports, improvements, comments, patches, 
5 .\" etc. to Steve Cheng <steve@ggi-project.org>.
6 .TH "PING" "8" "27 September 2002" "iputils-020927" "System Manager's Manual: iputils"
7 .SH NAME
8 ping, ping6 \- send ICMP ECHO_REQUEST to network hosts
9 .SH SYNOPSIS
11 \fBping\fR [ \fB-LRUbdfnqrvVaAB\fR]  [ \fB-c \fIcount\fB\fR]  [ \fB-i \fIinterval\fB\fR]  [ \fB-l \fIpreload\fB\fR]  [ \fB-p \fIpattern\fB\fR]  [ \fB-s \fIpacketsize\fB\fR]  [ \fB-t \fIttl\fB\fR]  [ \fB-w \fIdeadline\fB\fR]  [ \fB-F \fIflowlabel\fB\fR]  [ \fB-I \fIinterface\fB\fR]  [ \fB-M \fIhint\fB\fR]  [ \fB-Q \fItos\fB\fR]  [ \fB-S \fIsndbuf\fB\fR]  [ \fB-T \fItimestamp option\fB\fR]  [ \fB-W \fItimeout\fB\fR]  [ \fB\fIhop\fB\fR\fI ...\fR]  \fB\fIdestination\fB\fR
13 .SH "DESCRIPTION"
14 .PP
15 \fBping\fR uses the ICMP protocol's mandatory ECHO_REQUEST
16 datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway.
17 ECHO_REQUEST datagrams (``pings'') have an IP and ICMP
18 header, followed by a struct timeval and then an arbitrary
19 number of ``pad'' bytes used to fill out the packet.
20 .SH "OPTIONS"
21 .TP
22 \fB-a\fR
23 Audible ping.
24 .TP
25 \fB-A\fR
26 Adaptive ping. Interpacket interval adapts to round-trip time, so that
27 effectively not more than one (or more, if preload is set) unanswered probes
28 present in the network. Minimal interval is 200msec for not super-user.
29 On networks with low rtt this mode is essentially equivalent to flood mode.  
30 .TP
31 \fB-b\fR
32 Allow pinging a broadcast address.
33 .TP
34 \fB-B\fR
35 Do not allow \fBping\fR to change source address of probes.
36 The address is bound to one selected when \fBping\fR starts.
37 .TP
38 \fB-c \fIcount\fB\fR
39 Stop after sending \fIcount\fR ECHO_REQUEST
40 packets. With 
41 \fIdeadline\fR
42 option, \fBping\fR waits for
43 \fIcount\fR ECHO_REPLY packets, until the timeout expires.
44 .TP
45 \fB-d\fR
46 Set the SO_DEBUG option on the socket being used.
47 Essentially, this socket option is not used by Linux kernel. 
48 .TP
49 \fB-F \fIflow label\fB\fR
50 Allocate and set 20 bit flow label on echo request packets.
51 (Only \fBping6\fR). If value is zero, kernel allocates random flow label.
52 .TP
53 \fB-f\fR
54 Flood ping. For every ECHO_REQUEST sent a period ``.'' is printed,
55 while for ever ECHO_REPLY received a backspace is printed.
56 This provides a rapid display of how many packets are being dropped.
57 If interval is not given, it sets interval to zero and
58 outputs packets as fast as they come back or one hundred times per second,
59 whichever is more.
60 Only the super-user may use this option with zero interval.
61 .TP
62 \fB-i \fIinterval\fB\fR
63 Wait \fIinterval\fR seconds between sending each packet.
64 The default is to wait for one second between each packet normally,
65 or not to wait in flood mode. Only super-user may set interval
66 to values less 0.2 seconds.
67 .TP
68 \fB-I \fIinterface address\fB\fR
69 Set source address to specified interface address. Argument
70 may be numeric IP address or name of device. When pinging IPv6
71 link-local address this option is required.
72 .TP
73 \fB-l \fIpreload\fB\fR
74 If \fIpreload\fR is specified,
75 \fBping\fR sends that many packets not waiting for reply.
76 Only the super-user may select preload more than 3.
77 .TP
78 \fB-L\fR
79 Suppress loopback of multicast packets.  This flag only applies if the ping
80 destination is a multicast address.
81 .TP
82 \fB-n\fR
83 Numeric output only.
84 No attempt will be made to lookup symbolic names for host addresses.
85 .TP
86 \fB-p \fIpattern\fB\fR
87 You may specify up to 16 ``pad'' bytes to fill out the packet you send.
88 This is useful for diagnosing data-dependent problems in a network.
89 For example, \fB-p ff\fR will cause the sent packet
90 to be filled with all ones.
91 .TP
92 \fB-Q \fItos\fB\fR
93 Set Quality of Service -related bits in ICMP datagrams.  
94 \fItos\fR can be either decimal or hex number.
95 Traditionally (RFC1349), these have been interpreted as: 0 for reserved
96 (currently being redefined as congestion control), 1-4 for Type of Service
97 and 5-7 for Precedence.
98 Possible settings for Type of Service are: minimal cost: 0x02, 
99 reliability: 0x04, throughput: 0x08, low delay: 0x10.  Multiple TOS bits
100 should not be set simultaneously.  Possible settings for
101 special Precedence range from priority (0x20) to net control (0xe0).  You
102 must be root (CAP_NET_ADMIN capability) to use Critical or
103 higher precedence value.  You cannot set
104 bit 0x01 (reserved) unless ECN has been enabled in the kernel.
105 In RFC2474, these fields has been redefined as 8-bit Differentiated
106 Services (DS), consisting of: bits 0-1 of separate data (ECN will be used,
107 here), and bits 2-7 of Differentiated Services Codepoint (DSCP).
109 \fB-q\fR
110 Quiet output.
111 Nothing is displayed except the summary lines at startup time and
112 when finished.
114 \fB-R\fR
115 Record route.
116 Includes the RECORD_ROUTE option in the ECHO_REQUEST
117 packet and displays the route buffer on returned packets.
118 Note that the IP header is only large enough for nine such routes.
119 Many hosts ignore or discard this option.
121 \fB-r\fR
122 Bypass the normal routing tables and send directly to a host on an attached
123 interface.
124 If the host is not on a directly-attached network, an error is returned.
125 This option can be used to ping a local host through an interface
126 that has no route through it provided the option \fB-I\fR is also
127 used.
129 \fB-s \fIpacketsize\fB\fR
130 Specifies the number of data bytes to be sent.  
131 The default is 56, which translates into 64 ICMP
132 data bytes when combined with the 8 bytes of ICMP header data.
134 \fB-S \fIsndbuf\fB\fR
135 Set socket sndbuf. If not specified, it is selected to buffer
136 not more than one packet.
138 \fB-t \fIttl\fB\fR
139 Set the IP Time to Live.
141 \fB-T \fItimestamp option\fB\fR
142 Set special IP timestamp options.
143 \fItimestamp option\fR may be either 
144 \fItsonly\fR (only timestamps), 
145 \fItsandaddr\fR (timestamps and addresses) or 
146 \fItsprespec host1 [host2 [host3 [host4]]]\fR
147 (timestamp prespecified hops).
149 \fB-M \fIhint\fB\fR
150 Select Path MTU Discovery strategy.
151 \fIhint\fR may be either \fIdo\fR
152 (prohibit fragmentation, even local one), 
153 \fIwant\fR (do PMTU discovery, fragment locally when packet size
154 is large), or \fIdont\fR (do not set DF flag).
156 \fB-U\fR
157 Print full user-to-user latency (the old behaviour). Normally
158 \fBping\fR
159 prints network round trip time, which can be different
160 f.e. due to DNS failures. 
162 \fB-v\fR
163 Verbose output.
165 \fB-V\fR
166 Show version and exit.
168 \fB-w \fIdeadline\fB\fR
169 Specify a timeout, in seconds, before
170 \fBping\fR
171 exits regardless of how many
172 packets have been sent or received. In this case
173 \fBping\fR
174 does not stop after
175 \fIcount\fR
176 packet are sent, it waits either for
177 \fIdeadline\fR
178 expire or until
179 \fIcount\fR
180 probes are answered or for some error notification from network.   
182 \fB-W \fItimeout\fB\fR
183 Time to wait for a response, in seconds. The option affects only timeout
184 in absense of any responses, otherwise \fBping\fR waits for two RTTs.
186 When using \fBping\fR for fault isolation, it should first be run
187 on the local host, to verify that the local network interface is up
188 and running. Then, hosts and gateways further and further away should be
189 ``pinged''. Round-trip times and packet loss statistics are computed.
190 If duplicate packets are received, they are not included in the packet
191 loss calculation, although the round trip time of these packets is used
192 in calculating the minimum/average/maximum round-trip time numbers.
193 When the specified number of packets have been sent (and received) or
194 if the program is terminated with a
195 SIGINT, a brief summary is displayed. Shorter current statistics
196 can be obtained without termination of process with signal
197 SIGQUIT.
199 If \fBping\fR does not receive any reply packets at all it will
200 exit with code 1. If a packet 
201 \fIcount\fR
203 \fIdeadline\fR
204 are both specified, and fewer than
205 \fIcount\fR
206 packets are received by the time the
207 \fIdeadline\fR
208 has arrived, it will also exit with code 1. 
209 On other error it exits with code 2. Otherwise it exits with code 0. This
210 makes it possible to use the exit code to see if a host is alive or
211 not.
213 This program is intended for use in network testing, measurement and
214 management.
215 Because of the load it can impose on the network, it is unwise to use
216 \fBping\fR during normal operations or from automated scripts.
217 .SH "ICMP PACKET DETAILS"
219 An IP header without options is 20 bytes.
220 An ICMP ECHO_REQUEST packet contains an additional 8 bytes worth
221 of ICMP header followed by an arbitrary amount of data.
222 When a \fIpacketsize\fR is given, this indicated the size of this
223 extra piece of data (the default is 56). Thus the amount of data received
224 inside of an IP packet of type ICMP ECHO_REPLY will always be 8 bytes
225 more than the requested data space (the ICMP header).
227 If the data space is at least of size of struct timeval
228 \fBping\fR uses the beginning bytes of this space to include
229 a timestamp which it uses in the computation of round trip times.
230 If the data space is shorter, no round trip times are given.
231 .SH "DUPLICATE AND DAMAGED PACKETS"
233 \fBping\fR will report duplicate and damaged packets.
234 Duplicate packets should never occur, and seem to be caused by
235 inappropriate link-level retransmissions.
236 Duplicates may occur in many situations and are rarely (if ever) a
237 good sign, although the presence of low levels of duplicates may not
238 always be cause for alarm.
240 Damaged packets are obviously serious cause for alarm and often
241 indicate broken hardware somewhere in the
242 \fBping\fR packet's path (in the network or in the hosts).
243 .SH "TRYING DIFFERENT DATA PATTERNS"
245 The (inter)network layer should never treat packets differently depending
246 on the data contained in the data portion.
247 Unfortunately, data-dependent problems have been known to sneak into
248 networks and remain undetected for long periods of time.
249 In many cases the particular pattern that will have problems is something
250 that doesn't have sufficient ``transitions'', such as all ones or all
251 zeros, or a pattern right at the edge, such as almost all zeros.
252 It isn't necessarily enough to specify a data pattern of all zeros (for
253 example) on the command line because the pattern that is of interest is
254 at the data link level, and the relationship between what you type and
255 what the controllers transmit can be complicated.
257 This means that if you have a data-dependent problem you will probably
258 have to do a lot of testing to find it.
259 If you are lucky, you may manage to find a file that either can't be sent
260 across your network or that takes much longer to transfer than other
261 similar length files.
262 You can then examine this file for repeated patterns that you can test
263 using the \fB-p\fR option of \fBping\fR.
264 .SH "TTL DETAILS"
266 The TTL value of an IP packet represents the maximum number of IP routers
267 that the packet can go through before being thrown away.
268 In current practice you can expect each router in the Internet to decrement
269 the TTL field by exactly one.
271 The TCP/IP specification states that the TTL field for TCP
272 packets should be set to 60, but many systems use smaller values
273 (4.3 BSD uses 30, 4.2 used 15).
275 The maximum possible value of this field is 255, and most Unix systems set
276 the TTL field of ICMP ECHO_REQUEST packets to 255.
277 This is why you will find you can ``ping'' some hosts, but not reach them
278 with
279 \fBtelnet\fR(1)
281 \fBftp\fR(1).
283 In normal operation ping prints the ttl value from the packet it receives.
284 When a remote system receives a ping packet, it can do one of three things
285 with the TTL field in its response:
286 .TP 0.2i
287 \(bu
288 Not change it; this is what Berkeley Unix systems did before the
289 4.3BSD Tahoe release. In this case the TTL value in the received packet
290 will be 255 minus the number of routers in the round-trip path.
291 .TP 0.2i
292 \(bu
293 Set it to 255; this is what current Berkeley Unix systems do.
294 In this case the TTL value in the received packet will be 255 minus the
295 number of routers in the path \fBfrom\fR
296 the remote system \fBto\fR the \fBping\fRing host.
297 .TP 0.2i
298 \(bu
299 Set it to some other value. Some machines use the same value for
300 ICMP packets that they use for TCP packets, for example either 30 or 60.
301 Others may use completely wild values.
302 .SH "BUGS"
303 .TP 0.2i
304 \(bu
305 Many Hosts and Gateways ignore the RECORD_ROUTE option.
306 .TP 0.2i
307 \(bu
308 The maximum IP header length is too small for options like
309 RECORD_ROUTE to be completely useful.
310 There's not much that that can be done about this, however.
311 .TP 0.2i
312 \(bu
313 Flood pinging is not recommended in general, and flood pinging the
314 broadcast address should only be done under very controlled conditions.
315 .SH "SEE ALSO"
317 \fBnetstat\fR(1),
318 \fBifconfig\fR(8).
319 .SH "HISTORY"
321 The \fBping\fR command appeared in 4.3BSD.
323 The version described here is its descendant specific to Linux.
324 .SH "SECURITY"
326 \fBping\fR requires CAP_NET_RAWIO capability
327 to be executed. It may be used as set-uid root.
328 .SH "AVAILABILITY"
330 \fBping\fR is part of \fIiputils\fR package
331 and the latest versions are  available in source form for anonymous ftp
332 ftp://ftp.inr.ac.ru/ip-routing/iputils-current.tar.gz.