← all topics

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)

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)

Graph abstraction (5-6)

Classifying routing algorithms (5-7)

QuestionOption AOption B
Global or decentralized information?Global: every router has the complete topology and all link costs → "link state" (LS) algorithmsDecentralized: 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 timeDynamic: 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)

Notation (5-8)

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)

  1. Write the link costs down as a list (x–v 3, x–w 6, …). You will scan it every row.
  2. Columns: Step, N', then one column D(v),p(v) per non-source node.
  3. Step 0: N' = {source}. For each neighbor of the source write c(source,v), source. Everything else is ∞.
  4. Each later step: among nodes not in N', pick the one with the smallest D. Add it to N'. Ties: pick either.
  5. 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.
  6. 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
StepN'D(v),p(v)D(w),p(w)D(x),p(x)D(y),p(y)D(z),p(z)
0u7,u3,u5,u∞∞
1uw6,w5,u11,w∞
2uwx6,w11,w14,x
3uwxv10,v14,x
4uwxvy12,y
5uwxvyz
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
StepN'D(v),p(v)D(w),p(w)D(x),p(x)D(y),p(y)D(z),p(z)
0u2,u5,u1,u∞∞
1ux2,u4,x2,x∞
2uxy2,u3,y4,y
3uxyv3,y4,y
4uxyvw4,y
5uxyvwz
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)

  1. For each destination, follow p() backwards until you reach the source. This is the shortest-path tree.
  2. 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.

DestinationLink (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):

StepN'D(t),p(t)D(u),p(u)D(v),p(v)D(w),p(w)D(y),p(y)D(z),p(z)
0x∞∞3,x6,x6,x8,x
1xv7,v6,v3,x6,x6,x8,x
2xvu7,v6,v3,x6,x6,x8,x
3xvuw7,v6,v3,x6,x6,x8,x
4xvuwy7,v6,v3,x6,x6,x8,x
5xvuwyt7,v6,v3,x6,x6,x8,x
6xvuwytz7,v6,v3,x6,x6,x8,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:

  1. (a) Compute the shortest path from t to all network nodes.

Same graph. Official table:

StepN'D(x),p(x)D(u),p(u)D(v),p(v)D(w),p(w)D(y),p(y)D(z),p(z)
0t∞2,t4,t∞7,t∞
1tu∞2,t4,t5,u7,t∞
2tuv7,v2,t4,t5,u7,t∞
3tuvw7,v2,t4,t5,u7,t∞
4tuvwx7,v2,t4,t5,u7,t15,x
5tuvwxy7,v2,t4,t5,u7,t15,x
6tuvwxyz7,v2,t4,t5,u7,t15,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)

Traps
• 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.
StepN'D(b),p(b)D(c),p(c)D(d),p(d)D(e),p(e)D(f),p(f)
0a4,a2,a7,a∞∞
1ac3,c6,c10,c∞
2acb6,c8,b∞
3acbd8,b12,d
4acbde11,e
5acbdef
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.
StepN'D(q),p(q)D(r),p(r)D(s),p(s)D(t),p(t)
0p2,p1,p∞∞
1pr2,p9,r11,r
2prq7,q11,r
3prqs9,s
4prqst
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 →