You are on page 1of 45

# Network Routing: algorithms & protocols

## Goal: find good path to each

destination
Graph abstraction of a network

Nodes: routers
cost)

## each router knows complete topology

Run routing algorithm to calculate
shortest path to each destination

distance-vector (Bellman-Ford)
Each router knows direct neighbors &
Calculate the shortest path to each
destination through an iterative process
based on the neighbors distances to
each destination

5
2

B
2

C
3

Routing protocols
define the format of routing
information exchanges
define the computation upon
network topology changes over
time, routing protocol must
continuously update the routers
with latest changes

5
2

v
2

## c(x,x) = cost of link (x,x)

w
3

- e.g., c(w,z) = 5

## cost could always be 1, or

inversely related to bandwidth,
or inversely related to
congestion

## Cost of path (x1, x2, x3,, xp) = c(x1,x2) + c(x2,x3) + + c(xp-1,xp)

Question: Whats the least-cost path between u and z ?

## Routing algorithm: algorithm that finds least-cost path

Dijkstras algorithm

is known
computes least cost paths from
one node to all other nodes
Create forwarding table for that
node

Notation:
c(i,j): link cost from node i to j

( if not known)
D(v): current value of cost of
path from source to dest. V
p(v): predecessor node along
path from source to v, (neighbor
of v)
N': set of nodes whose least cost

1
2
3
4
5
6
7
8
9

Initialization:
N' = {A}
for all nodes v
then D(v) = c(A,v)
else D(v) =

Loop
find w not in N' such that D(w) is
minimum
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 the old
cost, or known shortest path cost to
w plus cost from w to v */
14 until all nodes in N'

Step
0
1
2
3
4
5

2,A
1,A
5,A
infinity
infinity
2,A
4,D
2,D
infinity
2,A
3,E
4,E
3,E
4,E
4,E

start N'
A

B
2

C
3

1 E

Step
0
1
2
3
4
5

2,A
1,A
5,A
infinity
infinity
2,A
4,D
2,D
infinity
2,D
4,D
infinity
3,E
4,E
4,E

start N
A

## Resulting forwarding table at A:

Resulting shortest-path tree for A:
5
2

B
2

C
3

B (A, B)
D (A, D)
E (A, D)
C (A, D)
F (A, D)

## Dijkstras algorithm, discussion

Algorithm complexity: n nodes
each iteration: need to check all nodes, w, not in N
n(n+1)/2 comparisons: O(n2)
more efficient implementations possible: O(nlogn)
Oscillations possible:
e.g., link cost = amount of carried traffic

D
1

1
0

A
0 0

C
e

1+e
e

initially

B
1

2+e

D 1+e 1 B
0
0
C
recompute
routing

A
0 0

2+e

1+e

recompute

2+e

D 1+e 1 B
e
0
C

recompute

Bellman-Ford Equation
Define: Dx(y) := cost of least-cost path from x to y
Then Dx(y) = min {c(x,v) + Dv(y) }
where

v
2
2
1

w
3

1 y

c(u,x) + Dx(z),
c(u,w) + Dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4

## Node leading to shortest path is

next hop forwarding table

## Distance vector protocl (1)

Basic idea:
Each node periodically sends its own distance
vector estimate to neighbors
When a node x receives new DV estimate from
neighbor v, it updates its own DV using B-F
equation:
Dx(y)minv{c(x,v)+Dv(y)}foreachnodeyN
In normal cases, the estimate Dx(y) converge to the
actual least cost dx(y)

Outgoing

D()

DE

14

A,1

D,5

D,4

11

D,2

8
1

destination

destination

forwarding
table

## Distance Vector Protocol (2)

Iterative, asynchronous:
each local iteration caused
by:
DV update message from
neighbor

Distributed:
each node notifies neighbors

## 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

Y
7

= 7+1 = 8
Y

= 2+1 = 3

## node detects local link cost change

if cost change in least cost path, notify
neighbors (lines 23,24)

good
news
travels
fast

Y
50

algorithm
terminates

problem!

60

Y
50

Z
algorithm
continues
on!

## Distance Vector: poisoned reverse

If Z routes through Y to get to X :
Z tells Y its (Zs) distance to X is
infinite (so Y wont route to X via Z)

60

Y
50

Z
algorithm
terminates

## An example for Distance Vector routing

with Poisson reverse (PR)
A's routing table
Dst Dis Nex

B
C
D
E
F
G
H

1
3
4
4
7
6
2

B
B
B
B
B
H
H

A's update to B
w/o PR

B
C
D
E
F
G
H

1
3
4
4
7
6
2

A
C
D
E
F
G
H

1
2
3
3
6
5
3

A
C
D
E
F
G
H

A
C
C
C
C
C
H

1
4
5
5
8
7
3

A
A
A
A
A
A
H

B
C
D
E
F
G
H

6
2

2
H

4
G

C
1
E
4

1
3

D
4
F

## Comparison of LS and DV algorithms

distance vector:
distribute ones own routing table to neighbors
routing update can be large in size, but travels only one link

## each node only knows distances to other destinations

broadcast raw topology information to entire net
routing update is small in size, but travels over all links in the net

## Robustness: what happens if router malfunctions?

LS:

each node computes only its own table

DV:

## DV node can advertise incorrect path cost

each nodes table used by others

## What we have talked about routing

Dijkstra routing algorithm
Given

## a topology map, compute the shortest paths to

all the other nodes

Given

## the lists of distance to all destinations from all

the neighbors, compute the shortest path to
destination
Known problem: count-to-infinity
A simple (partial) solution: poison-reverse

## Routing in the Internet

The Global Internet: a large number of

each other:
Stub AS:

## Multihomed AS: stub ASes that are connected to multiple

service providers
Transit AS:

Intra-AS
Inter-AS

## Internet Hierarchical Routing

Inter-AS border (exterior gateway) routers

Intra-AS
(interior
gateway)
routers

## autonomous system (AS): a set of routers under the

Each AS makes its own decision on internal routing
protocol (IGP) to use

## Intra-AS and Inter-AS routing

Border routers:

C.b

B.a
A.a

A.c
d
A

a
b

inter-AS, intra-AS
routing in
gateway A.c

c
B

intra-AS
routing
protocol

inter-AS
routing
protocol

perform inter-AS
routing across AS
boundaries
perform intra-AS
routing with other
routers in each's own
AS
network layer
physical layer

C.b

a
Host-1

A.a

Inter-AS
routing
between
A and B
A.c

a
b

B.a
a

Host

18.2.4.157

b
B
Intra-AS routing
within AS B

## Intra-AS routing Forwarding table

within AS A
131.179.0.0
outf-1
18.0.0.0

outf-2

23.0.0.0

outf-2

157.34.128.0

outf-3

222.8.192.0

outf-4

Intra-AS Routing:

## Interior Gateway Protocols (IGP)

Most commonly used IGPs:
IS-IS:

## Intermediate System to Intermediate System

Routing protocol
OSPF: Open Shortest Path First
IGRP: Interior Gateway Routing Protocol (Cisco
proprietary)
RIP: Routing Information Protocol

## RIP ( Routing Information Protocol)

Distance vector algorithm
Distance metric: # of hops (max = 15 hops)

seconds

B
D

w
x
y

destination hops
u
1
v
2
w
2
x
3
y
3
z
2

## All routes via N invalidated; updates sent to neighbors

Use poison reverse to prevent ping-pong loops (16 hops = )

## RIP (Routing Information Protocol)

z
w
A

y
D

C
Destination Network Next Router
w
A
y
B
z
B
x
-.
.

## Num. of hops to dest.

2
2
7
1
....

Routing table in D

RIP: Example
Dest.
w
x
z
.

distance
1
1
4

from A to D

...

z
w
A

Destination Network

Next Router

## Num. of hops to dest.

w
y
z
x

A
B
BA
--

2
2
75
1

....

Routing table in D

RIP Implementation
route-d (daemon): an application-level process that

## manages RIP routing table and generates periodic RIP

send updates periodically to neighbors (if detect a failure, send
right away)

Keeps the resulting routing table only (not all the updates)
routed

routed

Transport
(UDP)
network
(IP)
physical

Transport
(UDP)
forwarding
table

forwarding
table

network
(IP)
physical

## OSPF (Open Shortest Path First)

each node knows its directly connected neighbors & the link
network

## ID of the node that created the LSP

a list of direct neighbors, with link cost to each
sequence number for this LSP message (SEQ)
time-to-live (TTL) for information carried in this LSP
Use raw IP packet (protocol ID = 89)

## Building a complete map using Link State

Everyone broadcasts a piece of the topology
Put all the pieces together, you get the complete

map

Theneachnodecarriesoutitsownroutingcalculationindependently

The routing daemon running at each node: Builds

Stores

## and forwards most recent LSP from all other

nodes
decrement TTL of stored LSP; discard info when TTL=0
Compute

## routes using Dijkstras algorithm

generates its own LSP periodically with increasing
SEQ

## Reliable Flooding of LSP

forward each received LSP to all neighbor nodes

each

## ISP is reliably delivered over each link

use the source-ID and SEQ in a LSP to detect
duplicates
LSPs sent both periodically and event-driven
X

## Advanced features supported by OSPF

Security: all OSPF messages authenticated
Multiple same-cost paths allowed
For each link, multiple cost metrics for different

## TOS (eg, satellite link cost set low for best

effort; high for real time)
Integrated uni- and multicast support:
Multicast

base as OSPF

## Hierarchical OSPF in large domains.

Hierarchical OSPF

Hierarchical OSPF
Two-level hierarchy: local area, backbone.

each nodes has detailed area topology; only know direction
(shortest path) to nets in other areas.
Area border routers: summarize distances to nets in own
area, advertise to other Area Border routers.
Backbone routers: run OSPF routing limited to backbone.
Boundary routers: connect to other ASs.

Inter-AS routing

## BGP (Border Gateway Protocol): the de facto standard

Path Vector protocol:

## similar to Distance Vector protocol

each Border router broadcast to neighbors (peers) entire path
(I.e, sequence of ASs) to destination
E.g.,
Path (X,Z) = X,Y1,Y2,Y3,,Z

Example:
Forwarding Table in Router d of AS A
Suppose AS A learns from the inter-AS protocol that

## subnet x is reachable from AS B (gateway A.c) but not

from AS C.
Inter-AS protocol propagates reachability info to all
internal routers.
Router d determines from intra-AS routing info that its
interface I is on the least cost path to c.
Puts in forwarding table entry (x, I).

## Choosing among multiple ASes

Now suppose AS1 learns from the inter-AS protocol

## that subnet x is reachable from AS3 and from AS2.

To configure forwarding table, router 1d must determine
towards which gateway it should forward packets for
dest x.
This is also the job on inter-AS routing protocol!
Hot potato routing: send packet towards closest of two
routers.
Learn from inter-AS
protocol that subnet
x is reachable via
multiple gateways

## Use routing info

from intra-AS
protocol to
determine
costs of least-cost
paths to each
of the gateways

## Hot potato routing:

Choose the
gateway
that has the
smallest least cost

Determine from
forwarding table the
to least-cost gateway.
Enter (x,I) in
forwarding table

## BGP (Border Gateway Protocol): the de facto standard

BGP provides each AS a means to:
1.
2.
3.

## Obtain subnet reachability information from neighboring ASs.

Propagate the reachability information to all routers internal to
the AS.
Determine good routes to subnets based on reachability
information and policy.

## Allows a subnet to advertise its existence to rest of the

Internet: I am here

BGP basics
Pairs of routers (BGP peers) exchange routing info over a

## will forward any datagrams destined to that prefix

towards the prefix.
3c
3a
3b AS3

2a

1c

1a
AS1 1d

2c
AS2

2b

1b
eBGP session
iBGP session

## Distributing reachability info

With eBGP session between 3a and 1c, AS3 sends prefix

## reachability info to AS1.

1c can then use iBGP to distribute this new prefix reach info to all
routers in AS1
1b can then re-advertise the new reach info to AS2 over the 1b-to2a eBGP session
When router learns about a new prefix, it creates an entry for the
prefix in its forwarding table.
3c
3a
3b AS3

2a

1c

1a
AS1 1d

2c
AS2

1b

2b

eBGP session
iBGP session

attributes.

## prefix + attributes = route

most important attribute: AS-PATH: contains the ASs through
which the advert for the prefix passed: AS 67 AS 17

policy to accept/decline.
eBGP router also applies export policy to decide which
routers to tell which neighbor eBGP router

## BGP route selection

Router may learn about more than 1 route to some prefix. Router
must select route.
Elimination rules:
1.
2.
3.
4.

## Local preference value attribute: policy decision

Shortest AS-PATH
Closest NEXT-HOP router: hot potato routing

BGP messages
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
NOTIFICATION: reports errors in previous msg;
also used to close connection

## A,B,C are provider networks

X,W,Y are customers (of provider networks)
X is dual-homed: attached to two networks
X does not want to route from B via X to C
.. so X will not advertise to B a route to C

## A advertises to B the path AW

B advertises to X the path BAW
Should B advertise to C the path BAW?
No way! B gets no revenue for routing CBAW since
neither W nor C are Bs customers
B wants to force C to route to w via A
B wants to route only to/from its customers!

## 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 traffic

Performance:
Intra-AS: can focus on performance
Inter-AS: policy may dominate over performance