Docsity

Routing Algorithms - Computer Networks - Lecture Slides, Slides of Computer Networks

Partial preview of the text

Download Routing Algorithms - Computer Networks - Lecture Slides and more Slides Computer Networks in PDF only on Docsity!

4: Network Layer 4a-

Intro to Routing Algorithms

4: Network Layer 4a-

Routing

 IP Routing – each router is supposed to

send each IP datagram one step closer to

its destination

 How do they do that?

 Static Routing

  • Hierarchical Routing – in ideal world would that be enough? Well its not an ideal world

 Dynamic Routing

  • Routers communicate amongst themselves to determine good routes (ICMP redirect is a simple example of this)
  • Before we cover specific routing protocols we will cover principles of dynamic routing protocols

4: Network Layer 4a-

Routing Algorithm classification:

Global or decentralized?

Choice 2, if dynamic: global or decentralized

information?

Global:

 all routers have complete topology, link cost info

 “link state” algorithms

Decentralized:

 router knows physically-connected neighbors, link

costs to neighbors

 iterative process of computation, exchange of info

with neighbors (gossip)

 “distance vector” algorithms

4: Network Layer 4a-

Roadmap

 Details of Link State

 Details of Distance Vector

 Comparison

4: Network Layer 4a-

Global Dynamic Routing

A

D E

B C

F

2

2

1

3

1

1

2

5

3

5

See the big picture; Find the best Route

What algorithm do you use?

4: Network Layer 4a-

A Link-State Routing Algorithm

Dijkstra’s algorithm

 Know complete network topology with link costs for

each link is known to all nodes

 accomplished via “link state broadcast”

 In theory, all nodes have same info

 Based on info from all other nodes, each node

individually computes least cost paths from one

node (“source”) to all other nodes

 gives routing table for that node

 iterative: after k iterations, know least cost path to

k dest.’s

4: Network Layer 4a-

Dijsktra’s Algorithm

1 Initialization – know c(I,j) to start: 2 N = {A} 3 for all nodes v 4 if v adjacent to A 5 then D(v) = c(A,v) 6 else D(v) = infty 7 8 Loop 9 find w not in N such that D(w) is a minimum (optional?) 10 add w to N 11 update D(v) for all v adjacent to w and not in N: 12 D(v) = min( D(v), D(w) + c(w,v) ) 13 /* new cost to v is either old cost to v or known 14 shortest path cost to w plus cost from w to v */ 15 until all nodes in N

4: Network Layer 4a-

Dijkstra’s algorithm: example

Step 0 1 2 3 4 5

start N A AD ADE ADEB ADEBC ADEBCF

D(B),n(B) 2,B 2,B 2,B

D(C),n(C) 5,C 4,D 3,D 3,D

D(D),n(D) 1,A

D(E),n(E) infinity 2,D

D(F),n(F) infinity infinity 4,D 4,D 4,D

A

D E

B C

F

2 2 1

3

1

1 2

5

3

5

4: Network Layer 4a-

Complexity of Link State

Algorithm complexity: n nodes

 each iteration

 Find next w not in N such that D(w) is a minimum  Then for that w, check its best path to other destinations  => n*(n+1)/2 comparisons: O(n 2 )

 more efficient implementations possible using a

heap: O(nlogn)

4: Network Layer 4a-

Distance Vector Routing Algorithm

distributed:  each node communicates only with directly-

attached neighbors

iterative:

 continues until no nodes exchange info.

 self-terminating: no “signal” to stop

asynchronous:  nodes need not exchange info/iterate in lock

step!

4: Network Layer 4a-

Example: Distance Table for E

A

E D

B C

7 8 1 2

1

2

D ()

A

B

C

D

A

B

D

E cost to destination via

D (C,D)

E

c(E,D) + min {D (C,w)}D w

D (A,D)

E

c(E,D) + min {D (A,w)}D w

Loop back through E!

D (A,B)

E

c(E,B) + min {D (A,w)}B w

Loop back through E!

Column only for each neighbor

Rows for each possible dest!

D (row, col)

E

4: Network Layer 4a-

Distance table gives routing table

D ()

A

B

C

D

A

B

D

E cost to destination via

A

B

C

D

A,

D,

D,

D,

Outgoing link to use, cost

Distance table Routing table

= least cost

4: Network Layer 4a-

Distance Vector Algorithm:

1 Initialization (don’t start knowing link costs for all links in graph): 2 for all adjacent nodes v: 3 D (,v) = infty / the * operator means "for all rows" / 4 D (v,v) = c(X,v) 5 for all destinations, y 6 send min D (y,w) to each neighbor / w over all X's neighbors */

X X

X w

At all nodes, X:

Then in steady state…

4: Network Layer 4a-

Distance Vector Algorithm (cont.):

8 loop 9 wait (until I see a link cost change to neighbor V 10 or until I receive update from neighbor V) 11 12 if (c(X,V) changes by d) 13 /* change cost to all dest's via neighbor v by d / 14 / note: d could be positive or negative / 15 for all destinations y: D (y,V) = D (y,V) + d 16 17 else if (update received from V wrt destination Y) 18 / shortest path from V to some Y has changed / 19 / V has sent a new value for its min DV(Y,w) / 20 / call this received new value is "newval" */ 21 for the single destination y: D (Y,V) = c(X,V) + newval 22 23 if we have a new min D (Y,w)for any destination Y 24 send new value of min D (Y,w) to all neighbors 25 26 forever

w

X X

X X

X

w w