
_START_ARTICLE_
Ping
_START_PARAGRAPH_
ping是一种电脑网络工具，用来测试数据包能否透过IP协议到达特定主机。ping的运作原理是向目标主机传出一个ICMP的请求回显数据包，并等待接收回显回应数据包。程序会按时间和成功响应的次数估算丢失数据包率（丢包率）和数据包往返时间（网络时延，Round-trip delay time）。_NEWLINE_在1983年12月，Mike Muuss编写了首个这样的程序，用于在IP网络出现问题时方便探查其根源。因为这个程序的运作原理与潜水艇的主动声纳相似，他便用声纳的声音来为程序取名。David L. Mills曾提出另一个取名：Packet Internet Grouper/Gopher（后者指地鼠）。_NEWLINE_网络管理员之间也常将ping用作动词，如“ping一下计算机XXX，看它是否开着。”
_START_SECTION_
Linux系统下的示例
_START_PARAGRAPH_
具有iputils的Linux系统内的ping：_NEWLINE_root@localhost:~# ping www.wikipedia.org_NEWLINE_PING www.wikipedia.org (198.35.26.96): 56(84) data bytes64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=1 ttl=53 time=198.6 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=2 ttl=53 time=199.2 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=3 ttl=53 time=198.5 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=4 ttl=53 time=199.2 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=5 ttl=53 time=198.5 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=6 ttl=53 time=199.2 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=7 ttl=53 time=198.6 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=8 ttl=53 time=199.3 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=9 ttl=53 time=198.7 ms64 bytes from text-lb.ulsfo.wikimedia.org (198.35.26.96): seq=10 ttl=53 time=198.4 ms^C--- www.wikipedia.org ping statistics ---10 packets transmitted, 10 received, 0% packet loss, time 9021msrtt min/avg/max/mdev = 198.402/198.866/199.334/1.536 ms_NEWLINE_有时在ping的返回信息里面会显示“DUP!”，表明存在环路，例如：_NEWLINE_64 bytes from 10.0.0.1: icmp_seq=10 ttl=62 time=10.2 ms64 bytes from 10.0.0.1: icmp_seq=10 ttl=62 time=11.8 ms (DUP!)64 bytes from 10.0.0.1: icmp_seq=10 ttl=62 time=12.6 ms (DUP!)64 bytes from 10.0.0.1: icmp_seq=10 ttl=62 time=13.2 ms (DUP!)64 bytes from 10.0.0.1: icmp_seq=11 ttl=62 time=11.9 ms64 bytes from 10.0.0.1: icmp_seq=11 ttl=62 time=13.3 ms (DUP!)64 bytes from 10.0.0.1: icmp_seq=11 ttl=62 time=14.3 ms (DUP!)64 bytes from 10.0.0.1: icmp_seq=12 ttl=62 time=12.1 ms
_START_SECTION_
Windows系统下的示例
_START_PARAGRAPH_
Windows XP内置的ping：_NEWLINE_C:\> ping www.google.com_NEWLINE_Pinging www.l.google.com [64.233.183.103] with 32 bytes of data:Reply from 64.233.183.103: bytes=32 time=25ms TTL=245Reply from 64.233.183.103: bytes=32 time=22ms TTL=245Reply from 64.233.183.103: bytes=32 time=25ms TTL=246Reply from 64.233.183.103: bytes=32 time=22ms TTL=246Ping statistics for 64.233.183.103:    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:    Minimum = 22ms, Maximum = 25ms, Average = 23ms_NEWLINE_其中_NEWLINE_Pinging www.l.google.com [64.233.183.103] with 32 bytes of data:_NEWLINE_www.google.com是www.l.google.com DNS别名，IP地址是64.233.183.103。以32 bytes大小测试，可以以-l（Windows）参数更改，大小是1-65500_NEWLINE_Reply from 64.233.183.103: bytes=32 time=25ms TTL=245Reply from 64.233.183.103: bytes=32 time=22ms TTL=245Reply from 64.233.183.103: bytes=32 time=25ms TTL=246Reply from 64.233.183.103: bytes=32 time=22ms TTL=246_NEWLINE_反应时间25毫秒，TTL（Time To Live）值为245_NEWLINE_由上来看，到google通过255-245 = 10个路由_NEWLINE_Ping statistics for 64.233.183.103:    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:    Minimum = 22ms, Maximum = 25ms, Average = 23ms_NEWLINE_总计，最小22ms，最大25ms，平均23ms