Worked examples — Distance vector routing — RIP, Bellman-Ford, count-to-infinity
Before we start, one promise: every symbol used here was defined in the parent, but we restate the three we lean on hardest so you never have to scroll away.
The scenario matrix
Distance vector routing has a finite family of situations. If you can do one of each row, you can do all of them.
| # | Case class | What makes it different | Hit by |
|---|---|---|---|
| C1 | Basic min over 2+ neighbours | pick cheapest of several via-options | Ex 1 |
| C2 | Direct link vs indirect wins | the direct link is not the answer | Ex 2 |
| C3 | Multi-round convergence to steady state | tables change over several exchanges | Ex 3 |
| C4 | Tie between two next-hops | has two equal arguments | Ex 4 |
| C5 | Unreachable / input (degenerate) | a neighbour reports ; base cases | Ex 5 |
| C6 | Link break → count-to-infinity (2-node) | bad news travels slowly; RIP 16-cap | Ex 6 |
| C7 | Split horizon fixes / limiting behaviour | the 2-node loop is killed | Ex 7 |
| C8 | 3-node loop where split horizon FAILS | the exam twist / worst case | Ex 8 |
| C9 | Real-world word problem (RIP timers) | 30 s / 180 s / hop-count reasoning | Ex 9 |
We now walk every cell.
Ex 1 — C1: basic minimum over several neighbours
Forecast: guess which neighbour wins before computing. (Cheap link ≠ cheap total!)
- Cost via : . Why this step? Total = price to step onto + best price knows to finish.
- Cost via : . Why? 's link is cheapest but is far from — the sum is what matters.
- Cost via : . Why? Expensive link, but is almost at .
- Take the minimum: , next-hop . Why? Bellman-Ford keeps the single cheapest option.
Verify: and , so is genuinely smallest. Notice the cheapest link (, cost 1) lost — the answer is the cheapest total, exactly as the demands. ✔
Ex 2 — C2: direct link is NOT the winner

Forecast: there's a direct wire of cost 7. Do you take it? Guess.
- Neighbours of : (link 2) and (link 7). Look at the figure: two ways out of . Why? Every path from must leave through some direct neighbour.
- Via (direct): . Why ? A node reaches itself for free — base case.
- Via : . Why? advertised it reaches for 3, so total is .
- Minimum: , next-hop . Why B? The two-hop detour beats the direct wire.
Verify: trace the winning path . The direct link (7) is strictly worse, so a "direct link always wins" intuition is false — the red path in the figure is the cheap one. ✔
Ex 3 — C3: multi-round convergence
Forecast: how many exchanges before knows the true cost to ? Guess a number.
- Round 0 (know only yourself): everyone has , all else . Why? A router only knows its own link costs and that it reaches itself for free.
- Round 1 (learn direct neighbours): each node adds its neighbours. learns . still has — is 3 hops away, too far. Why? Info ripples one hop per exchange.
- Round 2: hears 's " at 1", so . still . Why? is now 2 hops from — reachable for , not yet for .
- Round 3: hears 's " at 2", so . Why? is 3 hops from ; it converges on exchange 3.
Verify: the true shortest path has cost . ✔ With nodes, convergence took exchanges — exactly the Bellman-Ford iteration bound the parent promised.
Ex 4 — C4: a tie between next-hops
Forecast: two equal totals are coming — will the router be confused?
- Via : .
- Via : . Why compute both? needs every argument; we don't pre-guess.
- Minimum: . Why still a valid answer? A tie means two shortest paths exist — the cost is unambiguous even if the route isn't.
- Next-hop: implementation picks one (usually the incumbent, to avoid route flapping). Why not both? A simple routing table stores one next-hop per destination; keeping the current one prevents needless churn.
Verify: both totals equal 5, and is the smallest possible — either path is genuinely shortest. No contradiction. ✔
Ex 5 — C5: degenerate inputs ( and self)
Forecast: does an report poison the answer?
- Via : . Why? Adding a finite link cost to "unreachable" is still unreachable — you can't finish the journey.
- Via : . Why? This is a real, finite route.
- Minimum: , next-hop . Why ? silently discards the branch; the good route survives.
- Self-cost: by definition (base case), never computed via the formula. Why special-cased? The recursion would loop forever on yourself; the base case stops it.
Verify: treat as a huge sentinel (in RIP, ). ✔, and is the free self-cost ✔. An unreachable neighbour cannot worsen an existing good route — it can only fail to help.
Ex 6 — C6: link break → count-to-infinity (2-node)

Forecast: lost its wire to . Will it correctly say " unreachable"? Guess.
- Break: 's direct route to vanishes. But recently told " at 2". Why is that dangerous? 's "2" secretly routed through , but can't see that.
- recomputes: via . Why wrong? This path is — a loop. The figure's red arrow bounces back.
- tells " at 3": updates . Why? trusts 's newest number blindly.
- Ping-pong: , , … climbing by 2 each full round. Why so slow? "Bad news travels slowly" — no one has authoritative " is gone" info.
- RIP cap: as soon as a value reaches , RIP declares unreachable, halting the loop. Why 16? by definition, bounding an otherwise infinite climb.
Verify: the sequence of is then . Count the steps: from to in jumps is values, so it caps after increments on 's side. Finite, but wastefully so. ✔
Ex 7 — C7: split horizon fixes it (limiting behaviour)
Forecast: what does advertise to about now?
- Recall the rule: never advertise a route back to the neighbour you learned it from. Why? That neighbour is on the path — telling it back creates the loop.
- learned via , so advertises "" to . Why ? From 's viewpoint, offers no independent route to .
- Link B–C dies. looks for alternatives: its only other neighbour says "". Why does this help? The stale "2" that fed the loop in Ex 6 is now absent.
- immediately sets and propagates the truth. Why fast? No false alternative exists → no ping-pong → good news (of the death) travels at full speed.
Verify: compare with Ex 6. There, had a fake option (); here that option is , so yields on the first recompute. Convergence in 1 step instead of 7. ✔
Ex 8 — C8: the exam twist — 3-node loop where split horizon FAILS

Forecast: the parent's mistake-callout warned this. Guess why the 2-node fix isn't enough here.
- Steady state: ; (both via ). See the figure's three routers. Why? and each cost .
- Split horizon at : learned via , so hides from — but still advertises " at 2" to (it did not learn from ). Likewise . Why is that the loophole? Split horizon only silences the neighbour on the path (); the sideways neighbour still hears the stale 2.
- Link C–Z dies. sees gone, but told " at 2" (allowed — didn't learn it from … wait, did!). The failure comes from a longer route: can go using 's stale "2": . Why does the loop survive? Bad news must travel around the triangle; each hop re-injects a slightly larger stale estimate.
- The three routers now chase each other around the loop, up to . Why split horizon can't stop it: split horizon breaks 2-node loops; a 3-node loop routes the lie the long way, past the one silenced neighbour.
Verify: the true post-break cost is (nothing reaches anymore). Any finite climbing value () is provably wrong — there is no path to at all once C–Z is cut. Only the -cap (plus poison reverse / hold-down timers) forces the truth. ✔ This is exactly the parent's steel-man: split horizon is necessary, not sufficient.
Ex 9 — C9: real-world word problem (RIP timers)
Forecast: does one lost packet kill a route? Guess yes/no first.
- (a) Timeout fires at s. Why? RIP declares a route dead if no update arrives within the 180 s timeout window.
- (b) Missed updates . Why 6? Updates come every 30 s; , so 6 consecutive missed broadcasts trigger the timeout.
- (c) No — the route survives one lost packet. Why? RIP runs over UDP (port 520), which does not retransmit. A single loss is tolerated because the next periodic update (at s) refreshes the timer long before the 180 s deadline.
- Design insight: the 180 s timeout the 30 s period deliberately gives slack. Why? It survives several lost updates before over-reacting — matching UDP's lossy, retransmit-free nature.
Verify: ✔. One loss at s leaves the next update at , so the timer resets and the route lives ✔. The timers are consistent: timeout is an integer multiple of the period.
Recall Quick self-test
Which cell is hardest and why? ::: C8 — split horizon fixes 2-node loops but a 3-node loop routes stale info the long way, so count-to-infinity survives until the 16-cap. In Ex 1, why did the cheapest link (, cost 1) lose? ::: Because was far from ; Bellman-Ford minimises the total , not the link alone. In Ex 5, why can an report never worsen a good route? ::: discards the branch; adding a finite link cost to stays , so it only fails to help. In Ex 9, why does one lost update not kill the route? ::: RIP over UDP is lossy but the 180 s timeout equals 6 update periods, so the next 30 s broadcast refreshes the timer.
Related vault topics: Bellman-Ford Algorithm, Dijkstra's Algorithm, Principle of Optimality, Dynamic Programming, Link-State Routing (OSPF), Routing Tables and Next-Hop Forwarding, BGP, UDP.