Upload
nguyen-hieu
View
216
Download
2
Tags:
Embed Size (px)
Citation preview
1The Fundamentals of Routing
EE122 Fall 2011Scott Shenker
http://inst.eecs.berkeley.edu/~ee122/Materials with thanks to Jennifer Rexford, Ion Stoica, Vern Paxson
and other colleagues at Princeton and UC Berkeley
Announcements 194 is set up: 4 units: CCN: 25571
Everyone should be off wait list by now. Waiting for more accounts
o Send me email if you need one. Will set up bspace for 194 to hand in homework
Open today with questions about project 1
Hope you all handed in HW1 HW2 out on Wednesday
Survey will be available after Wednesdays class 2
Questions about Project 1 (for Shaddi)
3
Warning. This lecture contains detailed calculations
Prolonged exposure may induce drowsiness
Do not operate heavy machinery while listening
4
Where Are We? Motivated our basic design decisions
Best-effort, packet-switching, blah, blah, blah
Last lecture: how to build reliable transport on top
This lecture: how to build the network itself
Basic Task: deliver packets Need to route them, from anywhere to anywhere
Today, we focus on routing 5
The Traditional Routing Curriculum Learning switches Link-state routing
Dijkstras Algorithm Distance-vector routing
Bellman-Ford
6
I have some bad news.. Dont have anything interesting to say about routing
Will follow standard curriculum Much of it covered in the text
But will focus more on principles than details
Will work through two algorithms, but details may wait until Wednesday..134 slides! Lets just see how timing goes If you dont want to be bored, ask questions!
7
Remember. Goal of the first portion of course is conceptual
Ignore real networks
Think about the basic concepts
Thats where we are. Later will deal with reality
8
9Basics of Routing and Forwarding
Addressing (at a conceptual level) Assume all hosts have unique IDs
No particular structure to those IDs
Later in course will talk about real IP addressing
10
Packets (at a conceptual level) Assume packet headers contain:
Source ID, Destination ID, and perhaps other information
11
DestinationIdentifierSource
Identifier
Payload
Why includethis?
Switches/Routers Multiple ports (attached to other switches or hosts)
Ports are typically duplex (incoming and outgoing)12
incoming links outgoing linksSwitch
Example of Network Graph
13
Six ports, incoming/outgoing
Four ports, incoming/outgoing
A Variety of Networks ISPs: carriers
Backbone Edge Border (to other ISPs)
Enterprises: companies, universities Core Edge Border (to outside)
Datacenters: massive collections of machines Top-of-Rack Aggregation and Core Border (to outside) 14
UUNETs North American Network
15
Level3s American Network
16
Enterprise Network
17
Partial Datacenter Network
18
Switches Enterprise/Edge: typically 24 to 48 ports Aggregation switches: 192 ports or more Backbone: typically fewer ports Border: typically very few ports
19
Forwarding Decisions When packet arrives, must choose outgoing port
Decision is based on routing state (table) in switch20
incoming links outgoing linksSwitch
Consider packet header
and routing table
Forwarding Decisions When packet arrives..
Must decide which outgoing port to use In single transmission time Forwarding decisions must be simple
Routing state dictates where to forward packets Assume decisions are deterministic
Global routing state means collection of routing state in each of the routers Will focus on where this routing state comes from But first, a few preliminaries. 21
Forwarding vs Routing Forwarding: data plane
Directing a data packet to an outgoing link Individual router using routing state
Routing: control plane Computing paths the packets will follow Routers talking amongst themselves Jointly creating the routing state
Two very different timescales.
22
23
Validity of Routing State
Valid Routing State Global routing state is valid if it produces
forwarding decisions that always deliver packets to their destinations Valid is my terminology, not standard
Goal of routing protocols: compute valid state But how can you tell if routing state if valid?
24
Necessary and Sufficient Condition Global routing state is valid if and only if:
There are no dead ends (other than destination) There are no loops
A dead end is when there is no outgoing port A packet arrives, but the forwarding decision does not
yield any outgoing port
A loop is when a packet cycles around the same set of nodes forever
25
Necessary: Obvious If you run into a deadend before hitting destination,
youll never reach the destination
If you run into a loop, youll never reach destination With deterministic forwarding, once you loop, youll loop
forever (assuming routing state is static)
26
Wandering Packets
27
Packet reaches deadend and stopsPacket falls into loop and never reaches destination
Sufficient: Easy Assume no deadends, no loops
Packet must keep wandering, without repeating If ever enter same switch from same port, will loop Because forwarding decisions are deterministic
Only a finite number of possible ports for it to visit It cannot keep wandering forever without looping Must eventually hit destination
28
The Secret of Routing Avoiding deadends is easy Avoiding loops is hard The key difference between routing protocols is
how they avoid loops! Dont focus on details of mechanisms Just ask how are loops avoided?
Will return to this later.
29
Making Forwarding Decisions Map PacketState+RoutingState into OutgoingPort
At line rates..
Packet State: Destination ID Source ID Incoming Port (from switch, not packet) Other packet header information?
Routing State: Stored in router
30
Forwarding Decision Dependencies Must depend on destination
Could also depend on : Source: requires n2 state Input port: not clear what this buys you Other header information: lets ignore for now
We will focus only on destination-based routing But first consider the alternative
31
Source/Destination-Based Routing
32
Paths from two different sources (to same destination) can be very different
Destination-Based Routing
33
Paths from two different sources (to same destination) must coincide once they overlap
Destination-Based Routing Paths to same destination never cross
Once paths to destination meet, they never split
Set of paths to destination create a delivery tree Must cover every node exactly once Spanning Tree rooted at destination
34
A Delivery Tree for a Destination
35
Checking Validity of Routing State Focus only on a single destination
Ignore all other routing state
Mark outgoing port with arrow There can only be one at each node
Eliminate all links with no arrows
Look at whats left.
36
Example 1
37
Pick Destination
38
Put Arrows on Outgoing Ports
39
Remove Unused Links
40
Leaves Spanning Tree: Valid
Second Example
41
Second Example
42
Is this valid?
Lesson. Very easy to check validity of routing state for a
particular destination
Deadends are obvious Node without outgoing arrow
Loops are obvious Disconnected from rest of graph
43
44
Computing Routing State
Forms of Route Computation Learn from observing.
Not covered in your reading
Centralized computation One node has the entire network map
Pseudo-centralized computation All nodes have the entire network map
Distributed computation No one has the entire network map
45
How Can You Avoid Loops? Restrict topology to spanning tree
If the topology has no loops, packets cant loop!
Central computation Can make sure no loops
Minimizing metric in distributed computation Loops are never the solution to a minimization problem
46
47
Self-Learning on Spanning Tree
Easiest Way to Avoid Loops Use a topology where loops are impossible!
Take arbitrary topology
Build spanning tree (algorithm covered later) Ignore all other links (as before)
Only one path to destinations on spanning trees
Use learning switches to discover these paths No need to compute routes, just observe them 48
Consider previous graph
49
A Spanning Tree
50
Another Spanning Tree
51
Yet Another Spanning Tree
52
Flooding on a Spanning Tree If you want to send a packet that will reach all
nodes, then switches can use the following rule: Ignoring all ports not on spanning tree!
Originating switch sends flood packet out all ports
When a flood packet arrives on one incoming port, send it out all other ports
53
Flooding on Spanning Tree
54
Flooding on Spanning Tree (Again)
55
Flooding on a Spanning Tree This works because the lack of loops prevents the
flooding from cycling back on itself Eventually all nodes will be covered, exactly once
56
This Enables Learning! There is only one path from source to destination
Each switch can learn how to reach a another node by remembering where its flooding packets came from!
If flood packet from Node A entered switch from port 4, then to reach Node A, switch sends packets out port 4
57
Learning from Flood Packets
58
Node A
Node A can be reachedthrough this port
Node A can be reachedthrough this port
Once a node has sent a flood message, all other switches know how to reach it.
General Approach Flood first packet All switches learn where you are When destination responds, all switches learn
where it is
Done.
59
60
Self-Learning SwitchWhen a packet arrives Inspect source ID, associate with incoming port Store mapping in the switch table Use time-to-live field to eventually forget mapping
A
B
C
D
Packet tells switch how to reach A.
61
Self Learning: Handling MissesWhen packet arrives with unfamiliar destination
Forward packet out all other ports
Response will teach switch about that destination
A
B
C
D
When in doubt, shout!
62
General RuleWhen switch receives a packet:index the switch table using destination IDif entry found for destination {
if dest on port from which packet arrivedthen drop packetelse forward packet on port indicated
}else flood
forward on all but the interface
on which the frame arrived
Why do this?
Summary of Learning Approach Avoids loop by restricting to spanning tree This makes flooding possible Flooding allows packet to reach destination And in the process switches learn how to reach
source of flood No route computation
63
Weaknesses of This Approach? Requires loop-free topology (Spanning Tree) Slow to react to failures (entries time out) Very little control over paths Spanning Trees suck.
64
On to other routing techniques
65
66
A Little Test
How many of you did the reading?
The Task Remove sheet of paper from beanbag, but do not
look at sheet of paper until I say so
You will have five minutes to complete this task
Each sheet says:You are node X You are connected to nodes Y,Z
Your job: find route from source (node 1) to destination (node 40) in five minutes
67
Ground Rules You may not:
Leave your seat (but you can stand) Pass your sheet of paper Let anyone copy your sheet of paper
You may: Ask nearby friends for advice Shout to other participants (anything you want) Curse your instructor (sotto voce)
You must: Try68
Go!
69
1 16 36 7 25
10 19 5 34 38
29 33 15 39 23
14 9 2 35 11
22 32 26 21 37
3 28 12 30 4
27 20 31 18 24
40 8 17 6 13
71
5 Minute Break
Questions Before We Proceed?
How Can You Avoid Loops? Restrict topology to spanning tree Central computation (can make sure no loops) Minimizing metric in distributed computation Any other techniques?
72
Organization for Rest of Lecture Link-state routing Distance-vector routing
Goal of today: basic idea May review details on Wednesday Definitely go over details in section
73
74
Link-State
Details in Section
Another Approach to Loop-Avoidance If one has a picture of the entire network, can
compute routing state that does not produce loops
This route computation can be done in many ways Here we will review Dijkstras algorithm briefly But thats just because it is expected from such courses
o Snore..
The real question is, how do you get picture of entire network?
75
76
Link-State Routing Is Conceptually Simple Each router keeps track of its incident links Each router broadcasts the link state
To give every router a complete view of the graph
Each router runs Dijkstras algorithm Compute shortest paths, then construct forwarding table
Example protocols Open Shortest Path First (OSPF) Intermediate System Intermediate System (IS-IS)
Challenges: scaling, transient disruptions
77
Link State Routing Each node floods its local information Each node then knows entire network topology
Host A
Host BHost E
Host D
Host C
N1 N2
N3
N4
N5
N7N6
78
Link State: Each Node Has Global View
Host A
Host BHost E
Host D
Host C
N1 N2
N3
N4
N5
N7N6
A
BE
DC
A
BE
DC A
BE
DC
A
BE
DC
A
BE
DC
A
BE
DC
A
BE
DC
How to Compute Routes Each node should have same global view They each compute their own routing tables Using exactly the same algorithm Can use any algorithm that avoids loops Computing shortest paths is one such algorithm
Associate a cost with each link Dont worry what it stands for.
79
Dijkstras Shortest Path Algorithm INPUT:
Network topology (graph), with link costs OUTPUT:
Least cost paths from one node to all other nodes Produces tree of routes
o Different from what we talked about beforeo Previous tree was rooted at destinationo This is rooted at sourceo But shortest paths are reversible!
80
Least Cost Routes No sensible cost metric will be minimized by
traversing a loop Least cost routes an easy way to avoid loops Least cost routes are also destination-based
i.e., do not depend on the source Why is this?
Therefore, least-cost paths form a spanning tree
81
82
Example
A
ED
CB
F
2
2
13
1
1
2
53
5
83
Notation
c(i,j): link cost from node ito j; cost infinite if not direct neighbors; 0
D(v): current value of cost of path from source to destination v
p(v): predecessor node along path from source to v, that is next to v
S: set of nodes whose least cost path definitively known
A
ED
CB
F
2
21
3
1
1
2
53
5
Source
84
Dijsktras Algorithm1 Initialization:2 S = {A};3 for all nodes v4 if v adjacent to A5 then D(v) = c(A,v); 6 else D(v) = ;7 8 Loop9 find w not in S such that D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent to w and not in S: 12 if D(w) + c(w,v) < D(v) then
// w gives us a shorter path to v than weve found so far13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
c(i,j): link cost from node i to j D(v): current cost source v p(v): predecessor node along
path from source to v, that is next to v
S: set of nodes whose least cost path definitively known
85
Example: Dijkstras AlgorithmStep
012345
start SA
D(B),p(B)2,A
D(C),p(C)5,A
D(D),p(D)1,A
D(E),p(E) D(F),p(F)
A
ED
CB
F2
21
3
1
1
2
53
5
1 Initialization:2 S = {A};3 for all nodes v4 if v adjacent to A5 then D(v) = c(A,v); 6 else D(v) = ;
86
Example: Dijkstras AlgorithmStep
012345
start SA
D(B),p(B)2,A
D(C),p(C)5,A
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
A
ED
CB
F2
21
3
1
1
2
53
5
D(D),p(D)1,A
D(E),p(E) D(F),p(F)
87
Example: Dijkstras AlgorithmStep
012345
start SA
AD
D(B),p(B)2,A
D(C),p(C)5,A
D(D),p(D)1,A
D(E),p(E) D(F),p(F)
A
ED
CB
F2
21
3
1
1
2
53
5
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
88
Example: Dijkstras AlgorithmStep
012345
start SA
AD
D(B),p(B)2,A
D(C),p(C)5,A4,D
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
A
ED
CB
F2
21
3
1
1
2
53
5
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
89
Example: Dijkstras AlgorithmStep
012345
start SA
ADADE
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
A
ED
CB
F2
21
3
1
1
2
53
5
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
90
Example: Dijkstras AlgorithmStep
012345
start SA
ADADE
ADEB
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
A
ED
CB
F2
21
3
1
1
2
53
5
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
91
Example: Dijkstras AlgorithmStep
012345
start SA
ADADE
ADEBADEBC
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
A
ED
CB
F2
21
3
1
1
2
53
5
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
92
Example: Dijkstras AlgorithmStep
012345
start SA
ADADE
ADEBADEBC
ADEBCF
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
A
ED
CB
F2
21
3
1
1
2
53
5
8 Loop9 find w not in S s.t. D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent
to w and not in S: 12 If D(w) + c(w,v) < D(v) then13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;
93
Example: Dijkstras AlgorithmStep
012345
start SA
ADADE
ADEBADEBC
ADEBCF
D(B),p(B)2,A
D(C),p(C)5,A4,D3,E
D(D),p(D)1,A
D(E),p(E)
2,D
D(F),p(F)
4,E
A
ED
CB
F2
21
3
1
1
2
53
5To determine path A C (say), work backward from C via p(v)
94
Running Dijkstra at node A gives the shortest path from A to all destinations
We then construct the forwarding table
The Forwarding Table
A
ED
CB
F2
21
3
1
1
2
53
5 Destination LinkB (A,B)C (A,D)D (A,D)E (A,D)F (A,D)
Complexity How much processing does running the Dijkstra
algorithm take? Assume a network consisting of N nodes
Each iteration: check all nodes w not in S N(N+1)/2 comparisons: O(N2) More efficient implementations: O(N log(N))
95
96
Flooding the Topology Information Each router sends information out its ports The next node sends it out through all of its ports
Except the one where the information arrived Need to remember previous msgs, suppress duplicates!
X A
C B D(a)
X A
C B D(b)
X A
C B D(c)
X A
C B D(d)
Making Flooding Reliable Reliable flooding
Ensure all nodes receive link-state information Ensure all nodes use the latest version
Challenges Packet loss Out-of-order arrival
Solutions Acknowledgments and retransmissions Sequence numbers
How can it still fail?97
When to Initiate Flood? Topology change
Link or node failure Link or node recovery
Configuration change Link cost change Potential problems with making cost dynamic!
Periodically Refresh the link-state information Typically (say) 30 minutes Corrects for possible corruption of the data
98
99
Convergence Getting consistent routing information to all nodes
E.g., all nodes having the same link-state database
Forwarding is consistent after convergence All nodes have the same link-state database All nodes forward packets on same paths
100
Convergence Delay Time elapsed before every router has a consistent
picture of the network Sources of convergence delay
Detection latency Flooding of link-state information Recomputation of forwarding tables Storing forwarding tables
Performance during convergence period Lost packets due to blackholes and TTL expiry Looping packets consuming resources Out-of-order packets reaching the destination
Very bad for VoIP, online gaming, and video
101
Inconsistent link-state database Some routers know about failure before others The shortest paths are no longer consistent Can cause transient forwarding loops
Transient Disruptions
A
ED
CB
F A
ED
CB
F
A and D think that thisis the path to C
E thinks that thisis the path to C
Loop!
102
Reducing Convergence Delay Faster detection
Smaller hello timers Link-layer technologies that can detect failures
Faster flooding Flooding immediately Sending link-state packets with high-priority
Faster computation Faster processors on the routers Incremental Dijkstra algorithm
Faster forwarding-table update Data structures supporting incremental updates
103
Scaling Link-State Routing Overhead of link-state routing
Flooding link-state packets throughout the network Running Dijkstras shortest-path algorithm Becomes unscalable when 100s of routers
Introducing hierarchy through areas
Area 0
Area 1 Area 2
Area 3 Area 4
areaborderrouter
104
Distance-Vector
Details in Section
Distributed Computation of Routes More scalable than Link-State
No global flooding
Each node computing the outgoing port based on: Local information (who it is connected to) Paths advertised by neighbors
105
Distributed Computation
106
I am one hop away
I am one hop away
I am one hop away
I am two hops away
I am two hops away
I am two hops away
I am two hops away
I am three hops away
I am three hops away
Loops in a Distributed Computation If the nodes choose their paths according to
different criterion, then loops can occur Example
Node A is minimizing hop count Node B is minimizing latency Node C is maximizing capacity Node D is minimizing price
Any of those goals are fine, if globally adopted Only a problem when nodes use different criteria
Any criteria that results in destination-based routing is fine.
107
108
Distance Vector Routing Each router knows the links to its neighbors
Does not flood this information to the whole network
Each router has provisional shortest path E.g.: Router A: I can get to router B with cost 11 via
next hop router D
Routers exchange this information with their neighboring routers Again, no flooding the whole network
Routers update their idea of the best path using info from neighbors
This iterative process converges with set of shortest paths
109
Information Flow in Distance Vector
Host A
Host BHost E
Host D
Host C
N1 N2
N3
N4
N5
N7N6
110
Information Flow in Distance Vector
Host A
Host BHost E
Host D
Host C
N1 N2
N3
N4
N5
N7N6
111
Information Flow in Distance Vector
Host A
Host BHost E
Host D
Host C
N1 N2
N3
N4
N5
N7N6
Why Is This Different From Flooding?
112
Bellman-Ford Algorithm INPUT:
Link costs to each neighbor Not full topology
OUTPUT: Next hop to each destination and the corresponding cost Does not give the complete path to the destination
113
114
Bellman-Ford - Overview Each router maintains a table
Best known distance from X to Y,via Z as next hop = DZ(X,Y)
Each local iteration caused by: Local link cost change Message from neighbor
Notify neighbors only if least cost path to any destination changes Neighbors then notify their neighbors if
necessary
wait for (change in local link cost or msg from neighbor)
recompute distance table
if least cost path to any dest has changed, notifyneighbors
Each node:
Bellman-Ford - Overview Each router maintains a table
Row for each possible destination Column for each directly-attached
neighbor to node Entry in row Y and column Z of node X best known distance from X to Y, via
Z as next hop = DZ(X,Y)
A C12
7
B D3
1
B CB 2 8C 3 7D 4 8
Node A
Neighbor (next-hop)
Destinations DC(A, D)
Bellman-Ford - Overview Each router maintains a table
Row for each possible destination Column for each directly-attached
neighbor to node Entry in row Y and column Z of node X best known distance from X to Y, via
Z as next hop = DZ(X,Y)
A C12
7
B D3
1
B CB 2 8C 3 7D 4 8
Node A
Smallest distance in row Y = shortestDistance of A to Y, D(A, Y)
117
Distance Vector Algorithm (contd)1 Initialization:2 for all neighbors V do3 if V adjacent to A4 D(A, V) = c(A,V);5 else6 D(A, V) = ;7 send D(A, Y) to all neighborsloop:
8 wait (until A sees a link cost change to neighbor V /* case 1 */9 or until A receives update from neighbor V) /* case 2 */10 if (c(A,V) changes by d) /* case 1 */11 for all destinations Y that go through V do12 DV(A,Y) = DV(A,Y) d13 else if (update D(V, Y) received from V) /* case 2 */
/* shortest path from V to some Y has changed */14 DV(A,Y) = DV(A,V) + D(V, Y); /* may also change D(A,Y) */15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever
c(i,j): link cost from node i to j DZ(A,V): cost from A to V via Z D(A,V): cost of As best path to V
Example:1st Iteration (C A)
A C12
7
B D3
1
B CB 2 8C 7D 8
Node A
A C DA 2 C 1 D 3
Node B
Node C
A B DA 7 B 1 D 1
B CA B 3 C 1
Node D7 loop:
13 else if (update D(A, Y) from C) 14 DC(A,Y) = DC(A,C) + D(C, Y);15 if (new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
DC(A, B) = DC(A,C) + D(C, B) = 7 + 1 = 8DC(A, D) = DC(A,C) + D(C, D) = 7 + 1 = 8
Example: 1st Iteration (B A)
A C12
7
B D3
1
B CB 2 8C 3 7D 5 8
Node A
A C DA 2 C 1 D 3
Node B
Node C
A B DA 7 B 1D 1
Node D7 loop:
13 else if (update D(A, Y) from B) 14 DB(A,Y) = DB(A,B) + D(B, Y);15 if (new min. for destination Y)16 send D(A, Y) to all neighbors 17 forever
DB(A, C) = DB(A,B) + D(B, C) = 2 + 1 = 3DB(A, D) = DB(A,B) + D(B, D) = 2 + 3 = 5
B CA B 3 C 1
Example: End of 1st Iteration
A C12
7
B D3
1
B CB 2 8C 3 7D 5 8
Node A Node B
Node C
A B DA 7 3 B 9 1 4D 4 1
Node D
B CA 5 8B 3 2C 4 1
End of 1st Iteration All nodes knows the best two-hop paths
A C DA 2 3 C 9 1 4D 2 3
Example: 2nd Iteration (A B)
A C12
7
B D3
1
B CB 2 8C 3 7D 5 8
Node A Node B
Node C
A B DA 7 3 B 9 1 4D 4 1
Node D
B CA 5 8B 3 2C 4 1
A C DA 2 3 C 5 1 4D 7 2 3
7 loop:
13 else if (update D(B, Y) from A) 14 DA(B,Y) = DA(B,A) + D(A, Y);15 if (new min. for destination Y)16 send D(B, Y) to all neighbors 17 forever
DA(B, C) = DA(B,A) + D(A, C) = 2 + 3 = 5DA(B, D) = DA(B,A) + D(A, D) = 2 + 5 = 7
Example: End of 2nd Iteration
A C12
7
B D3
1
B CB 2 8C 3 7D 4 8
Node A
A C DA 2 3 11C 5 1 4D 7 2 3
Node B
Node C
A B DA 7 3 6B 9 1 4D 12 4 1
Node D
B CA 5 4B 3 2C 4 1
End of 2nd Iteration All nodes knows the best three-hop paths
Example: End of 3rd Iteration
A C12
7
B D3
1
B CB 2 8C 3 7D 4 8
Node A
A C DA 2 3 6C 5 1 4D 7 2 3
Node B
Node C
A B DA 7 3 5B 9 1 4D 11 4 1
Node D
B CA 5 4B 3 2C 4 1
End of 2nd Iteration: Algorithm
Converges!
Intuition Initial state: best one-hop paths One round: best two-hop paths Two rounds: best three-hop paths
Kth round: best (k+1) hop paths
This must eventually converge.but how does it respond to changes in cost?
124
125
Distance Vector: Link Cost Changes
A C14
50
B1
goodnews travelsfast
A CA 4 6C 9 1
Node B
A BA 50 5B 54 1
Node C
Link cost changes heretime
Algorithm terminates
loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) /10 if (c(A,V) changes by d) /* case 1 */11 for all destinations Y that go through V do12 DV(A,Y) = DV(A,Y) d13 else if (update D(V, Y) received from V) /* case 2 */14 DV(A,Y) = DV(A,V) + D(V, Y); 15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever
A CA 1 6C 9 1
A BA 50 5B 54 1
A CA 1 6C 9 1
A BA 50 2B 51 1
A CA 1 3C 3 1
A BA 50 2B 51 1
126
DV: Count to Infinity Problem
A C14
50
B60
badnews travelsslowly
Node B
Node C
Link cost changes here time
loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) /10 if (c(A,V) changes by d) /* case 1 */11 for all destinations Y that go through V do12 DV(A,Y) = DV(A,Y) d13 else if (update D(V, Y) received from V) /* case 2 */14 DV(A,Y) = DV(A,V) + D(V, Y); 15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever
A CA 4 6C 9 1
A BA 50 5B 54 1
A CA 60 6C 9 1
A BA 50 5B 54 1
A CA 60 6C 9 1
A BA 50 7B 101 1
A CA 60 8C 9 1
A BA 50 7B 101 1
127
Distance Vector: Poisoned Reverse
A C14
50
B60 If B routes through C to get to A:
- B tells C its (Bs) distance to A is infinite (so C wont route to A via B)
- Will this completely solve count to infinityproblem?
Node B
Node C
Link cost changes here; C updates D(C, A) = 60 as B has advertised D(B, A) =
timeAlgorithm terminates
A CA 4 6C 9 1
A BA 50 5B 1
A CA 60 6C 9 1
A BA 50 5B 1
A CA 60 6C 9 1
A BA 50 B 1
A CA 60 51C 9 1
A BA 50 B 1
A CA 60 51C 9 1
A BA 50 B 1
Aside: Another Way to Avoid Loops? In Distributed Computation?
Exchange entire paths, not just cost of paths
Nodes can use arbitrary metrics to choose paths No need to agree on single metric
No loops, but algorithm might not converge
Will discuss later in semester128
Routing: Just the Beginning Link state and distance-vector (and path vector)
are the deployed routing paradigms But we know how to do much, much better Stay tuned for a later lecture where we:
Reduce convergence time to zero Respond to failures instantly!
129
Next Lecture Review computations (if needed)
What pieces are we missing? Naming Security Content retrieval ???
130