⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ping.texi

📁 压缩包中包含LINUX下多个命令的源码
💻 TEXI
字号:
@node ping@chapter ping@cindex ping@command{Ping} uses the ICMP protocol's mandatory ECHO_REQUEST datagram toelicit an ICMP ECHO_RESPONSE from a host or gateway.  ECHO_REQUEST datagrams(``pings'') have an IP and ICMP header, followed by a ``struct timeval''and then an arbitrary number of ``pad'' bytes used to fill out the packet.@section InvokingThe options are as follows:@table @samp@item --echo@opindex --echoSend ICMP_ECHO requests (default).@item --address@opindex --addressSend ICMP_ADDRESS packets.@item --timestamp@opindex --ntimestampSend ICMP_TIMESTAMP packets.@item --router@opindex --routerSend ICMP_ROUTERDISCOVERY packets.@item -c @var{N}@item --count=@var{N}@opindex -c@opindex --countStop after sending (and receiving) count ECHO_RESPONSE packets.@item -d@itemx -debug@opindex -d@opindex --debugSet the SO_DEBUG option on the socket being used.@item -i @var{N}@itemx --interval=@var{N}@opindex -i@opindex --intervalWait N seconds between sending each packet. The default is towait for one second between each packet.  This option is incompatiblewith the -f option.@item -n@itemx --numeric@opindex -n@opindex --numericNumeric output only.  No attempt will be made to lookup symbolicnames for host addresses.@item -r@itemx --ignore-routing@opindex -r@opindex --nignore-routingo-klogBypass the normal routing tables and send directly to a host onan attached network.  If the host is not on a directly-attachednetwork, an error is returned.  This option can be used to ping alocal host through an interface that has no route through it(e.g., after the interface was dropped by routed(8)).@item -v@itemx --verbose@opindex -v@opindex --verboseVerbose output.  ICMP packets other than ECHO_RESPONSE that arereceived are listed.@item -f@itemx --flood@opindex -f@opindex --floodFlood ping.  Outputs packets as fast as they come back or onehundred times per second, whichever is more.  For everyECHO_REQUEST sent a period ``.'' is printed, while for everyECHO_REPLY received a backspace is printed.  This provides arapid display of how many packets are being dropped.  Only thesuper-user may use this option.  This can be very hard on a networkand should be used with caution.@item -l @var{N}@item --preload=@var{N}@opindex -l@opindex --preloadIf N is specified, ping sends that many packets as fast aspossible before falling into its normal mode of behavior.@item -p @var{PAT}@itemx --pattern=@var{PAT}@opindex -p@opindex --patternYou may specify up to 16 ``pad'' bytes to fill out the packet yousend.  This is useful for diagnosing data-dependent problems in anetwork.  For example, ``-p ff'' will cause the sent packet to befilled with all ones.@item -q@itemx --quiet@opindex -q@opindex --quietQuiet output.  Nothing is displayed except the summary lines atstartup time and when finished.@item -R@itemx --route@opindex -R@opindex --routeRecord route.  Includes the RECORD_ROUTE option in theECHO_REQUEST packet and displays the route buffer on returnedpackets.  Note that the IP header is only large enough for ninesuch routes.  Many hosts ignore or discard this option.@item -s @var{N}@itemx --size=@var{N}@opindex -s@opindex --sizeSpecifies the number of data bytes to be sent.  The default is56, which translates into 64 ICMP data bytes when combined withthe 8 bytes of ICMP header data.@end tableWhen using ping for fault isolation, it should first be run on the localhost, to verify that the local network interface is up and running.Then, hosts and gateways further and further away should be ``pinged''.Round-trip times and packet loss statistics are computed.  If duplicatepackets are received, they are not included in the packet loss calculation,although the round trip time of these packets is used in calculating theminimum/average/maximum round-trip time numbers.  When the speci-fied number of packets have been sent (and received) or if the program isterminated with a SIGINT, a brief summary is displayed.This program is intended for use in network testing, measurement and man-agement.  Because of the load it can impose on the network, it is unwiseto use ping during normal operations or from automated scripts.@section ICMP Packet DetailsAn IP header without options is 20 bytes.  An ICMP ECHO_REQUEST packetcontains an additional 8 bytes worth of ICMP header followed by an arbitraryamount of data.  When a packetsize is given, this indicated thesize of this extra piece of data (the default is 56).  Thus the amount ofdata received inside of an IP packet of type ICMP ECHO_REPLY will alwaysbe 8 bytes more than the requested data space (the ICMP header).If the data space is at least eight bytes large, ping uses the firsteight bytes of this space to include a timestamp which it uses in thecomputation of round trip times.  If less than eight bytes of pad arespecified, no round trip times are given.@section Duplicate And Damaged PacketsPing will report duplicate and damaged packets.  Duplicate packets shouldnever occur, and seem to be caused by inappropriate link-levelretransmissions.  Duplicates may occur in many situations and are rarely(if ever) a good sign, although the presence of low levels of duplicates maynot always be cause for alarm.Damaged packets are obviously serious cause for alarm and often indicatebroken hardware somewhere in the ping packet's path (in the network or inthe hosts).@section Trying Different Data PatternsThe (inter)network layer should never treat packets differently dependingon the data contained in the data portion.  Unfortunately, data-dependentproblems have been known to sneak into networks and remain undetected forlong periods of time.  In many cases the particular pattern that willhave problems is something that doesn't have sufficient ``transitions'',such as all ones or all zeros, or a pattern right at the edge, such asalmost all zeros.  It isn't necessarily enough to specify a data patternof all zeros (for example) on the command line because the pattern thatis of interest is at the data link level, and the relationship betweenwhat you type and what the controllers transmit can be complicated.This means that if you have a data-dependent problem you will probablyhave to do a lot of testing to find it.  If you are lucky, you may manageto find a file that either can't be sent across your network or thattakes much longer to transfer than other similar length files.  You canthen examine this file for repeated patterns that you can test using the-p option of ping.@section TTL DetailsThe TTL value of an IP packet represents the maximum number of IP routersthat the packet can go through before being thrown away.  In currentpractice you can expect each router in the Internet to decrement the TTLfield by exactly one.The TCP/IP specification states that the TTL field for TCP packets shouldbe set to 60, but many systems use smaller values (4.3 BSD uses 30, 4.2used 15).The maximum possible value of this field is 255, and most Unix systemsset the TTL field of ICMP ECHO_REQUEST packets to 255.  This is why youwill find you can ``ping'' some hosts, but not reach them with telnet(1)or ftp(1).In normal operation ping prints the ttl value from the packet it receives.When a remote system receives a ping packet, it can do one ofthree things with the TTL field in its response:@table @bullet@itemNot change it; this is what Berkeley Unix systems did before the4.3BSD-Tahoe release.  In this case the TTL value in the receivedpacket will be 255 minus the number of routers in the round-trippath.@itemSet it to 255; this is what current Berkeley Unix systems do.  Inthis case the TTL value in the received packet will be 255 minus thenumber of routers in the path from the remote system to the pinginghost.@itemSet it to some other value.  Some machines use the same value forICMP packets that they use for TCP packets, for example either 30 or60.  Others may use completely wild values.@end tableMany Hosts and Gateways ignore the RECORD_ROUTE option.The maximum IP header length is too small for options like RECORD_ROUTEto be completely useful.  There's not much that that can be done aboutthis, however.Flood pinging is not recommended in general, and flood pinging the broadcastaddress should only be done under very controlled conditions.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -