Sub topic 8
Routing loops and count to infinity
This chapter assumes you know the Bellman-Ford update rule and how neighbors exchange vectors. It covers what goes wrong when a link fails.
Why bad news travels slowly
A distance-vector router only knows what its neighbors tell it. It cannot see the topology, so it cannot tell whether a neighbor's route to a destination passes back through itself. When a link fails, this blind spot creates a routing loop. Two routers each believe the other has a path to the destination, and packets bounce between them until their TTL expires.
A worked failure
Take a chain A - B - C with every link costing 1. B reaches A directly at cost 1, and C reaches A through B at cost 2. Then the A-B link fails.
- B notices the failure and marks its route to A as unreachable.
- Before B advertises that, it receives C's regular update saying "A is 2 away".
- B accepts, because C's offer (1 + 2 = 3) beats "unreachable". B now routes to A through C.
- C hears B say "A is 3 away". C's next hop for A is B, so it must accept the news and updates to 4.
- B hears 4 and updates to 5. The cycle continues.
Each exchange raises the cost by 2, and the costs climb toward infinity. This is called count to infinity.
Reproducing it
This code uses the dv_update function from the Bellman-Ford chapter. It repeats that function so the script runs on its own.
INFINITY = 16
def dv_update(me, link_cost, table, neighbor, advertised):
changed = False
for dest, adv in advertised.items():
if dest == me:
continue
new = min(link_cost + adv, INFINITY)
cur = table.get(dest)
if cur is None:
if new < INFINITY:
table[dest] = (new, neighbor)
changed = True
elif new < cur[0] or cur[1] == neighbor:
if (new, neighbor) != cur:
table[dest] = (new, neighbor)
changed = True
return changed
b = {"A": (INFINITY, "A")} # B just lost its direct route to A
c = {"A": (2, "B")} # C still routes to A through B
while True:
from_c = {d: v[0] for d, v in c.items()}
changed_b = dv_update("B", 1, b, "C", from_c)
from_b = {d: v[0] for d, v in b.items()}
changed_c = dv_update("C", 1, c, "B", from_b)
print(b["A"][0], c["A"][0])
if not (changed_b or changed_c):
breakThe output is 3 4, 5 6, 7 8, 9 10, 11 12, 13 14, 15 16, and then 16 16 twice. The loop only ends because costs reach the maximum metric.
Why the cap matters
RIP defines 16 as infinity. The cap turns an endless count into a bounded one, but it also limits RIP networks to a diameter of 15 hops. A larger cap would mean a longer loop, so the value trades network size against how long a failure can disrupt traffic.
The next chapter shows how split horizon, poison reverse, and hold-down timers prevent this loop or shorten it.
Exercise
In the worked failure, why must C accept B's advertisement of cost 3 for destination A, even though 3 is worse than C's current cost of 2?
Show answer
C's next hop for A is B, so B's advertisement is the authoritative current cost of that path. The rule accepts any news from the current next hop, whether better or worse. This keeps routers from holding stale costs, but here it lets the bad information circulate.