Sub topic 18
Count-to-infinity, split horizon and poison reverse
This chapter assumes you know how distance-vector routing works: each router keeps a distance table and updates it from its neighbours' advertisements with the Bellman-Ford rule, cost = neighbour's advertised cost + link cost. It also assumes you know that RIP treats a distance of 16 as unreachable.
Why bad news travels slowly
Distance-vector routers never see the whole network. A router only knows what its neighbours tell it. That works when costs fall, because a better route spreads quickly. It works badly when a link fails. A router cannot tell whether a neighbour's advertised route runs through the router itself.
Take three routers in a line, A, B and C, with every link costing 1. The destination is C.
- B reaches C directly at cost 1.
- A reaches C through B at cost 2.
Now the B–C link fails. B drops its direct route. Before B sends any update, it hears A's advertisement "C is 2 away". B cannot tell that A's route goes through B, so it adopts the route at cost 3 via A. B advertises 3 to A. A trusts B, its next hop, and raises its own cost to 4. The two routers keep raising each other's cost by 2 per round, and the real destination is gone. This is the count-to-infinity problem. It ends only when the cost reaches the protocol's infinity value, 16 in RIP.
While the costs climb, packets for C bounce between A and B until their TTL reaches 0. This is a routing loop.
Simulating it
The script below follows the example with infinity set to 16. Within a round, B hears A first, then A hears B. Run it with each of the three modes.
INF = 16
def run(mode, rounds=8):
dist = {"A": 2, "B": INF}
nxt = {"A": "B", "B": None}
def advert(x, y):
# What router x tells neighbour y about destination C.
if nxt[x] == y:
if mode == "split":
return None
if mode == "poison":
return INF
return dist[x]
for r in range(1, rounds + 1):
for y, x in (("B", "A"), ("A", "B")):
a = advert(x, y)
if a is None:
continue
cost = min(a + 1, INF)
if nxt[y] == x or cost < dist[y]:
dist[y] = cost
nxt[y] = x if cost < INF else None
print(mode, "round", r, "A =", dist["A"], "B =", dist["B"])
run("plain")
run("split")
run("poison")In plain mode the costs run A=4 and B=3 after round 1, A=6 and B=5 after round 2, and so on. A reaches 16 in round 7 and B in round 8. In split and poison modes both routers show 16 after round 1.
Split horizon
Split horizon is a rule about what a router advertises. It never advertises a route out of the interface it learned the route from. A learned C from B, so A stays silent about C when talking to B. B then has no stale route to adopt, and it correctly stays unreachable.
Poison reverse
Poison reverse is a stronger version of split horizon. A router does advertise the route back to the neighbour it learned it from, but with cost infinity (16 in RIP). A explicitly tells B "I cannot reach C except through you", so B drops any doubt immediately. Silence can mean "no information", so a silent router leaves the neighbour waiting for a timeout. A poisoned advertisement removes the stale route at once.
| Technique | What A sends to B about a route learned from B | Cost |
|---|---|---|
| Plain distance vector | The real cost | Count-to-infinity |
| Split horizon | Nothing | Smaller updates |
| Poison reverse | Cost infinity | Larger updates, faster removal |
Limits of the fixes
Real protocols add more mechanisms:
- Triggered updates: a router sends a change at once instead of waiting for the periodic timer (30 seconds in RIP).
- Hold-down timers: after a route is marked unreachable, the router ignores new information about it for a period.
- A small infinity: RIP sets infinity to 16 so counting ends quickly. The cost is that RIP cannot represent any path longer than 15 hops.
Common mistakes
- Saying split horizon sends cost 16. That is poison reverse. Split horizon sends nothing.
- Forgetting that split horizon is applied per interface, not per route.
- Assuming the fixes work for every topology. They do not (see the warning above).
- Counting by 1 per round. In the two-router example the cost rises by 2 per full exchange, because each router adds its link cost to the other's value.
Exercise
In the A–B–C example with plain distance vector and RIP's infinity of 16, what are A's and B's costs for C after round 3 of the simulation? Which technique makes both routers show 16 after round 1?
Show answer
After round 3, B = 7 and A = 8. Both split horizon and poison reverse give 16 for both routers after round 1. Under split horizon, A stays silent to B and B never adopts the stale route. Under poison reverse, A tells B "C is 16 away".
Exercise
Why can a three-router loop survive split horizon?
Show answer
Each router sends its route to a neighbour that is not the one it learned the route from, so the split horizon rule never blocks the advertisement. The stale route circulates around the three routers, and the cost still grows until it reaches infinity.