Distance vector routing — RIP, Bellman-Ford, count-to-infinity
WHAT is Distance Vector Routing?
Contrast this with Link-State routing (OSPF), where every router knows the whole topology. DV trades global knowledge for simplicity: "tell only neighbours, tell them everything."
WHY share with neighbours only? Because a router can only physically measure the cost to its direct neighbours (link cost). Everything beyond that must be learned second-hand. So information ripples outward, one hop per exchange.
HOW: deriving the Bellman-Ford update from scratch
Let = the cheapest cost from node to node . Let = the cost of the direct link from to its neighbour .
Step 1 — first principles. Any path from to (with ) must leave through some neighbour . Once you commit to leaving via , the best you can do afterward is (the best itself can do to reach ).
Step 2 — cost of going via . Why this step? The total = (price to step onto ) + (best price knows to finish the journey).
Step 3 — pick the best neighbour. Since we want the cheapest path and we don't know which neighbour is best, we minimise over all neighbours:
Why is this correct? It's just the principle of optimality: a shortest path's sub-paths are also shortest. If the best route to goes , then the portion must itself be 's shortest route to — otherwise we could swap in a cheaper tail and beat our own "shortest" path (contradiction).
The distributed twist: node doesn't compute itself — tells its current estimate in its distance-vector message. So in practice each router runs: where is the latest estimate of that received from . Whenever any changes, broadcasts its new vector to neighbours.

RIP — the real-world DV protocol
Key RIP facts (WHY they exist):
| Feature | Value | Why |
|---|---|---|
| Metric | hop count (1 per link) | simple, no bandwidth measurement needed |
| Max valid cost | 15 | a cost of 16 = ∞ (unreachable) → caps count-to-infinity |
| Update period | every 30 s | periodic full-vector broadcast to neighbours |
| Route timeout | 180 s | if no update in 6 periods, route declared dead |
| Transport | UDP 520 | lightweight; lost updates fixed by next period |
The Count-to-Infinity Problem
HOW it happens (WHY each step): Consider A — B — C, all link costs 1.
- Steady state: reaches at cost 1 (direct); reaches at cost 2 via B.
- The link B–C breaks.
- should now see as unreachable. But recently told : "I can reach C at cost 2!" — doesn't know 's route to C went through B itself.
- So concludes: "I'll reach C via A: cost ." (WRONG — that path loops .)
- tells "C is at 3", so updates to "C via B at "… and they ping-pong: 5, 6, 7 … up to 16 = ∞.
The root cause: a router advertises a route back to the very neighbour it learned it from.
Fixes
Worked Example 1 — one Bellman-Ford update
Network: A—B=2, B—C=3, A—C=7. Find 's cost to .
- 's neighbours: (cost 2) and (cost 7).
- Via : . Why? Direct link to the destination.
- Via : . Why? already advertised it reaches at 3.
- , next-hop . Why B? It's the cheaper of the two options.
Worked Example 2 — count-to-infinity trace
A—B—C, costs 1. Link B–C dies. Tables for "cost to C":
| Exchange | Why | ||
|---|---|---|---|
| before break | 1 (direct) | 2 (via B) | steady state |
| break, no split horizon | 3 (via A!) | 2 | B trusts A's stale "2" |
| next | 3 | 4 (via B) | A trusts B's "3" |
| … | 5 | 6 | ping-pong |
| eventually | 16=∞ | 16=∞ | RIP cap halts it |
Why this is the disaster: until they hit 16, packets to C loop A↔B forever.
Worked Example 3 — split horizon prevents it
Same break, with split horizon: learned C via B, so advertises "C = ∞" to . Now when B–C dies, has no false alternative (A told it ∞), so immediately marks C unreachable. Why it works: the looping estimate was never injected back.
Flashcards
What equation does distance vector routing implement?
In DV routing, what does each router send and to whom?
What metric and transport does RIP use?
In RIP, what cost value means "unreachable"?
What is count-to-infinity?
Root cause of count-to-infinity?
What is split horizon?
What is poison reverse?
Why doesn't split horizon fully solve count-to-infinity?
How many exchanges until DV converges in an n-node network (no failures)?
RIP route timeout period?
Why does "good news travel fast but bad news slow"?
Recall Feynman: explain to a 12-year-old
Imagine kids in a line, each only able to whisper to the kid next to them. You want everyone to know "how many steps to the candy shop." The kid at the shop says "0 steps." The next kid hears "0" and says "I'm 1 step." Each kid just adds 1 to the smallest number they hear and passes it on. Soon everyone knows their distance — without anyone seeing the whole map! The trouble: if the shop suddenly closes, a kid might still hear an old "I'm near the shop" whisper from a friend whose path actually went through him. So he thinks "oh, I'll go to the shop through my friend!" — but his friend was going through him. They keep adding 1, 1, 1… counting up forever. The rule "don't tell a friend about a route you learned from that friend" stops them being silly together.
Connections
- Link-State Routing (OSPF) — global-map alternative using Dijkstra's Algorithm
- Bellman-Ford Algorithm — the graph-theory core (also handles negative edges, unlike Dijkstra)
- Principle of Optimality / Dynamic Programming — why sub-paths of shortest paths are shortest
- BGP — a path-vector protocol; advertises full AS-paths to cure count-to-infinity at scale
- UDP — transport RIP relies on (port 520)
- Routing Tables and Next-Hop Forwarding
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, Distance Vector routing ka basic idea simple hai: har router sirf apne direct neighbours ko jaanta hai, aur unko bolta hai "main har destination tak kitni door hun." Phir har router apni table update karta hai ye formula se — Bellman-Ford: . Matlab "destination tak jaane ka cost = neighbour tak pahunchne ka cost + woh neighbour aage jitna cost bolta hai", aur sabse sasta wala option choose karo. Koi bhi router pura network map nahi dekhta — info dheere-dheere hop-by-hop spread hoti hai. Isiliye nodes ke liye max rounds mein sab converge ho jaata hai.
RIP isi ka real protocol hai: metric = hop count (har link = 1), chalta hai UDP port 520 par, har 30 second mein full table neighbours ko bhejta hai, aur 16 ka matlab infinity (unreachable) hota hai. Ye 16-cap jaan-bujhkar lagaya gaya hai taaki ek nasty problem control mein rahe.
Woh problem hai count-to-infinity. Funda: "good news fast, bad news slow." Jab koi link toot jaata hai, toh ek router apne dead route ko bhool nahi paata kyunki uska neighbour purana optimistic cost wapas bhej deta hai — aur dono ek-doosre ko 1, 1, 1 add karke cost badhate rehte hain, infinity tak. Root cause: router usi neighbour ko route advertise karta hai jisse usne woh route seekha tha.
Iska fix hai Split Horizon — jis neighbour se route seekha, usi ko us route ke baare mein mat batao (ya Poison Reverse mein cost 16 bhej do). Par yaad rakhna: split horizon sirf 2-node loop fix karta hai; 3+ routers ke ring mein bug phir bhi aa sakta hai, isiliye RIP ko 16-cap bhi chahiye. Exam mein ye distinction bahut poocha jaata hai!