Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Dijkstra's Algorithm: Shortest Path Finding in a Graph, Slides of Computer Networks

An example of dijkstra's algorithm, a popular algorithm for finding the shortest path between nodes in a graph. The algorithm is demonstrated through the use of a table, which shows the best distances from the starting node (a) to all other nodes in the graph. The document also explains the intuition behind the algorithm and discusses link cost changes and poisoned reverse.

Typology: Slides

2013/2014

Uploaded on 01/29/2014

sundar
sundar ๐Ÿ‡ฎ๐Ÿ‡ณ

4.7

(9)

110 documents

1 / 53

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Distance Vector Routing
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download Dijkstra's Algorithm: Shortest Path Finding in a Graph and more Slides Computer Networks in PDF only on Docsity!

Distance Vector Routing

How Distance-Vector (DV) works

Each router maintains its shortest distance to every

destination via each of its neighbors

via B via C to B to C to D

From node A

Neighbor

(next-hop)

Destinations dist

C (A, D): shortest

distance from A to D via C

A

How Distance-Vector (DV) works

How does A initialize its dist() table and DV?

via B via C to B?? to C?? to D??

From node A

A

min dist to B? to C? to D?

Aโ€™s DV

How Distance-Vector (DV) works

A

B

C

Link costs

How does A initialize its dist() table and DV?

How Distance-Vector (DV) works

Each router sends its DV to its immediate neighbors

via B via C

to B c (A,B) โˆž

to C โˆž c (A,C) to D โˆž โˆž

From node A

A

B

C

mindist to B c(A,B) to C c(A,C) to D โˆž

Aโ€™s DV

mindist to B 5 to C 6 to D 2

How Distance-Vector (DV) works

Routers process received DVs

A

B

C

Aโ€™s DV

mi n to B 5 to C 6 to D 2 via A via C

to A 5 โˆž

to C 15 1 to D โˆž โˆž

From node B Bโ€™s DV

mindist to A 5 to C 1 to D โˆž

Distance Vector Routing

  • Each router knows the links to its neighbors
  • Each router has provisional โ€œshortest pathโ€ to every other router -- its distance vector (DV)
  • Routers exchange this DV with their neighbors
  • Routers look over the set of options offered by their neighbors and select the best one
  • Iterative process converges to set of shortest paths

Distance Vector

  • c(i,j): link cost from node i to j
  • distZ(A,V): shortest dist. from A to V via Z
  • mindist(A,V): shortest dist. from A to V 0 At node A 1 Initialization: 2 for all destinations V do 3 if V is neighbor of A 4 distV( A, V ) = mindist(A,V) = c( A,V ); 5 else 6 distV( A, V ) = mindist(A,V) = โˆž; 7 send mindist( A, * ) to all neighbors loop: 8 wait (until A sees a link cost change to neighbor V /* case 1 / 9 or until A receives mindist(V,) from neighbor V ) /* case 2 / 10 if (c( A , V ) changes by ยฑ d ) / ๏ƒœ case 1 / 11 for all destinations Y do 12 distV( A,Y ) = distV( A,Y ) ยฑ d 13 else / ๏ƒœ case 2: / 14 for all destinations Y do 15 distV( A,Y ) = c( A,V ) + mindist( V, Y ); 16 update mindist( _A,_ ) 15 if (there is a change in mindist(A, *)) 16 send mindist( A, * ) to all neighbors 17 forever

Example: Initialization via B via C to A - - to B 2 โˆž to C โˆž 7 to D โˆž โˆž

A C

B D

from Node A via A via C via D to A 2 โˆž โˆž to B - - - to C โˆž 1 โˆž to D โˆž โˆž 3 from Node B from Node C via A via B via D to A 7 โˆž โˆž to B โˆž 1 โˆž to C - - - to D โˆž โˆž 1 via B via C to A โˆž โˆž to B 3 โˆž to C โˆž 1 to D - - from Node D min dist to A 0 to B 2 to C 7 to D โˆž min dist 0 2 7 โˆž min dist 2 0 1 3 min dist โˆž 3 1 0 min dist 7 1 0 1

Example: C sends update to A via B via C to A - - to B 2 โˆž to C โˆž 7 to D โˆž โˆž from Node A via A via C via D to A 2 โˆž โˆž to B - - - to C โˆž 1 โˆž to D โˆž โˆž 3 from Node B from Node C via A via B via D to A 7 โˆž โˆž to B โˆž 1 โˆž to C - - - to D โˆž โˆž 1 via B via C to A โˆž โˆž to B 3 โˆž to C โˆž 1 to D - - from Node D min dist 0 2 7 โˆž min dist โˆž 3 1 0 min dist 7 1 0 1

A C

B D

min dist 2 0 1 3

Example: C sends update to A via B via C to A - - to B 2 8 to C โˆž 7 to D โˆž 8 from Node A min dist 0 2 7 โˆž

A C

B D

min dist 7 1 0 1

Example: C sends update to A via B via C to A - - to B 2 8 to C โˆž 7 to D โˆž 8 from Node A min dist 0 2 7 8

A C

B D

Example: now B sends update to A via A via C via D to A 2 โˆž โˆž to B - - - to C โˆž 1 โˆž to D โˆž โˆž 3 from Node B from Node C via A via B via D to A 7 โˆž โˆž to B โˆž 1 โˆž to C - - - to D โˆž โˆž 1 via B via C to A โˆž โˆž to B 3 โˆž to C โˆž 1 to D - - from Node D min dist โˆž 3 1 0 min dist 7 1 0 1

A C

B D

min dist 2 0 1 3 via B via C to A - - to B 2 8 to C โˆž 7 to D โˆž 8 from Node A min dist 0 2 7 (^8) docsity.com

Example: now B sends update to A via A via C via D to A 2 โˆž โˆž to B - - - to C โˆž 1 โˆž to D โˆž โˆž 3 from Node B from Node C via A via B via D to A 7 โˆž โˆž to B โˆž 1 โˆž to C - - - to D โˆž โˆž 1 via B via C to A โˆž โˆž to B 3 โˆž to C โˆž 1 to D - - from Node D min dist โˆž 3 1 0 min dist 7 1 0 1

A C

B D

min dist 2 0 1 3 via B via C to A - - to B 2 8 to C 3 7 to D 5 8 from Node A min dist 0 2 7 8 Make sure you know why this is 5, not 4!