# Routing Algorithms

Δίκτυα και Επικοινωνίες

18 Ιουλ 2012 (πριν από 5 χρόνια και 10 μήνες)

543 εμφανίσεις

1
Routing Algorithms
Ali Erkan
Ithaca College
Part of Section 4.5
2
Routing Problem
AW/Kurose and Ross
Computer Networking 3/e KR 04.02
24p3 Wide x 22p7 Deep 2/c 3/19/04 rossi
1
2
3
Routing algorithm
Local forwarding table
0100 0101 0111 1001
0111
3 2 2 1
I Default router:AKA
ﬁrst-hop router
I Source router:
Default router of
source host
I Destination router:
Default router of
destination host
3
Abstract Graph Model Of A Computer Network
5
1
2
2
3
3
1
2
5
1
x y
u
v
z
w
I Graph G = (N;E)
I N is the set of nodes;a node corresponds to a...
I E is the set of edges;in a physical network,an edge corresponds to a
...;in a P2P network,it corresponds to a...
I Meaning of numbers?...
I Path is a sequence of edges fromone node to another
I Cost of a path is...
4
Routing AlgorithmClassiﬁcation
I Global:
 Router knows...

state algorithms
I Decentralized:
 Router knows...
 Iterative process of computation,exchange of info with neighbors

Distance
vector algorithms
I Static:
 Suitable for networks where routes change slowly over time
I Dynamic:
 Suitable for networks where routes change more quickly
 Required changes may be periodic
 Required changes may be reactive
5
I Distributed operation:
 Each router eventually learns entire network topology
 Each router computes routing info independently
 Deterministic algorithms guarantee all tables to be identical
I Topology dissemination:
 A router describes its neighbors with link state packets (LSPs)
 Routers use controlled ﬂooding to distribute LSPs everywhere
I One particular link state algorithm:Dijkstra’s method to determine
the minimumspanning tree for a source node
6
Dijkstra’s Algorithm
2 5
6
7 4
4
3
I What it needs,what it gives:
 Input:...
 Output:...
I What is “A graph data structure in the routers memory”?
I What is “A forwarding table”?
7
“A graph data structure in the routers memory”?
Router memory
Router memory
Router memory
Router memory
Router memory
2 5
6
7 4
4
3
2 5
6
7 4
4
3
2 5
6
7 4
4
3
2 5
6
7 4
4
3
2 5
6
7 4
4
3
2 5
6
7 4
4
3
a
b c
d e a
b c
d e
a
b c
d ea
b c
d e a
b c
d e
Each router eventually learns entire network topology;each router computes routing
info independently;deterministic algorithms guarantee all tables to be identical;a
router describes its neighbors with link state packets (LSPs);routers use controlled
ﬂooding to distribute LSPs everywhere.
8
“A forwarding table”?
Leon-Garcia & Widjaja: Communication Networks
1
2
3
4
5
6
A
B
Switch or router
Host
Figure 7.23
9
“A forwarding table”?
Leon-Garcia & Widjaja: Communication Networks
2 2
3 3
4 4
5 2
6 3
Node 1
Node 2
Node 3
Node 4
Node 6
Node 5
1 1
2 4
4 4
5 6
6 6
1 3
2 5
3 3
4 3
5 5
Destination Next node
1 1
3 1
4 4
5 5
6 5
1 4
2 2
3 4
4 4
6 6
1 1
2 2
3 3
5 5
6 3
Destination Next node
Destination Next node
Destination Next node
Destination Next node
Destination Next node
Figure 7.26
10
Dijkstra’s Algorithm
2 5
6
7 4
4
3
a
b c
d e
D(v):...
N
0
:...
p(v):...
11
Dijkstra’s Algorithm
INITIALIZATION:
N
0
= fug
For all nodes v
If v is a neighbor of u
...
...
LOOP UNTIL ALL NODES IN N
0
:
Find w not in N
0
such that D(w) is a minimum
0
Update D(v) for each neighbor v of w not in N
0
:
...
12
Dijkstra’s AlgorithmRunning On Node u
5
1
2
2
3
3
1
2
5
1
x y
u
v
z
w
N
0
Nodes that have been
D(v) Distance/cumulative-cost
to node v
p(v) Last node hopped before
reaching node v
Step
N
0
D(v);p(v)
D(w);p(w)
D(x);p(x)
D(y);p(y)
D(z);p(z)
0
u
...
...
...
...
...
1
ux
...
...
...
...
2
uxy
...
...
...
3
uxyv
...
...
4
uxyvw
...
5
uxyvwz
13
Dijkstra’s Algorithm:What Is The Forwarding Table?
5
1
2
2
3
3
1
2
5
1
x y
u
v
z
w
Forwarding table at router u:
Destination
Interface
v
...
x
...
y
...
w
...
z
...
14
Oscillations:Initial Routing
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
Three streams:
Streamx-to-w:x to w of 1 unit of bandwidth
Streamz-to-w:z to w of 1 unit of bandwidth
Streamy-to-w:y to x to w of e unit of bandwidth
15
Oscillations:x,y detect better path to w,clockwise
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
Changing streamroutes:
Streamy-to-w switches its path to...
Streamx-to-w switches its path to...
16
Oscillations:x,y,z detect better path to w,c-clockwise
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
Changing streamroutes:
Streamx-to-w switches its path to...
Streamz-to-w switches its path to...
Streamy-to-w switches its path to...
17
Oscillations:x,y,z detect better path to w,clockwise
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
AW/Kurose and Ross
Computer Networking 3/e KR 04.26
26p0 Wide x 26p5 Deep 2/c 3/23/04 rossi
w
y
z
x
1
0 0
0
e
1 + e
1
a. Initial routing
1
e
w
y
z
x
2 + e
1 + e 1
0 0
0
b. x, y detect better path
to w, clockwise
w
y
z
x
0
0 0
1
1 + e
2 + e
c. x, y, z detect better path
to w, counterclockwise
w
y
z
x
2 + e
1 + e 1
0 0
0
d. x, y, z, detect better path
to w, clockwise
1 1
e
1 1
e
1 1
e
Changing streamroutes:
Streamx-to-w switches its path to...
Streamz-to-w switches its path to...
Streamy-to-w switches its path to...
Routing oscillation has started
18
So how much trafﬁc do the link state packets create?
A B 1
B
DA
C
4 4
1 1
1
A C 4
I A’s LSP transmissions:
 Two LSPs to B.
 Same two LSPs to C.
I Upon receiving a LSP,each
router does the following:
 Store LSP in a database
 If new,forward to every
interface other than incoming
one
I A network with E edges will
copy at most 2E times
19
“...E edges will copy at most 2E times...”
A B 1
B
DA
C
4 4
1 1
1
A B 1
B
DA
C
4 4
1 1
1
A B 1
B
DA
C
4 4
1 1
1
20
“...E edges will copy at most 2E times...”
A B 1
B
DA
C
4 4
1 1
11
E
A B 1
B
DA
C
4 4
1 1
E
11
A B 1
B
DA
C
4 4
1 1
E
11
21
“...E edges will copy at most 2E times...”
B
CA D E
1
B A 1
AB
C D E
B A 1
22
“...E edges will copy at most 2E times...”
What is the upper limit for the number of LSPs for this network?
5
1
2
2
3
3
1
2
5
1
x y
u
v
z
w
E =:::
Numof LSPs by u :::
Numof LSPs by v :::
Numof LSPs by w :::
Numof LSPs by x :::
Numof LSPs by y :::
Numof LSPs by z :::
Numof LSPs :::
:::
23
True or False
I Link state algorithms is one classiﬁcation of routing algorithms
I Dijkstra’s algorithm...
...is a member of the set of link state algorithms,
...computes least cost paths from
one node (“source”) to
all other
nodes;gives forwarding table for that node,
...after k iterations,knows least cost path to k destinations.
I A router using Dijkstra’s algorithm...
...ﬁrst,gathers LSP to learn the topology,
...then,then runs the algorithmon the topology info
...then,as new LSP packets update the topology,reruns the
algorithmto update the forwarding table.