本頁使用了標題或全文手工轉換

ping

維基百科,自由的百科全書
前往: 導覽搜尋

ping是一種電腦網路工具,用來測試封包能否通過IP協定到達特定主機。ping的運作原理是向目標主機傳出一個ICMP echo@要求封包,並等待接收echo回應封包。程式會按時間和成功響應的次數估算遺失封包率(丟包率)和封包往返時間(網路時延,Round-trip delay time)。

在1983年12月,Mike Muuss編寫了首個這樣的程式,用於在IP網路出現問題時方便探查其根源。因為這個程式的運作原理與潛水艇主動聲納相似,他便用聲納的聲音來為程式取名。David L. Mills曾提出另一個取名:Packet Internet Grouper/Gopher(後者指地鼠)。

網路管理員之間也常將ping用作動詞,如「ping一下電腦X,看他是否開著。」

例子[編輯]

Linux 系統下的範例[編輯]

具有iputils的Linux系統內的ping:

 root@localhost# ping en.wikipedia.org
 PING rr.pmtpa.wikimedia.org (66.230.200.100) 56(84) bytes of data.
 64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=1 ttl=52 time=87.7 ms
 64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=2 ttl=52 time=95.6 ms
 64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=3 ttl=52 time=85.4 ms
 64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=4 ttl=52 time=95.8 ms
 64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=5 ttl=52 time=87.0 ms
 64 bytes from rr.pmtpa.wikimedia.org (66.230.200.100): icmp_seq=6 ttl=52 time=97.6 ms
 
 --- rr.pmtpa.wikimedia.org ping statistics ---
 10 packets transmitted, 10 received, 0% packet loss, time 8998ms
 rtt min/avg/max/mdev = 78.162/89.213/97.695/6.836 ms

有時在ping的返回條目裡面顯示的有「DUP!」,表明存在環路,例如:

64 bytes from 10.*.*.*: icmp_seq=10 ttl=62 time=10 ms
64 bytes from 10.*.*.*: icmp_seq=10 ttl=62 time=11 ms (DUP!)
64 bytes from 10.*.*.*: icmp_seq=10 ttl=62 time=12 ms (DUP!)
64 bytes from 10.*.*.*: icmp_seq=10 ttl=62 time=13 ms (DUP!)
64 bytes from 10.*.*.*: icmp_seq=11 ttl=62 time=10 ms
64 bytes from 10.*.*.*: icmp_seq=11 ttl=62 time=13 ms (DUP!)
64 bytes from 10.*.*.*: icmp_seq=11 ttl=62 time=14 ms (DUP!)
64 bytes from 10.*.*.*: icmp_seq=11 ttl=62 time=19 ms (DUP!)

Windows系統下的範例[編輯]

Windows XP內置的ping:

C:\>ping www.google.com
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=245
Reply from 64.233.183.103: bytes=32 time=22ms TTL=245
Reply from 64.233.183.103: bytes=32 time=25ms TTL=246
Reply from 64.233.183.103: bytes=32 time=22ms TTL=246
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

其中

Pinging www.l.google.com [64.233.183.103] with 32 bytes of data:

www.google.comwww.l.google.com DNS別名,IP位址是64.233.183.103。 以 32 bytes 大小測試,可以以-l(Windows)參數更改,大小是1-65500

Reply from 64.233.183.103: bytes=32 time=25ms TTL=245
Reply from 64.233.183.103: bytes=32 time=22ms TTL=245
Reply from 64.233.183.103: bytes=32 time=25ms TTL=246
Reply from 64.233.183.103: bytes=32 time=22ms TTL=246

反應時間25毫秒,TTL(Time To Live)值為245 由上來看,到 google 通過 255-245 = 10 個路由

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

總計,最小 22ms ,最大 25ms,平均 23ms

相關條目[編輯]

外部連結[編輯]