Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views37 pages

Routing Algorithms

The document discusses routing algorithms, focusing on their purpose of determining paths for packet transmission in networks. It highlights the Optimality Principle, which states that sub-solutions of an optimal solution must also be optimal, and introduces Dijkstra's Algorithm for finding the shortest path. The document also mentions various routing protocols such as RIP, OSPF, and BGP, along with their metrics and goals.

Uploaded by

rish.blackstar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views37 pages

Routing Algorithms

The document discusses routing algorithms, focusing on their purpose of determining paths for packet transmission in networks. It highlights the Optimality Principle, which states that sub-solutions of an optimal solution must also be optimal, and introduces Dijkstra's Algorithm for finding the shortest path. The document also mentions various routing protocols such as RIP, OSPF, and BGP, along with their metrics and goals.

Uploaded by

rish.blackstar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Routing Algorithms,

Optimality Principle and


Shortest Path Algorithm

S A N Shams Rishad
012 193 014
CSE 6125
Routing Algorithms Overview

• The main function of the network layer is routing packets from the
source machine to the destination machine
Routing Algorithms Overview
• Definition: Decide the path packets take from source → destination
• Type
• Non-Adaptive: Fixed Route (AKA Static Route)
• Adaptive: Adjusts with topology (AKA Dynamic Route)
• Metrics (for dynamic algorithms): hops, delay, bandwidth, cost,
reliability
• Goal: minimize delay, avoid loops, balance load
• Examples: RIP, OSPF, EIGRP, IS-IS, BGP
Optimality Principle (Bellman, 1957)

A problem is said to satisfy the Principle of Optimality if the sub-solutions of


an optimal solution of the problem are themselves optimal solutions for
their subproblems

“If router J lies on the optimal path from I to K, then the optimal path
from J to K is also along that route.”

…This principle is the foundation of all modern routing algorithms.


Optimality Principle (Bellman, 1957)

• Implication: all optimal routes form a tree rooted at the destination


• Sink tree ensures consistency & loop-free paths
• Multiple equal-cost paths ⇒ forms a DAG (Directed Acyclic Graph)
Shortest Path Algorithm
• Idea: Find path with minimum cost (not always fewest hops).
• Dijkstra’s Algorithm:
• Start from source, distance = 0, others = ∞
• Pick node with smallest distance, mark permanent
• Update neighbors’ distances if shorter path found
• Repeat until all nodes are permanent
• Complexity: O(n²) (faster with heaps)
• Use case: OSPF in real networks.
Dijkstra’s Shortest Path Algorithm
6
B E

2 9
• Shortest Path from a fixed node to
every other node
A 5 1 C
3
• E.g. cities and routes between them

8 3

D F
2
1. Mark all the Nodes as “Unvisited”

6
B E

2 9

A 5 1 C
3

8 3

D F
2

Visited nodes = [] Unvisited nodes = [A, B, C, D, E, F]


2. Assign to all Nodes a tentative distance value

6
B E Shortest Previous
Node
Distance Node
2 9
A
B
A 5 1 C C
3
D
8 3 E
F
D F
2

Visited nodes = [] Unvisited nodes = [A, B, C, D, E, F]


2. Assign to all Nodes a tentative distance value

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B ∞
A 5 1 C C ∞
3
D ∞
8 3 E ∞
F ∞
D F
2

Visited nodes = [] Unvisited nodes = [A, B, C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B ∞
A 5 1 C C ∞
3
D ∞
8 3 E ∞
F ∞
D F
2

Visited nodes = [] Unvisited nodes = [A, B, C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 8 D
8 3 E ∞
F ∞
D F
2

Visited nodes = [] Unvisited nodes = [A, B, C, D, E, F]


4. Mark current Node as “Visited”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 8 D
8 3 E ∞
F ∞
D F
2

Visited nodes = [A] Unvisited nodes = [B, C, D, E, F]


5. Choose new current Node from Unvisited Nodes with minimal
distance

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 8 D
8 3 E ∞
F ∞
D F
2

Visited nodes = [A] Unvisited nodes = [B, C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

2+6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 2+5 1 C C ∞
3
D 8 D
8 3 E ∞
F ∞
D F
2

Visited nodes = [A] Unvisited nodes = [B, C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

2+6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 2+5 1 C C ∞
3
D 8 D
8 3 E 8 B
F ∞
D F
2

Visited nodes = [A] Unvisited nodes = [B, C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

2+6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 2+5 1 C C ∞
3
D 7 B
8 3 E 8 B
F ∞
D F
2

Visited nodes = [A] Unvisited nodes = [B, C, D, E, F]


4. Mark current Node as “Visited”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 7 B
8 3 E 8 B
F ∞
D F
2

Visited nodes = [A, B] Unvisited nodes = [C, D, E, F]


5. Choose new current Node from Unvisited Nodes with minimal
distance

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 7 B
8 3 E 8 B
F ∞
D F
2

Visited nodes = [A, B] Unvisited nodes = [C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
7+3
D 7 B
8 3 E 8 B
F ∞
D F
7+2

Visited nodes = [A, B] Unvisited nodes = [C, D, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
7+3
D 7 B
8 3 E 8 B
F 9 D
D F
7+2

Visited nodes = [A, B] Unvisited nodes = [C, D, E, F]


4. Mark current Node as “Visited”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D] Unvisited nodes = [C, E, F]


5. Choose new current Node from Unvisited Nodes with minimal
distance

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C ∞
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D] Unvisited nodes = [C, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 8+9
A 0
B 2 A
A 5 8+1 C C ∞
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D] Unvisited nodes = [C, E, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 8+9
A 0
B 2 A
A 5 8+1 C C 17 E
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D] Unvisited nodes = [C, E, F]


4. Mark current Node as “Visited”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 17 E
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E] Unvisited nodes = [C, F]


5. Choose new current Node from Unvisited Nodes with minimal
distance

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 17 E
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E] Unvisited nodes = [C, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 17 E
3
D 7 B
8 9+3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E] Unvisited nodes = [C, F]


3. For the current Node, calculate the distance to all Unvisited
neighbors
3.1. Update shortest distance (if new < old)

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 9+3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E] Unvisited nodes = [C, F]


4. Mark current Node as “Visited”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E, F] Unvisited nodes = [C]


5. Choose new current Node from Unvisited Nodes with minimal
distance

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E, F] Unvisited nodes = [C]


4. Mark current Node as “Visited”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

Visited nodes = [A, B, D, E, F, C] Unvisited nodes = []


Say, we want to go from “A” to “C”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2
Say, we want to go from “A” to “C”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2
Say, we want to go from “A” to “C”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2
Say, we want to go from “A” to “C”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2
Say, we want to go from “A” to “C”

6
B E Shortest Previous
Node
Distance Node
2 9
A 0
B 2 A
A 5 1 C C 12 F
3
D 7 B
8 3 E 8 B
F 9 D
D F
2

From A to C: 3 + 2 + 5 + 2 = 12

You might also like