# TTL

TTl=time to live

PING的实现过程很简单，命令将引发IP层发送一个简单的IP包，而目的方收到这个包之后，将源和目的地址做一下交换，重新发出这个包即可，当然还要加一些超时的机制。

TTL在一定程度上反应了一个IP数据包经过的路由器的多少，但是也不完全是这样，因为数据包在网络上传播的时候，其传播时间和带宽有一定关系，有时候协议会把传播时间的长短折合在TTL里，能比较客观的反应网络的状况。

D:/Documents and Settings/hx>ping 61.152.93.131

Pinging 61.152.93.131 with 32 bytes of data:

Reply from 61.152.93.131: bytes=32 time=21ms TTL=118
Reply from 61.152.93.131: bytes=32 time=19ms TTL=118
Reply from 61.152.93.131: bytes=32 time=18ms TTL=118
Reply from 61.152.93.131: bytes=32 time=22ms TTL=118

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

D:/Documents and Settings/hx>ping 61.152.104.40

Pinging 61.152.104.40 with 32 bytes of data:

Reply from 61.152.104.40: bytes=32 time=28ms TTL=54
Reply from 61.152.104.40: bytes=32 time=18ms TTL=54
Reply from 61.152.104.40: bytes=32 time=18ms TTL=54
Reply from 61.152.104.40: bytes=32 time=13ms TTL=54

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

，理由一样64-54=10。

1，不是说包可能走很多路径吗，为什么我看到的4个包TTL都是一样的，没有出现不同？

2，对于上面例子第二台机器，为什么不认为它是经过了74个节点的Windows机器？因为128-74=54。

D:/Documents and Settings/hx>tracert 61.152.104.40

Tracing route to 61.152.104.40 over a maximum of 30 hops

1 13 ms 16 ms 9 ms 10.120.32.1
2 9 ms 9 ms 11 ms 219.233.244.105
3 12 ms 10 ms 10 ms 219.233.238.173
4 15 ms 15 ms 17 ms 219.233.238.13
5 14 ms 19 ms 19 ms 202.96.222.73
6 14 ms 17 ms 13 ms 202.96.222.121
7 14 ms 15 ms 14 ms 61.152.81.86
8 15 ms 14 ms 13 ms 61.152.87.162
9 16 ms 16 ms 28 ms 61.152.99.26
10 12 ms 13 ms 18 ms 61.152.99.94
11 14 ms 18 ms 16 ms 61.152.104.40

Trace complete.

D:/Documents and Settings/hx>ping 61.152.104.40 -i 11

Pinging 61.152.104.40 with 32 bytes of data:

Reply from 61.152.104.40: bytes=32 time=10ms TTL=54
Reply from 61.152.104.40: bytes=32 time=13ms TTL=54
Reply from 61.152.104.40: bytes=32 time=10ms TTL=54
Reply from 61.152.104.40: bytes=32 time=13ms TTL=54

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

D:/Documents and Settings/hx>

D:/Documents and Settings/hx>ping 61.152.104.40 -i 10

Pinging 61.152.104.40 with 32 bytes of data:

Reply from 61.152.99.94: TTL expired in transit.
Reply from 61.152.99.94: TTL expired in transit.
Reply from 61.152.99.94: TTL expired in transit.
Reply from 61.152.99.94: TTL expired in transit.

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

D:/Documents and Settings/hx>

，当TTL减为0时设备会丢弃包并发送一个TTL过期的ICMP反馈给源地址，这里的结果就是最好的证明。

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120