Chapter 4 Network Layer r 4 1 Introduction

  • Slides: 30
Download presentation
Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and datagram networks r 4. 3 What’s inside a router r 4. 4 IP: Internet Protocol m m Datagram format IPv 4 addressing ICMP IPv 6 r 4. 5 Routing algorithms m Link state m Distance Vector m Hierarchical routing r 4. 6 Routing in the Internet m m m RIP OSPF BGP r 4. 7 Broadcast and multicast routing Network Layer 1

ICMP: Internet Control Message Protocol r used by hosts & routers to communicate network-level

ICMP: Internet Control Message Protocol r used by hosts & routers to communicate network-level information m error reporting: unreachable host, network, port, protocol m echo request/reply (used by ping) r network-layer “above” IP: m ICMP msgs carried in IP datagrams m Not built on TCP! r ICMP message: type, code plus first 8 bytes of IP datagram causing error Type 0 3 3 3 4 Code 0 0 1 2 3 6 7 0 8 9 10 11 12 0 0 0 description echo reply (ping) dest. network unreachable dest host unreachable dest protocol unreachable dest port unreachable dest network unknown dest host unknown source quench (congestion control - not used) echo request (ping) route advertisement router discovery TTL expired bad IP header Network Layer 2

Traceroute and ICMP r Source sends series of UDP segments to dest m m

Traceroute and ICMP r Source sends series of UDP segments to dest m m m First has TTL =1 Second has TTL=2, etc. Unlikely port number r When nth datagram arrives to nth router: m m m Router discards datagram And sends to source an ICMP message (type 11, code 0) Message includes name of router& IP address Ethereal example r When ICMP message arrives, source calculates RTT r Traceroute does this 3 times Stopping criterion r UDP segment eventually arrives at destination host r Destination returns ICMP “host unreachable” packet (type 3, code 3) r When source gets this ICMP, stops. Network Layer 3

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and datagram networks r 4. 3 What’s inside a router r 4. 4 IP: Internet Protocol m m Datagram format IPv 4 addressing ICMP IPv 6 r 4. 5 Routing algorithms m Link state m Distance Vector m Hierarchical routing r 4. 6 Routing in the Internet m m m RIP OSPF BGP r 4. 7 Broadcast and multicast routing Network Layer 4

IPv 6 r Initial motivation: 32 -bit address space soon to be completely allocated.

IPv 6 r Initial motivation: 32 -bit address space soon to be completely allocated. r Additional motivation: m header format helps speed processing/forwarding m header changes to facilitate Qo. S m Checksum: removed entirely to reduce processing time at each hop IPv 6 datagram format: m fixed-length 40 byte header m no fragmentation allowed Very slow take off • IPv 4 still has space (CIDR, NAT) • Too trouble to upgrade Network Layer 5

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and datagram networks r 4. 3 What’s inside a router r 4. 4 IP: Internet Protocol m m Datagram format IPv 4 addressing ICMP IPv 6 r 4. 5 Routing algorithms m Link state m Distance Vector m Hierarchical routing r 4. 6 Routing in the Internet m m m RIP OSPF BGP r 4. 7 Broadcast and multicast routing Network Layer 6

Routing Algorithm classification Global or decentralized information? Global: r all routers have complete topology,

Routing Algorithm classification Global or decentralized information? Global: r all routers have complete topology, link cost info r “link state” algorithms Decentralized: r router knows physicallyconnected neighbors, link costs to neighbors r iterative process of computation, exchange of info with neighbors r “distance vector” algorithms Static or dynamic? Static: r routes change slowly over time Dynamic: r routes change more quickly m periodic update m in response to link cost changes Network Layer 7

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and datagram networks r 4. 3 What’s inside a router r 4. 4 IP: Internet Protocol m m Datagram format IPv 4 addressing ICMP IPv 6 r 4. 5 Routing algorithms m Link state m Distance Vector m Hierarchical routing r 4. 6 Routing in the Internet m m m RIP OSPF BGP r 4. 7 Broadcast and multicast routing Network Layer 8

A Link-State Routing Algorithm Dijkstra’s algorithm r net topology, link costs known to all

A Link-State Routing Algorithm Dijkstra’s algorithm r net topology, link costs known to all nodes m accomplished via “link state broadcast” m all nodes have same info r computes least cost paths from one node (“source”) to all other nodes m gives routing table for that node r iterative: after k iterations, know least cost path to k destinations Idea: r at each iteration increase spanning tree by the node that has least cost path to it 5 2 A B 2 1 D 3 C 3 1 5 F 1 E 2 Network Layer 9

A Link-State Routing Algorithm Notation: r c(i, j): link cost from node i to

A Link-State Routing Algorithm Notation: r c(i, j): link cost from node i to j. cost infinite if not direct neighbors r D(v): current value of cost of path from source to dest. V Examples: r c(B, C) = 3 r D(E) = 2 r p(B) = A r N = { A, B, D, E } 5 r p(v): predecessor node along path from source to v, that is next v r N: set of nodes already in spanning tree (least cost path known) 2 A B 2 1 D 3 C 3 1 5 F 1 E 2 Network Layer 10

Dijsktra’s Algorithm 1 Initialization: 2 N = {A} 3 for all nodes v 4

Dijsktra’s Algorithm 1 Initialization: 2 N = {A} 3 for all nodes v 4 if v adjacent to A 5 then D(v) = c(A, v) 6 else D(v) = infinity 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 11

Dijkstra’s algorithm: example Step N 0 A 1 AD 2 ADE 3 ADEB 4

Dijkstra’s algorithm: example Step N 0 A 1 AD 2 ADE 3 ADEB 4 ADEBC 5 ADEBCF D(B), p(B) D(C), p(C) D(D), p(D) D(E), p(E) D(F), p(F) 2, A 5, A 1, A infinity, 2, A 4, D 1, A 2, D infinity, 2, A 3, E 1, A 2, D 4, E 5 A 1 2 B 2 D 3 C 3 1 5 F 1 E 2 Network Layer 12

Spanning tree gives routing table Step N ADEBCF D(B), p(B) D(C), p(C) D(D), p(D)

Spanning tree gives routing table Step N ADEBCF D(B), p(B) D(C), p(C) D(D), p(D) D(E), p(E) D(F), p(F) 2, A 3, E 1, A 2, D 4, E Result from Dijkstra’s algorithm destination Routing table: 5 Outgoing link to use, cost B B, 2 C D, 3 D D, 1 E D, 2 F D, 4 A 1 2 B 2 D 3 C 3 1 5 F 1 E 2 Network Layer 13

Dijkstra’s algorithm performance Algorithm complexity (n nodes and l links) r Computation m n

Dijkstra’s algorithm performance Algorithm complexity (n nodes and l links) r Computation m n iterations m each iteration: need to check all nodes, w, not in N m n*(n+1)/2 comparisons: O(n 2) m more efficient implementations possible: O(n log n) r Messages m network topology and link cost known to all nodes m each node broadcasts its direct link cost m O(l) messages per broadcast announcement m O(n l) Network Layer 14

Dijkstra’s algorithm discussion Oscillations are possible r dynamic link cost e. g. , link

Dijkstra’s algorithm discussion Oscillations are possible r dynamic link cost e. g. , link cost = amount of carried traffic by link c(i, j) != c(j, i) m m r Example: D 1 1 0 A 0 0 C e 1+e e initially B 1 2+e A 0 D 1+e 1 B 0 0 C … recompute routing 0 D 1 A 0 0 C 2+e B 1+e … recompute 2+e A 0 D 1+e 1 B e 0 C … recompute Network Layer 15

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and

Chapter 4: Network Layer r 4. 1 Introduction r 4. 2 Virtual circuit and datagram networks r 4. 3 What’s inside a router r 4. 4 IP: Internet Protocol m m Datagram format IPv 4 addressing ICMP IPv 6 r 4. 5 Routing algorithms m Link state m Distance Vector m Hierarchical routing r 4. 6 Routing in the Internet m m m RIP OSPF BGP r 4. 7 Broadcast and multicast routing Network Layer 16

Distance Vector Algorithm (1) Bellman-Ford Equation (dynamic programming) Define dx(y) : = cost of

Distance Vector Algorithm (1) Bellman-Ford Equation (dynamic programming) Define dx(y) : = cost of least-cost path from x to y Then dx(y) = minv {c(x, v) + dv(y) } where min is taken over all neighbors of x Network Layer 17

Distance Vector Algorithm (3) r Dx(y) = estimate of least cost from x to

Distance Vector Algorithm (3) r Dx(y) = estimate of least cost from x to y r Distance vector: Dx = [Dx(y): y є N ] r Node x knows cost to each neighbor v: c(x, v) r Node x maintains Dx = [Dx(y): y є N ] r Node x also maintains its neighbors’ distance vectors m For each neighbor v, x maintains Dv = [Dv(y): y є N ] Network Layer 18

Distance vector algorithm (4) Basic idea: r Each node periodically sends its own distance

Distance vector algorithm (4) Basic idea: r Each node periodically sends its own distance vector estimate to neighbors r When a node x receives new DV estimate from neighbor, it updates its own DV using B-F equation: Dx(y) ← minv{c(x, v) + Dv(y)} for each node y ∊ N r Under minor, natural conditions, the estimate Dx(y) converge the actual least cost dx(y) Network Layer 19

Distance Vector Algorithm (5) Iterative, asynchronous: each local iteration caused by: r local link

Distance Vector Algorithm (5) Iterative, asynchronous: each local iteration caused by: r local link cost change r DV update message from neighbor Distributed: r each node notifies neighbors only when its DV changes m neighbors then notify their neighbors if necessary Each node: wait for (change in local link cost of msg from neighbor) recompute estimates if DV to any dest has changed, notify neighbors Network Layer 20

Distance Table: example A D (C, D) E D (A, D) E E A

Distance Table: example A D (C, D) E D (A, D) E E A B D A 1 14 5 B 7 8 5 C 6 9 4 D 4 11 2 C 2 8 1 E 1 cost to destination via D () 2 destination 7 B E D D = c(E, D) + minw {D (C, w)} = 2+2 = 4 D = c(E, D) + minw {D (A, w)} = 2+3 = 5 loop! X D (A, B) = c(E, B) + minw{D (A, w)} D (Y, Z) B = 8+6 = 14 loop! distance from X to = Y, via Z as next hop Z = c(X, Z) + minw{D (Y, w)} Network Layer 21

Distance table gives routing table E cost to destination via Outgoing link to use,

Distance table gives routing table E cost to destination via Outgoing link to use, cost B D A 1 14 5 A A, 1 B 7 8 5 B D, 5 C 6 9 4 C D, 4 D 4 11 2 D D, 2 Distance table destination A destination D () Routing table Network Layer 22

Distance Vector Algorithm: At all nodes, X: 1 Initialization: 2 for all adjacent nodes

Distance Vector Algorithm: At all nodes, X: 1 Initialization: 2 for all adjacent nodes v: 3 DX(*, v) = infinity /* the * operator means "for all rows" */ X 4 D (v, v) = c(X, v) 5 for all destinations, y X 6 send min D (y, w) to each neighbor /* w over all X's neighbors */ w Network Layer 23

Distance Vector Algorithm (cont. ): 8 loop 9 wait (until I see a link

Distance Vector Algorithm (cont. ): 8 loop 9 wait (until I see a link cost change to neighbor V 10 or until I receive update from neighbor V) 11 12 if (c(X, V) changes by d) 13 /* change cost to all dest's via neighbor V by d */ 14 /* note: d could be positive or negative */ 15 for all destinations y: DX(y, V) = DX(y, V) + d 16 17 else if (update received from V wrt destination Y) 18 /* shortest path from V to some Y has changed */ 19 /* V has sent a new value for its minw DV(Y, w) */ 20 /* call this received new value is "newval" */ 21 for the single destination y: DX(Y, V) = c(X, V) + newval 22 23 if we have a new minw DX(Y, w) for any destination Y 24 send new value of min w DX(Y, w) to all neighbors 25 Network Layer 26 forever 24

Distance Vector Algorithm: example X 2 Y 7 1 Z Network Layer 25

Distance Vector Algorithm: example X 2 Y 7 1 Z Network Layer 25

Distance Vector Algorithm: example X 2 Y 7 1 Z Z X D (Y,

Distance Vector Algorithm: example X 2 Y 7 1 Z Z X D (Y, Z) = c(X, Z) + minw{D (Y, w)} = 7+1 = 8 Y X D (Z, Y) = c(X, Y) + minw {D (Z, w)} = 2+1 = 3 Network Layer 26

Distance Vector: link cost changes Link cost changes: r node detects local link cost

Distance Vector: link cost changes Link cost changes: r node detects local link cost change r updates distance table (line 15) r if cost change in least cost path, notify neighbors (lines 23, 24) “good news travels fast” 1 X 4 Y 1 50 Z algorithm terminates Network Layer 27

Distance Vector: link cost changes Link cost changes: r good news travels fast r

Distance Vector: link cost changes Link cost changes: r good news travels fast r bad news travels slow - “count to infinity” problem! 60 X 4 Y 1 50 Z algorithm continues on! Network Layer 28

Distance Vector: poisoned reverse If Z routes through Y to get to X :

Distance Vector: poisoned reverse If Z routes through Y to get to X : r Z tells Y its (Z’s) distance to X is infinite (so Y won’t route to X via Z) r will this completely solve count to infinity problem? 60 X 4 Y 50 1 Z algorithm terminates Network Layer 29

Comparison of LS and DV algorithms Message complexity r LS: with n nodes, E

Comparison of LS and DV algorithms Message complexity r LS: with n nodes, E links, O(n. E) msgs sent r DV: exchange between neighbors only m convergence time varies Speed of Convergence r LS: O(n 2) algorithm requires O(n. E) msgs m may have oscillations r DV: convergence time varies m may be routing loops m count-to-infinity problem Robustness: what happens if router malfunctions? LS: m m node can advertise incorrect link cost each node computes only its own table DV: m m DV node can advertise incorrect path cost each node’s table used by others • error propagate thru network Network Layer 30