大网数据广告活动
服务器运维问答

How is the number of routers between source and destination known beforehand?

· 52CE 我爱测

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 …

问题原文

原帖链接 · eesweng · CC BY-SA 4.0

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?

已采纳解答

原帖链接 · fthinker · CC BY-SA 4.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。