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

Advanced Network Section 8

The document discusses routing protocols in computer networks, focusing on Dijkstra's algorithm and the Distance Vector Routing (DVR) Protocol. Dijkstra's algorithm computes the least cost paths from a source node to all other nodes using a centralized approach, while the DVR method utilizes the Bellman-Ford equation for dynamic routing updates among neighboring routers. The document also provides examples and iterations of both algorithms to illustrate their functionality in determining optimal paths in a network.

Uploaded by

israahussein737
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)
6 views20 pages

Advanced Network Section 8

The document discusses routing protocols in computer networks, focusing on Dijkstra's algorithm and the Distance Vector Routing (DVR) Protocol. Dijkstra's algorithm computes the least cost paths from a source node to all other nodes using a centralized approach, while the DVR method utilizes the Bellman-Ford equation for dynamic routing updates among neighboring routers. The document also provides examples and iterations of both algorithms to illustrate their functionality in determining optimal paths in a network.

Uploaded by

israahussein737
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/ 20

Semester Number

Academic year

Advanced Computer Network

Dr. Manal Shaaban


Routing protocols

Routing protocol goal: determine “good” paths (equivalently, routes), from sending hosts to receiving host, through
network of routers
path: sequence of routers packets traverse from given initial source host to final destination host
“good”: least “cost”, “fastest”, “least congested”
Graph abstraction: link costs
Dijkstra’s algorithm

 centralized: network topology, link notation


costs known to all nodes
 cx,y: direct link cost from node
• accomplished via “link state
broadcast” x to y; = ∞ if not direct
neighbors
• all nodes have same info
 D(v): current estimate of cost
 computes least cost paths from one of least-cost-path
of nodes from
whose least-cost-path source
definitively
node (“source”) to all other nodes to destination v
known

• gives forwarding table for that node  p(v): predecessor node along
 iterative: after k iterations, know path from source to v
 N': set of nodes whose least-
least cost path to k destinations cost-path definitively known
Dijkstra’s algorithm example
B C D E
Step N' D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E)
0 A 4,A 2,A ∞ ∞
1
2
3
4
5
Dijkstra’s algorithm example
B C D E
Step N' D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E)
0 A 4,A 2,A ∞ ∞

AC 3,C X 6,C 7,C


1

2
3
4
Dijkstra’s algorithm example
B C D E
Step N' D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E)
0 A 4,A 2,A ∞ ∞

1 AC 3,C
3,C X 7,C
6,C

2 ACB X
X
5,B 6,B
3
4
5
Dijkstra’s algorithm example
B C D E
Step N' D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E)
0 A 4,A 2,A ∞ ∞

1 AC 3,C
3,C X 7,C
6,C

2 ACB X
X
5,B 6,B

3 X X X 6,B
ACBD

4
Dijkstra’s algorithm example
B C D E
Step N' D(B),p(B) D(C),p(C) D(D),p(D) D(E),p(E)
0 A 4,A 2,A ∞ ∞

1 AC 3,C
3,C X 7,C
6,C

2 ACB X
X
5,B 6,B

3
X X X 6,B
ACBD

4 ACBDE
Distance vector algorithm
Distance Vector Routing (DVR) Protocol is a method used by routers to find the best
path for data to travel across a network. Each router keeps a table that shows the shortest
distance to every other router, based on the number of hops (or steps) needed to reach
them. Routers share this information with their neighbors, allowing them to update their
tables and find the most efficient routes. This protocol helps ensure that data moves
quickly and smoothly through the network.
Distance vector
algorithm
Based on Bellman-Ford (BF) equation (dynamic programming):
Bellman-Ford equation

Let Dx(y): cost of least-cost path from x to y.


Then:
Dx(y) = minv { cx,v + Dv(y) }

v’s estimated least-cost-path cost to y


min taken over all neighbors v of x direct cost of link from x to v
Here’s an example of how the Bellman-Ford algorithm works with a simple graph:

Consider a graph with 5 vertices and 9 edges, where each edge has a weight:

•Vertices: A, B, C, D, E
•Edges with weights:
•A → B: weight 4
•A → C: weight 2
•B → D: weight 2
•B → E: weight 4
•B → C: weight 3
•C → E: weight 5
•C → B: weight 1
•C → D: weight 4
•E → D: weight -5
Initialization: Set the distance to the
source vertex (say vertex A) to 0 and
all other vertices to infinity:

Distance[A] = 0
Distance[B] = ∞
Distance[C] = ∞
Distance[D] = ∞
Distance[E] = ∞
Relax all edges (V - 1) times: Here, V = 5 (the number of vertices), so we
will repeat the process 4 times.
First Iteration:
A → B: Distance[A] + 4= 0 + 4 = 4. So, Distance[B] = 4.
A → C: Distance[A] + 2 = 0 + 2 = 2. So, Distance[C] = 2.
B → D: Distance[B] + 2 = 4 + 2 = 6. So, Distance[D] = 6.
B → C: Distance[B] + 3 = 4 + 3 = 7, but Distance[C] = 2, so no update.
B → E: Distance[B] + 3 = 4 + 3 = 7. So, Distance[E] = 7.
C→ D: Distance[C] + 4 = 2 + 4 = 6. but Distance[D] =6 ,so no update.
C→ E: Distance[C] + 5 = 2 + 5 = 7. but Distance[E] =7 ,so no update.
C→ B: Distance[C] +1= 2 + 1 = 3. So, Distance[B] = 3.
E → D: Distance[E] + -5= 7-5= 2, but Distance[D] = 6, so update
Distance[D]=2.
After the first iteration, the distances are:
Distance[A] = 0
Distance[B] = 3
Distance[C] = 2
Distance[D] = 2
Distance[E] = 7
second Iteration:
A → B: Distance[A] + 3= 0 + 3 = 3. So, Distance[B] = 3.
A → C: Distance[A] + 2 = 0 + 2 = 2. So, Distance[C] = 2.
B → D: Distance[B] + 2 = 3 + 2 = 5. but, Distance[D] = 2.
B → C: Distance[B] + 3 = 3 + 3 = 6, but Distance[C] = 2, so no update.
B → E: Distance[B] + 3 = 3 + 3 = 6. So, Distance[E] = 6.
C→ D: Distance[C] + 4 = 2 + 4 = 6. but Distance[D] =2 ,so update.
C→ E: Distance[C] + 5 = 2 + 5 = 7. but Distance[E] =6 ,so no update.
C→ B: Distance[C] +1= 2 + 1 = 3. but, Distance[B] = 3 ,so no update.
E → D: Distance[E] + -5= 6-5= 1, but Distance[D] = 2, so update
Distance[D]=1.
After the second iteration, the distances are:
Distance[A] = 0
Distance[B] = 3
Distance[C] = 2
Distance[D] = 1
Distance[E] = 6
third Iteration:
A → B: Distance[A] + 4= 0 + 4 = 4. but Distance[B] = 3 so update it.
A → C: Distance[A] + 2 = 0 + 2 = 2. So, Distance[C] = 2.
B → D: Distance[B] + 2 = 3 + 2 = 5. but Distance[D] = 1 so update it
B → C: Distance[B] + 3 = 3 + 3 = 6, but Distance[C] = 2, so no update.
B → E: Distance[B] + 3 = 3 + 3 = 6. but Distance[E] = 6 so no update.
C→ D: Distance[C] + 4 = 2 + 4 = 6. but Distance[D] =1 ,so no update.
C→ E: Distance[C] + 5 = 2 + 5 = 7. but Distance[E] =6 ,so no update.
C→ B: Distance[C] +1= 2 + 1 = 3. but Distance[B] = 3 ,so no update .
E → D: Distance[E] + -5= 6-5= 1, but Distance[D] = 1, so no update
After the third iteration, the distances are:
Distance[A] = 0
Distance[B] = 3
Distance[C] = 2
Distance[D] = 1
Distance[E] = 6
Fourth Iteration:
A → B: Distance[A] + 4= 0 + 4 = 4. but Distance[B] = 3 so update it.
A → C: Distance[A] + 2 = 0 + 2 = 2. So, Distance[C] = 2.
B → D: Distance[B] + 2 = 3 + 2 = 5. but Distance[D] = 1 so update it
B → C: Distance[B] + 3 = 3 + 3 = 6, but Distance[C] = 2, so no update.
B → E: Distance[B] + 3 = 3 + 3 = 6. but Distance[E] = 6 so no update.
C→ D: Distance[C] + 4 = 2 + 4 = 6. but Distance[D] =1 ,so no update.
C→ E: Distance[C] + 5 = 2 + 5 = 7. but Distance[E] =6 ,so no update.
C→ B: Distance[C] +1= 2 + 1 = 3. but Distance[B] = 3 ,so no update .
E → D: Distance[E] + -5= 6-5= 1, but Distance[D] = 1, so no update
After the fourth iteration, the distances are:
Distance[A] = 0
Distance[B] = 3
Distance[C] = 2
Distance[D] = 1
Distance[E] = 6
Conclusion
The Bellman-Ford algorithm successfully calculates
the shortest paths from vertex A to all other
vertices, even with negative weight edges, and
detects any negative weight cycles (none in this
case).

You might also like