Network Layer: Routing The Problem A B R 1 R 2 R 4 R 3 Goal: for each destination, compute next hop 1 Lecture 9 2 Basic Assumptions Trivial solution: Flooding Dynamic environment: links and routers unreliable: Dynamic network! traffic patterns can change rapidly, affecting latency, bandwidth, packet drops Internet: alternative paths scarce (except on backbone) Local knowledge: Router knows all its incident links, and address of each neighbor Lecture 9 3 Rule: Forward packets to all ports except the ingress port. R 1 Advantages: Reaches destination! Even when network topology is completely unknown. Disadvantages: Some routers receive packet multiple times. Packets can go around in loops forever. Lecture 9 4
Slightly better: Controlled Flooding Each message has unique ID Messages are time-stamped and have limited time-to-live Problems: Doesn t scale Overhead: time, space Each message ID must be recorded Algorithm 2: Bellman-Ford Saw for Spanning Tree Protocol in bridges Idea: For each destination s aach node, periodically, tells all its neighbors what is its distance from s s: easy. dist s (s) = 0 always! Another node v: Mark neighbor with least distance as next hop break ties by neighbor ID Lecture 9 5 Lecture 9 6 Bellman-Ford: properties BF Algorithm: Lemma 1 Works for any non-negative link weights w(u,v): Works when the system operates asynchronously. Works regardless of the initial distances! Sketch here only the synchronous, unit-value weights. Lecture 9 7 After i time units, the value of the distance variable in any node v, d v satisfies d v min(i, distance(s,v)). Proof: induction on time, i (all distances). Base: i=0, d v 0 everywhere. Step: Suppose d u min(i, distance(s,u)) for all u at time i. Consider v at time i+1: If v assigns more than i, then done. Else v must have a neighbor u with value d < i in step i, and by induction distance(s,u) d-1, hence distance(s,v) d. Lecture 9 8
BF Algorithm: Lemma 2 At time i: if distance(s,v) i then d v distance(s,v). Proof: By induction on distance (all times together). Base: i=0, node is the source, trivial. Step: Suppose that the lemma holds for all nodes at distance d and all times. Consider a node v at distance d+1: v has a neighbor u at distance d. By induction, d u d by time d, hence v set its variable to at most d+1 at any time from i+1 and on. Problems with Bellman-Ford Suppose the source becomes unconnected: 1 D 0 1 G 2 E Lecture 9 9 Lecture 9 10 Fixes Split Horizon: don t tell dist to parent Add a hardwired bound on distances (TTL). Bound must be small to stabilize quickly Bound must be large to allow network growth. Advertise complete path Delete paths with cycles! DUAL: when cost increases, freeze table until all affected nodes know Distance Vector Algorithms Multiple instances of (some variant of) the BF Algorithm from each node: each node is the source in one instance n instances run in parallel (n = #nodes) Execution: Send distance vector when changes detected or upon timeout. Complexity: message size O(n), space O(n) for path-vector both O(Diam n) (Diam = max path length) Lecture 9 15 Lecture 9 16
Algorithm 3: Link State In distance vector, router knows only distance to each destination: hides much information! Link state: each router knows entire network topology. Compute shortest paths locally Key elements topology dissemination computing shortest routes Link state dissemination A router describes its incident links using a link state packet (LSP) Use flooding to distribute LSPs everywhere store an LSP in an LSP database if new, forward to every interface other than incoming one In a network with m links: each LSP copied at most 2m times (why?) Lecture 9 17 Lecture 9 18 Aging Creator of LSP puts timeout value in the header Router removes LSP when it times out So, on booting, router just has to wait for its old LSPs to be purged But what age to choose? if too small purged before fully flooded needs frequent updates if too large router waits idle for a long time on rebooting Router failure How to detect? HELLO protocol HELLO packet may be corrupted so age anyway on a timeout, flood the information Lecture 9 19 Lecture 9 20
Link State Algorithm Routers send out update messages whenever the state of a link changes/timeout. Each router calculates lowest cost path to all others, starting from itself: single source shortest paths algorithm. Usually: Dijkstra s. Computing shortest paths Dijkstra s Algorithm 1. Maintain a set of nodes P to whom we know shortest path, initially P={self} 2. Find the node closest to P: must be one of the nodes one hop away from nodes in P 3. Add this node to P O(m + n log n) steps for m links and n nodes Lecture 9 21 Lecture 9 22 Complexity of Link state Algorithms Denote m = # links. Communication complexity: message size O(m), Space complexity: O(m) Distance Vector vs Link State Basic ideas: DV: Each node advertises (sends to neighbors) distance to each destination; choose the closest based on neighbors announcements. LS: Each node advertises (floods to all) the state of its incident links; compute locally who s closets based on entire topology. Lecture 9 31 Lecture 9 32
Link state vs. distance vector Criteria Stability: LS wins? Multiple routing metrics: LS wins for generality Convergence time: depends on size of change communication overhead: DV wins memory overhead: DV wins Both are evenly matched Both widely used Choosing link costs Shortest path uses link costs Possible costs: Time Bandwidth Reliability Usually: cost determine amount of traffic on the link lower the cost, more the expected traffic if dynamic cost depends on load, can have oscillations (why?) Lecture 9 33 Lecture 9 34 Static metrics Simplest: set all link costs to 1. Min hop routing Propagation delay is roughly the same on all media but 28.8Kbps modem link 45Mbps T3! Actually, most time is spent waiting in queues Can assign cost inversely to bandwidth Dynamic metrics: time varying A first cut (ARPAnet original): Cost queue length independent of link capacity Many problems when network is loaded transient spikes caused major rerouting network completely ignored paths with high costs oscillations all tables computed simultaneously => low cost link flooded Lecture 9 35 Lecture 9 36
Modified metrics Example costs queue length averaged over a small time wide dynamic range queue queue length assumed to predict future loads no restriction on successively reported costs all tables computed simultaneously queue length averaged over a longer time dynamic range restricted cost also depends on intrinsic link capacity restriction on successively reported costs attempt to stagger table computation 225 140 90 75 60 30 9.6-Kbps satellite link 9.6-Kbps terrestrial link 56-Kbps satellite link 56-Kbps terrestrial link 25% 50% 75% 100% Utilization Lecture 9 37 Lecture 9 38 Routing dynamics Hierarchical routing Large networks need large routing tables more computation to find shortest paths more bandwidth wasted on exchanging DVs and LSPs Solution: hierarchical routing Key idea divide network into a set of domains gateways connect domains computers within domain unaware of outside computers gateways know only about other gateways Lecture 9 39 Lecture 9 40
Example Features only a few routers in each level not a strict hierarchy gateways participate in multiple routing protocols non-aggregable routers increase core table space Routing in the Internet Lecture 9 41 Lecture 9 42 RIP Routing Information Protocol Distance vector with split horizon and bounded distance Split horizon: never tell a neighbor the distance to s if the neighbor is next hop to s. Solves a common scenario of counting to infinity (but not all!) Cost metric is hop count Infinity = 16 Exchange distance vectors every 30 s Silence for 180 seconds interpreted as crash. Useful and popular for small networks easy to install OSPF Open Shortest Paths First Link-state algorithm with advanced features: May use multiple paths to balance load Possibly various metrics Hierarchical: Defines areas with autonomous routing Uses area border routers for next level in hierarchy Makes each routing table smaller Secure: LSPs are authenticated, databases are protected Complex Lecture 9 43 Lecture 9 44
IGRP => EIGRP (Extended) Interior Gateway Routing Protocol CISCO proprietary (1997); successor of RIP Distance Vector, like RIP several cost metrics (delay, bandwidth, reliability, load etc) routing tables exchanged only when costs change Loop-free routing achieved by DUAL Hierarchical routing in the Internet Two levels of routing: Organization are called autonomous systems (AS). Each AS implements its own routing Backbone level, connecting AS s Protocol between AS gateways: exterior gateway protocol Protocol within AS: interior gateway protocol Lecture 9 45 Lecture 9 46 Internet routing protocols Routing in the Internet AS A AS B AS C Interior RIP: distance vector OSPF: link-state IGRP (EIGRP): distance vector Others also possible BGP BGP Exterior: must have exactly one! BGP: path vector Interior Gateway Protocol Interior Gateway Protocol Interior Gateway Protocol Lecture 9 47 Stub AS (leaf) Transit AS e.g. backbone service provider Stub AS Lecture 9 48
Routing within a Stub AS Exterior Routing Protocols There is only one exit point (usually*), so routers within the AS can use default routing. Each router knows all Network IDs within AS. Packets destined to another AS are sent to the default router. Default router is the border gateway to the next AS. Routing tables in Stub AS s tend to be small. What we have to work with: Incompatibility of AS s link costs Different AS s have different objectives Some AS s don t trust others * Large AS s may have more than one ISP: multihomed Lecture 9 49 Lecture 9 50 Internet inter-as routing: BGP Path Vector protocol: Similar to Distance Vector protocol, but each node broadcasts to neighbors (peers) entire path (i.e, sequence of ASs) to destination E.g., node X may send its path to dest. Z: Path (X,Z) = X,Y1,Y2,Y3,,Z BGP Rationale Nodes may select paths based on their own discretion cost, payment, policy (don t route via competitors AS), loop prevention reasons. Nodes can control incoming traffic by controlling its route advertisements to peers: Lecture 9 51 Lecture 9 52
BGP BGP-4 Each AS has At least one border gateway to handle inter-as traffic At least one router that speaks BGP or node that participates in the routing protocol BGP speakers advertise Names of networks within the AS Names of networks reachable through the AS Full path information Intradomain protocols use heterogeneous metrics Withdrawn routes/negative advertisements Path-vector routing: complete paths Guarantees loop-free Example AS10 advertises 131.141 and 192.10.20 as local networks AS6 advertises same networks with path through (AS10) AS19 advertises same networks with path through (AS6,AS10) AS19 AS6 AS10 AS18 131.141 192.10.20 Lecture 9 53 Lecture 9 54 BGP implementation Extremely complex! BGP messages exchanged using TCP. BGP messages: OPEN: opens TCP connection to peer and authenticates sender UPDATE: advertises new path (or withdraws old) KEEPALIVE keeps connection alive in absence of UPDATES; also ACKs OPEN request NOTIFICATION: reports errors in previous msg; also used to close connection IP Datagram Lecture 9 55 56