0% found this document useful (0 votes)
110 views20 pages

Routing Algorithms: Suggested Reading

The document discusses routing algorithms. It outlines flooding, the distributed Bellman-Ford algorithm, and Dijkstra's shortest path first algorithm. The Bellman-Ford algorithm finds the shortest paths from a source node to all other nodes by iteratively finding paths of increasing hop counts. Dijkstra's algorithm builds a shortest path spanning tree by iteratively adding the closest node to the tree.

Uploaded by

Haseeb Hussain
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views20 pages

Routing Algorithms: Suggested Reading

The document discusses routing algorithms. It outlines flooding, the distributed Bellman-Ford algorithm, and Dijkstra's shortest path first algorithm. The Bellman-Ford algorithm finds the shortest paths from a source node to all other nodes by iteratively finding paths of increasing hop counts. Dijkstra's algorithm builds a shortest path spanning tree by iteratively adding the closest node to the tree.

Uploaded by

Haseeb Hussain
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Routing Algorithms

Suggested Reading:
Bertsekas and Gallager: 5.1 (5.1.1, 5.1.2), 5.2.3 (on Bellman-Ford 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’s Shortest Path First Algorithm
Problem

Given a topology, link costs, and a source-destination (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
A

1 1 4
R1 R2 R4 R6
2 2 3
2
R7 3
R5 2
R3 4 B
R8
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

1 1 4
R1 R2 R4 R6
2 2 3
2
R7 3
R5 2
R3 4 B
R8
Flooding
Routers forward packets to all ports
except the ingress port.

R1

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.
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)

1 1 4
R1 R2 R4 R6
2 2 3
2
R7 3
R5 2
R3 4
R8
A Spanning Tree
1 1 4
R1 R2 R4 R6
3
2 2
2
2
R7 3
R5
4
R3 R8

™ The solution is a spanning tree with 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 Bellman-Ford algorithm
™ Dijkstra’s shortest path first algorithm
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 dij=∞ 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} [Dj(h) +dji] for i≠8.

If all weights are positive, algorithm terminates in N-1 steps, where N is the
no. of nodes in the network.

*Notations are similar to those used in Bertsekas and Gallager.


Bellman-Ford Algorithm
Example
∞ ∞ ∞ ∞
1 1 4
R1 R2 R4 R6
2 2

3
∞ 2
3
∞ R5 2 R7
R3 4
R8

∞ ∞ ∞ 4 2
1 1
R1 R2 R4 R6
3
2 2
2 3
2 R7
2 3
4 R5
4 R8
R3
Bellman-Ford Algorithm
6 4 6 2
1 1 4
R1 R2 R4 R6
3
2 3
2 2 2
4 2 R7 3
R5
4
R3 R8
Solution
5 4 5 2
R1 1 R2 1 R4 R6
2 3
2 2
4 R7 3
R5 2
R3 4 R8
Routing Table for R8
Destination Next Hop

R1 R5
R2 R5
R3 R3
R4 R5
R5 R5
R6 R6
R7 R7
Distributed Bellman-Ford
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/eachange distance information from/with neighbors.


Bellman-Ford 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 Bellman-Ford
“Bad news travels slowly”
1 1 1
R1 R2 R3 R4

Consider the calculation of distances from/to R4:


Time R1 R2 R3
0 3,R2 2,R3 1, R4 R3 R4 fails
1 3,R2 2,R3 3,R2
2 3,R2 4,R3 3,R2 d34=inf.
3 5,R2 4,R3 5,R2
… “Counting
… to
…infinity” …
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
Bellman-Ford algorithm.
Dijkstra’s Shortest 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. lowest-cost) path to the tree.
™ Finds spanning tree routed on source router.
Dijkstra’s Shortest Path First Algorithm
Example

Step 1: Shortest path set, S = {R8}. Candidate set, C = {R3 , R5 , R7 , R6 }


Step 2: S = {R8 , R5},
R5
C = {R3 , R7 , R6 , R2 }. R8

R6
Step 3: S = {R8 , R5 , R6},
R5
C = {R3 , R7 , R2 , R4 }. R8

Step 4: S = {R8 , R5 , R6 , R7 }, R6

C = {R3 , R2 , R4}. R7
R5
R8
Dijkstra’s SPF Algorithm
Step 8 : S = {R8 , R5 , R6 , R7 , R2 , R1 , R4 },
C = {}.

1 1
R1 R2 R4 R6

2
R7 3
R5 2
4 R8
R3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy