CN04-Routing (Types and Algorithms)
CN04-Routing (Types and Algorithms)
Engineering
Computer Network
Routing: Types and Algorithms
Computer Network
Dr. Ahmed Abdel Halim @ Helwan University
Fall 2018
Dr. Ahmed M. Abd El-Haleem
Assistant Professor in
Communication and Electronic Department
Faculty of Engineering, Helwan University
E-mail: dr.ahmed.m.abd.elhaleem@gmail.com
Types of Routing
3
Advantages
– Simplicity
– No extra resources are needed
– More secure
Disadvantages
– lack of flexibility
– Network changes require manual
reconfiguration
– Does not scale well in large topologies
Types of Routing: Dynamic Routing
8
Advantages:
Improved performance , as seen by the
network user.
– Algorithm
• Is used for facilitating routing information
and best path determination.
Dynamic Routing: Algorithms
13
Definitions:
N = set of nodes in the network
s = source node
1) Start with the local node (router): the root of the tree.
2) Assign a cost of 0 to this node and make it the first
permanent node.
3) Examine each neighbor node of the node that was the last
permanent node.
4) Assign a cumulative cost to each node and make it tentative.
5) Among the list of tentative nodes
1) Find the node with the smallest cumulative cost and make it
permanent.
2) If a node can be reached from more than one direction
1) Select the direction with the shortest cumulative cost.
6) Repeat steps 3 to 5 until every node becomes permanent.
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
18
Step 1 [Initialization]
T = {s} Set of nodes so far incorporated
L(n) = w(s, n) for n ≠ s
initial path costs to neighboring nodes are simply link costs
Step 2 [Get Next Node]
find neighboring node not in T with least-cost path from s
incorporate node into T
also incorporate the edge that is incident on that node and a node in T
that contributes to the path
Step 3 [Update Least-Cost Paths]
L(n) = min[L(n), L(x) + w(x, n)] for all n Ï T
f latter term is minimum, path from s to n is path from s to x
concatenated with edge from x to n
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
19
Solution
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
20
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
21
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
22
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
23
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
24
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
25
Algorithms: Dijkstra’s Shortest
Path First (SPF) Algorithm
26
Algorithms: Dijkstra’s Shortest Path
First (SPF) Algorithm
Example
Algorithms: Bellman-Ford Algorithm
28
step 1 [Initialization]
L0(n) = , for all n s
Lh(s) = 0, for all h
step 2 [Update]
for each successive h 0
for each n ≠ s, compute: Lh+1(n)=minj[Lh(j) + w(j, n)]
Connect n with predecessor node j that gives min.
Eliminate any connection of n with different
predecessor node formed during an earlier
iteration
Path from s to n terminates with link from j to n
Algorithms: Bellman-Ford Example
30
5
B D
4
7
A 3 1 1
3
2
C 5
E
Algorithms: Bellman-Ford Example
31
5
Using vertex A B D
as the source 4
(setting its 7
distance to 0),
we initialize all A 3 1 1
the other
3
distances to ∞. 2
C 5
E
From A to
A B C D E
distance 0 ∞ ∞ ∞ ∞
path / / / / /
Algorithms: Bellman-Ford Example
32
Iteration 1: 5
Edges (uA,uB) 4
B D
and (uA,uC) 7
relax updating
the distances A 3 1 1
to B and C 3
2
C 5 E
From A to
A B C D E
distance 0 4 2 ∞ ∞
path A-B A-C / /
Algorithms: Bellman-Ford Example
33
Iteration 2: Edges 5
(uC,uB), (uB,uE), B D
(uB,uD), v and (uC,uD) 4
7
relax updating the
distances to B, D, A 3 1 1
and E respectively.
3
2
C 5 E
From A to
A B C D E
distance 0 3 2 9 7
path A-C-B A-C A-B/C-D A-B/C-E
Algorithms: Bellman-Ford Example
34
5
B D
4
7
A 3 1 1
3
2
C 5
E
From A to
A B C D E
distance 0 3 2 8 6
path A-C-B A-C A-C-B-D A-C-B-E
Algorithms: Bellman-Ford Example
35
5
B D
4
7
A 3 1 1
3
2
C 5
E
From A to
A B C D E
distance 0 3 2 7 6
path A-C-B A-C A-C-B-E-D A-C-B-E
Algorithms: Bellman-Ford Example
36
5
B D
4
7
A 3 1 1
3
2
C 5
E
From A to
A B C D E
distance 0 3 2 7 6
path A-C-B A-C A-C-B-E-D A-C-B-E
B D
37 A 1 1
3
2 E
C
From A to
A B C D E
∞ ∞ ∞ ∞ ∞
1 0 ∞ ∞ ∞ ∞
2 0 4 2 ∞ ∞
3 0 3 2 9 7
4 0 3 2 8 6
5 0 3 2 7 6
path A-C-B A-C A-C-B-E-D A-C-B-E
Algorithms: Bellman-Ford Example