xref: /csrg-svn/sbin/ping/ping.8 (revision 47463)
1*47463Scael.\" Copyright (c) 1985, 1991 The Regents of the University of California.
238645Sbostic.\" All rights reserved.
338645Sbostic.\"
443795Strent.\" %sccs.include.redist.man%
538645Sbostic.\"
6*47463Scael.\"     @(#)ping.8	6.7 (Berkeley) 03/16/91
738645Sbostic.\"
8*47463Scael.Dd
9*47463Scael.Dt PING 8
10*47463Scael.Os BSD 4.3
11*47463Scael.Sh NAME
12*47463Scael.Nm ping
13*47463Scael.Nd send
14*47463Scael.Tn ICMP ECHO_REQUEST
15*47463Scaelpackets to network hosts
16*47463Scael.Sh SYNOPSIS
17*47463Scael.Nm ping
18*47463Scael.Op Fl dfnqrvR
19*47463Scael.Op Fl c Ar count
20*47463Scael.Op Fl i Ar wait
21*47463Scael.Op Fl l Ar preload
22*47463Scael.Op Fl p Ar pattern
23*47463Scael.Op Fl s Ar packetsize
24*47463Scael.Sh DESCRIPTION
25*47463Scael.Nm Ping
2638643Sbosticuses the
27*47463Scael.Tn ICMP
28*47463Scaelprotocol's mandatory
29*47463Scael.Tn ECHO_REQUEST
30*47463Scaeldatagram to elicit an
31*47463Scael.Tn ICMP ECHO_RESPONSE
32*47463Scaelfrom a host or gateway.
33*47463Scael.Tn ECHO_REQUEST
34*47463Scaeldatagrams (``pings'') have an IP and
35*47463Scael.Tn ICMP
36*47463Scaelheader,
3738645Sbosticfollowed by a
38*47463Scael.Dq struct timeval
3938645Sbosticand then an arbitrary number of ``pad'' bytes used to fill out the
4038645Sbosticpacket.
4138645SbosticThe options are as follows:
4228707SkarelsOther options are:
43*47463Scael.Bl -tag -width Ds
44*47463Scael.It Fl c Ar count
4538645SbosticStop after sending (and receiving)
46*47463Scael.Ar count
47*47463Scael.Tn ECHO_RESPONSE
48*47463Scaelpackets.
49*47463Scael.It Fl d
50*47463ScaelSet the
51*47463Scael.Dv SO_DEBUG
52*47463Scaeloption on the socket being used.
53*47463Scael.It Fl f
5438645SbosticFlood ping.
5538645SbosticOutputs packets as fast as they come back or one hundred times per second,
5638645Sbosticwhichever is more.
57*47463ScaelFor every
58*47463Scael.Tn ECHO_REQUEST
59*47463Scaelsent a period ``.'' is printed, while for ever
60*47463Scael.Tn ECHO_REPLY
61*47463Scaelreceived a backspace is printed.
6238643SbosticThis provides a rapid display of how many packets are being dropped.
6338645SbosticOnly the super-user may use this option.
64*47463Scael.Bf -emphasis
65*47463ScaelThis can be very hard on a network and should be used with caution.
66*47463Scael.Ef
67*47463Scael.It Fl i Ar wait
6838645SbosticWait
69*47463Scael.Ar wait
70*47463Scaelseconds
71*47463Scael.Em between sending each packet .
7238645SbosticThe default is to wait for one second between each packet.
7338645SbosticThis option is incompatible with the
74*47463Scael.Fl f
7538645Sbosticoption.
76*47463Scael.It Fl l Ar preload
7738645SbosticIf
78*47463Scael.Ar preload
7938645Sbosticis specified,
80*47463Scael.Nm ping
8138645Sbosticsends that many packets as fast as possible before falling into its normal
8238645Sbosticmode of behavior.
83*47463Scael.It Fl n
8438645SbosticNumeric output only.
8538645SbosticNo attempt will be made to lookup symbolic names for host addresses.
86*47463Scael.It Fl p Ar pattern
8738645SbosticYou may specify up to 16 ``pad'' bytes to fill out the packet you send.
8838645SbosticThis is useful for diagnosing data-dependent problems in a network.
89*47463ScaelFor example,
90*47463Scael.Dq Li \-p ff
91*47463Scaelwill cause the sent packet to be filled with all
9238645Sbosticones.
93*47463Scael.It Fl q
9438645SbosticQuiet output.
9538645SbosticNothing is displayed except the summary lines at startup time and
9638645Sbosticwhen finished.
97*47463Scael.It Fl R
9838645SbosticRecord route.
99*47463ScaelIncludes the
100*47463Scael.Tn RECORD_ROUTE
101*47463Scaeloption in the
102*47463Scael.Tn ECHO_REQUEST
103*47463Scaelpacket and displays
10438645Sbosticthe route buffer on returned packets.
10538645SbosticNote that the IP header is only large enough for nine such routes.
10638645SbosticMany hosts ignore or discard this option.
107*47463Scael.It Fl r
10828707SkarelsBypass the normal routing tables and send directly to a host on an attached
10928707Skarelsnetwork.
11038645SbosticIf the host is not on a directly-attached network, an error is returned.
11128707SkarelsThis option can be used to ping a local host through an interface
11228707Skarelsthat has no route through it (e.g., after the interface was dropped by
113*47463Scael.Xr routed 8 ) .
114*47463Scael.It Fl s Ar packetsize
11538643SbosticSpecifies the number of data bytes to be sent.
116*47463ScaelThe default is 56, which translates into 64
117*47463Scael.Tn ICMP
118*47463Scaeldata bytes when combined
119*47463Scaelwith the 8 bytes of
120*47463Scael.Tn ICMP
121*47463Scaelheader data.
122*47463Scael.It Fl v
12338645SbosticVerbose output.
124*47463Scael.Tn ICMP
125*47463Scaelpackets other than
126*47463Scael.Tn ECHO_RESPONSE
127*47463Scaelthat are received are listed.
128*47463Scael.El
129*47463Scael.Pp
13038645SbosticWhen using
131*47463Scael.Nm ping
13238645Sbosticfor fault isolation, it should first be run on the local host, to verify
13338645Sbosticthat the local network interface is up and running.
13438645SbosticThen, hosts and gateways further and further away should be ``pinged''.
13525229SmckusickRound-trip times and packet loss statistics are computed.
13638645SbosticIf duplicate packets are received, they are not included in the packet
13738645Sbosticloss calculation, although the round trip time of these packets is used
13838645Sbosticin calculating the minimum/average/maximum round-trip time numbers.
13938645SbosticWhen the specified number of packets have been sent (and received) or
140*47463Scaelif the program is terminated with a
141*47463Scael.Dv SIGINT ,
142*47463Scaela brief summary is displayed.
143*47463Scael.Pp
14438645SbosticThis program is intended for use in network testing, measurement and
14538645Sbosticmanagement.
14638645SbosticBecause of the load it can impose on the network, it is unwise to use
147*47463Scael.Nm ping
14828707Skarelsduring normal operations or from automated scripts.
149*47463Scael.Sh ICMP PACKET DETAILS
15038643SbosticAn IP header without options is 20 bytes.
151*47463ScaelAn
152*47463Scael.Tn ICMP
153*47463Scael.Tn ECHO_REQUEST
154*47463Scaelpacket contains an additional 8 bytes worth
155*47463Scaelof
156*47463Scael.Tn ICMP
157*47463Scaelheader followed by an arbitrary amount of data.
15838645SbosticWhen a
159*47463Scael.Ar packetsize
16038645Sbosticis given, this indicated the size of this extra piece of data (the
16138645Sbosticdefault is 56).
162*47463ScaelThus the amount of data received inside of an IP packet of type
163*47463Scael.Tn ICMP
164*47463Scael.Tn ECHO_REPLY
165*47463Scaelwill always be 8 bytes more than the requested data space
166*47463Scael(the
167*47463Scael.Tn ICMP
168*47463Scaelheader).
169*47463Scael.Pp
17038643SbosticIf the data space is at least eight bytes large,
171*47463Scael.Nm ping
17238643Sbosticuses the first eight bytes of this space to include a timestamp which
17338645Sbosticit uses in the computation of round trip times.
17438645SbosticIf less than eight bytes of pad are specified, no round trip times are
17538645Sbosticgiven.
176*47463Scael.Sh DUPLICATE AND DAMAGED PACKETS
177*47463Scael.Nm Ping
17838645Sbosticwill report duplicate and damaged packets.
17938643SbosticDuplicate packets should never occur, and seem to be caused by
18038643Sbosticinappropriate link-level retransmissions.
18138645SbosticDuplicates may occur in many situations and are rarely (if ever) a
18238645Sbosticgood sign, although the presence of low levels of duplicates may not
18338645Sbosticalways be cause for alarm.
184*47463Scael.Pp
18538645SbosticDamaged packets are obviously serious cause for alarm and often
18638645Sbosticindicate broken hardware somewhere in the
187*47463Scael.Nm ping
18838645Sbosticpacket's path (in the network or in the hosts).
189*47463Scael.Sh TRYING DIFFERENT DATA PATTERNS
19038645SbosticThe (inter)network layer should never treat packets differently depending
19138645Sbosticon the data contained in the data portion.
19238643SbosticUnfortunately, data-dependent problems have been known to sneak into
19338643Sbosticnetworks and remain undetected for long periods of time.
19438643SbosticIn many cases the particular pattern that will have problems is something
19538645Sbosticthat doesn't have sufficient ``transitions'', such as all ones or all
19638645Sbosticzeros, or a pattern right at the edge, such as almost all zeros.
19738643SbosticIt isn't necessarily enough to specify a data pattern of all zeros (for
19838645Sbosticexample) on the command line because the pattern that is of interest is
19938645Sbosticat the data link level, and the relationship between what you type and
20038645Sbosticwhat the controllers transmit can be complicated.
201*47463Scael.Pp
20238645SbosticThis means that if you have a data-dependent problem you will probably
20338645Sbostichave to do a lot of testing to find it.
20438643SbosticIf you are lucky, you may manage to find a file that either can't be sent
20538643Sbosticacross your network or that takes much longer to transfer than other
20638643Sbosticsimilar length files.
20738643SbosticYou can then examine this file for repeated patterns that you can test
208*47463Scaelusing the
209*47463Scael.Fl p
210*47463Scaeloption of
211*47463Scael.Nm ping .
212*47463Scael.Sh TTL DETAILS
213*47463ScaelThe
214*47463Scael.Tn TTL
215*47463Scaelvalue of an IP packet represents the maximum number of IP routers
21638643Sbosticthat the packet can go through before being thrown away.
21738645SbosticIn current practice you can expect each router in the Internet to decrement
218*47463Scaelthe
219*47463Scael.Tn TTL
220*47463Scaelfield by exactly one.
221*47463Scael.Pp
222*47463ScaelThe
223*47463Scael.Tn TCP/IP
224*47463Scaelspecification states that the
225*47463Scael.Tn TTL
226*47463Scaelfield for
227*47463Scael.Tn TCP
228*47463Scaelpackets should
229*47463Scaelbe set to 60, but many systems use smaller values (4.3
230*47463Scael.Tn BSD
231*47463Scaeluses 30, 4.2 used
23238643Sbostic15).
233*47463Scael.Pp
23438643SbosticThe maximum possible value of this field is 255, and most Unix systems set
235*47463Scaelthe
236*47463Scael.Tn TTL
237*47463Scaelfield of
238*47463Scael.Tn ICMP ECHO_REQUEST
239*47463Scaelpackets to 255.
24038645SbosticThis is why you will find you can ``ping'' some hosts, but not reach them
24138645Sbosticwith
242*47463Scael.Xr telnet 1
24338645Sbosticor
244*47463Scael.Xr ftp 1 .
245*47463Scael.Pp
24638643SbosticIn normal operation ping prints the ttl value from the packet it receives.
24738643SbosticWhen a remote system receives a ping packet, it can do one of three things
248*47463Scaelwith the
249*47463Scael.Tn TTL
250*47463Scaelfield in its response:
251*47463Scael.Bl -bullet
252*47463Scael.It
253*47463ScaelNot change it; this is what Berkeley Unix systems did before the
254*47463Scael.Bx 4.3 tahoe
25538645Sbosticrelease.
256*47463ScaelIn this case the
257*47463Scael.Tn TTL
258*47463Scaelvalue in the received packet will be 255 minus the
25938643Sbosticnumber of routers in the round-trip path.
260*47463Scael.It
26138645SbosticSet it to 255; this is what current Berkeley Unix systems do.
262*47463ScaelIn this case the
263*47463Scael.Tn TTL
264*47463Scaelvalue in the received packet will be 255 minus the
26538645Sbosticnumber of routers in the path
266*47463Scael.Xr from
26738645Sbosticthe remote system
268*47463Scael.Em to
26938645Sbosticthe
270*47463Scael.Nm ping Ns Em ing
27138645Sbostichost.
272*47463Scael.It
27338643SbosticSet it to some other value.
274*47463ScaelSome machines use the same value for
275*47463Scael.Tn ICMP
276*47463Scaelpackets that they use for
277*47463Scael.Tn TCP
278*47463Scaelpackets, for example either 30 or 60.
27938643SbosticOthers may use completely wild values.
280*47463Scael.El
281*47463Scael.Sh BUGS
282*47463ScaelMany Hosts and Gateways ignore the
283*47463Scael.Tn RECORD_ROUTE
284*47463Scaeloption.
285*47463Scael.Pp
286*47463ScaelThe maximum IP header length is too small for options like
287*47463Scael.Tn RECORD_ROUTE
288*47463Scaelto
28938645Sbosticbe completely useful.
29038645SbosticThere's not much that that can be done about this, however.
291*47463Scael.Pp
29238645SbosticFlood pinging is not recommended in general, and flood pinging the
29338645Sbosticbroadcast address should only be done under very controlled conditions.
294*47463Scael.Sh SEE ALSO
295*47463Scael.Xr netstat 1 ,
296*47463Scael.Xr ifconfig 8 ,
297*47463Scael.Xr routed 8
298*47463Scael.Sh HISTORY
299*47463ScaelThe
300*47463Scael.Nm
301*47463Scaelcommand appeared in
302*47463Scael.Bx 4.3 .
303