mtr工具——“my traceroute”,原名“Matt’s traceroute”,是为最初开发它的人(Matt Kimball, 1997年)设计的——在某种程度上就像traceroute和ping的结合,它提供的数据比这两个命令加起来还要多。
像ping和traceroute一样,mtr使用icmp包来测试连接。虽然traceroute很可能安装在您使用的每个Unix系统上,但您可能必须单独安装mtr。如果你这样做,这里有一些命令:
- Ubuntu或Debian Systems:apt-get安装mtr
- Fedora或CentOS:YUM安装MTR
- Mac OS X:Brew Install MTR
- FreeBSD:PKG安装网/地铁
与Traceroute一样,MTR使用TTL(时间到实时值),以便它可以单独地报告路线的每条腿。它通过将TTL设置为1,然后2,然后3等来实现这一点。每次,它会收集到远程系统之旅的下一条腿的往返时间。例如,当它将TTL设置为2时,它会获得第二腿的定时信息。在每个连接时,路由器将TTL递减一个(这是路由器始终做的)。在最终设备处,它变为0并且追踪不再进一步。相反,在每个其他设备上发生一次“ICMP TTL超过”事件,将最后一次设备的测量发送回源,并完成报告。
延迟(往返)测量是接收到ICMP应答时的时间戳减去发射探测时的时间戳。
默认情况下,Traceroute发出三个探针aper hop,因此您将看到三个数字在Traceroute输出中的每台跳数。
下面是一些traceroute的输出示例:
$ traceroute world.pts.com traceroute到world.pts.com(192.74.137.5),30啤波Max,40字节包1 PIX(192.168.0.2)0.255 ms 0.478 ms 0.443 ms 2 * * * * 3 gig1-6.umcp-core.net.doz.org(136.160.255.33)9.856 ms 9.343 ms 9.822 ms 4 ten2-0.stpaul-core.net.doz.org(136.160.255.198)3.401 ms 3.858 ms 3.681 ms 5 te4-3.ccr01.bwi01.atlas.cogentco.com(38.104.12.17)2.920 ms 2.859 ms 3.280 ms 6 te4-2.cr01.phl01.atlas.cogentco.com(154.54.2.174)5.965 MS 5.945 MS 5.920 MS 7 TE0-0-0-7.cr22.jfk02.atlas.cogentco.com(154.54.31.53)9.084 MS TE0-0-0-7.CCR21。jfk02.atlas.cogentco.com(154.54.1.41)8.811 ms te0-0-0-7.cr22.jfk02.atlas.cogentco。COM(154.54.31.53)8.784 ms 8 be2096.ccr22.bos01.atlas.cogentco.com(154.54.30.42)14.991 ms be2094.ccr21.bos01 .atlas.cogentco.com(154.54.30.14)14.764 ms be2096.cr22.bos01.atlas.cogentco.com(154.54.30.42)14.964 ms 9 te4-1.mag02.bos01.atlas.cogentco.com(154.54.43.70)14.478 MS TE4-1.MAG01.BOS01。Atlas.cogentco.com(154.54.43.50)14.201 ms 14.171 ms 10 gi0-0-0-0.nr11.b000502-0.bos01.atlas.cogentco.com(154.24.6.237)14.891 MS 16.941 MS 16.702 MS 11cogent.bos.ma.towerstream.com(38.104.186.82)14.699 ms 14.188 ms 14.220 ms 12 g6-2.cr.bos1.ma.towerstream.com(64.119.143.81)14.904 MS 14.903 MS 14.888 MS 13 69.38.149.18(69.38.149.18)18.293 MS 34.857 MS 33.138 MS 14 64.119.19.154(64.119.137.154)33.122 MS 36.814 MS 36.329 MS 15 WLOWE.PTS.com(192.74.137.15)34.369 MS 34.567 MS 29.696 MS
mtr命令与traceroute有几个不同之处。首先,与top一样,它提供了一个值表,每秒钟刷新一次,允许您查看值是如何随时间更新的。您可以通过向该命令提供-i或-interval参数,并指定每次更新之间需要传递的秒数来降低此速度。
它还向您展示了Ping的数据包丢失。
MTR命令也向您展示路线中每个腿的许多统计信息。输出中的列(参见下面的示例)表示:
- 发送的报文数
- 每个跳丢失的数据包丢失% - 可以使用-report-cycles =##替换为您要发送的数据包数
- 最后发送的数据包的最后延迟
- Avg-average延迟
- 最短的往返
- WRST - 最长的往返旅行
- STDEV标准偏差
最后,AVG,最好和WRST都以毫秒为单位提供
My traceroute [v0.71] boson.xyz.org (0.0.0.0) Sun Aug 31 16:22:55 2014 Keys: Help Display mode重启统计字段顺序quit Packets ping Host Loss% Last Avg Best Wrst StDev192.168.0.1 50.0% 0.4 0.4 0.4 0.4 0.0 2。? ?3.gig1-6.umcp-core.net.dozz.org 0.0% 1.6 4.0 1.6 6.6 2.5 4。10 . ten2-0.stpaul- core.net.dozz.org 0.0% 2.7 2.8 2.8 2.8 2.8 0.1Te4-3.ccr01.bwi01.atlas.cogentco.com 0.0% 91.5 32.3 2.7 91.5 51.2Te4-2.ccr01.phl01.atlas.cogentco.com 0.0% 5.6 11.6 5.6 23.4 10.2 7。Te0-0-0-19.mpd21.jfk02.atlas.cogentco.com 0.0% 8.8 8.7 8.7 8.8 0.1 8。Be2095.ccr21.bos01.atlas.cogentco.com 0.0% 14.14.4 14.3 14.0.1 9。 te4-1.mag01.bos01.atlas.cogentco.com 0.0% 14.1 14.2 14.1 14.3 0.1 10. gi0-0-0-0.nr11.b000502-0.bos01.atlas.com 0.0% 14.7 14.6 14.6 14.7 0.1 11. cogent.bos.ma.towerstream.com 0.0% 14.1 14.1 14.1 14.1 0.1 12. g6-2.cr.bos1.ma.towerstream.com 0.0% 14.8 14.8 14.8 14.8 0.0 13. 69.38.149.18 0.0% 24.0 26.9 24.0 29.7 4.1 14. 64.119.137.154 0.0% 28.5 28.5 28.5 28.5 0.0 15. world.pts.com 0.0% 23.3 22.2 21.1 23.3 1.5
另一个常用的mtr命令是使用-r或-report命令。这将为您提供一个静态报告(而不是每秒更新一次)。相反,它会运行10次迭代(或使用-c (count)或-report-cycles选项告诉它的任何内容,并在最后显示结果。
你可以用下面的语法请求一个报告:
MTR -report
$ mtr world.pt.com -report boson.xyz.org Snt: 10 Loss% Last Avg Best Wrst StDev pix 50.0% 0.4 0.4 0.4 0.4 0.0 ??100.0 0.0 0.0 0.0 0.0 0.0 gig1 - 6. - umcp - core.net.doz.org 0.0% 12.6 4.0 1.5 12.6 - 3.6 ten2 - 0. - stpaul - core.net.doz.org 0.0% 8.2 5.3 2.7 13.0 - 4.1 te4 0.0% 2.9 33.4 2.6 139.2 - 52.1 - 3. - ccr01.bwi01.atlas.cogentco.com ccr01.phl01.atlas.cogentco.com te4 - 2. - 0.0% 5.7 52.9 5.5 201.2 74.9 te0 - 0 - 0 - 0.0% 8.5 8.6 8.5 8.7 - 0.1 19. - mpd21.jfk02.atlas.cogentco.comBe2095.ccr21.bos01.atlas.cogentco.com 0.0% 14.4 14.6 14.3 15.0 0.2 te4-1.mag01.bos01.atlas.cogentco.com 0.0% 14.5 28.5 14.0 157.2 45.2 gi0-0-0-0.nr11.b000502-0.bos01.atlas。cogentc cogent.bos.ma.towerstream.com 0.0% 0.0% 15.0 14.8 14.7 15.1 0.2 14.1 27.0 14.0 136.0 38.4 cr.bos1.ma.towerstream.com g6 - 2. - 0.0% 15.9 15.0 14.8 15.9 0.3 69.38.149.18 0.0% 22.6 23.5 18.3 34.2 4.7 world.pts.com 64.119.137.154 10.0% 23.0 25.4 19.6 32.0 4.7 21.9 23.7 19.2 29.9 3.6 0.0%
两个数据包丢失和延迟都告诉您连接的质量。大量损失将表示特定路由器的问题。注意在上面的第二行,我们看到100%的损失。这条路由器没有将任何东西发送回给我们,尽管这并不意味着它不是一个功能路由器。显然,连接正在到达最终目的地。但路由器可能不允许ICMP流量返回到源或花费太长。这 ???表示超时。您看到的一些损失可能是由于路由器上的速率限制设置。
一些使用MTR用于故障排除网络连接的人建议您在两个方向上运行报告,如果要完全诊断您的连接问题。