Download Dijkstra's Algorithm and Link State Routing in Computer Networks and more Summaries Computer Networks in PDF only on Docsity!
Lowest-Cost Routing
EE 122: Intro to Communication Networks
Fall 2010 (MW 4-5:30 in 101 Barker) Scott Shenker TAs: Sameer Agarwal, Sara Alspaugh, Igor Ganichev, Prayag Narula 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
• Revision to lecture schedule
– Advanced topics on routing
• Revision to homework schedule
– 3a: get midterm questions right
– 3b: new topics
• Changes to class structure
– 5 minute “technology break”
– Administrivia right after break
– Group problem solving (when possible)
o Sit next to smart people
Forwarding vs. Routing
• Forwarding: “data plane”
– Directing a data packet to an outgoing link
– Individual router using a forwarding table
• Routing: “control plane”
– Computing paths the packets will follow
– Routers talking amongst themselves
– Jointly creating a forwarding table
Why Does Routing Matter?
• Routing provides connectivity!
– Without routing, the network doesn’t function
• Routing finds “good” paths
– Propagation delay, throughput, packet loss
• Routing allows network to tolerate failures
– Limits packet loss during disruptions
• Routing can also provide “Traffic Engineering”
– Balance traffic over the routers and links
– Avoid congestion by directing traffic to lightly-loaded links
– (Not covered today)
• Centralized global state
– Single entity knows the complete network structure
– Can calculate all routes centrally
– Problems with this approach?
• Distributed global state
– Every router knows the complete network structure
– Independently calculates routes
– Problems with this approach?
• Distributed global computation
– Every router knows only about its neighboring routers
– Participates in global joint calculation of routes
– Problems with this approach?
Routing Requires Knowing Network
Link State Routing E.g. Algorithm: Dijkstra E.g. Protocol: OSPF Distance Vector Routing E.g. Algorithm: Bellman-Ford E.g. Protocol: RIP
Modeling a Network
• Modeled as a graph
– Routers nodes
– Link edges
o Possible edge costs
- (^) Hop
- (^) Delay
- (^) Congestion level
- (^) ….
• Goal of Routing
– Determine “good” path from source to destination
– “Good” usually means the lowest “cost” path
- (^) Where cost is usually hop-count or latency
A
D E
B C
F
Why Isn’t All Routing Lowest-Cost?
• Lowest-cost routing assumes all nodes evaluate
paths the same way
– i.e., use same “cost” metric
• Interdomain routing:
– Different domains care about different things
– Can exercise general “policy” goals
• Requires very different route computation
– Talk about on Wednesday….
• Each router has complete network picture
– Topology
– Link costs
• How does each router get the global state?
– Each router reliably floods information about its
neighbors to every other router (more later)
• Each router independently calculates the
shortest path from itself to every other router
– Using, for example, Dijkstra’s Algorithm
Link State Routing
Link State: Node State
Host A Host B Host E Host D Host C N N N N N N6 N A B (^) E D C A B (^) E D C A B (^) E D C A B (^) E D C A B (^) E D C A B (^) E D C A B (^) E D C
Dijkstra’s 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 (why?)
Dijsktra’s Algorithm
1 Initialization:
2 S = { A };
3 for all nodes v
4 if v adjacent to A
5 then D(v) = c(A,v);
6 else D(v) = ;
8 Loop
9 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 we’ve found so far
13 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
Example: Dijkstra’s Algorithm
Step
start S
A
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
D E
B C
F
1 Initialization:
2 S = {A};
3 for all nodes v
4 if v adjacent to A
5 then D(v) = c(A,v);
6 else D(v) = ;
Example: Dijkstra’s Algorithm
Step
start S
A
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
D E
B C
F
8 Loop 9 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 :
- (^) If D(w) + c(w,v) < D(v) then
- (^) D(v) = D(w) + c(w,v); p(v) = w; 14 until all nodes in S;
Example: Dijkstra’s Algorithm
Step
start S
A
AD
D(B),p(B)
2,A
D(C),p(C)
5,A
4,D
D(D),p(D)
1,A
D(E),p(E)
2,D
D(F),p(F)
A
D E
B C
F
8 Loop 9 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 :
- (^) If D(w) + c(w,v) < D(v) then
- (^) D(v) = D(w) + c(w,v); p(v) = w; 14 until all nodes in S;