The Internet, that is, the Internet, is the largest computer network in the world, or more precisely, a network of networks. It consists of tens of thousands of local area networks and millions of computers all over the world, and communicates between networks through the
TCP/IP protocol for heterogeneous networks. In the Internet, information is transmitted from one end to another through many segments of transmission media and devices (routers, switches, servers, gateways, etc.) in the network. Each device connected to the Internet, such as a host, router, access server, etc., generally has an independent IP address. Through Traceroute we can know what path the information takes from your computer to the host on the other end of the Internet. Of course, each time the data packet travels from the same source to the same destination, the path may be different, but basically the route taken is the same most of the time. In UNIX systems, we call it Traceroute, and in MS Windows it is Tracert. Traceroute measures how long it takes by sending small packets to the destination device until it returns. Each device on a path Traceroute needs to be tested 3 times. The output includes the time (ms) for each test and the name of the device (if any) and its IP address.
In most cases, as a network engineer or system administrator, under the UNIX host system, directly execute the command line:
Traceroute [parameter options] hostname (hostname can be a domain name or an ip address)
tracert of windows
C:\>tracert
Parameter descriptions:
tracert [-d] [-h maximum_hops] [-j computer-list] [-w timeout] target_name
This diagnostic utility works by sending Internet Control Message Protocol (CMP) with different time-to-live (TL) to the destination Reply messages to determine the route to the destination. Each router on the path must reduce its TTL value by at least 1 before forwarding the ICMP response, so the TTL is a valid hop count. When the TTL value of the packet is reduced to 0, the router sends back ICMP timeout information to the source system. Tracert can determine the route by sending the first reply with a TTL of 1 and incrementing the TTL value by 1 each time in subsequent transmissions until the target responds or the maximum TTL value is reached. Routers can be identified by examining the ICMP timeout (ime Exceeded) messages sent back by intermediate routers. Note that some routers "quietly" discard packets with expired time-to-live (TLS) and have no effect on tracert.
Parameters:
-d Specifies not to resolve addresses for computer names.
-h maximum_hops specifies the maximum number of hops to find the target.
-jcomputer-list Specifies loose source routing in computer-list.
-w timeout Wait the number of milliseconds specified by timeout for each reply.
target_name The name of the target computer, which can be a domain name or an IP address.
The above ip address comes from: http://www.ip2location.com/
linux之traceroute
The command parameters of
Traceroute: The usage of Traceroute is: Traceroute [options] <IP-address or domain-name> [data size]
The content of [options] is:
-d Use socket-level debugging.
-f<live value> Set the size of the live value TTL of the first detection packet.
-F Set the do not leave bit.
-g<gateway> Set source routing gateway, up to 8 can be set.
-i <network interface> Send packets using the specified network interface.
-I Use ICMP responses instead of UDP data messages.
-m<survival value> Set the maximum survival value TTL size of the detection packet.
-n Use the IP address directly instead of the hostname.
-p <communication port> Set the communication port of the UDP transport protocol. (default is 33434)
-q Set the number of TTL tests (default is 3)
-r Ignore the ordinary Routing Table and send the data packet directly to the remote host.
-s<source address> Set the IP address of the data packet sent by the local host.
-t <service type> Set the TOS value of the detection packet.
-v Displays the execution process of the command in detail.
-w<timeout seconds> Set the time to wait for the remote host to report back.
-x Enables or disables correctness checking of packets.
[data size]: The data byte length of each test packet (default is 38)
Because my vps system is CentOS, but the traceroute software is not installed, I need to install it myself
[root@localhost ~]# traceroute //没有这个命令
-bash: traceroute: command not found
Traceroute最简单的基本用法是:traceroute hostname
Traceroute程序的设计是利用ICMP及IP header的TTL(Time To Live)栏位(field)。首先,traceroute送出一个TTL是1的IP datagram(其实,每次送出的为3个40字节的包,包括源地址,目的地址和包发出的时间标签)到目的地,探测包是UDP格式,由于我们不想目的主机处理它们,因此目的端口设置为一个不可能的值。当路径上的第一个路由器(router)收到这个datagram时,它将TTL减1。此时,TTL变为0了,所以该路由器会将此datagram丢掉,并送回一个「ICMP time exceeded」消息(包括发IP包的源地址,IP包的所有内容及路由器的IP地址),traceroute 收到这个消息后,便知道这个路由器存在于这个路径上,接着traceroute 再送出另一个TTL是2 的datagram,发现第2 个路由器...... traceroute 每次将送出的datagram的TTL 加1来发现另一个路由器,这个重复的动作一直持续到某个datagram 抵达目的地。当datagram到达目的地后,该主机并不会送回ICMP time exceeded消息,因为它已是目的地了,那么traceroute如何得知目的地到达了呢?
Traceroute在送出UDP datagrams到目的地时,它所选择送达的port number 是一个一般应用程序都不会用的号码(30000 以上),所以当此UDP datagram 到达目的地后该主机会送回一个「ICMP port unreachable」的消息,而当traceroute 收到这个消息时,便知道目的地已经到达了。所以traceroute 在Server端也是没有所谓的Daemon 程式。
Traceroute提取发 ICMP TTL到期消息设备的IP地址并作域名解析。每次 ,Traceroute都打印出一系列数据,包括所经过的路由设备的域名及 IP地址,三个包每次来回所花时间。
Traceroute有一个固定的时间等待响应(ICMP TTL到期消息)。如果这个时间过了,它将打印出一系列的*号表明:在这个路径上,这个设备不能在给定的时间内发出ICMP TTL到期消息的响应。然后,Traceroute给TTL记数器加1,继续进行。
以上部分内容转自:http://yp.oss.org.cn/software/show_resource.php?resource_id=1057
(三)什么是Traceroute网关—Traceroute Gateway
一般使用Traceroute(或者是Tracert)是基于一台主机的,但是通常您只能知道以手边的主机为源地址到互联网络上任意一台在线的主机的路由连接质量以及数据传输效率的情况,而使用基于WEB的方式,只要一台主机安装了特定的CGI程序,用户就可以通过这台主机运行相关的程序,执行Traceroute的功能。这台主机我们把它叫做Traceroute网关。Traceroute网关可以帮助用户了解网络的物理与逻辑连接的拓扑情况以及数据传输的效率。如果这种网关足够多,我们就可以方便地了解到各主机之间连接的情况了。
(四)为什么要使用Traceroute?
1.几乎每一个网上人(尤其是Webmaster)对他们的计算机(或其它设备)与Internet的连接,路由(径),连通时间,速度等都很关心。使用由ChianNetMap组织起来的各地区Webmaster提供的Traceroute网关的服务,将给你一个满意的答案。从你的计算机到任何别的地方,ChinaNetMap(Traceroute)都能提供其间的每个设备(IP地址)及其连通时间。它可以让你画出通过网络的路径。
2.许多公司和单位都设有或正在设立自己的服务器-尤其是Web服务器。一旦有自己的Web服务器,随着网民数量的日益增加(包括潜在的,没法统计的网民),
你一定很想知道是否他们都能与你连接。你的ISP如何与一个或多个NAP连接,以及他们的连接效率会直接影响到你的连接质量.
3.在选择ISP,骨干网连接,你站点的主机时,大多数有见识的网民喜欢检查该Site的连接性能及其它是怎样精确的与谁连,连到哪儿。ChinaNetMap(Traceroute)将给你一个完美的答案。
(五)将来Traceroute实现的算法
下面讨论一下Traceroute将来的实现方法,详细信息参考RFC1393。目前Quidway系列路由器上Traceroute应用实现的方法仍然是上面所讲的方法。
将来要定义一个新的IP Traceroute选项,这样源站发出一个数据包(TTL为指定的缺省值,而不是1、2...),就可以使各个路由器返回一个新定义的ICMP Traceroute消息给源站,通过这种方式,只需通过n + 1个数据包,源站就可以记录下它发送出去的数据包所经过的路由器。
?
Number(选项号)18 ( F + C + Number = 82 )
?