]> git.saurik.com Git - apple/network_cmds.git/blame - ping.tproj/ping.8
network_cmds-245.tar.gz
[apple/network_cmds.git] / ping.tproj / ping.8
CommitLineData
2b484d24
A
1.\" Copyright (c) 1985, 1991, 1993\r
2.\" The Regents of the University of California. All rights reserved.\r
3.\"\r
4.\" Redistribution and use in source and binary forms, with or without\r
5.\" modification, are permitted provided that the following conditions\r
6.\" are met:\r
7.\" 1. Redistributions of source code must retain the above copyright\r
8.\" notice, this list of conditions and the following disclaimer.\r
9.\" 2. Redistributions in binary form must reproduce the above copyright\r
10.\" notice, this list of conditions and the following disclaimer in the\r
11.\" documentation and/or other materials provided with the distribution.\r
12.\" 4. Neither the name of the University nor the names of its contributors\r
13.\" may be used to endorse or promote products derived from this software\r
14.\" without specific prior written permission.\r
15.\"\r
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
26.\" SUCH DAMAGE.\r
27.\"\r
28.\" @(#)ping.8 8.2 (Berkeley) 12/11/93\r
29.\" $FreeBSD: /repoman/r/ncvs/src/sbin/ping/ping.8,v 1.51 2004/04/09 19:58:34 markm Exp $\r
30.\"\r
31.Dd October 2, 2002\r
32.Dt PING 8\r
33.Os\r
34.Sh NAME\r
35.Nm ping\r
36.Nd send\r
37.Tn ICMP ECHO_REQUEST\r
38packets to network hosts\r
39.Sh SYNOPSIS\r
40.Nm\r
41.Op Fl AaDdfnoQqRrv\r
42.Op Fl c Ar count\r
43.Op Fl i Ar wait\r
44.Op Fl l Ar preload\r
45.Op Fl M Cm mask | time\r
46.Op Fl m Ar ttl\r
47.Op Fl P Ar policy\r
48.Op Fl p Ar pattern\r
49.Op Fl S Ar src_addr\r
50.Op Fl s Ar packetsize\r
51.Op Fl t Ar timeout\r
52.Op Fl z Ar tos\r
53.Ar host\r
54.Nm\r
55.Op Fl AaDdfLnoQqRrv\r
56.Op Fl c Ar count\r
57.Op Fl I Ar iface\r
58.Op Fl i Ar wait\r
59.Op Fl l Ar preload\r
60.Op Fl M Cm mask | time\r
61.Op Fl m Ar ttl\r
62.Op Fl P Ar policy\r
63.Op Fl p Ar pattern\r
64.Op Fl S Ar src_addr\r
65.Op Fl s Ar packetsize\r
66.Op Fl T Ar ttl\r
67.Op Fl t Ar timeout\r
68.Op Fl z Ar tos\r
69.Ar mcast-group\r
70.Sh DESCRIPTION\r
71The\r
72.Nm\r
73utility uses the\r
74.Tn ICMP\r
75.No protocol Ap s mandatory\r
76.Tn ECHO_REQUEST\r
77datagram to elicit an\r
78.Tn ICMP ECHO_RESPONSE\r
79from a host or gateway.\r
80.Tn ECHO_REQUEST\r
81datagrams\r
82.Pq Dq pings\r
83have an IP and\r
84.Tn ICMP\r
85header, followed by a\r
86.Dq struct timeval\r
87and then an arbitrary number of\r
88.Dq pad\r
89bytes used to fill out the packet.\r
90The options are as follows:\r
91.Bl -tag -width indent\r
92.It Fl A\r
93Audible.\r
94Output a bell\r
95.Tn ( ASCII\r
960x07)\r
97character when no packet is received before the next packet\r
98is transmitted.\r
99To cater for round-trip times that are longer than the interval\r
100between transmissions, further missing packets cause a bell only\r
101if the maximum number of unreceived packets has increased.\r
102.It Fl a\r
103Audible.\r
104Include a bell\r
105.Tn ( ASCII\r
1060x07)\r
107character in the output when any packet is received.\r
108This option is ignored\r
109if other format options are present.\r
110.It Fl c Ar count\r
111Stop after sending\r
112(and receiving)\r
113.Ar count\r
114.Tn ECHO_RESPONSE\r
115packets.\r
116If this option is not specified,\r
117.Nm\r
118will operate until interrupted.\r
119.It Fl D\r
120Set the Don't Fragment bit.\r
121.It Fl d\r
122Set the\r
123.Dv SO_DEBUG\r
124option on the socket being used.\r
125.It Fl f\r
126Flood ping.\r
127Outputs packets as fast as they come back or one hundred times per second,\r
128whichever is more.\r
129For every\r
130.Tn ECHO_REQUEST\r
131sent a period\r
132.Dq .\&\r
133is printed, while for every\r
134.Tn ECHO_REPLY\r
135received a backspace is printed.\r
136This provides a rapid display of how many packets are being dropped.\r
137Only the super-user may use this option.\r
138.Bf -emphasis\r
139This can be very hard on a network and should be used with caution.\r
140.Ef\r
141.It Fl I Ar iface\r
142Source multicast packets with the given interface address.\r
143This flag only applies if the ping destination is a multicast address.\r
144.It Fl i Ar wait\r
145Wait\r
146.Ar wait\r
147seconds\r
148.Em between sending each packet .\r
149The default is to wait for one second between each packet.\r
150The wait time may be fractional, but only the super-user may specify\r
151values less than 1 second.\r
152This option is incompatible with the\r
153.Fl f\r
154option.\r
155.It Fl L\r
156Suppress loopback of multicast packets.\r
157This flag only applies if the ping destination is a multicast address.\r
158.It Fl l Ar preload\r
159If\r
160.Ar preload\r
161is specified,\r
162.Nm\r
163sends that many packets as fast as possible before falling into its normal\r
164mode of behavior.\r
165Only the super-user may use this option.\r
166.It Fl M Cm mask | time\r
167Use\r
168.Dv ICMP_MASKREQ\r
169or\r
170.Dv ICMP_TSTAMP\r
171instead of\r
172.Dv ICMP_ECHO .\r
173For\r
174.Cm mask ,\r
175print the netmask of the remote machine.\r
176Set the\r
177.Va net.inet.icmp.maskrepl\r
178MIB variable to enable\r
179.Dv ICMP_MASKREPLY .\r
180For\r
181.Cm time ,\r
182print the origination, reception and transmission timestamps.\r
183.It Fl m Ar ttl\r
184Set the IP Time To Live for outgoing packets.\r
185If not specified, the kernel uses the value of the\r
186.Va net.inet.ip.ttl\r
187MIB variable.\r
188.It Fl n\r
189Numeric output only.\r
190No attempt will be made to lookup symbolic names for host addresses.\r
191.It Fl o\r
192Exit successfully after receiving one reply packet.\r
193.It Fl P Ar policy\r
194.Ar policy\r
195specifies IPsec policy for the ping session.\r
196For details please refer to\r
197.Xr ipsec 4\r
198and\r
199.Xr ipsec_set_policy 3 .\r
200.It Fl p Ar pattern\r
201You may specify up to 16\r
202.Dq pad\r
203bytes to fill out the packet you send.\r
204This is useful for diagnosing data-dependent problems in a network.\r
205For example,\r
206.Dq Li \-p ff\r
207will cause the sent packet to be filled with all\r
208ones.\r
209.It Fl Q\r
210Somewhat quiet output.\r
211.No Don Ap t\r
212display ICMP error messages that are in response to our query messages.\r
213Originally, the\r
214.Fl v\r
215flag was required to display such errors, but\r
216.Fl v\r
217displays all ICMP error messages.\r
218On a busy machine, this output can be overbearing.\r
219Without the\r
220.Fl Q\r
221flag,\r
222.Nm\r
223prints out any ICMP error messages caused by its own ECHO_REQUEST\r
224messages.\r
225.It Fl q\r
226Quiet output.\r
227Nothing is displayed except the summary lines at startup time and\r
228when finished.\r
229.It Fl R\r
230Record route.\r
231Includes the\r
232.Tn RECORD_ROUTE\r
233option in the\r
234.Tn ECHO_REQUEST\r
235packet and displays\r
236the route buffer on returned packets.\r
237Note that the IP header is only large enough for nine such routes;\r
238the\r
239.Xr traceroute 8\r
240command is usually better at determining the route packets take to a\r
241particular destination.\r
242If more routes come back than should, such as due to an illegal spoofed\r
243packet, ping will print the route list and then truncate it at the correct\r
244spot.\r
245Many hosts ignore or discard the\r
246.Tn RECORD_ROUTE\r
247option.\r
248.It Fl r\r
249Bypass the normal routing tables and send directly to a host on an attached\r
250network.\r
251If the host is not on a directly-attached network, an error is returned.\r
252This option can be used to ping a local host through an interface\r
253that has no route through it\r
254(e.g., after the interface was dropped by\r
255.Xr routed 8 ) .\r
256.It Fl S Ar src_addr\r
257Use the following IP address as the source address in outgoing packets.\r
258On hosts with more than one IP address, this option can be used to\r
259force the source address to be something other than the IP address\r
260of the interface the probe packet is sent on.\r
261If the IP address\r
262is not one of this machine's interface addresses, an error is\r
263returned and nothing is sent.\r
264.It Fl s Ar packetsize\r
265Specify the number of data bytes to be sent.\r
266The default is 56, which translates into 64\r
267.Tn ICMP\r
268data bytes when combined\r
269with the 8 bytes of\r
270.Tn ICMP\r
271header data.\r
272.It Fl T Ar ttl\r
273Set the IP Time To Live for multicasted packets.\r
274This flag only applies if the ping destination is a multicast address.\r
275.It Fl t Ar timeout\r
276Specify a timeout, in seconds, before ping exits regardless of how\r
277many packets have been received.\r
278.It Fl v\r
279Verbose output.\r
280.Tn ICMP\r
281packets other than\r
282.Tn ECHO_RESPONSE\r
283that are received are listed.\r
284.It Fl z Ar tos\r
285Use the specified type of service.\r
286.El\r
287.Pp\r
288When using\r
289.Nm\r
290for fault isolation, it should first be run on the local host, to verify\r
291that the local network interface is up and running.\r
292Then, hosts and gateways further and further away should be\r
293.Dq pinged .\r
294Round-trip times and packet loss statistics are computed.\r
295If duplicate packets are received, they are not included in the packet\r
296loss calculation, although the round trip time of these packets is used\r
297in calculating the round-trip time statistics.\r
298When the specified number of packets have been sent\r
299(and received)\r
300or if the program is terminated with a\r
301.Dv SIGINT ,\r
302a brief summary is displayed, showing the number of packets sent and\r
303received, and the minimum, mean, maximum, and standard deviation of\r
304the round-trip times.\r
305.Pp\r
306If\r
307.Nm\r
308receives a\r
309.Dv SIGINFO\r
310(see the\r
311.Cm status\r
312argument for\r
313.Xr stty 1 )\r
314signal, the current number of packets sent and received, and the\r
315minimum, mean, and maximum of the round-trip times will be written to\r
316the standard error output.\r
317.Pp\r
318This program is intended for use in network testing, measurement and\r
319management.\r
320Because of the load it can impose on the network, it is unwise to use\r
321.Nm\r
322during normal operations or from automated scripts.\r
323.Sh ICMP PACKET DETAILS\r
324An IP header without options is 20 bytes.\r
325An\r
326.Tn ICMP\r
327.Tn ECHO_REQUEST\r
328packet contains an additional 8 bytes worth of\r
329.Tn ICMP\r
330header followed by an arbitrary amount of data.\r
331When a\r
332.Ar packetsize\r
333is given, this indicated the size of this extra piece of data\r
334(the default is 56).\r
335Thus the amount of data received inside of an IP packet of type\r
336.Tn ICMP\r
337.Tn ECHO_REPLY\r
338will always be 8 bytes more than the requested data space\r
339(the\r
340.Tn ICMP\r
341header).\r
342.Pp\r
343If the data space is at least eight bytes large,\r
344.Nm\r
345uses the first eight bytes of this space to include a timestamp which\r
346it uses in the computation of round trip times.\r
347If less than eight bytes of pad are specified, no round trip times are\r
348given.\r
349.Sh DUPLICATE AND DAMAGED PACKETS\r
350The\r
351.Nm\r
352utility will report duplicate and damaged packets.\r
353Duplicate packets should never occur when pinging a unicast address,\r
354and seem to be caused by\r
355inappropriate link-level retransmissions.\r
356Duplicates may occur in many situations and are rarely\r
357(if ever)\r
358a good sign, although the presence of low levels of duplicates may not\r
359always be cause for alarm.\r
360Duplicates are expected when pinging a broadcast or multicast address,\r
361since they are not really duplicates but replies from different hosts\r
362to the same request.\r
363.Pp\r
364Damaged packets are obviously serious cause for alarm and often\r
365indicate broken hardware somewhere in the\r
366.Nm\r
367packet's path (in the network or in the hosts).\r
368.Sh TRYING DIFFERENT DATA PATTERNS\r
369The\r
370(inter)network\r
371layer should never treat packets differently depending on the data\r
372contained in the data portion.\r
373Unfortunately, data-dependent problems have been known to sneak into\r
374networks and remain undetected for long periods of time.\r
375In many cases the particular pattern that will have problems is something\r
376that does not have sufficient\r
377.Dq transitions ,\r
378such as all ones or all zeros, or a pattern right at the edge, such as\r
379almost all zeros.\r
380It is not\r
381necessarily enough to specify a data pattern of all zeros (for example)\r
382on the command line because the pattern that is of interest is\r
383at the data link level, and the relationship between what you type and\r
384what the controllers transmit can be complicated.\r
385.Pp\r
386This means that if you have a data-dependent problem you will probably\r
387have to do a lot of testing to find it.\r
388If you are lucky, you may manage to find a file that either\r
389cannot\r
390be sent across your network or that takes much longer to transfer than\r
391other similar length files.\r
392You can then examine this file for repeated patterns that you can test\r
393using the\r
394.Fl p\r
395option of\r
396.Nm .\r
397.Sh TTL DETAILS\r
398The\r
399.Tn TTL\r
400value of an IP packet represents the maximum number of IP routers\r
401that the packet can go through before being thrown away.\r
402In current practice you can expect each router in the Internet to decrement\r
403the\r
404.Tn TTL\r
405field by exactly one.\r
406.Pp\r
407The\r
408.Tn TCP/IP\r
409specification recommends setting the\r
410.Tn TTL\r
411field for\r
412.Tn IP\r
413packets to 64, but many systems use smaller values\r
414.No ( Bx 4.3\r
415uses 30,\r
416.Bx 4.2\r
417used 15).\r
418.Pp\r
419The maximum possible value of this field is 255, and most\r
420.Ux\r
421systems set\r
422the\r
423.Tn TTL\r
424field of\r
425.Tn ICMP ECHO_REQUEST\r
426packets to 255.\r
427This is why you will find you can\r
428.Dq ping\r
429some hosts, but not reach them with\r
430.Xr telnet 1\r
431or\r
432.Xr ftp 1 .\r
433.Pp\r
434In normal operation\r
435.Nm\r
436prints the ttl value from the packet it receives.\r
437When a remote system receives a ping packet, it can do one of three things\r
438with the\r
439.Tn TTL\r
440field in its response:\r
441.Bl -bullet\r
442.It\r
443Not change it; this is what\r
444.Bx\r
445systems did before the\r
446.Bx 4.3 tahoe\r
447release.\r
448In this case the\r
449.Tn TTL\r
450value in the received packet will be 255 minus the\r
451number of routers in the round-trip path.\r
452.It\r
453Set it to 255; this is what current\r
454.Bx\r
455systems do.\r
456In this case the\r
457.Tn TTL\r
458value in the received packet will be 255 minus the\r
459number of routers in the path\r
460.Em from\r
461the remote system\r
462.Em to\r
463the\r
464.Nm Ns Em ing\r
465host.\r
466.It\r
467Set it to some other value.\r
468Some machines use the same value for\r
469.Tn ICMP\r
470packets that they use for\r
471.Tn TCP\r
472packets, for example either 30 or 60.\r
473Others may use completely wild values.\r
474.El\r
475.Sh RETURN VALUES\r
476The\r
477.Nm\r
478utility returns an exit status of zero if at least one response was\r
479heard from the specified\r
480.Ar host ;\r
481a status of two if the transmission was successful but no responses\r
482were received; or another value\r
483(from\r
484.In sysexits.h )\r
485if an error occurred.\r
486.Sh SEE ALSO\r
487.Xr netstat 1 ,\r
488.Xr ifconfig 8 ,\r
489.Xr routed 8 ,\r
490.Xr traceroute 8\r
491.Sh HISTORY\r
492The\r
493.Nm\r
494utility appeared in\r
495.Bx 4.3 .\r
496.Sh AUTHORS\r
497The original\r
498.Nm\r
499utility was written by\r
500.An Mike Muuss\r
501while at the US Army Ballistics\r
502Research Laboratory.\r
503.Sh BUGS\r
504Many Hosts and Gateways ignore the\r
505.Tn RECORD_ROUTE\r
506option.\r
507.Pp\r
508The maximum IP header length is too small for options like\r
509.Tn RECORD_ROUTE\r
510to be completely useful.\r
511.No There Ap s\r
512not much that can be done about this, however.\r
513.Pp\r
514Flood pinging is not recommended in general, and flood pinging the\r
515broadcast address should only be done under very controlled conditions.\r
516.Pp\r
517The\r
518.Fl v\r
519option is not worth much on busy hosts.\r