Routing Algorithms
Routing Algorithms
Routing Algorithms
value in arriving
packet’s header
0111 1
3 2
Graph abstraction
5
3
v w 5
2
u 2 1 z
3
1 2
Graph: G = (N,E)
x 1
y
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), (u,w)}
Dijkstra’s algorithm Notation:
net topology, link costs known to • c(x,y): link cost from node x to
all nodes y; = ∞ if not direct neighbors
accomplished via “link state • D(v): current value of cost of
broadcast” path from source to dest. v
all nodes have same info
• p(v): predecessor node along
computes least cost paths from path from source to v
one node (‘source”) to all other
nodes • N': set of nodes whose least cost
gives forwarding table for path definitively known
that node
iterative: after k iterations, know
least cost path to k dest.’s
Dijsktra’s Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
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 old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'
Dijkstra’s algorithm: example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
1 C
A 1
2
5
1 F E
1 3 2
2
B D
1 C
A 1
E 3 F
1 1
2
2
B D
Hierarchical Routing
Our routing study thus far - idealization
• all routers identical
• network “flat”
… not true in practice
scale: with 200 million destinations:
can’t store all dest’s in routing tables! administrative autonomy
routing table exchange would swamp links!
internet = network of
networks
each network admin may
want to control routing in
its own network
Hierarchical Routing
aggregate routers into Gateway router
regions, “autonomous
Direct link to router in
systems” (AS)
another AS
routers in same AS run
same routing protocol
– “intraAS” routing protocol
routers in different AS can
run different intraAS
routing protocol
Interconnected AS’s
Gate Way
Routers
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
Forwarding table is
configured by both intra
and interAS routing
Intra-AS
Routing
Inter-AS
Routing
algorithm
algorithm algorithm
Intra AS sets entries for
Forwarding internal dests
table
InterAS & IntraAs sets
entries for external dests