11 · Control plane, routing algorithms, link state (Dijkstra) ★
Slides 5-1 → 5-13 · K&R 5.1, 5.2.1 · HW6 P3, P4a
Two network-layer functions (5-2)
- Forwarding (data plane): move a packet from a router's input to the right router output. Local to one router.
- Routing (control plane): determine the route packets take from source to destination. Network-wide.
- Two ways to build the control plane: per-router control (traditional) and logically centralized control (SDN).
Per-router vs SDN control plane (5-3, 5-4)
| Per-router control (5-3) | Logically centralized, SDN (5-4) |
|---|---|
| A routing algorithm runs in every router. The pieces in each router talk to each other to compute routes. | A remote controller computes the forwarding tables and installs them in the routers. |
| Each router builds its own forwarding table. | Routers only hold a small control agent (CA) that talks to the controller. |
Routing protocol goal (5-5)
- Goal: find "good" paths (routes) from sending host to receiving host through a network of routers.
- Path: the sequence of routers a packet crosses from source to destination.
- "Good" = least cost, "fastest", or "least congested". In this course: least-cost path.
Graph abstraction (5-6)
- G = (N, E). N = set of routers (nodes), E = set of links (edges).
- c(a,b) = cost of the direct link between a and b. No direct link → c(a,b) = ∞. Slide example: c(w,z) = 5, c(u,z) = ∞.
- Cost of a path = sum of its link costs:
c(x1,x2) + c(x2,x3) + … + c(xp−1,xp). - Who sets costs: the network operator. They can be always 1 (fewest hops), inversely related to bandwidth, or inversely related to congestion.
Classifying routing algorithms (5-7)
| Question | Option A | Option B |
|---|---|---|
| Global or decentralized information? | Global: every router has the complete topology and all link costs → "link state" (LS) algorithms | Decentralized: routers initially know only the costs to attached neighbors; iterative computation plus exchange with neighbors → "distance vector" (DV) algorithms |
| How fast do routes change? | Static: routes change slowly over time | Dynamic: routes change more quickly, via periodic updates or in response to link cost changes |
A third axis in K&R 5.2: load-sensitive (costs track congestion) vs load-insensitive (OSPF, RIP, BGP today).
Link-state routing (5-8)
- Link-state broadcast: every node floods the costs of its own links to all other nodes.
- Result: all nodes have the same map (same topology, same costs).
- Each node then runs Dijkstra with itself as the source. Output: least-cost paths to every other node, which gives that node's forwarding table.
- Iterative: after k iterations, the least-cost paths to k destinations are known.
Notation (5-8)
- c(x,y): link cost from x to y; ∞ if not direct neighbors.
- D(v): current cost of the path from the source to v (a running best guess).
- p(v): predecessor of v on that path (the node just before v).
- N': set of nodes whose least-cost path is definitively known.
Dijkstra's algorithm (5-9)
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N':
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
How to solve: the Dijkstra table (Table 5.1 style)
- Write the link costs down as a list (x–v 3, x–w 6, …). You will scan it every row.
- Columns: Step, N', then one column
D(v),p(v)per non-source node. - Step 0: N' = {source}. For each neighbor of the source write
c(source,v), source. Everything else is ∞. - Each later step: among nodes not in N', pick the one with the smallest D. Add it to N'. Ties: pick either.
- Update only its neighbors w that are not in N':
D(w) = min( D(w), D(added) + c(added,w) ). If the new value is strictly smaller, change p(w) to the added node. Otherwise copy the old entry. - Repeat until every node is in N'. With n nodes you get steps 0 … n−1.
Worked: slide 5-10 example (source u)
| Link costs |
|---|
| u–v 7, u–w 3, u–x 5, w–v 3, w–x 4, w–y 8, x–y 7, x–z 9, v–y 4, y–z 2 |
| Step | N' | D(v),p(v) | D(w),p(w) | D(x),p(x) | D(y),p(y) | D(z),p(z) |
|---|---|---|---|---|---|---|
| 0 | u | 7,u | 3,u | 5,u | ∞ | ∞ |
| 1 | uw | 6,w | 5,u | 11,w | ∞ | |
| 2 | uwx | 6,w | 11,w | 14,x | ||
| 3 | uwxv | 10,v | 14,x | |||
| 4 | uwxvy | 12,y | ||||
| 5 | uwxvyz |
Step 0: u's neighbors v 7, w 3, x 5. y, z not adjacent → ∞.
Step 1: smallest D = w (3). Add w. Neighbors of w:
v: min(7, 3+3) = 6 → 6,w
x: min(5, 3+4) = 5 → stays 5,u
y: min(∞, 3+8) = 11 → 11,w
Step 2: smallest D = x (5). Add x. Neighbors of x:
y: min(11, 5+7=12) = 11 → stays 11,w
z: min(∞, 5+9) = 14 → 14,x
Step 3: smallest D = v (6). Add v. Neighbors of v:
y: min(11, 6+4) = 10 → 10,v
Step 4: smallest D = y (10). Add y.
z: min(14, 10+2) = 12 → 12,y
Step 5: add z. Done.
Paths from predecessors: z ← y ← v ← w ← u, so u→w→v→y→z costs 3+3+4+2 = 12 ✓.
Worked: slide 5-11 example (source u, the 5-6 graph)
| Link costs |
|---|
| u–v 2, u–x 1, u–w 5, v–x 2, v–w 3, x–w 3, x–y 1, w–y 1, w–z 5, y–z 2 |
| Step | N' | D(v),p(v) | D(w),p(w) | D(x),p(x) | D(y),p(y) | D(z),p(z) |
|---|---|---|---|---|---|---|
| 0 | u | 2,u | 5,u | 1,u | ∞ | ∞ |
| 1 | ux | 2,u | 4,x | 2,x | ∞ | |
| 2 | uxy | 2,u | 3,y | 4,y | ||
| 3 | uxyv | 3,y | 4,y | |||
| 4 | uxyvw | 4,y | ||||
| 5 | uxyvwz |
Step 1: add x (1). w: min(5, 1+3) = 4,x. y: 1+1 = 2,x. v: min(2, 1+2) = 2,u stays. Step 2: v and y tie at 2; slide picks y. w: min(4, 2+1) = 3,y. z: 2+2 = 4,y. Step 3: add v (2). w: min(3, 2+3) = 3 stays. Step 4: add w (3). z: min(4, 3+5) = 4 stays. Step 5: add z.
How to solve: table → forwarding table (5-10, 5-12)
- For each destination, follow p() backwards until you reach the source. This is the shortest-path tree.
- The node right after the source on that chain is the next hop. The forwarding table entry is the link
(source, next hop).
Slide 5-11/5-12 from u: y ← x ← u, w ← y ← x ← u, z ← y ← x ← u, v ← u.
| Destination | Link (5-12) |
|---|---|
| v | (u,v) |
| x | (u,x) |
| y | (u,x) |
| w | (u,x) |
| z | (u,x) |
Worked: HW6 P3 (shortest paths from x)
Q (HW6 P3): Consider the network with nodes t, u, v, w, x, y, z and these undirected link costs: x–v 3, x–w 6, x–y 6, x–z 8, y–z 12, y–v 8, y–t 7, v–t 4, v–u 3, v–w 4, w–u 3, t–u 2. Using Dijkstra's shortest-path algorithm, compute the shortest path from x to all network nodes. Show how the algorithm works by computing a table similar to Table 5.1.
| Link costs (HW6 figure) |
|---|
| x–v 3, x–w 6, x–y 6, x–z 8, y–z 12, y–v 8, y–t 7, v–t 4, v–u 3, v–w 4, w–u 3, t–u 2 |
Official table (column order t, u, v, w, y, z; the official solution repeats final entries in every row):
| Step | N' | D(t),p(t) | D(u),p(u) | D(v),p(v) | D(w),p(w) | D(y),p(y) | D(z),p(z) |
|---|---|---|---|---|---|---|---|
| 0 | x | ∞ | ∞ | 3,x | 6,x | 6,x | 8,x |
| 1 | xv | 7,v | 6,v | 3,x | 6,x | 6,x | 8,x |
| 2 | xvu | 7,v | 6,v | 3,x | 6,x | 6,x | 8,x |
| 3 | xvuw | 7,v | 6,v | 3,x | 6,x | 6,x | 8,x |
| 4 | xvuwy | 7,v | 6,v | 3,x | 6,x | 6,x | 8,x |
| 5 | xvuwyt | 7,v | 6,v | 3,x | 6,x | 6,x | 8,x |
| 6 | xvuwytz | 7,v | 6,v | 3,x | 6,x | 6,x | 8,x |
Step 0: x's neighbors: v 3, w 6, y 6, z 8. t, u not adjacent → ∞.
Step 1: smallest = v (3). Add v. Neighbors of v not in N':
t: min(∞, 3+4) = 7 → 7,v
u: min(∞, 3+3) = 6 → 6,v
w: min(6, 3+4=7) = 6 → stays 6,x
y: min(6, 3+8=11) = 6 → stays 6,x
Step 2: u, w, y tie at 6; official picks u. Add u. Neighbors of u:
t: min(7, 6+2=8) = 7 → stays 7,v
w: min(6, 6+3=9) = 6 → stays
Step 3: w and y tie at 6; add w. Its neighbors x, v, u are all in N'. No change.
Step 4: add y (6).
t: min(7, 6+7=13) = 7 stays
z: min(8, 6+12=18) = 8 stays
Step 5: add t (7). Its neighbors y, v, u are in N'.
Step 6: add z (8). Done.
Forwarding table at x: t ← v ← x and u ← v ← x, so t and u go out (x,v). v → (x,v), w → (x,w), y → (x,y), z → (x,z).
Worked: HW6 P4a (shortest paths from t)
Q (HW6 P4): Consider the network from P3 (link costs: x–v 3, x–w 6, x–y 6, x–z 8, y–z 12, y–v 8, y–t 7, v–t 4, v–u 3, v–w 4, w–u 3, t–u 2). Using Dijkstra's algorithm, and showing your work in a table similar to Table 5.1, do the following:
- (a) Compute the shortest path from t to all network nodes.
Same graph. Official table:
| Step | N' | D(x),p(x) | D(u),p(u) | D(v),p(v) | D(w),p(w) | D(y),p(y) | D(z),p(z) |
|---|---|---|---|---|---|---|---|
| 0 | t | ∞ | 2,t | 4,t | ∞ | 7,t | ∞ |
| 1 | tu | ∞ | 2,t | 4,t | 5,u | 7,t | ∞ |
| 2 | tuv | 7,v | 2,t | 4,t | 5,u | 7,t | ∞ |
| 3 | tuvw | 7,v | 2,t | 4,t | 5,u | 7,t | ∞ |
| 4 | tuvwx | 7,v | 2,t | 4,t | 5,u | 7,t | 15,x |
| 5 | tuvwxy | 7,v | 2,t | 4,t | 5,u | 7,t | 15,x |
| 6 | tuvwxyz | 7,v | 2,t | 4,t | 5,u | 7,t | 15,x |
Step 0: t's neighbors: u 2, v 4, y 7. x, w, z → ∞.
Step 1: add u (2). Neighbors of u:
v: min(4, 2+3=5) = 4 → stays 4,t
w: min(∞, 2+3) = 5 → 5,u
Step 2: add v (4). Neighbors of v:
x: min(∞, 4+3) = 7 → 7,v
w: min(5, 4+4=8) = 5 → stays
y: min(7, 4+8=12) = 7 → stays
Step 3: add w (5). x: min(7, 5+6=11) = 7 stays.
Step 4: x and y tie at 7; official picks x. Add x.
z: min(∞, 7+8) = 15 → 15,x
y: min(7, 7+6=13) = 7 stays
Step 5: add y (7). z: min(15, 7+12=19) = 15 stays.
Step 6: add z (15). Done.
Forwarding table at t: u → (t,u); v → (t,v); w ← u ← t → (t,u); x ← v ← t → (t,v); y → (t,y); z ← x ← v ← t → (t,v).
Dijkstra discussion (5-13, 5-23)
- Algorithm complexity with n nodes: each iteration checks all nodes not in N'. Total n(n+1)/2 comparisons → O(n²).
- Faster: with a heap, O(n log n) (slide wording).
- Message complexity: every router must learn every link cost. Slide 5-23 says O(n²) messages for n routers. K&R states it as O(|N|·|E|) (each of the n nodes floods its link states over the E links).
- Oscillations (5-13): possible when link cost = amount of traffic carried (load-dependent). All routers see the cheap path, all move traffic onto it, it becomes expensive, they all move back. Routes flip every run.
- Fixes (K&R): do not use load-sensitive costs, or make routers run LS at randomized times so they don't all switch together.
• Only update neighbors of the node you just added. Non-neighbors copy their old entry.
• Use
D(added) + c(added,w), not c(source,added) + c(added,w). D(added) is the full path cost.• Change p(w) only on a strict improvement. On a tie keep the old predecessor (quick check 5, step 3: e stays 8,b when the d route also gives 8).
• Pick the min among nodes not yet in N'. Once in N', a node's D never changes.
• Read each edge weight carefully off the figure. In HW6, x–v is 3 and v–y is 8, which are easy to swap.
• Forwarding table = first hop from the source, found by tracing p() back to the source. Not the predecessor itself.
• Don't forget ∞ for nodes not adjacent to the source in step 0.
Quick check
1. Forwarding vs routing: which plane, which scope?
Forwarding = data plane, move a packet from input to output inside one router. Routing = control plane, compute the path from source to destination across the network.2. Per-router control plane vs SDN?
Per-router: a routing algorithm runs in every router and they interact. SDN: a remote controller computes forwarding tables and installs them via control agents in the routers.3. Link state vs distance vector: what does each router know at the start?
LS (global): after the link-state broadcast, the complete topology and all link costs. DV (decentralized): only the costs to its attached neighbors.4. What is N'? When is D(v) final?
N' = nodes whose least-cost path is definitively known. D(v) is final the moment v is added to N'.5. Dijkstra from a on this graph. Links: a–b 4, a–c 2, a–d 7, b–c 1, b–e 5, c–d 4, c–e 8, d–e 2, d–f 6, e–f 3. Give the table and a's forwarding table.
| Step | N' | D(b),p(b) | D(c),p(c) | D(d),p(d) | D(e),p(e) | D(f),p(f) |
|---|---|---|---|---|---|---|
| 0 | a | 4,a | 2,a | 7,a | ∞ | ∞ |
| 1 | ac | 3,c | 6,c | 10,c | ∞ | |
| 2 | acb | 6,c | 8,b | ∞ | ||
| 3 | acbd | 8,b | 12,d | |||
| 4 | acbde | 11,e | ||||
| 5 | acbdef |
Step 1: add c (2). b: min(4, 2+1) = 3,c. d: min(7, 2+4) = 6,c. e: 2+8 = 10,c. Step 2: add b (3). e: min(10, 3+5) = 8,b. Step 3: add d (6). e: min(8, 6+2=8) = 8 → tie, keep b. f: 6+6 = 12,d. Step 4: add e (8). f: min(12, 8+3) = 11,e. Step 5: add f (11).Chains: b ← c ← a; d ← c ← a; e ← b ← c ← a; f ← e ← b ← c ← a. Every destination goes out link (a,c). Costs: b 3, c 2, d 6, e 8, f 11.
6. Dijkstra from p. Links: p–q 2, p–r 1, r–q 2, q–s 5, r–s 8, r–t 10, s–t 2. Give the table and p's forwarding table.
| Step | N' | D(q),p(q) | D(r),p(r) | D(s),p(s) | D(t),p(t) |
|---|---|---|---|---|---|
| 0 | p | 2,p | 1,p | ∞ | ∞ |
| 1 | pr | 2,p | 9,r | 11,r | |
| 2 | prq | 7,q | 11,r | ||
| 3 | prqs | 9,s | |||
| 4 | prqst |
Step 1: add r (1). q: min(2, 1+2=3) = 2,p stays. s: 1+8 = 9,r. t: 1+10 = 11,r. Step 2: add q (2). s: min(9, 2+5) = 7,q. Step 3: add s (7). t: min(11, 7+2) = 9,s. Step 4: add t (9).Forwarding at p: q → (p,q); r → (p,r); s ← q ← p → (p,q); t ← s ← q ← p → (p,q).
7. Slide 5-10 example: give u's forwarding table.
w → (u,w); x → (u,x); v ← w ← u → (u,w); y ← v ← w ← u → (u,w); z ← y ← v ← w ← u → (u,w).8. HW6 P3 graph, but c(x,v) drops from 3 to 1. New D() from x?
Step 0: v 1,x w 6,x y 6,x z 8,x t ∞ u ∞ Step 1: add v (1): t 1+4 = 5,v; u 1+3 = 4,v; w min(6, 1+4) = 5,v; y min(6, 9) = 6,x Step 2: add u (4): t min(5, 4+2=6) = 5 stays; w min(5, 4+3=7) = 5 stays Step 3: add t or w (both 5). t: y min(6, 5+7) stays. w: no new neighbors. Step 4: add the other one at 5. Step 5: add y (6): z min(8, 18) = 8 stays Step 6: add z (8)v 1, u 4, t 5, w 5, y 6, z 8. t, u, w now go out (x,v).
9. How many comparisons does basic Dijkstra make with n = 10 nodes? Big-O?
n(n+1)/2 = 10·11/2 = 55. O(n²). With a heap: O(n log n).10. What causes oscillations in LS routing, and how do you avoid them?
Load-dependent link costs (cost = traffic carried). Every router shifts to the newly cheap path at once, making it expensive. Avoid with load-insensitive costs or randomized LS run times.11. In LS, why do all routers compute consistent routes?
Because the link-state broadcast gives every node the same map, and each runs the same Dijkstra on it.12. Static vs dynamic routing?
Static: routes change slowly over time. Dynamic: routes change quickly, through periodic updates or in response to link cost changes.← prev · all topics · next →