Recall warm-up
- In a weighted router graph, what two pieces of information does router X store in its routing table for each destination Y?
Stuck? Peek at 3.4.1 Routing vs forwarding, weighted-graph model & shortest paths
- Forwarding = local per-packet lookup (data plane); Routing = network-wide shortest-path computation (control plane).
- Graph model: routers = vertices V, links = edges E with positive cost c(u, v).
- Routing table entry at u for d: stores
(Destination d, Cost D_u(d), Next Hop = first neighbour along shortest path).
- What does a router do when a destination IP matches multiple rows in its forwarding table?
Stuck? Peek at 3.1.5 Forwarding tables & Longest Prefix Match (LPM)
- Match condition: Row
N/n(maskM) matches destinationDiff(D AND M) == N(i.e.Dfalls in[N .. N + 2³²⁻ⁿ − 1]). - Longest Prefix Match (LPM): Among all matching rows, pick the one with the largest prefix length n.
- Default route
0.0.0.0/0: matches every address with n = 0 (used only if nothing else matches).
- Match condition: Row
- What is a direct neighbour of a router?
Stuck? Peek at 1.3.2 Propagation, queuing and processing delay; multi-hop pipelining
- Tp = d / v, v = 2 × 10⁸ m/s default; independent of size and rate.
- Nodal delay = d_proc + d_queue + Tt + Tp.
- One packet, h equal links: h·Tt + h·Tp.
- N packets, h equal links: (N + h − 1)·Tt + h·Tp (+ (h − 1)·d_proc).
- Unequal links: first packet ΣTt + ΣTp, then + (N − 1) × max Tt.
- Traffic intensity L·a/R → 1: queues explode.
The Hook
Imagine standing at a country crossroads with no map. You only know the distance to the two villages directly down the road from you: Village B is 2 km away, and Village C is 6 km away. Then a traveller from B tells you, "From B, I can reach City D in 5 km!" Instantly you add two numbers: 2 km (to B) + 5 km (B to D) = 7 km via B!
That simple idea — "my best distance to Y is the minimum over all my neighbours v of (cost to v + v's distance to Y)" — is the Bellman-Ford equation, the engine of Distance Vector (DV) routing.
Predict First
Router A has two neighbours: B (at link cost 2) and C (at link cost 6). B reports its distance to D is 8, and C reports its distance to D is 2. What distance and next hop to D does Router A compute?
,Via B: 2 + 8 = 10. Via C: 6 + 2 = 8. Since min(10, 8) = 8, Router A sets D_A(D) = 8 via next-hop C (until B learns a better route via C in the next round!).
Core Concept
The Bellman-Ford Equation
Let Dₓ(y) be router x's current estimate of the minimum cost from x to destination y, and let N(x) be the set of direct neighbours of x. Whenever x receives a distance vector D_v = [D_v(y) : y ∈ V] from each neighbour v ∈ N(x), it updates its table using:
Dₓ(y) = min_{v ∈ N(x)} { c(x, v) + D_v(y) }And the next hop from x to y is the neighbour v* that achieves this minimum.
What is in a Distance Vector Message?
Three critical facts tested on GATE:
- A distance vector from router v is a 1-D list of pairs
(Destination y, Distance D_v(y))for all destinations in the network. - No next-hop or path is sent! Router v tells its neighbours how far y is, NOT which path v takes to get there.
- A router sends its distance vector ONLY to its immediate neighbours (never flooded across the whole network).
Round-by-Round Trace to Convergence
Let's trace synchronous DV rounds on our 4-router graph (A–B=2, A–C=6, B–C=3, B–D=8, C–D=2):
| Round | Router A’s vector [A, B, C, D] | Router B’s vector [A, B, C, D] | Router C’s vector [A, B, C, D] | Router D’s vector [A, B, C, D] |
|---|---|---|---|---|
| Round 0 (Init: direct links only) | [0, 2, 6, ∞] | [2, 0, 3, 8] | [6, 3, 0, 2] | [∞, 8, 2, 0] |
| Round 1 (1st exchange) | [0, 2, 5 (via B), 8 (via C)] | [2, 0, 3, 5 (via C)] | [5 (via B), 3, 0, 2] | [8 (via C), 5 (via C), 2, 0] |
| Round 2 (2nd exchange — CONVERGED!) | [0, 2, 5 (via B), 7 (via B)] | [2, 0, 3, 5 (via C)] | [5 (via B), 3, 0, 2] | [7 (via C), 5 (via C), 2, 0] |
Putting it together
- Distance Vector routing uses the distributed Bellman-Ford equation D_x(y) = min_v { c(x,v) + D_v(y) }.
- Routers exchange vectors of distances (without path details) only with their immediate neighbours.
- Each synchronous round propagates shortest-path improvements one additional hop across the network.
Visual
The supplied notes include an interactive visual for this concept; this reading view preserves the surrounding explanation and sequence.
Worked Examples
Router X has three direct neighbours P, Q, and R with link costs c(X,P) = 4, c(X,Q) = 2, and c(X,R) = 5. For destination Z, the neighbours advertise D_P(Z) = 6, D_Q(Z) = 9, and D_R(Z) = 4. What distance and next hop to Z does X put in its routing table?
Show the full solution
Compute the three candidates:
• Via P: 4 + 6 = 10
• Via Q: 2 + 9 = 11
• Via R: 5 + 4 = 9
Minimum is 9, so X sets D_X(Z) = 9 with next hop R.
In our 4-router graph (A–B=2, A–C=6, B–C=3, B–D=8, C–D=2), why didn't Router A discover the cost-7 path to D in Round 1?
Show the full solution
In Round 0, B only knew its direct edge to D (D_B⁰(D) = 8), because B had not yet heard from C that B → C → D costs 3 + 2 = 5. Only in Round 1 did B compute D_B¹(D) = 5, and only in Round 2 did A receive that updated value from B to compute 2 + 5 = 7. Each hop along a multi-hop shortest path takes one round for the distance improvement to propagate!
Router R1 has direct links to R2 (cost 3) and R3 (cost 5). Currently R1's best route to destination D is via R2 with total cost 11 (so R2 had advertised D_R2(D) = 8, while R3 advertised D_R3(D) = 7). Now R2 sends an updated distance vector saying D_R2(D) = 10. What is R1's new distance and next hop to D?
Show the full solution
Trap! When your current next hop (R2) gets worse (from 8 to 10), you MUST recompute the cost through R2 as 3 + 10 = 13 (you cannot keep the old 11!). Now compare:
• Via R2: 3 + 10 = 13
• Via R3: 5 + 7 = 12
So R1 updates its table to cost 12 via R3!
GATE Traps
- Keeping the old cost when the current next-hop worsens: A router does NOT take
min(old_D_x(y), new_candidates)when the old route went through the very neighbour whose cost just increased! - Distance Vector messages go ONLY to direct neighbours: Never say DV broadcasts/floods vectors to all routers.
Memory Hook
Add your link cost to each neighbour's column, then pick the smallest number in each row!
Connect the Dots
Notice how blindly trusting a neighbour's distance worked great when costs decreased. Next question (3.4.3): What happens when the link to C breaks completely, and B asks A for a route to C without realising that A's route to C goes right back through B?
Self-Test
- NAT
Router A has neighbours B (link cost 3) and C (link cost 7). B advertises distance 9 to destination Z, and C advertises distance 4 to destination Z. What is Router A’s shortest distance to Z after applying the Bellman-Ford update?
Write your answer before opening the key.
- MCQ
In Distance Vector routing, to which routers does a router send its distance vector, and what does the vector contain?
- To all routers in the network; it contains the full topology graph.
- Only to its immediate neighbours; it contains its current estimated shortest distance to every destination.
- Only to its immediate neighbours; it contains the complete list of routers along each shortest path.
- Only to the default router; it contains only its direct link costs.
- NAT
Router X has two neighbours M (link cost 2) and N (link cost 6). Initially M advertises distance 5 to D and N advertises distance 4 to D, so X routes to D via M with cost 7. Next, M sends an update that its distance to D has increased to 9 (while N still advertises 4). What is X’s new distance to D?
Write your answer before opening the key.
- MSQ
Which of the following statements about Distance Vector (Bellman-Ford) routing are TRUE?
- It is a distributed, iterative algorithm where routers exchange information only with directly connected neighbours.
- In the absence of link failures, a k-hop shortest path takes at most k synchronous exchange rounds to be discovered.
- Each router knows the complete topology (all nodes and edges) of the entire network.
- RIP (Routing Information Protocol) is based on Distance Vector routing.
Rule Card
- Bellman-Ford:
Dₓ(y) = min_{v ∈ N(x)} { c(x, v) + D_v(y) }. - DV message: contains
[(y, Dₓ(y))]for all destinations y; sent only to immediate neighbours. - If the current next-hop's distance increases, recompute that branch before taking the minimum.
Concept Ledger
- distance vector
- Bellman-Ford equation
- neighbour
- DV exchange
- rounds
- convergence
Answer Vault
Try the questions first. Open when you are ready to check.
Warm-up answers
- The shortest known distance D_X(Y) and the next-hop neighbour v along that path.
- It picks the row with the longest prefix length (Longest Prefix Match).
- A router connected to it by a single physical link (1 hop away, with known direct link cost c(x, v)).
Self-test answers
- 11 — min(3 + 9, 7 + 4) = min(12, 11) = 11 (via C).
- B — In DV routing, each router sends its vector of estimated distances (without paths or next hops) ONLY to its direct neighbours.
- A: DV does not send the full topology graph to all routers.
- C: Standard DV does not include the full path (that is Path Vector, like BGP).
- D: DV exchanges happen between all pairs of direct neighbours.
- 10 — Since X’s route was via M, the cost via M becomes 2 + 9 = 11. Comparing with N (6 + 4 = 10), X switches to N with new distance 10.
- ABD — DV is distributed and iterative, propagates 1 hop per synchronous round, and is used by RIP. Routers in DV do NOT know the full network topology.
- C: DV routers know only distances and next-hop neighbours, not the full network topology.
Flashcards
- Write the Bellman-Ford equation for Router x’s distance to y.
Reveal answer
D_x(y) = min over all neighbours v of { c(x, v) + D_v(y) }. - Who receives a router’s Distance Vector message, and is the next-hop included in the message?
Reveal answer
Only immediate (1-hop) neighbours receive it; the next-hop is NOT included (only destination and distance). - What must Router X do if its current next-hop neighbour V reports a LARGER distance to Y?
Reveal answer
Recompute the cost via V (c(X,V) + new D_V(Y)) and then take the minimum over all neighbours.
Exam shortcuts
- Column-Shift Method for GATE DV Tables: Write each neighbour's advertised vector as a column, add the link cost
c(x, v)to the entire column, and read the row-wise minimum across columns! — solving full-table GATE Bellman-Ford questions in 20 seconds without arithmetic slips. - When current next-hop gets worse: If the update comes from your current next-hop v* and D_{v*}(y) increased, your old cost is GONE — replace it before taking the min! — GATE questions where a link cost increases.