300 likes | 379 Views
Network Layer (contd.) Routing. network link physical. link physical. M. M. M. H t. M. H n. H n. H n. H n. H t. H t. H t. H t. M. M. M. M. H n. H t. H t. H l. H l. H l. H n. H n. H n. H t. H t. H t. M. M. M. Packet transfer in network. source. message.
E N D
network link physical link physical M M M Ht M Hn Hn Hn Hn Ht Ht Ht Ht M M M M Hn Ht Ht Hl Hl Hl Hn Hn Hn Ht Ht Ht M M M Packet transfer in network source message application transport network link physical segment datagram frame Encapsulation switch destination message application transport network link physical router
Network-Layer Functions • Forwarding: move packets from router’s input to router output Image courtesy: http://www.nd.edu/~networks/Image%20Gallery/gallery_old.htm Network Layer
Image courtesy: http://www.nd.edu/~networks/Image%20Gallery/gallery_old.htm application transport network data link physical application transport network data link physical Routing Routing Goal: determine “good” paths (sequences of routers) through network from source to dest. ?? 1. Send data 2. Receive data ?? ??
5 3 5 2 2 1 3 1 2 1 x z w y u v Routing: Graph formulation Graph abstraction for the routing problem: • graph nodes are routers • graph edges are physical links • links have properties: delay, capacity, $ cost, policy Graph: G = (N,E) N = set of routers = { u, v, w, x, y, z } E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
5 3 5 2 2 1 3 1 2 1 x z w u y v Graph abstraction: costs • c(x,x’) = cost of link (x,x’) • - e.g., c(w,z) = 5 • cost could always be 1, or • inversely related to bandwidth, • or inversely related to • congestion Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp) Network Layer
Key Desired Properties of a Routing Algorithm • Simplicity • Robustness • Optimality • find good path (for user/provider)
- Robustness - Optimality - Simplicity Routing Design Space • Routing has a large design space • who decides routing? • source routing: end hosts make decision • network routing: networks make decision • how many paths from source s to destination d? • multi-path routing • single path routing • will routing adapt to network traffic demand? • adaptive routing • static routing • …
Routing Design Space: examplenetwork routing - Robustness - Optimality - Simplicity • Routing has a large design space • who decides routing? • source routing: end hosts make decision • network routing: networks/routers make decision - Based on information available from the network • how many paths from source s to destination d? • multi-path routing • single path routing • will routing adapt to network traffic demand? • adaptive routing • static routing • …
Global or decentralized information? Global: all routers have complete topology, link cost info “link state” algorithms Decentralized: router knows physically-connected neighbors, link costs to neighbors iterative process of computation, exchange of info with neighbors “distance vector” algorithms 5 3 5 2 2 1 3 1 2 1 x z w u y v Routing Algorithm design based on available information Network Layer
Link state (LS) routing algorithm Network Layer
Network topology, link costs known to all nodes accomplished via “link state broadcast” all nodes have same info Problem Given a topology, link costs, and a source-destination (S-D) pair, determine a route from S to D so that the route has the minimum cost (i.e., is the shortest). Solution: Dijkstra’s shortest-path algorithm 5 3 5 2 2 1 3 1 2 1 x z w u y v Link-State Routing Algorithm Network Layer
Parameters: c(x,y): link cost from node x to y; = ∞ if not direct neighbors D(v): current value of cost of path from source to dest. v p(v): predecessor node along path from source to v N': set of nodes whose least cost path definitively known A Link-State Routing Algorithm: Dijkstra’s Algorithm Network Layer
5 3 5 2 2 1 3 1 2 1 x z w u y v Dijkstra’s algorithm: example Shortest paths: u x: 1,u u v: 2,u u y: 2,x u w: 3,y u z: 4,y D(v),p(v) 2,u 2,u 2,u D(x),p(x) 1,u D(w),p(w) 5,u 4,x 3,y 3,y D(y),p(y) ∞ 2,x Step 0 1 2 3 4 5 N' u ux uxy uxyv uxyvw uxyvwz D(z),p(z) ∞ ∞ 4,y 4,y 4,y Network Layer
x z w u y v destination link (u,v) v (u,x) x y (u,x) (u,x) w z (u,x) Dijkstra’s algorithm: example (2) Resulting shortest-path tree from u: Shortest paths: u x: 1,u u v: 2,u u y: 2,x u w: 3,y u z: 4,y Resulting forwarding table in u: Network Layer
Dijkstra’s Algorithm 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' Network Layer
Let’s solve this example! Determine shortest paths from R1 to all other nodes with corresponding predecessor nodes! Network Layer
Distance Vector routing algorithm Network Layer
Practically entire network topology (each link state) may not be known accurately Only the information to a direct neighbor may be known Distance-vector routing algorithm operates by Each router trusting its direct neighbors Each router maintain a table (vector) estimating the best known distance to each destination which line to use to get there Tables (vectors) are updated by exchanging information with the direct neighbors Distance Vector Routing
At node i, the basic update rule where - di denotes the distance estimation from i to the destination, - N(i) is set of neighbors of node i, and - dij is the distance of the direct link from i to j - dj denotes the distance estimation feedback from j to i Based on Bellman-Ford algorithm Distance Vector Routing: Basic Idea destination j i
wait for (change in local link cost or msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors Distance Vector Algorithm Each node: Iterative & Distributed • neighbors then notify their neighbors and so on… Network Layer
cost to x y z x 0 2 7 y from ∞ ∞ ∞ z ∞ ∞ ∞ 2 1 7 z x y D-V Algorithm example node x table node y table cost to x y z x ∞ ∞ ∞ 2 0 1 y from z ∞ ∞ ∞ node z table cost to x y z x ∞ ∞ ∞ y from ∞ ∞ ∞ z 7 1 0 time Network Layer Initially:
cost to x y z x 0 2 7 y from ∞ ∞ ∞ z ∞ ∞ ∞ 2 1 7 z x y Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 node x table cost to x y z x 0 2 3 y from 2 0 1 z 7 1 0 node y table cost to x y z x ∞ ∞ ∞ 2 0 1 y from z ∞ ∞ ∞ node z table cost to x y z x ∞ ∞ ∞ y from ∞ ∞ ∞ z 7 1 0 time Network Layer
cost to x y z x 0 2 7 y from ∞ ∞ ∞ z ∞ ∞ ∞ 2 1 7 z x y node x table cost to x y z x 0 2 3 y from 2 0 1 z 7 1 0 node y table cost to cost to x y z x y z x ∞ ∞ x 0 2 7 ∞ 2 0 1 y y from 2 0 1 from z z ∞ ∞ ∞ 7 1 0 node z table cost to cost to x y z x y z x 0 2 7 x ∞ ∞ ∞ y from y 2 0 1 from ∞ ∞ ∞ z z 3 1 0 7 1 0 time Network Layer
cost to x y z x 0 2 7 y from ∞ ∞ ∞ z ∞ ∞ ∞ 2 1 7 z x y node x table cost to cost to x y z x y z x 0 2 3 x 0 2 3 y from 2 0 1 y from 2 0 1 z 7 1 0 z 3 1 0 node y table cost to cost to cost to x y z x y z x y z x ∞ ∞ x 0 2 7 ∞ 2 0 1 x 0 2 3 y y from 2 0 1 y from from 2 0 1 z z ∞ ∞ ∞ 7 1 0 z 3 1 0 node z table cost to cost to cost to x y z x y z x y z x 0 2 7 x 0 2 3 x ∞ ∞ ∞ y y 2 0 1 from from y 2 0 1 from ∞ ∞ ∞ z z z 3 1 0 3 1 0 7 1 0 time Network Layer
1 4 1 50 x z y Distance Vector: link cost changes Link cost changes: • node detects local link cost change • updates routing info, recalculates distance vector • if DV changes, notify neighbors At time t0, y detects the link-cost change, updates its DV, and informs its neighbors. “good news travels fast” At time t1, z receives the update from y and updates its table. It computes a new least cost to x and sends its neighbors its DV. At time t2, y receives z’s update and updates its distance table. y’s least costs do not change and hence y does not send any message to z. Network Layer
Distance-Vector Algorithms: Link cost changes A goes down or line between A and B is down • Bad news propagate slowly • This is called the counting-to-infinity problem Distances to A
A B C D Solution: Split Horizon Hack • Actual distance to a destination is not reported on the line on which packets to that destination are sent. • Instead these distances are reported as • “infinity: Poisoned reverse” • Will this completely solve count-to-infinity problem? C tells D the truth about its distance to A, but lies to B and says the distance is infinity.
A topology where split horizon fails Suppose that D becomes unreachable from C. A and B are reporting infinite distances to C, but they are reporting distances of length 2 to each other. A and B will count to infinity.
Message complexity LS: with n nodes, E links, O(nE) msgs sent DV: exchange between neighbors only convergence time varies Speed of Convergence LS: O(n2) algorithm requires O(nE) msgs may have oscillations DV: convergence time varies may be routing loops count-to-infinity problem Robustness: what happens if router malfunctions? LS: node can advertise incorrect link cost each node computes only its own table DV: DV node can advertise incorrect path cost each node’s table used by others error propagate through network Comparison of LS and DV algorithms Network Layer