Unit 1 Routing_algorithm
Unit 1 Routing_algorithm
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
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
At time t0, y detects the link-cost change, updates its DV,
if DV changes, notify neighbors
and informs its neighbors.
“good
news At time t1, z receives the update from y and updates its table.
travels 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.
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d Forwarding table is
configured by both
intra- and inter-AS
Intra-AS
Routing
Inter-AS
Routing routing algorithm
algorithm algorithm
Intra-AS sets entries
Forwarding for internal dests
table
Inter-AS & Intra-As
sets entries for
external dests
Network Layer 4-21
Inter-AS tasks AS1 needs:
Suppose router in 1. to learn which dests
AS1 receives are reachable
datagram for which through AS2 and
dest is outside of AS1 which through AS3
Router should forward 2. to propagate this
packet towards on of
the gateway routers,
reachability info to
but which one? all routers in AS1
Job of inter-AS routing!
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.
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