Network Layer Routing IS250 Spring 2010 chuang@ischool.berkeley.edu Outline Introduction - Router operation - Metric vs. policy based routing Metric-based routing - Shortest path computation - Distance vector and link-state algorithms and protocols Policy-based routing - Border Gateway Protocol (BGP) John Chuang 2 Two Basic Functions in Packet Switching Routing - Learn the best route to (or best next-hop for) any given destination - Exchange local link status or destination reachability information - Compute best path to destinations • Algorithms for computing shortest paths (e.g., Dijkstra’s) • Policies that reflect business agreements (use BGP) - Update the routing table Packet forwarding - For each packet received on an incoming link, forward it to an outgoing link according to the routing table John Chuang 3 Routing of Atoms John Chuang 4 Routing of Bits Backbone MAN Ethernet Local loop Host A Host B 12.2.14.60 128.32.226.87 John Chuang 5 Packet Switch (Router) Special-purpose computer system - CPU Memory I/O interfaces Software Connects to - Other packet switches - End hosts Store-and-forward paradigm - “Stores” packet in memory Examines packet’s destination address Looks up next-hop in routing table “Forwards” packets toward destination (hop-by-hop) John Chuang 6 Packet Switch in Action Incoming links Packet Outgoing links Data Plane Destination Outgoing Address Link w.x.y.z C Routing table John Chuang Control Plane Control plane of a router communicates with its counterparts at other routers using routing protocols (e.g., RIP, OSPF, BGP) 7 What is the Best Route? Route selection may be based on: - Latency/hop-count Bandwidth capacity Loss rate Cost Security requirements Business relationships (e.g., transit or peering agreements) - … Two flavors of routing: metric-based and policybased John Chuang 8 Metric-Based Routing and Policy-Based Routing Both used in practice for routing on the Internet - Metric-based routing typically employed within a network domain - Policy-based routing typically employed across network domains A network domain, also known as an autonomous system (AS), is a collection of IP networks and routers, usually under the control of a single administrative entity, that presents a common routing policy to the Internet - Examples: ISPs, corporations, universities John Chuang 9 Outline Introduction - Router operation - Metric vs. policy based routing Metric-based routing - Shortest path computation - Distance vector and link-state algorithms and protocols Policy-based routing - Border Gateway Protocol (BGP) John Chuang 10 Routing: A Graph Theoretic Perspective Note that each node has different view of the network, and therefore different routing table John Chuang 11 Shortest Path Computation Algorithm from graph theory Distributed computation (no central authority) A switch - Must learn route to all destinations - While communicating only with directly connected neighbors Example: John Chuang 12 Shortest Path Algorithms Distance vector - Switches exchange routing table info Link state - Switches exchange link status info Both used in practice - e.g., RIP (RFC 1058, 1388, 1723) is a distance vector routing protocol, OSPF (RFC 1131, 1247) is a link state routing protocol John Chuang 13 Link-State Routing Pair of switches periodically - Test link between them - Broadcast link status message to all switches in network Switch - Receives link status messages - Computes new routes (using Dijkstra’s algorithm) John Chuang 14 Dijkstra’s Algorithm Shortest Path First (SPF) algorithm Greedy algorithm Input: graph with nodes and weighted edges Output: shortest paths from source node i to every other node; cost of each path John Chuang 15 Dijkstra’s Algorithm John Chuang Source: Doug Comer 16 Algorithm Intuition Start at source node Move outward At each step: - Find node u that - has not been considered before; and - is closest to source - Compute: - Distance from u to each neighbor v - If distance shorter, make path to v go through u John Chuang 17 Dijkstra’s Algorithm Example Distance Predecessor John Chuang 18 Node A’s Routing Table John Chuang Destination Address B Next Hop (Cost) B (2) C D (3) D D (1) E D (2) F D (4) 19 Routing Dynamics Dijkstra’s Algorithm has a run-time of O(|V|2+|E|), but the routers run the algorithm continuously to keep their routing tables updated Link states constantly updated - New links can be added to network - Latency can change continuously - if link goes down, cost = infinity Routing tables may have transient inconsistency - Link state messages take time to propagate across network - Routers not synchronized in running route computation algorithm - Transient routing loops or routing black-holes John Chuang 20 Outline Introduction - Router operation - Metric vs. policy based routing Metric-based routing - Shortest path computation - Distance vector and link-state algorithms and protocols Policy-based routing - Border Gateway Protocol (BGP) John Chuang 21 Internet Routing Protocols Interior Gateway Protocols (IGPs) - Intra-AS or intra-domain Metric-based routing (e.g., hops, latency, cost) AS free to choose IGP and metric Examples: RIP, OSPF, IBGP Exterior Gateway Protocols (EGPs) - Inter-AS or inter-domain - Policy-based routing - All AS’s have to use the same EGP (currently BGP v4) John Chuang 22 Route Advertisement Instead of computing shortest paths based on DV or LS information, inter-domain routing is based on advertisements of routes Example: ISP1 sends route advertisement to ISP2 - ISP1 is willing to receive packets, destined to end-hosts within its domain, from ISP2 - ISP2 will enter this information into its routing table John Chuang 23 Network Interconnection transit Backbone AS 1 A Backbone AS 3 C AS 2 B Backbone peering Transit AS3 is a transitprovider of AS1: - For a payment, AS3 agrees to advertise route to AS1 to rest of Internet AS2 and AS3 are peers: - Exchange route advertisements (without any payments) John Chuang 24 Stub, Transit, and Multi-homed Three different types of AS: - Stub AS - Transit AS Backbone A Backbone A - Multi-homed AS Backbone A Backbone C AS 3 B Backbone Backbone A Backbone C AS 4 B Backbone Transit Backbone C AS 1 B Backbone AS 5 B Backbone Backbone C Backbone A Transit Transit AS 2 B Backbone Transit John Chuang 25 Border Gateway Protocol (BGP) Version 4: RFC 1771 (March 1995) Routing among Autonomous Systems No routing metrics Provisions for policies - Individual AS’s control advertisement of routes Facilities for transit routing - transit vs. stub domains - Multi-homing Reliable transport - Two BGP peers establish TCP session John Chuang 26 BGP Attributes Community attribute (no-advertise, no-export, internet) controls propagation of advertisement John Chuang 27 Community Attribute No Advertise No Export Internet John Chuang 28 BGP Attributes Community attribute (no-export, no-advertise, internet) controls propagation of advertisement Other attributes used for selecting best path among multiple paths to same destination: - Weight (local to a router) Local preference (propagated throughout AS) Multi-exit discriminator (suggestion to external AS) Origin (IGP, EGP, Incomplete) AS_Path (AS hop count, loop detection) Next hop (IP Address) John Chuang 29 BGP Path Selection 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. If the path specifies a next hop that is inaccessible, drop the update. Prefer the path with the largest weight. If the weights are same, prefer the path with largest local preference. If the local preferences are same, prefer the path originated by BGP running on this router. If no route was originated, prefer the route that with shortest AS_path. If all paths have the same AS_path length, prefer the path with the lowest origin type (where IGP < EGP < incomplete). If the origin codes are same, prefer the path with lowest MED attribute. If the paths have same MED, prefer external over internal path. If the paths are same, prefer path through the closest IGP neighbor. Prefer path with lowest IP address, as specified by the BGP router ID. John Chuang 30 Summary Packet switching as key network layer responsibility Packet switching = routing + packet forwarding Internet uses combination of metric-based routing (intra-domain) and policy-based routing (inter-domain) - Metric-based routing: shortest path computation based on distance vector or link state algorithms - Policy-based routing: route advertisements John Chuang 31