Traceroute (tracert) implementation principle

Source: Internet
Author: User

Traceroute (tracert) implementation principle 2008.11.4

The implementation of the traceroute program mainly involves the use of the time to live (TTL) field of the IP header.

The TTL field is set to prevent endless flow of data in the network due to incorrect routing or other software and hardware reasons. The TTL field specifies the TTL of the data. The initial value of TTL is set by the source host. When a data packet passes through the router, the router that processes the data packet must subtract the TTL value from the number of seconds that the data packet stays in the router. But in fact, most routers simply reduce the TTL value by 1, so the TTL field is eventually implemented as a hop counter. When the value of the TTL field is reduced to 0, the router will not forward the datagram, but discard it and generate an ICMP timeout error message sent to the source host to notify the occurrence of the error. The key to the traceroute program is that the source address of the returned ICMP timeout error message is the IP address passing through the router. By increasing the value of the TTL field in turn, you can obtain the route information of a datagram on its transmission path.

The traceroute program sendsEcho Request)Message, And the IP header TTL field value is increased repeatedly. At the beginning, TTL is equal to 1. In this way, when the first vro arrives, the TTL value is reduced to 0, resulting in a timeout error. Therefore, the vro generates a copy.ICMP timeout error messageReturn to the source host. Then, the host sendsThe TTL value increases by 1.So that IP packets can be transmitted to the next vro. The next vro will generate an ICMP timeout error message and return it to the source host. Repeat this process until the datagram arrives at the final destination host. At this time, the destination host will returnEcho Replay)Message. In this way, the source host only needs to parse each returned ICMP packet, and can grasp the routing information of the datagram on the way from the source host to the target host.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.