茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1670929 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
F09_490.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

一網情深 : [轉貼]Ping 的基礎用法

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]Ping 的基礎用法
Ping的基礎用法

ping是一個電腦網路工具,用來測試特定主機能否通過IP到達。

簡單說,就是由執行 ping 的主機送出資料給另一主機,並等待其回應,以檢查兩台主機間之網路狀況的工具。

例如,假設 A = 您的電腦,B = www.yahoo.com.tw
我利用執行cmd之後
輸入ping www.yahoo.com.tw -t
會一直重複出現測試結果。time值越低越好。

出現下列結果:
Reply from 203.84.119.112: bytes=32 time=150ms TTL=51
Request timed out
Reply from 202.43.195.12: bytes=32 time=257ms TTL=50
Reply from 202.43.195.12: bytes=32 time=56ms TTL=52
Reply from 202.43.195.12: bytes=32 time=80ms TTL=52
Reply from 202.43.195.12: bytes=32 time=150ms TTL=51
Reply from 202.43.195.12: bytes=32 time=243ms TTL=52


ping 這個程式,就是發一個封包給對方,待對方回答之後,計算兩者間隔以判斷網路狀況。
t=0:A-ping!-------------------B (A 發出 ping)
t=x:A-------------------ping!-B (ping 抵達 B)
t=y:A---------------ping!-----B (B 回應 ping)
t=z:A-ping!-------------------B (ping 回道 A)
A 便會計算從 t=0 到 t=z 的往返時間,回報 time=150ms (0.15秒).
TTL 是 Time to Live 的簡稱,封包每經過一個 host/router,TTL 就會減一。一般從 64 開始算,所以,您的 TTL=51 意思是 www.yahoo.com.tw 的回答經過了 64-51 共 13 台機器,回到您的主機。
如果您的主機發出了 ping,但卻收不到回答 (可能是封包在網路中掉了,或是 www.yahoo.com.tw 拒絕回答 ) ,那主機會回報 request timed out.

根據資料顯示,網路確定塞車。因為往返時間有一次 time=56ms,意思是機器明明做的到 56ms 的,但是有時候它花了 time=257ms,多餘的時間就是塞在半路上的時間。
另外, TTL 時間也有問題,它有時候50,有時候51,有時候52,意思是每個 ping 封包經過的路徑不同,最常見的原因就是塞車造成封包改道。
根據以上資料判斷,網路本身在塞。.

列出一個正常的 ping參考:
Reply from 209.131.36.158: bytes=32 time=211ms TTL=52
Reply from 209.131.36.158: bytes=32 time=231ms TTL=52
Reply from 209.131.36.158: bytes=32 time=254ms TTL=52
Reply from 209.131.36.158: bytes=32 time=173ms TTL=52
Reply from 209.131.36.158: bytes=32 time=195ms TTL=52
Reply from 209.131.36.158: bytes=32 time=216ms TTL=52
Reply from 209.131.36.158: bytes=32 time=237ms TTL=52
Reply from 209.131.36.158: bytes=32 time=156ms TTL=52
Reply from 209.131.36.158: bytes=32 time=178ms TTL=52

注意 TTL 很固定,代表封包從未繞道避開塞車。time 也很穩定,從未掉封包。

常用參數:
-t 
不停的ping地方主機,直到你按下Control-C。
-a
解析電腦NetBios名。
示例﹕
ping -a 203.84.219.114
Pinging iceblood.yofor.com [203.84.219.114] with 32 bytes of data:
Reply from 203.84.219.114: bytes=32 time<10ms TTL=254
Reply from 203.84.219.114: bytes=32 time<10ms TTL=254
Reply from 203.84.219.114: bytes=32 time<10ms TTL=254
Reply from 203.84.219.114: bytes=32 time<10ms TTL=254
Ping statistics for 203.84.219.114:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

從上面就可以知道IP為203.84.219.114的電腦NetBios名為w2.rc.vip.sg1.yahoo.com。
-n.
發送count指定的Echo資料包數。
一般ping都只發送四個資料包,通過這個命令可以自己定義發送的個數,對衡量網路速度很有幫助,比如我想測試發送50個資料包的返回的平均時間為多少,最快時間為多少,最慢時間為多少就可以通過以下獲知﹕
示例﹕
ping -n 50 202.103.96.68
Pinging 202.103.96.68 with 32 bytes of data:
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Request timed out.
………………
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Reply from 202.103.96.68: bytes=32 time=50ms TTL=241
Ping statistics for 202.103.96.68:
Packets: Sent = 50, Received = 48, Lost = 2 (4% loss),Approximate round trip times in milli-seconds:
Minimum = 40ms, Maximum = 51ms, Average = 46ms

從以上我就可以知道在給202.103.96.68發送50個資料包的過程當中,返回了48個,其中有兩個由於未知原因丟失,這48個資料包當中返回速度最快為40ms,最慢為51ms,平均速度為46ms。

原文出處:Ping的基礎用法 @ 采奕資訊股份有限公司 :: 隨意窩 Xuite日誌
前一個主題 | 下一個主題 | | | |

討論串




Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|