Computer Networks Group Universität Paderborn Computer Networks Chapter 6: Routing Holger Karl
Dec 26, 2015
WS 05/06, v 1.1 Computer Networks - Routing 2
Goals of this chapter
Building larger networks by simply interconnecting LANs is limited, it does not scale
To build larger networks, the following questions have to be explicitly solved:
What are good paths that a packet should take to get from a source node to a destination node?
How to represent these paths by routing tables and how to construct them efficiently?
How to use routing tables (once constructed) efficiently? How to organize larger networks with respect to an addressing
structure that allows efficient & compact routing tables?
In addition, we will look at how the Internet’s routing structure looks like as a case study
WS 05/06, v 1.1 Computer Networks - Routing 3
Overview
From spanning trees to routing tables Computing routing tables Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
WS 05/06, v 1.1 Computer Networks - Routing 4
Goal: Build LARGE networks
The “internetworking” mechanisms described in previous chapter can help packets to reach their destination
Hubs: broadcast; switch: send to directly connected network Bridge: Flooding causes problems; spanning tree solves some of
them
Can we directly extend these mechanisms to large networks (millions or more nodes)?
Flooding clearly not a good idea Need some structure to decide where a packet should go A single spanning tree is not good, can introduce considerable
detours
WS 05/06, v 1.1 Computer Networks - Routing 5
Desirable: Shortest paths!
Instead of a single spanning tree for an entire network, provide shortest paths
Given a source and destination node for a packet, what is the shortest way to deliver the packet?
What does “shortest” mean? Fewest hops? Smallest delivery time? Lowest cost?
Choice to make: to which neighbor to forward a packet?
WS 05/06, v 1.1 Computer Networks - Routing 6
Destination
Forwarding table of W
Routing tables expressing costs
Routing table: For a given node and all its direct neighbors, express cost to send to any destination
Construct from routing table: Forwarding table
For a given node and any destination, express to which neighbor a packet should be passed on to minimize cost
Trivial to construct from routing table, but smaller and quicker to search
M P Z
U 2 3 4
V 3 2 3
X 4 3 2
Y 4 4 3
Destination
Neig
hb
or
Routing table of W
M P Z
U (2) V (2) X (2)
WS 05/06, v 1.1 Computer Networks - Routing 7
Properties for routing algorithms
Routing algorithm = an algorithm to compute routing tables Properties/classifications
Correct, simple Centralized/distributed Robustness
Can compensate quickly for failing links
Non-adaptive/adaptive to current situation of a network Also called: static/dynamic routing
Stable – will converge to an equilibrium over time Optimality (in throughput, delay, … or some other metric) Fairness
WS 05/06, v 1.1 Computer Networks - Routing 8
Overview
From spanning trees to routing tables Computing routing tables
Link-state routing algorithms Distance-vector routing algorithms
Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
WS 05/06, v 1.1 Computer Networks - Routing 9
Computing routing tables – A centralized view
Given a graph G=(V,E) and a cost function c : E! Real Compute, for each node v 2 V, the routing table to each
destination u 2 V Such that for each pair (v,u), the path (v, s1, …, sn, u) with
the minimal smallest cost can be derived easily from the routing table
By simply choosing the neighbor with the smallest entry Cost of a path is the sum of the costs of its edges
“All pairs-shortest path problem” Approach: Compute shortest paths from a given node to all
possible destination nodes; do that for all nodes in the network “Shortest path tree” NOT a minimum spanning tree computation
WS 05/06, v 1.1 Computer Networks - Routing 10
Centralized shortest path – Dijkstra
Given graph G=(V,E), cost c : E! real, source node A Algorithm can be applied to any source node, of course
Compute shortest paths to all destinations (and their cost)
Dijkstra’s algorithm Label each node with distance to source node A (or 1, if not known) Label each node as either tentative or permanent
Only nodes labeled permanent have final distance estimates
Label each node with its predecessor in the path towards the source Or mark as “unknown”
Initially, all labels are (1, tentative, unknown)
WS 05/06, v 1.1 Computer Networks - Routing 11
Centralized shortest path – Dijkstra
Initial action: Make node A permanent Whenever a node X is changed from tentative to
permanent with label (cX, permanent, W): For all neighbors Y of X with label (1, tentative, - ):
Replace label of Y by (cX + c(X,Y), tentative, X) First time a path is found for node Y
For all neighbors Y of X with label (cY, tentative, U):If cX + c(X,Y) < cY, replace label by (cX + c(X,Y), tentative, X)
A better path to Y has been found, via X instead of via U
Once relabeling step is complete, search (in entire graph) tentative node with smallest cost – and make it permanent
This is the closest node to A which is still uncertain, for any other node a still cheaper path might be found
Proceed until all nodes are labeled as “permanent”
WS 05/06, v 1.1 Computer Networks - Routing 13
Centralized vs. distributed algorithms – Link-state routing
Dijkstra’s algorithm nice and well But how to obtain centralized view of the entire network to
be able to apply Dijkstra’s algorithm? Assumption: only direct neighbors know the (current) cost of a link
or know whether a link has failed/been restored/upgraded/…
Solution: Have each node distribute this information – state of all its links – in the entire network
Then, all nodes know entire network topology & can apply Dijkstra’s algorithm
Distribution itself can happen via flooding
! Link-state routing Intuition: Little information (about direct neighbors) is spread over
large distances (to the entire network)
WS 05/06, v 1.1 Computer Networks - Routing 14
Overview
From spanning trees to routing tables Computing routing tables
Link-state routing algorithms Distance-vector routing algorithms
Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
WS 05/06, v 1.1 Computer Networks - Routing 15
Alternative approach: Distance-vector routing
Alternative idea to link state routing: Distribute lot’s of information over short distances
Distribute everything a node currently knows (or believes) about the entire network topology, but only to direct neighbors
This information is represented by the routing table (containing outgoing link and cost)
If reduced to cost only, also called a distance vector
Invented by Bellman & Ford (1957)
After receiving a routing table from a neighbor, compare whether it contains “good news”, i.e., a shorter route than the one currently known
Assumption: each router knows cost to each of its direct neighbors
In practice: It suffices to exchange distance vectors
WS 05/06, v 1.1 Computer Networks - Routing 16
Distance-vector routing – Formally
Suppose that node X Has distance vector (x1, … xn) for each of the n possible
destinations in the network Receives distance vector (y1, … , yn) from its neighbor Y
Has cost cXY to reach neighbor Y
Then: Node X compares, for every destination i,xi < yi + cXY
i.e., is it cheaper to go first to Y and then to i rather than to go to node i directly?
If yes, replace outgoing link for node i by y, update cost to yi + cXY
Algorithms keeps iterating
WS 05/06, v 1.1 Computer Networks - Routing 17
Distance-vector routing – Example
This is the (current version of)
routing table!
8
10
12
6
WS 05/06, v 1.1 Computer Networks - Routing 18
Overview
From spanning trees to routing tables Computing routing tables Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
WS 05/06, v 1.1 Computer Networks - Routing 19
Solution for LARGE networks?
What happens to routings when networks grow? Routing tables become longer and longer, requiring more memory Searching through routing/forwarding tables takes more and more
time, reducing throughput of a router/increasing delay Run-time of routing algorithms becomes larger
But: does a given node really care about details of the route “far away”?
Suppose you send a packet to an Australian university – do you care which route it takes from one campus router to the next?
It suffices to get the packet towards Australia For local packets, a router better should care!
! Hierarchical routing
WS 05/06, v 1.1 Computer Networks - Routing 20
Hierarchical routing – Regions
Group nodes/routers into regions Routers know
How to reach each node/router in their own region How to reach each other region
Perspectiveof one router
WS 05/06, v 1.1 Computer Networks - Routing 21
Routing within and between regions
A router perceives all routers in a “foreign” region as the same node, does not distinguish routing tables
Packet destined to own region: routed as normal Packet destined to other region: get it to the region, don’t
worry about details of routing there Once a packet enters its destination region, router knows about
the details how to reach the destination node
Necessary: Router must be able to easily infer the target region from packet’s destination!
Requires adequate addressing structure for a quick address ! region mapping
Treated a few slides later
WS 05/06, v 1.1 Computer Networks - Routing 22
Price of hierarchy
Hierarchical routing good for algorithm runtime, memory required for routing tables, next-hop lookup times, …
What is the price to pay?
Routes become non-optimal Since no longer all the details of the network are represented,
routing algorithms might miss optimization potential Can this overhead be bounded? Is it acceptable in practice?
WS 05/06, v 1.1 Computer Networks - Routing 23
Only regions? Or multiple levels of hierarchy?
If network becomes REALLY big, these two levels of hierarchy might again not suffice
Group regions into clusters, clusters into domains, domains into conglomerates, … (or whatever terminology pleases you)
Obvious question: How many levels of hierarchy? How many entities should be grouped together to form the next-
level conglomerate structure?
Good rule of thumb: For n nodes, use ln n levels of hierarchy
Requires e ln n entries in each routing table
Then: Good balance between routing overhead and smaller routing table sizes
WS 05/06, v 1.1 Computer Networks - Routing 24
Gateways between networks
Gateways are those nodes that connect to peer conglomerates
Such conglomerates arefairly independent of eachother
Different routing protocolscan be used – an interiorgateway protocol in each conglomerate
Between gateways, yet another protocol is conceivable – an exterior gateway protocol – operating only on the “gateway graph”
Because of autonomy, the name autonomous system is used
Gateways
WS 05/06, v 1.1 Computer Networks - Routing 25
Broadcast & multicast
Broadcast routing: Make sure every node receives a copy of a given packet
Unrestricted flooding is one (not particularly good) implementation option
Better: Construct minimum spanning tree, copy each packet going in on a given edge to all other tree edges
Related: Construction of minimal connected dominating set
Multicast routing: Ensure that each node of an explicitly given subset of all nodes receives a copy of a given packet
Algorithmically: Steiner tree problem, NP complete Several approximations, e.g., Takahashi & Matsuyama Various network constructions, tree-based or mesh-based
approaches
WS 05/06, v 1.1 Computer Networks - Routing 26
Overview
From spanning trees to routing tables Computing routing tables Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
WS 05/06, v 1.1 Computer Networks - Routing 27
Addressing – Failure of simple addresses
Think back to the MAC/LLC layer: Each device has a globally unique MAC address
Why is there then a need to talk about some other addressing scheme?
How did spanning tree algorithm for bridges work? Each bridge had to store a separate entry for each device to
which is was routing packets Lot’s of memory, CPU overhead (for searching)
! Clearly, this does not scale to large networks
WS 05/06, v 1.1 Computer Networks - Routing 28
Addressing and hierarchical routing
“Flat” addresses – addresses that express no structure – do not work well together with hierarchical routing
Necessary: Addresses that express/respect the hierarchical routing structure
Essentially, something like: Group-IDn:Group-IDn-1:…:Group-ID1:Device-ID
Hierarchical addresses – addresses are relative to higher groups
Perspectiveof one routerPerspectiveof one router
WS 05/06, v 1.1 Computer Networks - Routing 30
Overview
From spanning trees to routing tables Computing routing tables Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
IP addressing Growing pains: Subnetting, classless addressing Inter- and intra-domain routing in IP
WS 05/06, v 1.1 Computer Networks - Routing 31
Addressing case study: Internet IP addresses
IP addresses (traditionally) distinguish only two levels of hierarchies
Network interfaces/hosts Note: “hosts” is somewhat incorrect since their interfaces are actually
addressed; still common terminology Networks
Different sizes of networks conjectured, defined as three classes ! Classful addressing
Network classes: Big – medium – small (class A, B, and C) Routers have to know about all other networks (or at least about a
router that knows about all of them as a default solution to send a packet)
An IP address is 32 bits, split into a network part (with three possible lengths) and an interface/host part
Usually written as dotted decimal, four decimals between 0 and 255
WS 05/06, v 1.1 Computer Networks - Routing 32
Classful IP addressing
In addition to three network classes A, B, and C, there is class D for multicast; class E as “reserved”
Encodes network class of this address
128 NWs; 16 M hosts
16K NWs; 64K hosts
2M NWs; 256 hosts
WS 05/06, v 1.1 Computer Networks - Routing 33
Some reserved IP addresses
Some IP addresses are set aside for special uses Not all of the network/host combinations are available
WS 05/06, v 1.1 Computer Networks - Routing 34
Forwarding using IP addresses/IP routing tables
A router is in charge of its “own” network, has to known how to handle packets for all destinations within
Upon a packet arrival, check if packet is destined for own network
If no: Look at “network” bits of the destination address, look up corresponding outgoing link, forward packet to that router
If no outgoing link known, use a “default”, fallback peer router
If yes: Look at “host” bits of the destination address, look up corresponding outgoing link, forward packet to that host
Basically, fairly straightforward, two-level hierarchical forwarding and routing
WS 05/06, v 1.1 Computer Networks - Routing 36
Overview
From spanning trees to routing tables Computing routing tables Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
IP addressing Growing pains: Subnetting, classless addressing Inter- and intra-domain routing in IP
WS 05/06, v 1.1 Computer Networks - Routing 37
Growing pains…
How does IP hold up when networks grow? Two main problems ensue
Class A and B networks can contain MANY hosts, too many for a router to easily deal with ! subnetting
Network classes waste a lot of addresses Example: Organization with 2000 hosts requires a class B address,
wasting 64K-2K ¼ 62.000 host addresses!
! Classless addressing
WS 05/06, v 1.1 Computer Networks - Routing 38
Subnetting
Suppose an organization has a class B address but is organized into several LANs
Example: university with different departments
Main router does not really want to bother with all the nodes in the individual departments but wants to look only at whole networks
Obvious case for hierarchical routing and addressing – how to put hierarchies into existing IP addresses?
WS 05/06, v 1.1 Computer Networks - Routing 39
Subnetting – Hierarchies in addresses
Manipulating the class bits to introduce more hierarchy levels is not practical
Idea: have more hierarchy levels implicitly Introduce a subnet, represented by “borrowing” bits from the host
part of the IP address Local router has to know where to apply this split – needs a
subnet mask Represented as u.x.y.u/#bits or as bit pattern needed to mask out
the host bits
Original host part
WS 05/06, v 1.1 Computer Networks - Routing 40
Forwarding with subnetting in place
Forwarding when packet is not destined to “own” network: as above; send to router in charge
Subnetting not visible outside the network!
Packet is destined to own network: Router checks list of subnets belonging to the current network Either another router/outgoing link is known ! send packet there Or this router itself is in charge of the packet’s subnetwork ! send
packet directly to the host in charge Or nothing is known ! Send to default router
In effect: subnetting has introduced another hierarchy level between networks and hosts as in the traditional internet addressing
WS 05/06, v 1.1 Computer Networks - Routing 41
Classless Interdomain Routing (CIDR)
To solve second problem (running out of addresses because large chunks of addresses are allocated in big networks), essentially a similar idea is used
Just like in subnetting, break out bits from the host part to form networks of a more suitable size
But: Make these networks visible to other routers! No extension in the IP packets needed But more information in the routing tables has to be stored Lookup and forwarding algorithms become more complicated
WS 05/06, v 1.1 Computer Networks - Routing 42
Overview
From spanning trees to routing tables Computing routing tables Hierarchical routing Addressing Case study: IP routing, forwarding, & addressing
IP addressing Growing pains: Subnetting, classless addressing Inter- and intra-domain routing in IP
WS 05/06, v 1.1 Computer Networks - Routing 43
Autonomous systems in the IP world
Large organizations can own multiple networks that are under a single administrative control
Forming an autonomous system or a routing domain
Autonomous system form yet another level of aggregating routing information
Gives raise to inter- and intra-domain routing
Inter-domain routing is hard One organization might not be interested in carrying a competitor’s
traffic, … Routing metrics of different domains cannot be compared; only
reachability can be expressed Scale – currently, inter-domain routers have to know about
140.000 networks
WS 05/06, v 1.1 Computer Networks - Routing 44
Structure of autonomous systems in the IP
Resulting structure Stub AS: Only a single connection to other AS; only carries local
traffic Multihomed AS: Has connections to multiple other ASs but refuses
to carry non-local traffic for anybody else Transit AS: Multiple connections, does carry both local and transit
traffic – typical example of an Internet service provider (ISP)
Backbone service provider 2
Backbone service provider 1Consumer
ISP 1
ConsumerISP 2
Largecompany
Smallcompany 1
Smallcompany 2
Peering point
WS 05/06, v 1.1 Computer Networks - Routing 45
Intra-domain routing: OSPF
Internet’s most prevalent intra-domain (=interior gateway) routing protocol: Open Shortest Path First
Main properties Open, variety of routing distances, dynamic algorithm Routing based on traffic type (e.g., real-time traffic uses different
paths) – different metrics for a link for different traffic Load balancing: also put some packets on the 2nd, 3rd best path Hierarchical routing, “areas” as additional level, some security in
place, support tunneled routers
Essential operation: Compute shortest paths on graph abstraction of an autonomous system
Link state algorithm Link state information reliably flooded, sequence numbers,
triggered or periodically, with time to live
WS 05/06, v 1.1 Computer Networks - Routing 46
Inter-domain routing: BGPv4
Routing between domains: Border Gateway Protocols (BGP)
Routing complicated by politics, e.g., only route packets for paying customers, do not route transit traffic, …
Legal constraints, e.g.: Traffic originating and ending in Canada must not leave Canada while in transit!
BGP’s perspective: only autonomous systems and their connections
Only talk about reachability, “optimal” is a vain hope
Operation: Distance vector protocol But not only keep track of cost via a given neighbor, but store
entire paths to destination ASs More robust, solves problems like count to infinity Infernally complicated protocol…
WS 05/06, v 1.1 Computer Networks - Routing 47
Example: Routing table sizes for Internet AS
http://www.mcvax.org/~jhma/routing/bgp-hist.html
WS 05/06, v 1.1 Computer Networks - Routing 48
Bridging addressing gap: ARP
What happens once a packet arrives at its destination network / LAN?
How to turn an IP address (which is all that is known about the destination) into a MAC address that corresponds to the MAC address?
Simple solution: Yell! Broadcast on the LAN, asking which node has IP address x Node answers with its MAC address Router can then address packet to that MAC address
Address Resolution Protocol (ARP)
WS 05/06, v 1.1 Computer Networks - Routing 49
Some internetworking issues
Other things to watch out for Fragmentation Connection-oriented vs. connection-less networks Tunneling Dynamic Host Configuration Protocol (DHCP) IP version 6 Multicasting Network Address Translation Virtual Circuits Routing for Quality of Service support QoS concepts: Integrated and Differentiated Services ATM / Label switching / MPLS Routing in ad hoc networks, peer-to-peer networks …
… but are not covered here due to lack of time
WS 05/06, v 1.1 Computer Networks - Routing 50
Conclusion
Routing in large networks not only requires adequate routing algorithms for general graphs
Also an appropriate, hierarchical network structure is required
Network structure has to be reflected in the addressing structure
Flat addresses would result in prohibitive overhead
Different metrics and goals have to be fulfilled, in particular in inter-domain routing where optimality is only a single aspect
WS 05/06, v 1.1 Computer Networks - Routing 51
Some IP design principles – A historical side remark
RFC 1958, based on papers from mid-80s: Make sure it works – before writing the standard Keep it simple Make clear choices Exploit modularity Expect heterogeneity Avoid static options and parameters Look for a good design; it need not be perfect (80-20 rule) Be strict when sending and tolerant when receiving Think about scalability Consider performance and cost