The two questions cover link-state routing (running Dijkstra's algorithm by hand, reading a forwarding table off the result, and what changes when a link fails) and distance-vector routing (the Bellman-Ford equation and one round of updates on a four-router network). Each question also has a discussion item, on what goes wrong when link costs follow load and when a link fails.
Link-state routing gives every router the whole map. Each router floods the costs of its own links to all the others, so u can run Dijkstra's algorithm on the complete graph §5.2.1. The table in this question records three things at each step. N′ is the set of routers whose least-cost path from u is settled. D(v) is the cost of the cheapest path from u to v found so far, and p(v) is the router just before v on that path.
Each step does the same two things. It moves the router outside N′ with the smallest D into N′. Then, for each of that router's neighbours still outside N′, it checks whether going through the router just added is cheaper than the best path known so far, and updates D and p if it is.
Router u runs Dijkstra's algorithm to find its least-cost path to every other router. Each number is the cost of one link, in both directions.
Run Dijkstra's algorithm from u. Leave a column blank once its router is in N′. Step 0 is done for you.
| Step | N′ | D(v), p(v) | D(w), p(w) | D(x), p(x) | D(y), p(y) | D(z), p(z) |
|---|---|---|---|---|---|---|
| 0 | u | 4, u | ∞ | 1, u | ∞ | ∞ |
| 1 | ||||||
| 2 | ||||||
| 3 | ||||||
| 4 | ||||||
| 5 |
Darken the links of u's least-cost-path tree on the figure. Then fill in u's forwarding table.
| Destination | v | w | x | y | z |
|---|---|---|---|---|---|
| Outgoing link |
Right after u builds its table, link v–x fails. u learns of the failure from a flooded link-state advertisement and reruns Dijkstra. Which destinations in u's forwarding table now use a different outgoing link, and what do they cost now?
In your answer, u sends traffic for every destination out the same link. Suppose instead each link's cost were its current traffic load. What happens the next time u reruns Dijkstra? And the time after that?
1Least costs: v 3, w 5, x 1, y 4, z 8
| Step | N′ | D(v), p(v) | D(w), p(w) | D(x), p(x) | D(y), p(y) | D(z), p(z) |
|---|---|---|---|---|---|---|
| 0 | u | 4, u | ∞ | 1, u | ∞ | ∞ |
| 1 | ux | 3, x | 7, x | 4, x | ∞ | |
| 2 | uxv | 5, v | 4, x | ∞ | ||
| 3 | uxvy | 5, v | 10, y | |||
| 4 | uxvyw | 8, w | ||||
| 5 | uxvywz |
Step 1 adds x, the cheapest router outside N′ (cost 1). Going through x, v costs 1 + 2 = 3, which beats the direct link's 4; w costs 1 + 6 = 7 and y costs 1 + 3 = 4. Step 2 adds v (3), and w drops from 7 to 3 + 2 = 5. Step 3 adds y (4): z becomes 4 + 6 = 10, and w stays at 5 because 4 + 3 = 7 is worse. Step 4 adds w (5), and z drops to 5 + 3 = 8. Step 5 adds z. Each update has the form D(v) = min(D(v), D(w) + c(w,v)), where w is the router just added. There are no ties.
If your D(v) stayed at 4, you did not update v after adding x. A path through a router that is already settled can be cheaper than the direct link, and that is the update Dijkstra's algorithm exists to make.
If you added v before x, you picked the next router by looking at u's links in the figure. The rule is the smallest D among routers outside N′, and x (1) is smaller than v (4).
2Every destination leaves on link (u, x)
The figure is the question's graph with link costs on the links. The heavy links are u's least-cost-path tree: every router's p() links it to the router before it on its cheapest path from u. The green number beside each router is its least cost from u, from the last row of the table in part 1.
The tree leaves u by a single link, (u, x).
| Destination | v | w | x | y | z |
|---|---|---|---|---|---|
| Outgoing link | (u, x) | (u, x) | (u, x) | (u, x) | (u, x) |
The forwarding table records only the first link of each least-cost path. To find it, trace p() back to u: z comes from w, w from v, v from x and x from u, so z's traffic leaves on (u, x).
If you wrote (u, v) for destination v, you used the direct link. The direct link costs 4, and the path u–x–v costs 3, so v's traffic also leaves on (u, x).
3v, w and z move to link (u, v), at costs 4, 6 and 9
The same graph with link v–x removed (dashed). The heavy links are the new least-cost-path tree, and the green numbers are the new least costs from u.
Routers v, w and z now hang off u's other link, (u, v). Routers x and y still leave on (u, x).
With v–x gone, the only way to v is the direct link, at cost 4. For w, the path u–v–w costs 4 + 2 = 6, which beats u–x–w at 1 + 6 = 7. For z, u–v–w–z costs 6 + 3 = 9, which beats u–x–y–z at 1 + 3 + 6 = 10. Destination y's path u–x–y never used v–x, so y and x keep their routes and costs. Because u has the whole map, it recomputes the routes from the updated map in one run of Dijkstra, and every router does the same when the advertisement reaches it.
If you said only v changes, you checked the router at the end of the failed link. The paths to w and z went through v, so they change too.
If you said all five change, you assumed a failure reroutes everything. Only paths that used the failed link change, and u–x and u–x–y do not use it.
DThe routes oscillate
With all of u's traffic on u–x, that link carries the load, so its cost is now high. The next run of Dijkstra therefore moves every destination to u–v. Now u–v carries the load and u–x is idle, so the run after that moves everything back. When link costs follow traffic load, the routes flip every time they are recomputed, and the load never settles §5.2.1.
Real networks avoid this by not tying link costs to load, or by not having every router recompute at the same moment.
If you answered that the routes settle on a balanced split, you assumed u moves only some of the traffic. Dijkstra gives each destination a single least-cost path, so all of a destination's traffic moves together, and the other link is then the cheaper one.
§5.2.1 The Link-State (LS) Routing Algorithm · video · knowledge checks · practice problems
Figures after the authors' Chapter 5 slides, copyright © 1996–2025 J.F. Kurose and K.W. Ross.
GW CSCI 4431/6431 Computer Networks · Routing Worksheet
A distance-vector router does not have the map. It knows the cost of each of its own links and the distance vectors its neighbours send it §5.2.2. A distance vector Dx is the list of x's current estimates of its cost to every destination, so Dx(y) is x's estimate of the cheapest path from x to y. In each round, every router sends its current vector to its neighbours and recomputes its own vector from what it receives. The question asks for the rule a router uses to do that: how the cost of a link to a neighbour combines with what that neighbour reports.
Four routers run the distance vector algorithm. At t = 0 each router knows only the costs of its own links, and sends that distance vector to its neighbors. The table holds the vectors sent at t = 0.
| Vector at t = 0 | to a | to b | to c | to d |
|---|---|---|---|---|
| Da | 0 | 1 | 6 | ∞ |
| Db | 1 | 0 | 3 | 8 |
| Dc | 6 | 3 | 0 | 2 |
| Dd | ∞ | 8 | 2 | 0 |
Write the Bellman-Ford equation a uses to compute Da(d).
Da(d) =
At t = 1, a receives the t = 0 vectors from b and c. Compute a's new distance vector and next hops.
| Destination | via b: c(a,b) + Db | via c: c(a,c) + Dc | Da | Next hop |
|---|---|---|---|---|
| b | ||||
| c | ||||
| d |
By t = 2 the vectors have stopped changing. These are the vectors every router holds at t = 2:
| Vector at t = 2 | to a | to b | to c | to d |
|---|---|---|---|---|
| Da | 0 | 1 | 4 | 6 |
| Db | 1 | 0 | 3 | 5 |
| Dc | 4 | 3 | 0 | 2 |
| Dd | 6 | 5 | 2 | 0 |
Right after t = 2, link c–d fails. c knows only its own link costs and the vectors its neighbors sent it, which are the rows in the t = 2 table. Using only that information, what does c compute for its cost to d, and what is wrong with that answer? Would a link-state router make the same mistake?
1Da(d) = min{ c(a,b) + Db(d), c(a,c) + Dc(d) }
The minimum runs over a's neighbours, b and c. For each neighbour, a adds the cost of its link to that neighbour to the neighbour's own estimate of its cost to d, and keeps the smaller total. In general, Dx(y) = min over neighbours v of { c(x,v) + Dv(y) } §5.2.2.
If you left out c(a,b) and c(a,c), you used the neighbour's number as if it were a's. Db(d) measures the path from b to d, so a still has to pay to reach b.
If your equation had a direct term from a to d, note that a has no link to d. That term would be ∞ and never wins, so it is left out, and d is reached only through a neighbour.
If you added the two alternatives, you combined them instead of choosing between them. They are two different ways to reach d, so a keeps the cheaper one.
2Da = (0, 1, 4, 8) with next hops b, b, c
| Destination | via b: c(a,b) + Db | via c: c(a,c) + Dc | Da | Next hop |
|---|---|---|---|---|
| b | 1 + 0 = 1 | 6 + 3 = 9 | 1 | b |
| c | 1 + 3 = 4 | 6 + 0 = 6 | 4 | b |
| d | 1 + 8 = 9 | 6 + 2 = 8 | 8 | c |
Compared with its t = 0 vector (0, 1, 6, ∞), a's estimate to c drops from 6 to 4 and its estimate to d drops from ∞ to 8. Because its vector changed, a sends the new one to b and c. The t = 2 table shows the next step of the same process: Da(d) falls again to 6, because by t = 1 b has learned of the path b–c–d, which costs 5, and a can now use it at 1 + 5.
If you wrote 6 for c with next hop c, you kept the direct link. A direct link is not always the cheapest path: reaching c through b costs 1 + 3 = 4.
If you wrote 9 for d, you took the via-b column for every row. Compare the two columns in each row and keep the smaller number; for d that is the via-c column.
This worksheet updates all four routers in lock-step rounds, t = 0, 1, 2. Real routers send an update whenever their vector changes, in no fixed order, and the algorithm still reaches the same vectors §5.2.2.
Dc computes 8, via b, but b's path to d runs through c
With c–d gone, c's neighbours are a and b. Through a it costs 6 + 6 = 12, and through b it costs 3 + 5 = 8, so c picks 8 with next hop b. But b's 5 is the path b–c–d, which goes through c and the failed link. A distance vector holds only costs, not the paths behind them, so nothing in b's row tells c that b's cheapest route runs back through c itself. Datagrams for d now bounce between b and c.
The stale costs then feed each other. When b hears c's new 8, b's options are 3 + 8 = 11 via c, 8 on its direct link to d, and 1 + 6 = 7 via a, whose 6 was itself a path through b and c. So b moves to 7. Each router's estimate to d is raised by the others' old numbers, and the estimates climb round by round (c goes from 8 to 10 to 11, over about five rounds) until they settle on the real best path, b's direct link to d. Without that direct link, they would count up toward infinity. This is the "bad news travels slowly" problem §5.2.2.
A link-state router would not make this mistake. The failure is flooded to every router, and each runs Dijkstra on the full map, which no longer has the link. It never uses another router's cost estimate, as in Q1 part 3 §5.2.1.
If you answered that c's cost to d becomes ∞, you applied the failure only to c's own link. c does not know whether its neighbours have another route to d, and b's row says they do, so c computes 8.
§5.2.2 The Distance-Vector (DV) Algorithm · video · knowledge checks · practice problems
GW CSCI 4431/6431 Computer Networks · Routing Worksheet