Routing 1 Network Layer Network Layer goals: understand principles behind network layer services: ...

27
Routing 1 Network Layer Network Layer goals: understand principles behind network layer services: routing (path selection) how a router works instantiation and implementation in the Internet Overview: network layer services routing principle: path selection hierarchical routing IP what’s inside a router? Postal- service mail carrier

Transcript of Routing 1 Network Layer Network Layer goals: understand principles behind network layer services: ...

Page 1: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 1

Network LayerNetwork Layer

goals: understand

principles behind network layer services: routing (path

selection) how a router works

instantiation and implementation in the Internet

Overview: network layer services routing principle: path

selection hierarchical routing IP what’s inside a router?

Postal-service mail carrier

Page 2: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 2

Network layer functions

transport packet from sending to receiving hosts

network layer protocols in every host, router

Important functions: Forwarding/switching:

per-router action of moving a packet arriving at an input port to the appropriate output port

Routing/Path determination: calculation of the route that the packet will take through the network (from source to dest); this is a network-wide process. Routing algorithms

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

HOST A

HOST B

Page 3: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 3

DATAGRAM ROUTING (The internet model)

routers: no state about end-to-end connections no network-level concept of 'connection'

packets are typically routed using destination host ID packets between same source-destination pair may take

different paths

1. Send data 2. Receive data

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

Each router has a forwarding table that

maps destination addresses to link

interfaces

Page 4: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 4

Routing

Graph (undirected) Graph (undirected) abstraction for routing abstraction for routing algorithms:algorithms:

nodes represent routers Lines/graph edges are

physical links link cost: delay, cost of

sending a packet across link, or congestion level

Goal: determine good path(sequence of routers) through

network from source to destination.

Routing protocol

A

ED

CB

F

2

2

13

1

1

2

53

5

'good' path: typically means

minimum cost path other definitions

possible

Physical distance, link speed, monetary cost, etc.

Page 5: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 5

ClassificationClassification of Routing Algorithms of Routing Algorithms

Global or decentralized Global or decentralized information?information?

Global: Least-cost path is computed using

complete, global knowledge of the network: topology, link cost info

Link State (LS) algorithms

Decentralized: Least-cost path is calculated in an

iterative, distributed manner router only knows physically-

connected neighbours, link costs to neighbours Involves an iterative process of

calculation & exchange of distance vector information with neighbours

Distance Vector (DV) algorithms

Static or dynamic?Static or dynamic?Static: routes change slowly over

time

Dynamic: routes change more quickly

periodic update in response to topology

or link cost changes

Page 6: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 6

Distance Vector Routing AlgorithmDistance Vector Routing Algorithm

iterative:iterative: continues until no nodes exchange

information anymore self-terminating: no signal to stop

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

lock step!

distributed:distributed: each node communicates only with

directly-attached neighbours

Page 7: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 7

Distance Vector Algorithm Distance Vector Algorithm

Bellman-Ford Equation (dynamic programming)Bellman-Ford Equation (dynamic programming)

Define

dx(y) := cost of least-cost path from x to y

Then

dx(y) = min {c(x,v) + dv(y) }

where min is taken over all neighbors v of x

v

Page 8: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 8

Bellman-Ford example Bellman-Ford example

u

yx

wv

z2

2

13

1

1

2

53

5 By inspection from the graph,we can see that:

dv(z) = 5, dx(z) = 3, dw(z) = 3

du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z), c(u,w) + dw(z) } = min {2 + 5, 1 + 3, 5 + 3} = 4

The node that arrives with the minimum cost = the nextnexthophop neighbour along the shortest path ➜ forwarding table

B-F equation says:

The least cost path from node u to z is one of the paths that passes through node u’s neighbors

Page 9: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 9

Distance Vector Routing AlgorithmDistance Vector Routing Algorithm

Distance Table data structure row for each possible destination column for each directly-attached

neighbor

Calculation of values example: Node X, routing for

destination Y via directly attached neighbor Z:

D (Y,Z)X

distance from X toY, via Z as next hop

c(X,Z) + min {D (Y,w)}Z

w

=

=

D ()

A

B

C

D

A

1

7

6

4

B

14

8

9

11

D

5

5

4

2

Ecost to destination via

dest

inat

ion

Directly attached neighbors of E

A

E D

CB7

8

1

2

1

2Currently known minimum-cost path from Z to Y

Page 10: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 10

DISTANCE TABLE: Example

A

E D

CB7

8

1

2

1

2

D ()

A

B

C

D

A

1

7

6

4

B

14

8

9

11

D

5

5

4

2

Ecost to destination via

dest

inat

ion

D (C,D)E

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

w== 2+2 = 4

D (A,D)E

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

w== 2+3 = 5

D (A,B)E

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

w== 8+6 = 14

loop!

loop!

ENTRIES IN THE DATA TABLE for NODE E (after DV converges)

Node E to C via D

Node E to A via D

Node E to A via B

Direct link Any possible path from D to C

Page 11: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 11

Distance table gives routing table

D ()

A

B

C

D

A

1

7

6

4

B

14

8

9

11

D

5

5

4

2

Ecost to destination via

dest

inat

ion

A

B

C

D

A,1

D,5

D,4

D,2

Outgoing link to use, cost

dest

inat

ion

Distance tableDistance table Routing tableRouting table

DDEE()()

A

E D

CB78

12

1

2

Page 12: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 12

Distance Vector Routing: Distance Vector Routing: (more details)

Iterative, Iterative, asynchronous:asynchronous:

Each local iteration (Distance Table update) caused by:

Change of cost of an attached link

Receipt of message update from neighbour

Distributed:Distributed: each node notifies

neighbours only when its least-cost pathleast-cost path to any destination changes

Iterative, Iterative, asynchronous:asynchronous:

Each local iteration (Distance Table update) caused by:

Change of cost of an attached link

Receipt of message update from neighbour

Distributed:Distributed: each node notifies

neighbours only when its least-cost pathleast-cost path to any destination changes

wait for (change in local link cost or msg from neighbor)

recompute distance table

if a least-costleast-cost path to any destination has changed,

notify neighbors

Each node:Each node:

BELLMAN-FORD ALGORITHM – Internet RIP, BGP, IDRP, Novell IPX, ARPANet

Page 13: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 13

Distance Vector Algorithm:Distance Vector Algorithm:Distance Vector Algorithm:Distance Vector Algorithm:

1 Initialization:

2 for all adjacent nodes v:

3 D (*,v) =infinite ( 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 each node, X: X Z12

7

Y

Initially, set all link costs to all destination nodes to infinite (∞)

Send a table of vectors to each neighbor of X

Page 14: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 14

Distance Vector Algorithm (cont.):8 loop 9 wait (until I see a link cost change to neighbor V 10 or until I receive an update from neighbor V) 11 //link cost change//link cost change12 if (c(X,V) changes by c(X,V) changes by dd) 13 /* change cost to all dest's via neighbor v by dd */ 14 /* note: dd could be positive or negative */ 15 for all destinations y: D (y,V) = D (y,V) + dd 16 //receipt of routing table from neighbor V//receipt of routing table from neighbor V17 else if (update received from V wrt destination Yupdate received from V wrt destination Y) 18 /* shortest path from V to some Y has changed */ 19 /* V has sent a new value new value for its min Dmin DVV(Y,w) (Y,w) */ 20 /* call this received new value as newval */ 21 for the single destination y: D (Y,V) = c(X,V) + newval newval 22 //new least-cost to any destination Y found //new least-cost to any destination Y found 23 if we have a new min D (Y,w) for any destination Ywe 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

XX

XX

X

w

w

Change in link cost; therefore, update Entire column in distance table

Received one update from neighbor v; therefore,Calculate new link cost in distancetable

Page 15: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 15

Distance Vector Algorithm: example

X Z12

7

Y

D (Y,Z)X

c(X,Z) + min {D (Y,w)}w=

= 7+1 = 8

Z

D (Z,Y)X

c(X,Y) + min {D (Z,w)}w=

= 2+1 = 3

Y

Let’s examine one sample computation here

Page 16: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 16

Distance Vector Algorithm: example

X Z12

7

Y

Examine which table finds a new

minimum cost value after an

update

Page 17: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 17

Distance Vector: link cost changes

Link cost changes: node detects local link cost

change updates distance table (line 15) if cost change in least cost path,

notify neighbours (lines 23,24)

X Z14

50

Y1

algorithmterminates“good

news travelsfast”

Note: The illustrations limits the exchange of packets between nodes Y and Z only.

Page 18: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 18

Distance Vector: link cost changes

Link cost changes: good news travels fast bad news travels slow -

'count to infinity' problem!

X Z14

50

Y60

algorithmcontinues

on!

Routing loop bet. Y & Z – will persist after 4444

iterations

Page 19: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 19

Distance Vector: link cost changes

X Z14

50

Y60

algorithmcontinues

on!

Link-cost change: the new link-cost to X changes from 4 to 60.

ROUTING LOOP! Node Y doesn’t know that Z would pass through Y itself to get to X (at this point in time, Z is still using the old least-cost path (from Node Y to X is equal to 4)

Routing Table for Node Y

Routing Table for Node Z

Sometime after t0: Node Y calculates the new least-cost path, and finds that passing through Z is more cost

effective to reach Node X

At time t1: Node Y broadcasts the new least-cost path to Z (neighbor)

Sometime after t1: Node Z receives the new least-cost to Node X from Y, then computes

a new least-cost to X

Node Z computes the new least-cost to X, then updates its Routing Table

t2: Node Z informs y of its new least-cost to X, since it has changed (increased)

And so on, and so forth…

Page 20: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 20

Distance Vector: poisoned reverse

If Z routes through Y to get to X : Z tells Y its (Z's) distance to X is

infinite (so Y won’t route to X via Z) will this completely solve count to

infinity problem? X Z14

50

Y60

algorithmterminates

It does not. Loops with nodes >= 3 will not be detected!

Page 21: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

Routing 21

Poisone Reverse AlgorithmExampleHow to apply the Poisoned Reverse Algorithm?

A B C D

A 4 ∞∞ ∞∞ ∞∞

B ∞∞ 1 ∞∞ ∞∞

C ∞∞ 8 3 ∞∞

D ∞∞ ∞∞ 6 7

Eventually, the value 8 would become ∞∞because it is not a direct link, and it is not

the least-cost path for destination C

If the link is NOT a direct link and if the link-cost is NOT equal to the minimum

cost for a given destination node, then set the link-cost = ∞ ∞ (infinite)

via

des

tin

atio

n

∞∞

Inspect each row,

Page 22: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

22

Link-State Routing AlgorithmLink-State Routing Algorithm

Dijkstra’s algorithm• net topology, link costs known

to all nodes– accomplished via “link state

broadcast” – all nodes have the same info

• computes least cost paths from one node (‘source”) to all other nodes– gives forwarding table for

that node• iterative: after k iterations,

know least cost path to k dest.’s

Notation:• c(x,y): link cost from

node x to y; set equal to ∞ if not direct neighbors

• D(v): current value of cost of path from source to dest. v

• p(v): predecessor node along path from source to v

• N': set of nodes whose least cost path definitively known

Page 23: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

23

Dijsktra’s Algorithm

1 Initialization: 2 N' = {u} 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) 6 else D(v) = ∞ 7 8 Loop 9 find w not in N' such that D(w) is a minimum 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'

Page 24: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

24

Dijkstra’s algorithm: exampleStep

012345

N'u

uxuxy

uxyvuxyvw

uxyvwz

D(v),p(v)2,u2,u2,u

D(w),p(w)5,u4,x3,y3,y

D(x),p(x)1,u

D(y),p(y)∞

2,x

D(z),p(z)∞ ∞

4,y4,y4,y

u

yx

wv

z2

2

13

1

1

2

53

58 Loop 9 find w not in N' such that D(w) is a minimum 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'

1 Initialization: 2 N' = {u} 3 for all nodes v 4 if v adjacent to u 5 then D(v) = c(u,v) 6 else D(v) = ∞

Page 25: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

25

Dijkstra’s algorithm: example (2)

u

yx

wv

z

Resulting shortest-path tree from u:

vx

y

w

z

(u,v)(u,x)

(u,x)

(u,x)

(u,x)

destination link

Resulting forwarding table in u:Next hop router for node u

to take: (either v or x)

Page 26: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

26

Algorithm complexity: n nodes• each iteration: need to check all nodes, w, not in N• n(n+1)/2 comparisons: O(n2)• more efficient implementations possible: O(nlogn)

Oscillations possible:• e.g., link cost = amount of carried traffic

A

D

C

B1 1+e

e0

e

1 1

0 0

A

D

C

B2+e 0

001+e1

A

D

C

B0 2+e

1+e10 0

A

D

C

B2+e 0

e01+e1

initially… recompute

routing… recompute … recompute

destinationdestination

sourcesource

Dijkstra’s algorithm, discussionDijkstra’s algorithm, discussion

Page 27: Routing 1 Network Layer Network Layer goals:  understand principles behind network layer services:  routing (path selection)  how a router works  instantiation.

27

Dijkstra’s algorithm, discussionDijkstra’s algorithm, discussion

A

D

C

B1 1+e

e0

e

1 1

0 0

A

D

C

B2+e 0

001+e1

A

D

C

B0 2+e

1+e10 0

A

D

C

B2+e 0

e01+e1

initially… recompute

routing… recompute … recompute

destinationdestination

sourcesource

Solution:Solution: Oscillations can be prevented by not running the LS algorithm at the same time. Let routers use randomised sending times for sending the link advertisement.

Clock-wise routesCounter-clock-wise

routesClock-wise routes

Problem:Problem: Oscillations with congestion-sensitive routing Oscillations with congestion-sensitive routing