1-3、ping 和tracert 命令的使用_第1张图片

1-3、ping 和tracert 命令的使用_第2张图片

C:\>ping 192.168.0.1

Pinging 192.168.0.1 with 32 bytes of data:
Reply from 192.168.0.1: bytes=32 time=12ms TTL=64
Reply from 192.168.0.1: bytes=32 time=12ms TTL=64
Reply from 192.168.0.1: bytes=32 time=5ms TTL=64
Reply from 192.168.0.1: bytes=32 time=2ms TTL=64

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

C:\>

TTL有3个值,64 , 128 , 255
对应的OS linux , windows, router
其实这是不准确的,可以修改注册表的值来改变TTL的值

C:\>ping www.baidu.com

Pinging www.a.shifen.com [14.215.177.39] with 32 bytes of data:
Reply from 14.215.177.39: bytes=32 time=10ms TTL=54
Reply from 14.215.177.39: bytes=32 time=10ms TTL=54
Reply from 14.215.177.39: bytes=32 time=10ms TTL=54
Reply from 14.215.177.39: bytes=32 time=16ms TTL=54

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

C:\>

ping www.baidu.com 其TTL值是54 ,64-54=10 ,所以我的这个电脑访问百度经过了10个路由器

可以用tracert来验证其是不是经过10个路由器,从以下结果可以知道是经过10路由器,但是不包含最后一个路由器的。
C:\>tracert www.baidu.com

Tracing route to www.a.shifen.com [14.215.177.39]
over a maximum of 30 hops:

1 2 ms 1 ms 9 ms 192.168.0.1
2 7 ms 3 ms 1 ms 192.168.1.1
3 6 ms 9 ms 11 ms 100.64.0.1
4 7 ms 4 ms 7 ms 113.106.42.53
5 9 ms 5 ms 7 ms 17.107.38.59.broad.fs.gd.dynamic.163data.com.cn [59.38.107.17]
6 20 ms 4 ms 16 ms 202.105.158.73
7 13 ms 14 ms 26 ms 113.96.4.66
8 Request timed out.
9 10 ms 8 ms 20 ms 14.29.121.202
10
Request timed out.
11 23 ms 7 ms 8 ms 14.215.177.39

Trace complete.