traceroute命令详解和使用例子

通过traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径。当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不一样,但基本上来说大部分时候所走的路由是相同的linux系统中,我们称之为traceroute,在MS Windows中为tracert。 traceroute通过发送小的数据包到目的设备直到其返回,来测量其需要多长时间。一条路径上的每个设备traceroute要测3次。输出结果中包括每次测试的时间(ms)和设备的名称(如有的话)及其IP地址。
在大多数情况下,在linux主机系统下,直接执行命令行:traceroute hostname
而在Windows系统下是执行tracert的命令: tracert hostname
1.命令格式:
traceroute[参数][主机]
2.命令功能:
traceroute指令让你追踪网络数据包的路由途径,预设数据包大小是40Bytes,用户可另行设置。
具体参数格式:traceroute [-dFlnrvx][-f<存活数值>][-g<网关>...][-i<网络界面>][-m<存活数值>][-p<通信端口>][-s<来源地址>][-t<服务类型>][-w<超时秒数>][主机名称或IP地址][数据包大小]
3.命令参数:
-d 使用Socket层级的排错功能。
-f 设置第一个检测数据包的存活数值TTL的大小。
-F 设置勿离断位。
-g 设置来源路由网关,最多可设置8个。
-i 使用指定的网络界面送出数据包。
-I 使用ICMP回应取代UDP资料信息。
-m 设置检测数据包的最大存活数值TTL的大小。
-n 直接使用IP地址而非主机名称。
-p 设置UDP传输协议的通信端口。
-r 忽略普通的Routing Table,直接将数据包送到远端主机上。
-s 设置本地主机送出数据包的IP地址。
-t 设置检测数据包的TOS数值。
-v 详细显示指令的执行过程。
-w 设置等待远端主机回报的时间。
-x 开启或关闭数据包的正确性检验。
4.使用实例:
实例1:traceroute 用法简单、最常用的用法
# traceroute www.baidu.com 
DDU ICMP controls consist of 3 controls : TDDUOSPING - A non blocking PING protocolTDDUOSTRACEROUTE - A non blocking TraceRoute ProtocolTDDUOSDNS - A non blocking ARP/RARP controlAbout TDDUOSDNS :Host names are resolved to IP addresses, and IP address can be resolved to host names. If you enter an IP into the ADDRESS property, the HOST property will be completed, and the OnHostLookup event will occur. If you enter an IP or a HOST name into the HOST property, the ADDRESS property will be completed, and the OnAddressLookup event will occure. The runtime property OK can be queried to see if the lookup was successful. To reduce lookup overhead, an IP/Hostname cache can be used by setting the UseIPCache property to true. The cache is only persistent for the current session, and maynot be saved between sessions. You can use FlushIPCache method to clear the cache.When combined with the other controls in this package, the delay normally associated with connecting a socket can be avoided. Each control must have a unique TDDUOSDNS control.About the Demo :The demo project shows how to use each control. The TDDUOSDNS control is shown both in combination with other controls, and used independantly. DNS not an ICMP protocol, but it is included to prevent the windows application from blocking.Blocking is when your windows program stops responding to messages, waiting for a call to return. Normally, all calls blocks for a very short time, and is not noticable - but when you have to wait for 5 or 10 seconds or even longer, the application can appear to be crashed. By using threads, callback messages, and events, I have illustrated how it is possible to avoid blocking in an application.These controls form a custom set of TCP/IP controls I have been developing over the past year. The ICMP controls were written over the period of a week, and I consulted several references for information. I would like to thank Quinn Shute for his excellent book "Windows Socket Network Programming&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值