xref: /csrg-svn/sbin/ping/ping.8 (revision 65103)
161530Sbostic.\" Copyright (c) 1985, 1991, 1993
261530Sbostic.\"	The Regents of the University of California.  All rights reserved.
338645Sbostic.\"
443795Strent.\" %sccs.include.redist.man%
538645Sbostic.\"
6*65103Smckusick.\"     @(#)ping.8	8.2 (Berkeley) 12/11/93
738645Sbostic.\"
847463Scael.Dd
947463Scael.Dt PING 8
1047463Scael.Os BSD 4.3
1147463Scael.Sh NAME
1247463Scael.Nm ping
1347463Scael.Nd send
1447463Scael.Tn ICMP ECHO_REQUEST
1547463Scaelpackets to network hosts
1647463Scael.Sh SYNOPSIS
1747463Scael.Nm ping
1847463Scael.Op Fl dfnqrvR
1947463Scael.Op Fl c Ar count
2047463Scael.Op Fl i Ar wait
2147463Scael.Op Fl l Ar preload
2247463Scael.Op Fl p Ar pattern
2347463Scael.Op Fl s Ar packetsize
2447463Scael.Sh DESCRIPTION
2547463Scael.Nm Ping
2638643Sbosticuses the
2747463Scael.Tn ICMP
2847463Scaelprotocol's mandatory
2947463Scael.Tn ECHO_REQUEST
3047463Scaeldatagram to elicit an
3147463Scael.Tn ICMP ECHO_RESPONSE
3247463Scaelfrom a host or gateway.
3347463Scael.Tn ECHO_REQUEST
3447463Scaeldatagrams (``pings'') have an IP and
3547463Scael.Tn ICMP
3647463Scaelheader,
3738645Sbosticfollowed by a
3847463Scael.Dq struct timeval
3938645Sbosticand then an arbitrary number of ``pad'' bytes used to fill out the
4038645Sbosticpacket.
4138645SbosticThe options are as follows:
4247463Scael.Bl -tag -width Ds
4347463Scael.It Fl c Ar count
4438645SbosticStop after sending (and receiving)
4547463Scael.Ar count
4647463Scael.Tn ECHO_RESPONSE
4747463Scaelpackets.
4847463Scael.It Fl d
4947463ScaelSet the
5047463Scael.Dv SO_DEBUG
5147463Scaeloption on the socket being used.
5247463Scael.It Fl f
5338645SbosticFlood ping.
5438645SbosticOutputs packets as fast as they come back or one hundred times per second,
5538645Sbosticwhichever is more.
5647463ScaelFor every
5747463Scael.Tn ECHO_REQUEST
58*65103Smckusicksent a period ``.'' is printed, while for every
5947463Scael.Tn ECHO_REPLY
6047463Scaelreceived a backspace is printed.
6138643SbosticThis provides a rapid display of how many packets are being dropped.
6238645SbosticOnly the super-user may use this option.
6347463Scael.Bf -emphasis
6447463ScaelThis can be very hard on a network and should be used with caution.
6547463Scael.Ef
6647463Scael.It Fl i Ar wait
6738645SbosticWait
6847463Scael.Ar wait
6947463Scaelseconds
7047463Scael.Em between sending each packet .
7138645SbosticThe default is to wait for one second between each packet.
7238645SbosticThis option is incompatible with the
7347463Scael.Fl f
7438645Sbosticoption.
7547463Scael.It Fl l Ar preload
7638645SbosticIf
7747463Scael.Ar preload
7838645Sbosticis specified,
7947463Scael.Nm ping
8038645Sbosticsends that many packets as fast as possible before falling into its normal
8138645Sbosticmode of behavior.
8247463Scael.It Fl n
8338645SbosticNumeric output only.
8438645SbosticNo attempt will be made to lookup symbolic names for host addresses.
8547463Scael.It Fl p Ar pattern
8638645SbosticYou may specify up to 16 ``pad'' bytes to fill out the packet you send.
8738645SbosticThis is useful for diagnosing data-dependent problems in a network.
8847463ScaelFor example,
8947463Scael.Dq Li \-p ff
9047463Scaelwill cause the sent packet to be filled with all
9138645Sbosticones.
9247463Scael.It Fl q
9338645SbosticQuiet output.
9438645SbosticNothing is displayed except the summary lines at startup time and
9538645Sbosticwhen finished.
9647463Scael.It Fl R
9738645SbosticRecord route.
9847463ScaelIncludes the
9947463Scael.Tn RECORD_ROUTE
10047463Scaeloption in the
10147463Scael.Tn ECHO_REQUEST
10247463Scaelpacket and displays
10338645Sbosticthe route buffer on returned packets.
10438645SbosticNote that the IP header is only large enough for nine such routes.
10538645SbosticMany hosts ignore or discard this option.
10647463Scael.It Fl r
10728707SkarelsBypass the normal routing tables and send directly to a host on an attached
10828707Skarelsnetwork.
10938645SbosticIf the host is not on a directly-attached network, an error is returned.
11028707SkarelsThis option can be used to ping a local host through an interface
11128707Skarelsthat has no route through it (e.g., after the interface was dropped by
11247463Scael.Xr routed 8 ) .
11347463Scael.It Fl s Ar packetsize
11438643SbosticSpecifies the number of data bytes to be sent.
11547463ScaelThe default is 56, which translates into 64
11647463Scael.Tn ICMP
11747463Scaeldata bytes when combined
11847463Scaelwith the 8 bytes of
11947463Scael.Tn ICMP
12047463Scaelheader data.
12147463Scael.It Fl v
12238645SbosticVerbose output.
12347463Scael.Tn ICMP
12447463Scaelpackets other than
12547463Scael.Tn ECHO_RESPONSE
12647463Scaelthat are received are listed.
12747463Scael.El
12847463Scael.Pp
12938645SbosticWhen using
13047463Scael.Nm ping
13138645Sbosticfor fault isolation, it should first be run on the local host, to verify
13238645Sbosticthat the local network interface is up and running.
13338645SbosticThen, hosts and gateways further and further away should be ``pinged''.
13425229SmckusickRound-trip times and packet loss statistics are computed.
13538645SbosticIf duplicate packets are received, they are not included in the packet
13638645Sbosticloss calculation, although the round trip time of these packets is used
13738645Sbosticin calculating the minimum/average/maximum round-trip time numbers.
13838645SbosticWhen the specified number of packets have been sent (and received) or
13947463Scaelif the program is terminated with a
14047463Scael.Dv SIGINT ,
14147463Scaela brief summary is displayed.
14247463Scael.Pp
14338645SbosticThis program is intended for use in network testing, measurement and
14438645Sbosticmanagement.
14538645SbosticBecause of the load it can impose on the network, it is unwise to use
14647463Scael.Nm ping
14728707Skarelsduring normal operations or from automated scripts.
14847463Scael.Sh ICMP PACKET DETAILS
14938643SbosticAn IP header without options is 20 bytes.
15047463ScaelAn
15147463Scael.Tn ICMP
15247463Scael.Tn ECHO_REQUEST
15347463Scaelpacket contains an additional 8 bytes worth
15447463Scaelof
15547463Scael.Tn ICMP
15647463Scaelheader followed by an arbitrary amount of data.
15738645SbosticWhen a
15847463Scael.Ar packetsize
15938645Sbosticis given, this indicated the size of this extra piece of data (the
16038645Sbosticdefault is 56).
16147463ScaelThus the amount of data received inside of an IP packet of type
16247463Scael.Tn ICMP
16347463Scael.Tn ECHO_REPLY
16447463Scaelwill always be 8 bytes more than the requested data space
16547463Scael(the
16647463Scael.Tn ICMP
16747463Scaelheader).
16847463Scael.Pp
16938643SbosticIf the data space is at least eight bytes large,
17047463Scael.Nm ping
17138643Sbosticuses the first eight bytes of this space to include a timestamp which
17238645Sbosticit uses in the computation of round trip times.
17338645SbosticIf less than eight bytes of pad are specified, no round trip times are
17438645Sbosticgiven.
17547463Scael.Sh DUPLICATE AND DAMAGED PACKETS
17647463Scael.Nm Ping
17738645Sbosticwill report duplicate and damaged packets.
17838643SbosticDuplicate packets should never occur, and seem to be caused by
17938643Sbosticinappropriate link-level retransmissions.
18038645SbosticDuplicates may occur in many situations and are rarely (if ever) a
18138645Sbosticgood sign, although the presence of low levels of duplicates may not
18238645Sbosticalways be cause for alarm.
18347463Scael.Pp
18438645SbosticDamaged packets are obviously serious cause for alarm and often
18538645Sbosticindicate broken hardware somewhere in the
18647463Scael.Nm ping
18738645Sbosticpacket's path (in the network or in the hosts).
18847463Scael.Sh TRYING DIFFERENT DATA PATTERNS
18938645SbosticThe (inter)network layer should never treat packets differently depending
19038645Sbosticon the data contained in the data portion.
19138643SbosticUnfortunately, data-dependent problems have been known to sneak into
19238643Sbosticnetworks and remain undetected for long periods of time.
19338643SbosticIn many cases the particular pattern that will have problems is something
19438645Sbosticthat doesn't have sufficient ``transitions'', such as all ones or all
19538645Sbosticzeros, or a pattern right at the edge, such as almost all zeros.
19638643SbosticIt isn't necessarily enough to specify a data pattern of all zeros (for
19738645Sbosticexample) on the command line because the pattern that is of interest is
19838645Sbosticat the data link level, and the relationship between what you type and
19938645Sbosticwhat the controllers transmit can be complicated.
20047463Scael.Pp
20138645SbosticThis means that if you have a data-dependent problem you will probably
20238645Sbostichave to do a lot of testing to find it.
20338643SbosticIf you are lucky, you may manage to find a file that either can't be sent
20438643Sbosticacross your network or that takes much longer to transfer than other
20538643Sbosticsimilar length files.
20638643SbosticYou can then examine this file for repeated patterns that you can test
20747463Scaelusing the
20847463Scael.Fl p
20947463Scaeloption of
21047463Scael.Nm ping .
21147463Scael.Sh TTL DETAILS
21247463ScaelThe
21347463Scael.Tn TTL
21447463Scaelvalue of an IP packet represents the maximum number of IP routers
21538643Sbosticthat the packet can go through before being thrown away.
21638645SbosticIn current practice you can expect each router in the Internet to decrement
21747463Scaelthe
21847463Scael.Tn TTL
21947463Scaelfield by exactly one.
22047463Scael.Pp
22147463ScaelThe
22247463Scael.Tn TCP/IP
22347463Scaelspecification states that the
22447463Scael.Tn TTL
22547463Scaelfield for
22647463Scael.Tn TCP
22747463Scaelpackets should
22847463Scaelbe set to 60, but many systems use smaller values (4.3
22947463Scael.Tn BSD
23047463Scaeluses 30, 4.2 used
23138643Sbostic15).
23247463Scael.Pp
23338643SbosticThe maximum possible value of this field is 255, and most Unix systems set
23447463Scaelthe
23547463Scael.Tn TTL
23647463Scaelfield of
23747463Scael.Tn ICMP ECHO_REQUEST
23847463Scaelpackets to 255.
23938645SbosticThis is why you will find you can ``ping'' some hosts, but not reach them
24038645Sbosticwith
24147463Scael.Xr telnet 1
24238645Sbosticor
24347463Scael.Xr ftp 1 .
24447463Scael.Pp
24538643SbosticIn normal operation ping prints the ttl value from the packet it receives.
24638643SbosticWhen a remote system receives a ping packet, it can do one of three things
24747463Scaelwith the
24847463Scael.Tn TTL
24947463Scaelfield in its response:
25047463Scael.Bl -bullet
25147463Scael.It
25247463ScaelNot change it; this is what Berkeley Unix systems did before the
25347463Scael.Bx 4.3 tahoe
25438645Sbosticrelease.
25547463ScaelIn this case the
25647463Scael.Tn TTL
25747463Scaelvalue in the received packet will be 255 minus the
25838643Sbosticnumber of routers in the round-trip path.
25947463Scael.It
26038645SbosticSet it to 255; this is what current Berkeley Unix systems do.
26147463ScaelIn this case the
26247463Scael.Tn TTL
26347463Scaelvalue in the received packet will be 255 minus the
26438645Sbosticnumber of routers in the path
26547463Scael.Xr from
26638645Sbosticthe remote system
26747463Scael.Em to
26838645Sbosticthe
26947463Scael.Nm ping Ns Em ing
27038645Sbostichost.
27147463Scael.It
27238643SbosticSet it to some other value.
27347463ScaelSome machines use the same value for
27447463Scael.Tn ICMP
27547463Scaelpackets that they use for
27647463Scael.Tn TCP
27747463Scaelpackets, for example either 30 or 60.
27838643SbosticOthers may use completely wild values.
27947463Scael.El
28047463Scael.Sh BUGS
28147463ScaelMany Hosts and Gateways ignore the
28247463Scael.Tn RECORD_ROUTE
28347463Scaeloption.
28447463Scael.Pp
28547463ScaelThe maximum IP header length is too small for options like
28647463Scael.Tn RECORD_ROUTE
28747463Scaelto
28838645Sbosticbe completely useful.
28938645SbosticThere's not much that that can be done about this, however.
29047463Scael.Pp
29138645SbosticFlood pinging is not recommended in general, and flood pinging the
29238645Sbosticbroadcast address should only be done under very controlled conditions.
29347463Scael.Sh SEE ALSO
29447463Scael.Xr netstat 1 ,
29547463Scael.Xr ifconfig 8 ,
29647463Scael.Xr routed 8
29747463Scael.Sh HISTORY
29847463ScaelThe
29947463Scael.Nm
30047463Scaelcommand appeared in
30147463Scael.Bx 4.3 .
302