Network Layer
Network layer Physical layer: move bits between physically connected stations Data link layer: move frames between physically connected stations Network layer: move packets from source A to destination B where A and B can be world-apart
Main Network Layer Design Issues Routing: Where to send the packets received?
Routing Routing – Determining the path from the source to the destination. At a router, it means which output port should a packet to be sent to Desirable properties of the routing algorithms: correctness: of course simplicity: for efficiency robustness: must be able to sustain the changes in the networks (cannot just rely on reboot) stability: when run long enough, should converge to equilibrium fairness: every one gets to send optimality: as efficient as possible, of course Sometimes, these properties may conflict
Flooding Flooding send all the incoming packet to all outgoing links except the one the packet arrived on Reliable, fast, large overhead, not scalable user: military, distributed database(update everything), highly reliable packets.
Flooding Problems? A packet will be sent for infinite number of times Hop count. Don’t forward the same packet for more than H times. How to set H? Ask why when H=MAX DISTANCE, the packet must be delivered. – Consider the path between the sender and receiver.
Shortest Path Algorithm find the shortest path from the source to all other nodes. Dijkstra algorithm: finding the shortest paths from the source s to all other nodes in the network. 1) Initial set = empty, 2) maintain the distance from s to all other nodes (distance(s, s) = 0, distance(s, t) = infinite) 3) repeat until all nodes are included in the set 4) find a node d currently not in the set with shortest distance 5) include d in the set for other nodes not in set 7) if distance(s, m) > distance(s, d) + dist(d, m) then distance(s, m) = distance(s, d) + dist (d, m)
Dijkstra’s algorithm: example Step 1 2 3 4 5 start N A AD ADE ADEB ADEBC ADEBCF D(B),p(B) 2,A D(C),p(C) 5,A 4,D 3,E D(D),p(D) 1,A D(E),p(E) infinity 2,D D(F),p(F) infinity 4,E A E D C B F 2 1 3 5
Shortest Path Node added to the set has found its minimum distance path (visiting ONLY the nodes currently in the set, of course) to the source. Suppose this is not true. At a step, we add node W to the set but there is another path sZW with distance shorter than d(W). Supose Z is the first node in the path currently not in the set; such as Z must exist (why?). d(Z) must be less than d(W) (why?) and we would have added Z to the set at this step rather than W. So if we added W, we are using the shortest path. Note that any subpath on an optimal path is still optimal.
Link State Algorithm Each router independently computes optimal paths Must make sure that Each router sees the same cost for each link (using the same network topology) Uses the same algorithm (shortest path algorithm for OSPF) to compute the best path
Distance Vector Algorithm The LS algorithm works for relatively small networks, because it is necessarily a centralized algorithm. For larger networks, too expensive to store and disseminate the network topology, use DV algorithms.
Distance Vector Routing Algorithm Distance Table data structure each node has its own row for each possible destination column for each directly-attached neighbor to node example: in node X, for dest. Y via neighbor Z: D (Y,Z) X distance from X to Y, via Z as next hop c(X,Z) + min {D (Y,w)} Z w =
Distance Table of E A E D C B cost to destination via A 1 14 5 B 7 8 C 6 4 14 8 9 11 5 2 cost to destination via destination A E D C B 7 8 1 2 Lets look at an example. Here A, B, C, D, and E are routers and the links are labeled with their costs. And this is a distance table at router E. You can see that there is one row per each destination an one column per each neighbor. The distance from E to A via B is 14 because E-B is 8, while the best path from B to A is B-C-D-E-A and is 6. The distance from E to A via D is 5 because E-D is 2, while the best path from D to A is D-E-A and is 3. If you look at the third row, it says that you can reach C via A with cost 6, via B with cost 9 and via D with 4. So the shortest distance to C is 4 via D. If E were to advertise its distance vector it will send <A,1>,<B,5>,<C,4>,<D,2>.
Routing Table of E A B C D 1 7 6 4 14 8 9 11 5 2 cost to destination via destination Outgoing link to use, cost A B C D A,1 D,5 D,4 D,2 destination Distance table Routing table
Distance Vector Algorithm Iterative, asynchronous: each iteration caused by: local link cost change message from neighbor: its least cost path change from neighbor Distributed: each node notifies neighbors only when its least cost path to any destination changes neighbors then notify their neighbors if necessary Each node: wait for (change in local link cost or msg from neighbor) recompute distance table if least cost path to any dest has changed, notify neighbors
Example Y X Z 1 2 7 D (Y,Z) c(X,Z) + min {D (Y,w)} = 7+1 = 8 D (Z,Y) c(X,Y) + min {D (Z,w)} w = 2+1 = 3 Y
Example X Z 1 2 7 Y
Convergence of the algorithm router detects local link cost change updates distance table if cost change in least cost path, notify neighbors X Z 1 4 50 Y “good news travels fast” algorithm terminates
Problems with DV Routing Link cost changes: good news travels fast bad news travels slow “count to infinity” problem! X Z 1 4 50 Y 60 algorithm continues on! Suppose that link cost is increased from 4 to 60. Once again router Y senses the change, updates the distance table. It sees that it can reach X via Z with distance 6. Since the shortest distance changed, it notifies the neighbor Z. The router Z in turn updates its table and informs Y. This goes on and on. Do you know when it terminates? What will be the entries in distance table when it converges? It finally reaches steady state with distance from Y to X via Z as 51 and Z to X via Y as 52. This is the problem with distance vector routing. Good news travels fast but bad news travels slow. This results in what is known as count to infinity problem.
Path Vector Algorithm C B D The neighbor also tells about the path it is using. Line FG goes down. Node F wants to find path to D. B: BCD E: EFGCD I: IFGCD F can quickly decide to ignore the paths from I and E. A G F H E J I