Post on 19-Dec-2015
Routing 4-1
Introduction To Computer Networks
-89מבוא לרשתות תקשורת 350
(Routing)ניתוב פרופ' אמיר הרצברג
Chapter 4, Network LayerComputer Networking: A Top Down Approach Featuring the Internet, 3rd edition. Jim Kurose, Keith RossAddison-Wesley, July 2005. ** Group purchase ?? **
Based on foils by Kurose & Ross ©, see: http://www.aw.com/kurose-ross/
My site: http://AmirHerzberg.com
Course site http://www.cs.biu.ac.il/~89-350/
Routing 4-2
Routing: Agenda Network layer services: datagram vs. virtual
circuit Link-state routing: OSPF Distance-vector routing: RIP Hierarchical and Inter-AS routing: BGP
Routing 4-3
Network layer functions
transport packet from sending to receiving hosts
network layer protocols in every host, router
three important functions: path determination: route
taken by packets from source to dest. Routing algorithms
call setup: some network architectures require router call setup along path before data flows
forwarding: move packets from router’s input to appropriate router output
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
networkdata linkphysical
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
ThisLecture
IP
Routing 4-4
Network service modelQ: What service model for
“channel” transporting packets from sender to receiver?
Two main service abstractions:
Datagram vs. Virtual Circuit
A1: Datagram: best effort only
• IP service
A2: Virtual Circuit… any of: • loss-free delivery• congestion feedback to sender• in-order delivery• guaranteed bandwidth• no jitter• Like phone
Routing 4-5
Virtual Circuits (VC) Service
call setup before data can flow, teardown after Packets carry VC identifier (not destination host ID) every router/switch on source-dest path maintains
“state” for connections transport-layer connection only involved two end systems
link, router resources (bandwidth, buffers) may be allocated to VC for circuit-like performance, guaranteed bandwidth/delay
“like telephone circuit” performance-wise network actions along source-to-dest path
Routing 4-6
Virtual circuits: signaling protocols used to setup, maintain and teardown VC
Teardown may initiate at either end – or any router along VC Exercise: design simple VC protocol
used in ATM, frame-relay, SNA, X.25 Also `premium` Internet services (RSVP, MPLS)
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
1. Initiate call 2. incoming call
3. Accept call4. Call connected5. Data flow begins 6. Receive data
Routing 4-7
Datagram networks: the Internet model no call setup at network layer routers: no state about end-to-end connections
no network-level concept of “connection”
packets forwarded using destination host address packets in same connection may take different paths
application
transportnetworkdata linkphysical
application
transportnetworkdata linkphysical
1. Send data 2. Receive data
Routing 4-8
Datagram or VC network: why?
Datagram (IP) data exchange among
computers “elastic” service, no
strict timing req. “smart” end systems
(computers) can adapt, perform
control, error recovery simple inside network,
complexity at “edge” many link types
different characteristics uniform service difficult
VC (ATM, MPLS) evolved from telephony “dumb” end systems
telephones complexity in network
human conversation: strict timing, reliability
requirements
Guaranteed service
Routing 4-9
Routing: Agenda Network layer services: datagram vs. virtual
circuit Link-state routing: OSPF Distance-vector routing: RIP Hierarchical and Inter-AS routing: BGP
Routing 4-10
Routing
Graph abstraction for routing algorithms:
graph nodes are routers
graph edges are channels In Internet: a network link cost: delay, $ cost,
congestion level, reliability… [measure!]
Goal: determine “good” path
(sequence of routers) thru network from source to
dest.
Routing protocol
A
ED
CB
F
2
2
13
1
1
2
53
5
“good” path: Typically means minimum
cost path Cost is not always additive Other def’s possible
Routing 4-11
Routing Algorithm classification
Global or decentralized information, decisions?
Global: all routers have complete
topology, link cost info “link state” algorithmsDecentralized: router knows physically-
connected neighbors, link costs to neighbors
iterative process of computation, exchange of info with neighbors
“distance vector” algorithms
Static or dynamic?Static: Does not handle changes
/ failures Implicitly: restart upon
change (failure/recovery)Dynamic: Change routes (due
changes in costs, topology) periodically in response to change
in cost / topology / faults/ recoveries
Routing 4-12
Link-State Routing: Shortest Path AlgorithmsGlobal, Static Link-State Source Routing: Link state is fixed: c)i,j(, cost from i to j (∞ if no link)
Known to each source (A) [E.g. with Flood (PI) or PIF – later] Source routing: find path from each source A to all other
nodes
Single Source Shortest Paths Tree Problem: Given graph G=(V,E), source node AV Find shortest-paths tree TG for A; for each node v:
DA)v(: cost of shortest path from source A to v• We simplify and write D(v) for DA(v)
All paths in T are shortest length: D(v)=∑(u,w)path(A,v)c(u,w) NOT Minimum Spanning Tree (Exercise: show why!) Not same tree for all sources (why?)
Routing 4-13
Dijsktra’s AlgorithmBuilds shortest-paths tree T iterativelyAfter k iterations, T contains k links (and k+1 nodes)
Given graph G=(V,E), source node AV, and link cost function c(x,y)0
let T ={ A }Let D(x)={0 if x=A, ∞ otherwise)while (T does not contain all nodes) { find edge (x,y)E with x in T and y not in T minimizing D(x)+c(x,y) add (x,y) to T D(y)=D(x)+c(x,y) }Output T, D
This usually holds… Why needed?Alg for negative costs?
Routing 4-14
Dijkstra’s algorithm: example
Step012345
NodesA
ADADE
ADEBADEBC
ADEBCF
D)B(222
D)C(5433
D)D(1
D)E(infinity
2
D)F(infinityinfinity
444
A
ED
CB
F
2
2
13
1
1
2
53
5
Routing 4-15
Dijkstra’s algorithm, discussionAlgorithm complexity: n nodes, static link costs each iteration: need to check all nodes, w, not in T n*(n+1)/2 comparisons: O(n2) more efficient implementations (e.g. heap): O(nlogn)
Dynamic costs (e.g. c(i,j)=|traffic(i,j)|) may oscillate: B,C,D send to A (1,e,1 units), each use Dijkstra Initial, sensible state: DA, CBA Oscillate between: BCDA, DCBA !!
A
D
C
B1 1+e
e0
e
1 1
0 0
A
D
C
B2+e 0
001+e1
A
D
C
B0 2+e
1+e10 0
A
D
C
B2+e 0
e01+e1
initially… recompute
routing… recompute … recompute
Routing 4-16
OSPF (Open Shortest Path First)
“Open”: publicly available, standard routing protocol
Link State algorithm LS packet (`advertisement`) flooding Topology map at each node Route computation using Dijkstra’s
algorithm
Routing 4-17
OSPF Flooding Each node x sends Link State Packet (LSP)
periodically / on link state change, with: ID of x, list of direct neighbors and costs Sequence number (64 bit, assume to never wrap around) Time to live
Sequence number used to identify *newer* LSP An older LSP is discarded What if a router crash and sequence number reset to 0?
Receiving node floods LSP to all its neighbors Except neighbor where the LSP came from
Reliability via acknowledgement and retransmission Variant of PI (Propagation of Information) protocol
In recitation: PI, PIF (Prop. of Info. w/ Feedback)
Routing 4-18
OSPF “advanced” features
Multiple cost metrics For different Type Of Service [TOS] E.g., satellite: high bandwidth, but high latency
Collected topology allows… Multiple same-cost pathsMulticast OSPF (MOSPF)
Hierarchical OSPF in large domains. Security: all OSPF messages authenticated
(to prevent malicious intrusion)
Routing 4-19
Routing: Agenda Network layer services: datagram vs. virtual
circuit Link-state routing: OSPF Distance-vector routing: RIP Hierarchical and Inter-AS routing: BGP
Routing 4-20
Distance Vector Routing Algorithm
Iterative, Dynamic: continues until no
nodes exchange info. self-terminating: no
“signal” to stop restart upon changeAsynchronous: nodes need not
exchange info/iterate in lock step!
Distributed: each node
communicates only with directly-attached neighbors
Distance Table data structure
each node has its own table row for each possible
destination column for each neighbor example: in node X, for dest. Y
via neighbor Z:
D )Y,Z(X
distance from X toY, via Z as next hop
c)X,Z( + min {D )Y,w(}Z
w
=
=
Routing 4-21
Distance Table: example
A
E D
CB7
8
1
2
1
2
D )(
A
B
C
D
A
1
7
6
4
B
14
8
9
11
D
5
5
4
2
Ecost to destination via
dest
inat
ion
D )C,D(E
c)E,D( + min {D )C,w(}D
w== 2+2 = 4
D )A,D(E
c)E,D( + min {D )A,w(}D
w== 2+3 = 5
D )A,B(E
c)E,B( + min {D )A,w(}B
w== 8+6 = 14
loop!
loop!
Routing 4-22
Distance table gives routing table
D )(
A
B
C
D
A
1
7
6
4
B
14
8
9
11
D
5
5
4
2
Ecost to destination via
dest
inat
ion
A
B
C
D
A,1
D,5
D,4
D,4
Outgoing link to use, cost
dest
inat
ion
Distance table Routing table
Routing 4-23
Distance Vector Routing: overview
Iterative, asynchronous: each local 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
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
Each node:
Routing 4-24
Distance Vector Algorithm at node x:Initialization: for all nodes y and all neighbors v: DX)y,v( = {c)x,v( for y=v, else ∞}
On Detect_cost_of_link to neighbor v (i.e. c(x,v)) changes by d /* change cost to all dest's via neighbor v by d */ /* note: d could be positive or negative */ for all destinations y: DX(y,v) = DX(y,v) + d
On Rcv <y, D> from neighbor v: /* shortest path from v to some y has changed */ /* v sent a new value for its minWDV(y,w) */ DX(y,v) = c(x,v) + D
Every T seconds (or always, if T=0): If DX(y)=minWDX(y,w) changed (for any destination y), then send <y, DX(y)> to all neighbors
Routing 4-25
Distance Vector Algorithm: example
X Z12
7
Y
D )Y,Z(X
c)X,Z( + min {D )Y,w(}w=
= 7+1 = 8
Z
D )Z,Y(X
c)X,Y( + min {D )Z,w(}w=
= 2+1 = 3
Y
Routing 4-26
Distance Vector Algorithm: example
X Z12
7
Y
Routing 4-27
Distance Vector: link cost changesLink cost changes: node detects local link cost
change updates distance table if cost change in least cost path,
notify neighbors Example when DX)y,v( reduced:
X Z14
50
Y1
algorithmterminates(converges – no activity)
“goodnews travelsfast”(and noloops)
Routing 4-28
Distance Vector: Convergence If network stabilizes, then DV eventually outputs shortest paths (and halts)
Assuming FIFO, max delay Δ, min weight w [why?] Consider single, fixed target node y; DY(y)=0 Let x(0)=y, x(0), x(1),…x(n) be the nodes by order of min-
distance from y Claim: for all i (0≤i≤n), eventually Dx(i)(y)=D(i), the min-
distance from x(i) to y. Proof: by induction on i. Trivially holds for i=0 (i.e. x(0)=y). Assume from time t, there are no new `detect cost change`
events, and x(0)…x(i) stabilized to D(i). We prove the claim holds for i+1 as well. For every j>i, eventually Dx(j)(y)D(i+1) [why?] Then, eventually x(i+1) receives D(j) from x(j), s.t. j≤i and
D(i)=D(j)+c(x(j),x(i))… Claim follows! But… convergence can be veeery sloooooooow…
Routing 4-29
Slow convergence: “count to infinity”
Link cost changes: bad news travels slow!
Bad news = DX)y,v( increased (e.g. link down) Convergence time depends on cost ratios, not
just on nX Z
14
50
Y60
algorithmcontinues
on!
Packets sent from Z, Y to X will loop btw Z, Y!!
Routing 4-30
Distance Vector: poisoned reverse(fix to most `count to infinity` scenarios)
If Z routes through Y to get to X : Z tells Y its (Z’s) distance to X is infinite
(so Y won’t route to X via Z) Exercises: modify code; re-do convergence analysis Often helps – but complexity still depends on cost
ratios, not just on n; Exercise: demonstrate this!
X Z14
50
Y60
algorithmterminates
Routing 4-31
RIP ( Routing Information Protocol)
Standard distance vector algorithm Distance vectors exchanged among neighbors
every 30 sec via RIP advertisement Distance metric: # of hops
≤15hops; 16=unreachable Each advertisement: list of up to 25
destination nets Sent using UDP (why?)
Routing 4-32
RIP: Example
Destination Network Next Router Num. of hops to dest. w A 2
y B 2 z B 7
x -- 1…. …. ....
w x yA
C
D B
Routing table in D
z
Routing 4-33
RIP: Example
Destination Network Next Router Num. of hops to dest. w A 2
y B 2 z B A 7 5
x -- 1…. …. ....Routing table in D
Dest Next hops w - - x - - z C 4 …. … ...
Advertisementfrom A to D
w x yA
C
D Bz
Routing 4-34
RIP: Link Failure and Recovery If no advertisement heard after 180 sec -->
neighbor/link declared dead routes via neighbor invalidated new advertisements sent to neighbors neighbors in turn send out new advertisements
(if tables changed) link failure info quickly propagates to entire net poison reverse used to prevent ping-pong
loops• Send infinite distance (= 16 hops) to first hop toward
destination
Routing 4-36
Routing: Agenda Network layer services: datagram vs. virtual
circuit Link-state routing: OSPF Distance-vector routing: RIP Hierarchical and Inter-Autonomous Systems
routing: BGP
Routing 4-37
Hierarchical Routing and Autonomous Systems
scale: with 200 million destinations:
can’t store all dest’s in routing tables!
routing table exchange would swamp links!
administrative autonomy internet = network of
networks (Autonomous Systems)
AS= Autonomous System, a network under a single administrative control
Identified by 16-bit AS Number (ASN)
Our routing study thus far - idealization all routers identical network “flat”… not true in practice
Routing 4-38
Hierarchical Routing and AS
Aggregate routers By “autonomous
systems” (AS) Or: within a huge AS
routers in same AS run same routing protocol “intra-AS” routing
protocol routers in different AS
can run different intra-AS routing protocol
special routers in AS run intra-AS routing
protocol with all other routers in AS
Use inter-AS routing protocol to route to Nets in other AS-es
BGP (Border Gateway Protocol): Internet’s inter-AS protocol
gateway routers
Routing 4-39
Intra-AS and Inter-AS routing
Gateways:•perform inter-AS routing amongst themselves•perform intra-AS routing with other routers in their AS
inter-AS, intra-AS routing in
gateway A.c
network layer
link layer
physical layer
a
b
b
aaC
A
Bd
A.a
A.c
C.bB.a
cb
c
Routing 4-40
Intra-AS and Inter-AS routing
Host h2
a
b
b
aaC
A
Bd c
A.a
A.c
C.bB.a
cb
Hosth1
Intra-AS routingwithin AS A
Inter-AS routingbetween A and B
Intra-AS routingwithin AS B
How to publish inter-AS route to hosts? 1st idea: gateway publish it as if it had a link, via Intra-AS protocol (RIP/OSPF/…)
O(E) messages per each entry (network prefix) ?
Routing 4-41
I-BGP: Efficient Distribution of BGP routes
Host h2
a
b
b
aaC
A
Bd c
A.a
A.c
C.bB.a
cb
Hosth1
E-BGP
I-BGP distribution of routes in AS B
How to publish inter-AS route to hosts? Solution: send to each router using I-BGP
No flooding inside AS Identify gateway; use Intra-AS routing to reach it
Routing 4-42
Routing with I-BGP and RIP/OSPF
AS 1 AS 2192.0.2.1
135.207.0.0/16
10.10.10.10
I-BGP: 135.207.0.0/16Next Hop = 192.0.2.1
192.0.2.0/30
Forwarding Table
135.207.0.0/16
destination next hop
10.10.10.10192.0.2.0/30 10.10.10.10
I-BGP
192.0.2.1135.207.0.0/16
destination next hop
+
Intra
10.10.10.10192.0.2.0/30
destination next hop
E-BGP
Routing 4-43
Connecting Autonomous Systems Types of Autonomous Systems
Transit AS (ISP): AS x that transfers traffic AS y to AS z
Non-Transit AS (customer): never transfers…
• Stub AS: small corporation: connected via single ISP • Multihomed AS: large corporation; connected via
multiple connections to other AS’s (at least one ISP – Transit AS)
Use Border Gateway Protocol (BGP) Focus on policies, not optimization E.g., allow multihomed AS to refuse to transit
Routing 4-44
Inter-AS routing with BGP(Border Gateway Protocol)
Path Vector protocol similar to Distance Vector protocol Broadcast to neighbors (peers) Broadcast announcements: list of
<Path,Attributes> Path is sequence of ASes to destination
(network prefix, e.g. xx.yy/16) Attributes provide information to select best
route
Routing 4-45
Internet inter-AS routing: BGP
Suppose: gateway X send its path to peer gateway W
W may or may not select path offered by Xcost, policy (don’t route via competitors
AS), loop prevention reasons.
If W selects path advertised by X, then:Path (W, xx.yy/16) = w, Path (X, xx.yy/16)
Control incoming traffic by controlling announcements to peers…
Routing 4-46
Customers and Providers
Customer pays provider for access to the Internet
provider
customerIP traffic
provider customer
Routing 4-47
Customers Don’t Always Need BGP
provider
customer
Default route 0.0.0.0/0pointing to provider.
Configured route 192.0.2.0/24pointing to customer
192.0.2.0/24
Static routing is the most common way of connecting anautonomous routing domain to the Internet. This helps explain why BGP is a mystery to many …
Routing 4-48
Customer-Provider Hierarchy
IP trafficprovider customer
Routing 4-49
The Peering Relationship
peer peer
customerprovider
Peers provide transit between their respective customers
Peers do not provide transit between peers
Peers (often) do not exchange $$$trafficallowed
traffic NOTallowed
Routing 4-50
Peering Provides Shortcuts
Peering also allows connectivity betweenthe customers of “Tier 1” providers.
peer peer
customerprovider
4-51
BGP Operations (Simplified)
Establish session on TCP port 179
Exchange all active routes
Exchange incremental updates
AS1
AS2
While connection is ALIVE exchangeroute UPDATE messages
BGP session
Routing 4-52
Why different Intra- and Inter-AS routing ?
Policy: Inter-AS: admin wants control over how its traffic
routed, who routes through its net. Intra-AS: single admin, so no policy decisions
needed
Scale: hierarchical routing saves table size, reduced
update trafficPerformance: Intra-AS: can focus on performance Inter-AS: policy may dominate over performance
Routing 4-53
Routing: summary
Next and final stop: the Data
link layer!
What we’ve covered: network layer services routing principles: link state
and distance vector hierarchical routing Internet routing protocols RIP,
OSPF, BGP