1

我正在尝试为路由信息协议实现一个模拟器。我想我已经完成了大部分实现,但我不太确定当节点从不同节点接收表时使用的算法的一部分。

if 语句之一如下:

if address is known by p1 with a link of p2 then:
   if the cost for p2 is not exactly one less than p1's cost:
       act as if this address was unknown to p1

其中 p1 正在从 p2 接收表格。这是否意味着如果 p1 在其表中有地址,并且 p1 中与该地址关联的链接是到 p2 的链接,那么检查 p2 的成本是否不完全小于 p1s 成本?

谢谢

4

1 回答 1

0

Yes, that's what it means.

When p1 gets routing information about some network n from p2, it must decide whether or not to use the new route. Normally, it will use the new route (setting the link to p2) only if it is better than the route it currently knows for n. However, in the case that p2 was the gateway it already had for n -- in other words, it got the information from p2 earlier -- then it accepts the new information, even if the new cost is higher than the old cost.

This allows p2 to inform its neighbours that it has lost connectivity to some other network (by setting its cost to the RIP equivalent of infinity). If the neighbours previously relied on p2 to reach that network, they will now invalidate their routes to that network and await information from some other gateway which does have connectivity. It also allows p2 to inform its neighbours that the cost of reaching n has increased and they should use a cheaper route if they can find one.

于 2012-11-06T20:00:53.007 回答