ping ,time,TTL詳解

一,什麼是ping

PING (Packet Internet Grope),因特網包探索器,用於測試網絡連接量的程序。Ping發送一個ICMP回聲請求消息給目的地並報告是否收到所希望的ICMP回聲應答。他是怎麼工作的呢,看下圖

ping ,time,TTL詳解

                                                             

二,什麼是TTl

TTL:生存時間
  指定數據包被路由器丟棄之前允許通過的網段數量。
  TTL 是由發送主機設置的,以防止數據包不斷在 IP 互聯網絡上永不終止地循環。轉發 IP 數據包時,要求路由器至少將 TTL 減小 1。
使用PING時涉及到的 ICMP 報文類型:
  一個爲ICMR請求回顯(ICMP Echo Request)
  一個爲ICMP回顯應答(ICMP Echo Reply)
TTL 字段值可以幫助我們識別操作系統類型。
  UNIX 及類 UNIX 操作系統 ICMP 回顯應答的 TTL 字段值爲 255
  Compaq Tru64 5.0 ICMP 回顯應答的 TTL 字段值爲 64
  微軟 Windows NT/2K操作系統 ICMP 回顯應答的 TTL 字段值爲 128
  微軟 Windows 95 操作系統 ICMP 回顯應答的 TTL 字段值爲 32
  當然,返回的TTL值是相同的
  但有些情況下有所特殊
  LINUX Kernel 2.2.x & 2.4.x ICMP 回顯應答的 TTL 字段值爲 64
  FreeBSD 4.1, 4.0, 3.4;
  Sun Solaris 2.5.1, 2.6, 2.7, 2.8;
  OpenBSD 2.6, 2.7,
  NetBSD
  HP UX 10.20
  ICMP 回顯應答的 TTL 字段值爲 255
  Windows 95/98/98SE
  Windows ME
  ICMP 回顯應答的 TTL 字段值爲 32
  Windows NT4 WRKS
  Windows NT4 Server
  Windows 2000
  Windows XP
  ICMP 回顯應答的 TTL 字段值爲 128
  這樣,我們就可以通過這種方法來辨別操作系統

三,舉例說明

C:\Documents and Settings>ping blog.51yip.com

Pinging blog.51yip.com [173.201.152.6] with 32 bytes of data:

Reply from 173.201.152.6: bytes=32 time=257ms TTL=45
Reply from 173.201.152.6: bytes=32 time=256ms TTL=45
Reply from 173.201.152.6: bytes=32 time=262ms TTL=45
Reply from 173.201.152.6: bytes=32 time=258ms TTL=45

Ping statistics for 173.201.152.6:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 256ms, Maximum = 262ms, Average = 258ms

由此我們可以斷定,blog.51yip.com是一臺linux主機,經過了64-45=19次中轉後到達本機,time=257ms,這個時間是一次請求的時間,這個時間越小,說明速度越快,越大說明速度越慢。

ping 127.0.0.1

Pinging 127.0.0.1 with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

在這裏的TTL=128是表示二個意思:

1,請求主機是一臺WINDOWS系統的電腦

2,並且沒有經過路由中轉,也就是請求的是本機。每次請求的時間呢,小於百萬份之一秒。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章