Routing Algorithms
Routing Algorithms
value in arriving
packet’s header
0111 1
3 2
N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
Oscillations possible:
e.g., link cost = amount of carried traffic
A
1 1+e 2+e A 0 0 A
2+e 2+e A 0
D B D 1+e1 B D
0 0 0 0 B D 1+e1 B
0 e 0 0 1 1+e 0 e
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
Network Layer 4-9
Distance Vector Algorithm (1)
Bellman-Ford Equation (dynamic
programming)
Define
dx(y) := cost of least-cost path from x to y
Then
dx(y) = min {c(x,v) + dv(y) }
from
from
y ∞∞ ∞ y 2 0 1 y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y table
cost to cost to cost to
x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
from
from
y 2 0 1 y 2 0 1 y 2 0 1 7
z ∞∞ ∞ z 7 1 0 z 3 1 0
node z table
cost to cost to cost to
x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
from
y ∞∞ ∞ y 2 0 1 y 2 0 1
z 71 0 z 3 1 0 z 3 1 0
time
Network Layer 4-15
Distance Vector: link cost changes
Link cost changes: 1
node detects local link cost y
4 1
change
x z
updates routing info, recalculates 50
distance vector
if DV changes, notify neighbors
At time t0, y detects the link-cost change, updates its DV,
“good and informs its neighbors.
news
travels At time t1, z receives the update from y and updates its table.
It computes a new least cost to x and sends its neighbors its DV
fast”
At time t2, y receives z’s update and updates its distance table.
y’s least costs do not change and hence y does not send any
message to z.
Network Layer 4-16
Distance Vector: link cost changes
Link cost changes:
good news travels fast
bad news travels slow - “count to infinity” problem! 60
44 iterations before algorithm stabilizes: see text
y
Poissoned reverse:
If Z routes through Y to get to X :
4 1
Z tells Y its (Z’s) distance to X is infinite (so Y won’t route to X
via Z) x z
will this completely solve count to infinity problem? 50
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d Forwarding table is
configured by both intra-
and inter-AS routing
Intra-AS Inter-AS
algorithm
Routing Routing Intra-AS sets entries for
algorithm algorithm
internal dests
Forwarding Inter-AS & Intra-As sets
table entries for external
dests
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
Network Layer 4-22
Example: Setting forwarding
table in router 1d
Suppose AS1 learns from the inter-AS
protocol that subnet x is reachable from
AS3 (gateway 1c) but not from AS2.
Inter-AS protocol propagates
reachability info to all internal routers.
Router 1d determines from intra-AS
routing info that its interface I is on the
least cost path to 1c.
Puts in forwarding table entry (x,I).
u destination hops
v
u 1
A B w v 2
w 2
x 3
x y 3
z C D z 2
y
C
Destination Network Next Router Num. of hops
to dest.
w A 2
y B 2
z B 7
x -- 1
…. …. ....
Routing table in D
C
Destination Network Next Router Num. of hops
to dest.
w A 2
y B 2
z BA 75
x -- 1
…. Routing….
table in D ....
Network Layer 4-29
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 (infinite distance = 16 hops)
Transprt Transprt
(UDP) (UDP)
network forwarding network
forwarding table (IP)
(IP)
link table link
physical physical
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
AS1 1d
eBGP session
iBGP session
Network Layer 4-37
Distributing reachability info
With eBGP session between 3a and 1c, AS3 sends prefix
reachability info to AS1.
1c can then use iBGP do 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-to-2a eBGP session
When router learns about a new prefix, it creates an
entry for the prefix in its forwarding table.
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
AS1 1d
eBGP session
iBGP session
Network Layer 4-38
Path attributes & BGP routes
When advertising a prefix, advert includes BGP
attributes.
prefix + attributes = “route”
Two important attributes:
AS-PATH: contains the ASs through which the advert
for the prefix passed: AS 67 AS 17
NEXT-HOP: Indicates the specific internal-AS router
to next-hop AS. (There may be multiple links from
current AS to next-hop-AS.)
When gateway router receives route advert,
uses import policy to accept/decline.
Figure 4.5
-BGPnew
: a simple BGP scenario
A,B,C are provider networks
X,W,Y are customer (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
Figure 4.5
-BGPnew: a simple BGP scenario
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 B’s customers
B wants to force C to route to w via A
B wants to route only to/from its customers!
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