EE 122 Discussion 4 LinkState Routing Distance Vector

  • Slides: 37
Download presentation
EE 122: Discussion #4 Link-State Routing Distance Vector Routing

EE 122: Discussion #4 Link-State Routing Distance Vector Routing

Routing: What to keep in mind • Many ways to route: flooding, link-state, distancevector,

Routing: What to keep in mind • Many ways to route: flooding, link-state, distancevector, path-vector… • Main considerations for a routing algorithm – Scale – Message complexity – How many messages sent in… • initialization? • link dies? • link updates? • link comes up? – Speed of Convergence – Robustness – What happens if a router… • fails? • misbehaves? • is sabotaged?

Link-State (LS) Algorithm • Broadcast link-state packets • All routers know entire graph •

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 B 2 • Routing table

Distance Vector (DV) Routing Each node maintains 2 things B 2 • Routing table A – Cost of going to every destination, through every neighbor 5 6 D 1 1 C Node D B C • Forwarding information Neighbors A 8 4 – Next hop neighbor for every destination Destinations B 6 2 C 7 1

Distance Vector Routing • Three “functions” – Initialization – Neighbor update message – Link

Distance Vector Routing • Three “functions” – Initialization – Neighbor update message – Link update

Distance Vector Routing Initialization • For all neighbor nodes, – Set routing table entry

Distance Vector Routing Initialization • For all neighbor nodes, – Set routing table entry to cost of link with neighbor B 2 A 5 6 D 1 1 C Node D • For all other nodes in network, – Set routing table entry to infinity (or “? ”) • Notify neighbors B C A ? ? B 6 ? C ? 1

Distance Vector Routing Neighbor Update Msg 6 B 1 • Whenever a node gets

Distance Vector Routing Neighbor Update Msg 6 B 1 • Whenever a node gets forwarding information from neighbor (say X) C – Update cost to every destination through neighbor X – Update forwarding information C->D: {(A, 5), (B, 1), (D, 1)} D Node D B C A ? ? B 6 ? C ? 1

Distance Vector Routing Neighbor Update Msg • Whenever I get a message from D’s

Distance Vector Routing Neighbor Update Msg • Whenever I get a message from D’s cost of reaching A thru C neighbor (say X) about their = forwarding information D’s cost C – Update costof to reaching every destination + X through neighbor – Update forwarding information C’s cost of reaching A C->D: {(A, 5), (B, 1), (D, 1)} 6 B 1 A D 1 C 5 Node D B C A ? ? B 6 ? C ? 1

Distance Vector Routing Neighbor Update Msg • Whenever a node gets forwarding information from

Distance Vector Routing Neighbor Update Msg • Whenever a node gets forwarding information from neighbor (say X) 1 A – Update cost to every destination through neighbor X – Update forwarding information C->D: {(A, 5), (B, 1), (D, 1)} 6 B D 1 C 5 Node D B C A ? ? 6 B 6 ? 2 C ? 1

Distance Vector Routing Neighbor Update Msg • Whenever a node gets forwarding information from

Distance Vector Routing Neighbor Update Msg • Whenever a node gets forwarding information from neighbor (say X) 6 B 1 A D 1 C 5 – Update cost to every destination Node D through neighbor X B C – Update forwarding information D->BC: {(A, 6), (B, 2), (C, 1)} A ? ? 6 • If forwarding information changed, send it to all neighbors B 6 ? 2 C ? 1

Distance Vector Routing Link Update • Whenever a link updates – Update cost in

Distance Vector Routing Link Update • Whenever a link updates – Update cost in table – Update forwarding information • If forwarding information changed, send it to all neighbors 6 B 1 A 1 D 1 C 5 Node D B C A ? ? 6 B 661 ? 2 C ? 1

Distance Vector Routing Link Update • Whenever a link updates – Update cost in

Distance Vector Routing Link Update • Whenever a link updates – Update cost in table – Update forwarding information 6 B 1 A 1 D 1 C 5 Node D B D->BC: {(A, 6), (B, 1), (C, 1)} • If forwarding information A ? changed, send it to all neighbors C ? 6 B 661 ? 2 C ? 1

Distance Vector (DV) Routing /* Distance to node u through neighbor n. Initialized all

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 Neighbor d[n][n] = c[n]; b[n] = c[n]; send_to_neighbors(b); } link_update(l, n) { // Diff between old and new a = c[n] – l; c[n] = l; change = false; foreach u in Graph // Update distance to u through n d[n][u] += a; // If new min distance, update if b[u] != min(d[*][u]) b[u] = min(d[*][u]); change = true; if change send_to_neighbors(b); } recv_update(v, n) { change = false; foreach u in Graph // Update distance to u through n d[n][u] = c[n] + v[u]; // If new min distance, update if b[u] != min(d[*][u]) b[u] = min(d[*][u]); change = true; if change send_to_neighbors(b); }

Group Work: DV Routing “Game” • Groups of 5 -10 – Pair up so

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

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 Neighbor d[n][n] = c[n]; b[n] = c[n]; send_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! link_update(l, n) { // Diff between old and new a = c[n] – l; c[n] = l; change = false; foreach u in Graph // Update distance to u through n d[n][u] += a; // If new min distance, update if b[u] != min(d[*][u]) b[u] = min(d[*][u]); change = true; if change send_to_neighbors(b); } recv_update(v, n) { change = false; foreach u in Graph // Update distance to u through n d[n][u] = c[n] + v[u]; // If new min distance, update if b[u] != min(d[*][u]) b[u] = min(d[*][u]); change = true; if change send_to_neighbors(b); }

DV Routing: Scenario 1 1 A 1 D E 8 1 4 C 6

DV Routing: Scenario 1 1 A 1 D E 8 1 4 C 6 A->B path = A –> D –> E –> C –> B B 1 Node A Node B C D C E B 7 4 A 4 10 C 6 3 C 1 D 8 1 D E 7 2 E Node C Node D A B D E A 6 5 5 3 9 B 9 1 7 3 9 D 7 4 2 8 E 8 3 Node E A C E B C D A 1 7 3 A 12 4 2 3 B 4 5 3 B 8 2 4 4 2 C 9 1 3 5 1 E 3 5 1 D 11 3 1

DV: initialize() 6 D 1 1 B 2 A C 5 initialize() { foreach

DV: initialize() 6 D 1 1 B 2 A C 5 initialize() { foreach u in Graph b[u] = nil; foreach n in Neighbor foreach u in Graph d[n][u] = infinity; d[n][n] = c[n]; send_vector_to_neighbors(); } Node A n B u B 2 C ? Node B n A u A 2 B->ACD: {(A, 2), (C, 1), (D, 6)} C D ? ? Node C n A u A 5 ? ? Node D n B u A ? B D C ? 5 C ? 1 ? B 6 ? D ? ? 6 D ? ? 1 C ? 1

DV: Message 1 6 D 1 1 B 2 A 1. B->ACD: {(A, 2),

DV: Message 1 6 D 1 1 B 2 A 1. B->ACD: {(A, 2), (C, 1), (D, 6)} C 5 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 change send_vector_to_neighbors(); } Node A n B u B 2 ? C ? 3 5 D ? 8 ? C Node B n A u A 2 C->ABD: {(A, 3), (B, 1), (D, 1)} C D ? ? C ? 1 ? D ? ? 6 Node C n A u A 5 ? 3 ? Node D n B u A ? 8 B ? 1 ? B 6 ? D ? ? 7 1 C ? 7 1 B D C ?

DV: Message 2 6 D 1 1 B 2 A 1. B->ACD: {(A, 2),

DV: Message 2 6 D 1 1 B 2 A 1. B->ACD: {(A, 2), (C, 1), (D, 6)} 2. C->ABD: {(A, 3), (B, 1), (D, 1)} C 5 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 change send_vector_to_neighbors(); } Node A n B u B 2 C ? 6 Node B n A u A 2 A->BC: {(B, 2), (C, 3), (D, 6)} C D ? 4 ? Node C n A u A 5 ? 3 ? Node D n B u A ? 8 B D C ? 4 C ? 3 5 C ? 1 ? B 6 ? 2 D ? 8 ? 6 D ? ? 2 6 D ? ? 7 1 C ? 7 1

DV: Message 3 6 D 1 1 B 2 A 1. B->ACD: {(A, 2),

DV: Message 3 6 D 1 1 B 2 A 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)} C 5 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 change send_vector_to_neighbors(); } Node A n B u B 2 C ? 6 Node B n A u A 2 No change D->BC: {(A, 4), (B, 2), (C, 1)} ? 4 ? Node C n A u A 5 C D ? 3 ? Node D n B u A ? 8 B D C ? 4 C ? 3 5 C ? 5 1 ? B ? 7 1 ? B 6 ? 2 D ? 8 ? 6 D ? 8 ? 2 6 D ? 11 ? 7 1 C ? 7 1

DV: Message 4 6 D 1 1 B 2 A 1. 2. 3. 4.

DV: Message 4 6 D 1 1 B 2 A 1. 2. 3. 4. C 5 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 change send_vector_to_neighbors(); } Node A n B u B 2 C ? 6 Node B n A u A 2 B->ACD: {(A, 2), (C, 1), (D, 6)} C->ABD: {(A, 3), (B, 1), (D, 1)} A->BC: {(B, 2), (C, 3), (D, 6)} D->BC: {(A, 4), (B, 2), (C, 1)} No change B->ACD: {(A, 2), (C, 1), (D, 2)} C D ? 4 ? 10 Node C n A u A 5 B D ? 3 ? 5 Node D n B u A ? 8 C ? 4 C ? 3 5 C ? 5 1 ? 7 B ? 7 1 ? 3 B 6 ? 2 D ? 8 ? 6 D ? 8 ? 2 6 D ? 11 ? 7 1 C ? 7 1

DV: Message 5 6 D 1 1 B 2 A 1. 2. 3. 4.

DV: Message 5 6 D 1 1 B 2 A 1. 2. 3. 4. 5. C 5 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 change send_vector_to_neighbors(); } Node A n B u B 2 C ? 6 Node B n A u A 2 B->ACD: {(A, 2), (C, 1), (D, 6)} C->ABD: {(A, 3), (B, 1), (D, 1)} A->BC: {(B, 2), (C, 3), (D, 6)} D->BC: {(A, 4), (B, 2), (C, 1)} B->ACD: {(A, 2), (C, 1), (D, 2)} A->BC: {(B, 2), (C, 3), (D, 4)} C D ? 4 ? 10 Node C n A u A 5 B D ? 3 ? 5 Node D n B u A ? 8 C ? 4 C ? 3 5 C ? 5 1 ? 7 B ? 7 1 ? 3 B 6 ? 2 D ? 84 ? 6 D ? 8 ? 2 6 D ? 11 ? 73 1 C ? 7 1

DV: Message 6 6 D 1 1 B 2 A C 5 recv_update(v, n)

DV: Message 6 6 D 1 1 B 2 A C 5 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 change send_vector_to_neighbors(); } Node A n B u B 2 C ? 6 Node B n A u A 2 1. 2. 3. 4. 5. 6. B->ACD: {(A, 2), (C, 1), (D, 6)} C->ABD: {(A, 3), (B, 1), (D, 1)} A->BC: {(B, 2), (C, 3), (D, 6)} D->BC: {(A, 4), (B, 2), (C, 1)} B->ACD: {(A, 2), (C, 1), (D, 2)} A->BC: {(B, 2), (C, 3), (D, 4)} Converged! C D ? 4 ? 10 Node C n A u A 5 B D ? 3 ? 5 Node D n B u A ? 8 1 ? 3 B 6 ? 2 1 C ? 7 1 C ? 3 5 C ? 5 1 ? 7 B ? 7 D ? 84 ? 6 D ? 86 ? 2 6 D ? 11 9 ? 7 3 C ? 4

DV Routing: Scenario 2 • Flip paper to other side – Same node –

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

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 Neighbor d[n][n] = c[n]; b[n] = c[n]; send_to_neighbors(b); } link_update(l, n) { // Diff between old and new a = c[n] – l; c[n] = l; change = false; foreach u in Graph // Update distance to u through n d[n][u] += a; // If new min distance, update if b[u] != min(d[*][u]) b[u] = min(d[*][u]); change = true; if change send_to_neighbors(b); } recv_update(v, n) { change = false; foreach u in Graph // Update distance to u through n d[n][u] = c[n] + v[u]; // If new min distance, update if b[u] != min(d[*][u]) b[u] = min(d[*][u]); change = true; if change send_to_neighbors(b); }

DV Routing: Scenario 2 2 D 2 A 2 E 1. 2. 3. 4.

DV Routing: Scenario 2 2 D 2 A 2 E 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. B 2 C 2 19 Count to Infinity! Node A Node B C D 12. 13. 14. 15. 16. 17. 18. 19. 20. C->ABE: (E, 6) A->CD: (E, 8) B->CD: (E, 8) D->AB: (E, 10) C->ABE: (E, 10) A->CD: (E, 12) B->CD: (E, 12) D->AB: (E, 14) C->ABE: (E, 14) A->CD: (E, 16) B->CD: (E, 16) Node C C D D->AB: (E, 18) C->ABE: (E, 18) A->CD: (E, 20) B->CD: (E, 20) D->AB: (E, 22) C->ABE: (E, 19) A->CD: (E, 21) B->CD: (E, 21) D->AB: (E, 23) Node D A B E Node E A B C B 4 4 A 2 6 6 A 2 6 A 4 21 C 2 6 B 6 2 B 4 21 D 6 2 D 4 4 4 C 2 19 E 4 8 12 16 20 21 24 25 E 6 10 14 18 22 2 19 E 6 10 14 18 22 D 6 23

Count to infinity [1] A Node B 1 A B 1 C A C

Count to infinity [1] A Node B 1 A B 1 C A C 1 3 B … C … Node C B A 2 B … C … 27

Count to infinity [2] A Node B ∞ A B 1 C A C

Count to infinity [2] A Node B ∞ A B 1 C A C ∞ 3 B … C … Node C B A 2 B … C … 28

Count to infinity [2] A Node B ∞ A B 1 A C ∞

Count to infinity [2] A Node B ∞ A B 1 A C ∞ 3 B … C … B->C: { (A, 3), … } C Node C B A 2 4 B … C … 29

Count to infinity [3] A Node B ∞ A B 1 C A C

Count to infinity [3] A Node B ∞ A B 1 C A C ∞ 5 B … C … Node C B A 2 4 B … C->B: { (A, 4), … }

Count to infinity [4] A Node B ∞ A B 1 C ∞ 5

Count to infinity [4] A Node B ∞ A B 1 C ∞ 5 B … C … B->C: { (A, 5), … } C …and they counted happily ever after to infinity! A Node C B A 6 B … C … 31

Why does this occur? • Routers B and C don’t know that their paths

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 32

DV Routing: Poison Reverse send_to_neighbors (b) { foreach n in Neighbors send(b); } send_to_neighbors_poison_reverse

DV Routing: Poison Reverse send_to_neighbors (b) { foreach n in Neighbors send(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 infinity if n == min_neighbor(d[*][u]) // Tie-breaker: alphabetic c[u] = infinity; send(c); }

Count to infinity [1] A Node B 1 A B 1 C A C

Count to infinity [1] A Node B 1 A B 1 C A C 1 ∞ B … C … Node C B A 2 B … C … 34

DV Routing: Scenario 2 2 D 2 A 2 E B 2 C 2

DV Routing: Scenario 2 2 D 2 A 2 E B 2 C 2 19 Before link change with Poison Reverse Node A Node B C D Node C C D Node D A B E Node E A B C B 4 4 A 2 ? ? A 2 6 A 4 C 2 ? C 2 6 B ? 2 ? B 6 2 B 4 D ? 2 D 6 2 D 4 4 ? C 4 4 C 2 E 4 ? E 4 8 E ? ? 2 E 6 6 D 6

DV Routing: Scenario 2 2 D 2 A 2 E Node A 1. 2.

DV Routing: Scenario 2 2 D 2 A 2 E Node A 1. 2. 3. 4. 5. 2 19 6. 7. 8. 9. 10. B 2 C C-> A: (E, 19) A-> C: (E, ? ) B-> C: (E, 8) D-> A: (E, 23) C-> A: (E, 10) A-> C: (E, ? ) B-> C: (E, ? ) D-> A: (E, ? ) C-> A: (E, 19) A-> C: (E, ? ) Node C Node B C D B: (E, 19) E: (E, ? ) 11. D-> A: (E, ? ) B: (E, 23) 12. B-> C: (E, ? ) D: (E, 21) D: (E, ? ) B: (E, ? ) E: (E, 10) D: (E, 12) D: (E, ? ) B: (E, 16) B: (E, 19) E: (E, ? ) D: (E, 21) C A D Node E Node D B E A C B B 4 4 A 2 ? ? A 2 6 A 4 21 C 2 ? C 2 6 B ? 2 ? B 6 2 B 4 21 D ? 2 D 6 2 D 4 4 ? C 4 4 C 2 19 E 4 21 12 21 ? 23 ? E 4 21 ? 8 ? 18 21 25 E ? ? 10 ? 2 19 E 6 23 14 23 6 ? 23 D 6 23

Link-State vs. Distance Vector Link-State Distance Vector • Message complexity – O(|N||E|) messages sent

Link-State vs. Distance Vector Link-State Distance Vector • 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 – 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