EE122: Discussion #4
Link-State RoutingDistance Vector Routing
Routing: What to keep in mind
• Many ways to route: flooding, link-state, distance-vector, path-vector…
• Main considerations for a routing algorithm– Scale– Message complexity – How many messages sent in…
– Speed of Convergence– Robustness – What happens if a router…
• initialization? • link dies?
• link updates? • link comes up?
• fails? • is sabotaged?
• misbehaves?
Link-State (LS) Algorithm
• Broadcast link-state packets• All routers know entire graph• Run Dijkstra’s Algorithm (this is in the textbook!)
Distance Vector (DV) Routing
Each node maintains 2 things
• Routing table– Cost of going to every destination,
through every neighbor
• Forwarding information– Next hop neighbor for every
destination
Node D
B C
A 8 4
B 6 2
C 7 1
B
A C
D
11
5
2
6
4
2
1Destinations
Neighbors
Distance Vector Routing
• Three “functions”– Initialization– Neighbor update message– Link update
Distance Vector RoutingInitialization
• For all neighbor nodes,– Set routing table entry to cost of link
with neighbor
• For all other nodes in network,– Set routing table entry to infinity (or
“?”)
• Notify neighbors
Node D
B C
A ? ?
B 6 ?
C ? 1
B
A C
D
11
5
2
6B
C
D
1
6
Distance Vector RoutingNeighbor Update Msg
• Whenever a node gets forwarding information from neighbor (say X)– Update cost to every destination
through neighbor X– Update forwarding information
Node D
B C
A ? ?
B 6 ?
C ? 1C->D: {(A, 5), (B, 1), (D, 1)}
B
C
D
1
6
Distance Vector RoutingNeighbor Update Msg
• Whenever I get a message from neighbor (say X) about their forwarding information– Update cost to every destination
through neighbor X– Update forwarding information
Node D
B C
A ? ?
B 6 ?
C ? 1C->D: {(A, 5), (B, 1), (D, 1)}
D’s cost of reaching A thru C =
D’s cost of reaching C +
C’s cost of reaching A
B
C
D
1
6
A 5
1
Distance Vector RoutingNeighbor Update Msg
• Whenever a node gets forwarding information from neighbor (say X)– Update cost to every destination
through neighbor X– Update forwarding information
Node D
B C
A ? ? 6
B 6 ? 2
C ? 1C->D: {(A, 5), (B, 1), (D, 1)}
B
C
D
1
6
A 5
1
Node D
B C
A ? ? 6
B 6 ? 2
C ? 1
Distance Vector RoutingNeighbor Update Msg
• Whenever a node gets forwarding information from neighbor (say X)– Update cost to every destination
through neighbor X– Update forwarding information
• If forwarding information changed, send it to all neighbors
Node D
B C
A ? ? 6
B 6 ? 2
C ? 1
D->BC: {(A, 6), (B, 2), (C, 1)}
B
C
D
1
6
A 5
1
B
C
D
1
6
A 5
1
Node D
B C
A ? ? 6
B 6 ? 2
C ? 1
Distance Vector RoutingLink Update
• Whenever a link updates– Update cost in table– Update forwarding information
• If forwarding information changed, send it to all neighbors
Node D
B C
A ? ? 6
B 6 1 ? 2
C ? 1
1
B
C
D
1
6
A 5
1
Node D
B C
A ? ? 6
B 6 ? 2
C ? 1
Distance Vector RoutingLink Update
• Whenever a link updates– Update cost in table– Update forwarding information
• If forwarding information changed, send it to all neighbors
Node D
B C
A ? ? 6
B 6 1 ? 2
C ? 1
1
D->BC: {(A, 6), (B, 1), (C, 1)}
Distance Vector (DV) Routing/* Distance to node u through neighbor n. Initialized all to infinity. */d[n][u] = infinity;/* Distance to neighbor n. Know from beginning. */c[n] = {…};/* Best distances, initialize all as infinity. */b[u] = infinity;
initialize() {/* Set all values can from
known neighbor distances. */foreach n in Neighbord[n][n] = c[n];b[n] = c[n];send_to_neighbors(b);
}
link_update(l, n) {// Diff between old and newa = c[n] – l;c[n] = l;change = false;foreach u in Graph// Update distance to u through nd[n][u] += a;// If new min distance, updateif b[u] != min(d[*][u])b[u] = min(d[*][u]);change = true;if changesend_to_neighbors(b);
}
recv_update(v, n) {change = false;foreach u in Graph// Update distance to u through nd[n][u] = c[n] + v[u];// If new min distance, updateif b[u] != min(d[*][u])b[u] = min(d[*][u]);change = true;if changesend_to_neighbors(b);
}
Group Work: DV Routing “Game”• Groups of 5-10
– Pair up so there are 5 nodes• Worksheet
– Node name– Link state: (neighbor, cost)
• Rules– No talking
• You can tell your group what node you are• Can ask questions
– Communicate via pieces of paper• Write and hand messages only to neighbors• Message format: (A - __ B - __ C - __ D - __ E - __)
– After converge route a piece of paper from A to B• Write your node on the paper before forwarding, to show the path• Node B bring paper to me• First group to finish get a prize!
Distance Vector (DV) Routing/* Distance to node u through neighbor n. Initialized all to infinity. */d[n][u] = infinity;/* Distance to neighbor n. Know from beginning. */c[n] = {…};/* Best distances, initialize all as infinity. */b[u] = infinity;
initialize() {/* Set all values can from
known neighbor distances. */foreach n in Neighbord[n][n] = c[n];b[n] = c[n];send_to_neighbors(b);
}
link_update(l, n) {// Diff between old and newa = c[n] – l;c[n] = l;change = false;foreach u in Graph// Update distance to u through nd[n][u] += a;// If new min distance, updateif b[u] != min(d[*][u])b[u] = min(d[*][u]);change = true;if changesend_to_neighbors(b);
}
recv_update(v, n) {change = false;foreach u in Graph// Update distance to u through nd[n][u] = c[n] + v[u];// If new min distance, updateif b[u] != min(d[*][u])b[u] = min(d[*][u]);change = true;if changesend_to_neighbors(b);
}
• After converge route a piece of paper from A to B• Write your node on the paper before
forwarding, to show the path• Node B bring paper to me• First group to finish get a prize!
DV Routing: Scenario 1
D E
A C B
11
1
1
4
6
8
Node A
C D
B 7 4
C 6 3
D 8 1
E 7 2
Node B
C E
A 4 10
C 1 9
D 3 9
E 2 8
Node C
A B D E
A 6 5 5 3
B 9 1 7 3
D 7 4 4 2
E 8 3 5 1
Node D
A C E
A 1 7 3
B 4 5 3
C 4 4 2
E 3 5 1
Node E
B C D
A 12 4 2
B 8 2 4
C 9 1 3
D 11 3 1
A->B path = A –> D –> E –> C –> B
DV: initialize()B
Node AB C
B 2 ?C ? 5D ? ?
A C
D
11
5
2
6
initialize() {foreach u in Graph
b[u] = nil;foreach n in Neighbor
foreach u in Graphd[n][u] = infinity;
d[n][n] = c[n];send_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? ?
C ? 1 ?
D ? ? 6
un
Node C
A B D
A 5 ? ?
B ? 1 ?
D ? ? 1
un
Node D
B C
A ? ?
B 6 ?
C ? 1
un
B->ACD: {(A, 2), (C, 1), (D, 6)}
DV: Message 1B
Node AB C
B 2 ?C ? 3 5D ? 8 ?
A C
D
11
5
2
6
recv_update(v, n) {change = false;foreach u in Graph
d[n][u] = c[n] + v[u];if d[b[u]][u] > d[n][u]
b[u] = n;change = true;
if changesend_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? ?
C ? 1 ?
D ? ? 6
un
Node C
A B D
A 5 ? 3 ?
B ? 1 ?
D ? ? 7 1
un
Node D
B C
A ? 8 ?
B 6 ?
C ? 7 1
un
1. B->ACD: {(A, 2), (C, 1), (D, 6)}
C->ABD: {(A, 3), (B, 1), (D, 1)}
DV: Message 2B
Node AB C
B 2 ? 6C ? 3 5D ? 8 ? 6
A C
D
11
5
2
6
recv_update(v, n) {change = false;foreach u in Graph
d[n][u] = c[n] + v[u];if d[b[u]][u] > d[n][u]
b[u] = n;change = true;
if changesend_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? 4 ?
C ? 1 ?
D ? ? 2 6
un
Node C
A B D
A 5 ? 3 ?
B ? 1 ?
D ? ? 7 1
un
Node D
B C
A ? 8 ? 4
B 6 ? 2
C ? 7 1
un
1. B->ACD: {(A, 2), (C, 1), (D, 6)}2. C->ABD: {(A, 3), (B, 1), (D, 1)}
A->BC: {(B, 2), (C, 3), (D, 6)}
DV: Message 3B
Node AB C
B 2 ? 6C ? 3 5D ? 8 ? 6
A C
D
11
5
2
6
recv_update(v, n) {change = false;foreach u in Graph
d[n][u] = c[n] + v[u];if d[b[u]][u] > d[n][u]
b[u] = n;change = true;
if changesend_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? 4 ?
C ? 5 1 ?
D ? 8 ? 2 6
un
Node C
A B D
A 5 ? 3 ?
B ? 7 1 ?
D ? 11 ? 7 1
un
Node D
B C
A ? 8 ? 4
B 6 ? 2
C ? 7 1
un
1. B->ACD: {(A, 2), (C, 1), (D, 6)}2. C->ABD: {(A, 3), (B, 1), (D, 1)}3. A->BC: {(B, 2), (C, 3), (D, 6)}
No change
D->BC: {(A, 4), (B, 2), (C, 1)}
DV: Message 4B
Node AB C
B 2 ? 6C ? 3 5D ? 8 ? 6
A C
D
11
5
2
6
recv_update(v, n) {change = false;foreach u in Graph
d[n][u] = c[n] + v[u];if d[b[u]][u] > d[n][u]
b[u] = n;change = true;
if changesend_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? 4 ? 10
C ? 5 1 ? 7
D ? 8 ? 2 6
un
Node C
A B D
A 5 ? 3 ? 5
B ? 7 1 ? 3
D ? 11 ? 7 1
un
Node D
B C
A ? 8 ? 4
B 6 ? 2
C ? 7 1
un
1. B->ACD: {(A, 2), (C, 1), (D, 6)}2. C->ABD: {(A, 3), (B, 1), (D, 1)}3. A->BC: {(B, 2), (C, 3), (D, 6)}4. D->BC: {(A, 4), (B, 2), (C, 1)}
No change
B->ACD: {(A, 2), (C, 1), (D, 2)}
DV: Message 5B
Node AB C
B 2 ? 6C ? 3 5D ? 8 4 ? 6
A C
D
11
5
2
6
recv_update(v, n) {change = false;foreach u in Graph
d[n][u] = c[n] + v[u];if d[b[u]][u] > d[n][u]
b[u] = n;change = true;
if changesend_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? 4 ? 10
C ? 5 1 ? 7
D ? 8 ? 2 6
un
Node C
A B D
A 5 ? 3 ? 5
B ? 7 1 ? 3
D ? 11 ? 7 3 1
un
Node D
B C
A ? 8 ? 4
B 6 ? 2
C ? 7 1
un
1. B->ACD: {(A, 2), (C, 1), (D, 6)}2. C->ABD: {(A, 3), (B, 1), (D, 1)}3. A->BC: {(B, 2), (C, 3), (D, 6)}4. D->BC: {(A, 4), (B, 2), (C, 1)}5. B->ACD: {(A, 2), (C, 1), (D, 2)}
A->BC: {(B, 2), (C, 3), (D, 4)}
DV: Message 6B
Node AB C
B 2 ? 6C ? 3 5D ? 8 4 ? 6
A C
D
11
5
2
6
recv_update(v, n) {change = false;foreach u in Graph
d[n][u] = c[n] + v[u];if d[b[u]][u] > d[n][u]
b[u] = n;change = true;
if changesend_vector_to_neighbors();
}
un
Node B
A C D
A 2 ? 4 ? 10
C ? 5 1 ? 7
D ? 8 6 ? 2 6
un
Node C
A B D
A 5 ? 3 ? 5
B ? 7 1 ? 3
D ? 11 9 ? 7 3 1
un
Node D
B C
A ? 8 ? 4
B 6 ? 2
C ? 7 1
un
1. B->ACD: {(A, 2), (C, 1), (D, 6)}2. C->ABD: {(A, 3), (B, 1), (D, 1)}3. A->BC: {(B, 2), (C, 3), (D, 6)}4. D->BC: {(A, 4), (B, 2), (C, 1)}5. B->ACD: {(A, 2), (C, 1), (D, 2)}6. A->BC: {(B, 2), (C, 3), (D, 4)}
Converged!
DV Routing: Scenario 2• Flip paper to other side
– Same node– But new forwarding table!
• Something happens to your network!• Same Rules
– No talking• You can tell your group what node you are (but that’s it!)• Can ask me questions
– Communicate via pieces of paper• Write and hand messages only to neighbors
• Go!
Distance Vector (DV) Routing/* Distance to node u through neighbor n. Initialized all to infinity. */d[n][u] = infinity;/* Distance to neighbor n. Know from beginning. */c[n] = {…};/* Best distances, initialize all as infinity. */b[u] = infinity;
initialize() {/* Set all values can from
known neighbor distances. */foreach n in Neighbord[n][n] = c[n];b[n] = c[n];send_to_neighbors(b);
}
link_update(l, n) {// Diff between old and newa = c[n] – l;c[n] = l;change = false;foreach u in Graph// Update distance to u through nd[n][u] += a;// If new min distance, updateif b[u] != min(d[*][u])b[u] = min(d[*][u]);change = true;if changesend_to_neighbors(b);
}
recv_update(v, n) {change = false;foreach u in Graph// Update distance to u through nd[n][u] = c[n] + v[u];// If new min distance, updateif b[u] != min(d[*][u])b[u] = min(d[*][u]);change = true;if changesend_to_neighbors(b);
}
DV Routing: Scenario 2
A
D
E
C
B
2
2
2
2
2
Node A
C D
B 4 4
C 2 6
D 6 2
E 4 8 12 16 20 21
8 12 16 20 24 25
Node B
C D
A 4 4
C 2 6
D 6 2
E 4 8 12 16 20 21
8 12 16 20 24 25
Node C
A B E
A 2 6 6
B 6 2 6
D 4 4 4
E 6 10 14 18 22
6 10 14 18 22
2 19
Node D
A B
A 2 6
B 6 2
C 4 4
E 6 10 14 18 22
6 10 14 18 22
Node E
C
A 4 21
B 4 21
C 2 19
D 6 23
19
1. C->ABE: (E, 6)2. A->CD: (E, 8)3. B->CD: (E, 8)4. D->AB: (E, 10)5. C->ABE: (E, 10)6. A->CD: (E, 12)7. B->CD: (E, 12)8. D->AB: (E, 14)9. C->ABE: (E, 14)10. A->CD: (E, 16)11. B->CD: (E, 16)12. D->AB: (E, 18)
13. C->ABE: (E, 18)14. A->CD: (E, 20)15. B->CD: (E, 20)16. D->AB: (E, 22)17. C->ABE: (E, 19)18. A->CD: (E, 21)19. B->CD: (E, 21)20. D->AB: (E, 23)
Count to Infinity!
27
Count to infinity [1]
A
B
C
1
1
Node B
A C
A 1 3
B …
C …
Node C
B
A 2
B …
C …
28
Count to infinity [2]
A
B
C
∞
1
Node B
A C
A ∞ 3
B …
C …
Node C
B
A 2
B …
C …
Node B
A C
A ∞ 3
B …
C …
29
Count to infinity [2]
A
B
C
1
∞
Node C
B
A 2
B …
C …
Node B
A C
A ∞ 3
B …
C …B->C: { (A, 3), … }
Node C
B
A 4
B …
C …
Count to infinity [3]
A
B
C
1
∞
Node C
B
A 2
B …
C …
Node B
A C
A ∞ 5
B …
C …
Node C
B
A 4
B …
C …C->B: { (A, 4), … }
31
Count to infinity [4]
A
B
C
1
…and they counted happily ever after to infinity!
∞Node B
A C
A ∞ 5
B …
C …B->C: { (A, 5), … }
Node C
B
A 6
B …
C …
32
Why does this occur?
• Routers B and C don’t know that their paths to A are through each other!
• Poison Reverse: To the neighbor who is providing me my best path, I advertise a cost of infinity
DV Routing: Poison Reversesend_to_neighbors (b) {
foreach n in Neighborssend(b);
}
send_to_neighbors_poison_reverse(b) {foreach n in Neighbors
c = copy(b);foreach u in Graph
// If use neighbor to get u, say cost is infinityif n == min_neighbor(d[*][u]) // Tie-breaker: alphabetic
c[u] = infinity;send(c);
}
34
Count to infinity [1]
A
B
C
1
1
Node B
A C
A 1 ∞
B …
C …
Node C
B
A 2
B …
C …
DV Routing: Scenario 2
A
D
E
C
B
2
2
2
2
2
Node A
C D
B 4 4
C 2 ?
D ? 2
E 4 ?
Node B
C D
A 4 4
C 2 6
D 6 2
E 4 8
Node C
A B E
A 2 ? ?
B ? 2 ?
D 4 4 ?
E ? ? 2
Node D
A B
A 2 6
B 6 2
C 4 4
E 6 6
Node E
C
A 4
B 4
C 2
D 6
19
Before link change with Poison Reverse
DV Routing: Scenario 2
A
D
E
C
B
2
2
2
2
2
Node A
C D
B 4 4
C 2 ?
D ? 2
E 4 21 12 21
? 23 ?
Node B
C D
A 4 4
C 2 6
D 6 2
E 4 21 ? 21
8 ? 1825
Node C
A B E
A 2 ? ?
B ? 2 ?
D 4 4 ?
E ? ? 10 ? 2 19
Node D
A B
A 2 6
B 6 2
C 4 4
E 6 23 14 23
6 ? 23
Node E
C
A 4 21
B 4 21
C 2 19
D 6 23
19
1. C-> A: (E, 19) B: (E, 19) E: (E, ?)
2. A-> C: (E, ?) D: (E, 21)3. B-> C: (E, 8) D: (E, ?)4. D-> A: (E, 23) B: (E, ?)5. C-> A: (E, 10) B: (E, ?) E: (E,
10)6. A-> C: (E, ?) D: (E, 12)7. B-> C: (E, ?) D: (E, ?)8. D-> A: (E, ?) B: (E, 16)9. C-> A: (E, 19) B: (E, 19) E:
(E, ?)10. A-> C: (E, ?) D: (E, 21)11. D-> A: (E, ?) B: (E, 23)12. B-> C: (E, ?) D: (E, 21)
Link-State vs. Distance Vector
Link-State• Message complexity
– O(|N||E|) messages sent– Link cost change -> everyone
notified
• Speed of convergence– O(|N|2) with O(|N||E|) messages
• Robustness– Table calculation semi-separated
between nodes
Distance Vector• Message complexity
– Messages only between neighbors
– Link cost change -> notify only if changes the cost of the min path
• Speed of convergence– Can be slow– Potential of loops– Count-to-infinity
• Robustness– Node’s table dependent on other
nodes’ calculations
Top Related