Routing Algorithms
Suggested Reading:
Bertsekasand Gallager: 5.1 (5.1.1, 5.1.2), 5.2.3
(on BellmanFord and
Dijkstra’s)
Kurose and Rose (2001 Edition): 4.1, 4.2, 4.3, 4.4
Also http://www.stanford.edu/class/cs224a
: routing protocol
Outline
Flooding
Distributed Bellman Ford Algorithm
Dijkstra’sShortest Path First Algorithm
Problem
Given a topology, link costs, and a sourcedestination (SD) pair,
determine a route from S to D so that the route has the minimum
cost (i.e., is the shortest).
Example network
The shortest route A to B:
R1, R2, R5, R8
R7
R6
R4
R2
R1
114
2
4
2
23
2
3
R8
A
B
R5
R3
Routing Metrics
Metrics
Link state: up or down (stability)
Delay to send an average size packet (Make high speed links
attractive, but closeness counts)
Bandwidth
Link utilization
For simplicity, our examples assume that the cost for the path is
additive.
Example network
In this simple case, solution is clear from inspection
R7
R6
R4
R2
R1
114
2
4
2
23
2
3
R8
A
B
R5
R3
Flooding
Advantages:
Simple.
Every destination in the network is reachable.
Disadvantages:
Some routers receive a packet multiple times.
Packets can go round in loops forever.
Inefficient.
Routers forward packets to all ports
except the ingress port.
R1
Spanning Trees
Find the lowest cost route from each of
(R1, …, R7) to R8
(the same as from R8
to the rest for this case)
R5
R3
R7
R6
R4
R2
R1
114
2
4
2
23
2
3
R8
A Spanning Tree
R3
R1
R5
R4
R8
R6
The solution is a spanning treewith R8
as the source of the tree.
Tree:There are no loops.
Spanning:All nodes included.
Will see two algorithms that build spanning trees automatically:
The distributed BellmanFord algorithm
Dijkstra’sshortest path first algorithm
R2
R7
1
14
2
4
2
2
3
23
Bellman Ford Algorithm*
Finds the shortest paths, from a given source node, say node 8, to all other
nodes (i is the index for destinations).
General idea:
–First find the shortest single arc path,
–Then the shortest path of at most two arcs, etc.
–Let dij
be the cost between node i to j; and d
ij=∞if (i,j) is not directly linked
Let Di(h) be the shortest distance from 8 to i using at most h hops/arcs. (h
can be regarded as time also.)
–Di(1) = d8i
for i≠8, D8(h) = 0 for all h.
–Di(h+1) = min {j} [D
j(h) +dji] for i≠8.
If all weights are positive, algorithm terminates in N1 steps, where N is the
no. of nodes in the network.
*Notations are similar to those used in Bertsekasand Gallager.
BellmanFord Algorithm
R5
R3
R7
R8
R6
R4
R2
R1
Example
114
2
4
2
23
2
3
∞
∞
∞
∞
∞
∞
∞
R2
R5
R7
R4
R6
R8
R3
R1
11
4
2
2
3
2
4
2
3
∞
∞
∞
4
2
3
2
BellmanFord Algorithm
R3
R5
R7
R8
R6
R4
R2
R1
11
4
2
2
2
3
3
2
4
64 6 2
4
2
3
R8
R6
R4
R2
R1
R3
R5
1
1
4
2
3
2
5452
4
2
3
2
R7
Solution
Routing Table for R8
R7
R7
R6
R6
R5
R5
R5
R4
R3
R3
R5
R2
R5
R1
Destination Next Hop
Distributed BellmanFord
Let N(i) be a set of neighbors of node i:
Di(h+1) = min {j in N(i)} [Dj(h) +dji] for i≠8; D8(h+1) = 0
Only need to keep/eachangedistance information from/with neighbors.
BellmanFord Algorithm
Questions:
1.
How long can the algorithm take to run?
2.
How do we know that the algorithm always
converges?
3.
What happens when link costs change, or when
routers/links fail?
A Problem with BellmanFord
R4
R3
R2
R1
111
“Bad news travels slowly”
Consider the calculation of distances from/to R
4:
…………
5,R2
4,R3
5,R2
3
3,R2
4,R3
3,R2
2
3,R2
2,R3
3,R2
1
1, R4
2,R3
3,R2
0
R3
R2
R1
Time
“Counting to infinity”
R3
R4
fails
d34=inf.
Counting to Infinity Problem
Solutions
1.
Set infinity = “some small integer”(e.g. 16). Stop
when count = 16.
2.
Split Horizon: Because R2
received lowest cost path
from R3, it does not advertise cost to R3
3.
There are many problems with (and fixes for) the
BellmanFord algorithm.
Dijkstra’sShortest Path First Algorithm
Routers send out update messages whenever the state of a
link changes. Hence the name: “Link State”algorithm.
Each router calculates lowest cost path to all others, starting
from itself.
At each step of the algorithm, router adds the next shortest
(i.e. lowestcost) path to the tree.
Finds spanning tree routed on source router.
Dijkstra’sShortest Path First Algorithm
Example
R6
R8
R6
R8
R5
R8
R5
R5
R7
83576
85
3762
856
3724
8567
324
{}
.
{
,,,
}
{,},
{,,,}.
{,,},
{,,,}.
{,,,},
{,,}.
Step 1: Shortest path set, Candidate set,
Step 2:
Step 3:
Step 4:
SRCRRRR
SRR
CRRRR
SRRR
CRRRR
SRRRR
CRRR
=
=
=
=
=
=
=
=
Dijkstra’sSPF Algorithm
R5
R7
R3
R4
R2
R8
R6
R1
11
4
2
3
2
{}.
},,,,,,,{
4127658
=
=
C
RRRRRRRS :8 Step
Enter the password to open this PDF file:
File name:

File size:

Title:

Author:

Subject:

Keywords:

Creation Date:

Modification Date:

Creator:

PDF Producer:

PDF Version:

Page Count:

Preparing document for printing…
0%
Comments 0
Log in to post a comment