I was studying Computer Networking book of Kurose and Ross and under Traceroute subsection I've read following:

More specifically, suppose there are N - 1 routers between the source and the destination. Then the source will send N special packets into the network, with each packet addressed to the ultimate destination. These N special packets are marked 1 through N, with the first packet marked 1 and the last packet marked N. When the nth router receives the nth packet marked n, the router does not forward the packet toward its destination, but instead sends a message back to the source.

I'd thought route of a packet is determined depending on the traffic and other factors while it travels from source to destination. So, I thought number of routers that a packet passes through may change from time to time.

But from the quote, I understand that number of routers between source and destination is known before a packet travels from source to destination. If that is the case, how this number is known by the source? If not, can someone explain this routing phenomena to me?


You are right in your original line of thinking. The number of hops is not known before hand and can indeed change. You are taking the quote a bit too literally, i.e incorrectly understanding that there is literally a packet marked N that the nth router receives and also somehow knows itself as the nth router. Not your fault, as the quote is confusing.

In a traceroute ICMP packets are sent out with a TTL (time to live) field that times out on the first, then second, then ... nth hop. At each hop when a time out occurs, a ICMP Time Exceeded message is sent back to the origin (you). By gathering the progressive timeout messages you can generate the path to the target network. The nth router, which is your target, does not timeout and sends back a ICMP echo reply (when echos are used as the traceroute message medium).

Bringing it back to your quote and taken not quite so literally, the nth packet will be the last message sent out by you, which ultimately reaches the target, after you have generated the path up to that point - for the n-1 routers - by sending messages with progressively longer TTLs.

Hope that helps.

  • It helped a lot. Thank you and @HBruijn. – eesweng Aug 16 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.