The network layer: routing

77
The network layer: routing CS168, Fall 2014 Sylvia Ratnasamy http://inst.eecs.berkeley.edu/ ~cs168/fa14/

description

The network layer: routing. CS168, Fall 2014 Sylvia Ratnasamy http://inst.eecs.berkeley.edu/~cs168/fa14/. Last Time. Forwarding: “data plane” Directing one data packet Each router using local routing state Routing: “control plane” Computing the forwarding tables that guide packets - PowerPoint PPT Presentation

Transcript of The network layer: routing

Page 1: The  network  layer: routing

The network layer: routing

CS168, Fall 2014Sylvia Ratnasamy

http://inst.eecs.berkeley.edu/~cs168/fa14/

Page 2: The  network  layer: routing

Last Time

‣ Forwarding: “data plane” - Directing one data packet- Each router using local routing state

‣ Routing: “control plane” - Computing the forwarding tables that guide packets- Jointly computed by routers using a distributed ptotocol

‣ Routing will be our focus for the next ~2 lectures!

Page 3: The  network  layer: routing

Last Time

‣ Two correctness conditions for routing state:- no deadends

- no loops

Page 4: The  network  layer: routing

Outline

‣ Least-cost path routing

‣ Approach 1: link-state routing

‣ Approach 2: distance-vector routing

‣ Routing in the Internet (next lecture)

Page 5: The  network  layer: routing

dest. next hopz ?

41 2

v

u z

v ?

link costs

could represent: propagation delay

dest. next hopu ?v ?

dest. next hopz ?u ?

Page 6: The  network  layer: routing

6

41 2

v

u z

least-cost path from u to z: u v z

least cost path from u to v: u v

vv v

v

dest. next hopzu u

zdest. next hop

zdest. next hop

uv v

Page 7: The  network  layer: routing

Least-cost path routing

‣ Given: router graph & link costs

‣ Goal: find least-cost path

from each source router to each destination router

7

Page 8: The  network  layer: routing

“Least Cost” Routes

‣ “Least cost” routes an easy way to avoid loops- No sensible cost metric is minimized by traversing a loop

‣ Least cost routes are also “destination-based”- i.e., do not depend on the source- Why is this?

‣ Least-cost paths form a spanning tree

Page 9: The  network  layer: routing

Outline

‣ Least-cost path routing

‣ Approach 1: link-state routing

‣ Approach 2: distance-vector routing

‣ Routing in the Internet

9

Page 10: The  network  layer: routing

10

u z

v

4

1 2

dest. next hopzv

cost

*

Page 11: The  network  layer: routing

11

u z

v

4

1 2

dest. next hopzv

zv

cost41

*

Page 12: The  network  layer: routing

12

u z

v

4

1 2

dest. next hopzv

zv

cost41

v 3

*

Page 13: The  network  layer: routing

13

v

2

1 3

u z

x

21

dest. next hopzv

cost

x

*

Page 14: The  network  layer: routing

14

v

2

1 3

u z

x

21

dest. next hopzv

cost

x

- -v 1x 2

*

Page 15: The  network  layer: routing

15

v

2

1 3

u z

x

21

dest. next hopzv

cost

x

- -v 1x 2

v 4

*

Page 16: The  network  layer: routing

16

v

2

1 3

u z

x

21

dest. next hopzv

cost

x

- -v 1x 2

v 4x 3

*

Page 17: The  network  layer: routing

17

2

1

3

z2

1

v

yx

3

5

1

2

u

w

5

dest. next hopzw

cost

yvx

*

Page 18: The  network  layer: routing

18

2

1

3

z2

1

v

yx

3

5

1

2

w

u

5

dest. next hopzw

cost

yvx

- -

v 2x 1

w 5- -

*

Page 19: The  network  layer: routing

19

2

1

z2

1

v

yx

3

5

1

2

u

w35

dest. next hopzw

cost

yvx

- -

v 2x 1

w 5- -

x 4x 2

*

Page 20: The  network  layer: routing

20

2

1

z2

1

v

yx

3

5

1

2

u

w35

dest. next hopzw

cost

yvx

- -

v 2x 1

w 5- -

x 4x 2

*

Page 21: The  network  layer: routing

21

2

1

3

z2

1

v

yx

3

5

1

2

u

w

5

dest. next hopzw

cost

yvx

- -

v 2x 1

w 5- -

x 4x 2

x 43

*

Page 22: The  network  layer: routing

22

2

1

3

z2

1

v

yx

3

5

1

2

u

w

5

dest. next hopzw

cost

yvx

- -

v 2x 1

w 5- -

x 4x 2

x3

4

*

Page 23: The  network  layer: routing

23

2

1

3

z2

1

v

yx

3

5

1

2

u

w

5

dest. next hopzw

cost

yvx

- -

v 2x 1

w 5- -

x 4x 2

x3

4

*

Page 24: The  network  layer: routing

Routing algorithm for source u

‣ Input: router graph & link costs

‣ Output: least-cost path

from source router u to every other router

24

Page 25: The  network  layer: routing

Dijkstra’s algorithm

‣ Source router considers every other router- starting from next “closest” neighbor

‣ Checks whether it can improve current paths- by using that router as an intermediate point

‣ Ends when all intermediaries have been considered

‣ See text / 61C notes for exact algorithm25

Page 26: The  network  layer: routing

From routing algorithm to protocol

‣ Note: Dijkstra’s is a local computation! - computed by one node given complete network graph

‣ Possibilities:- Option#1: a separate machine runs the algorithm - Option#2: every router runs the algorithm

‣ The Internet currently uses Option#2

26

Page 27: The  network  layer: routing

Link State Routing

‣ Every router knows its local “link state” - router u: “(u,v) with cost=2; (u,x) with cost=1”

‣ A router floods its link state to all other routers- does so periodically or when its link state changes

‣ Hence, every router learns the entire network graph- runs Dijkstra’s locally to compute its forwarding table

‣ OSPF is a link-state protocol (IETF RFC 2328 or 5340)- Berkeley runs OSPF internally!

Page 28: The  network  layer: routing

Link State Routing

‣ Are loops possible?

A and D think that thisis the path to C

E thinks that thisis the path to C

A

ED

CB

FA

ED

CB

F

13

1

15

5

55

5

Page 29: The  network  layer: routing

Convergence

‣ All routers have consistent routing information- E.g., all nodes having the same link-state database

‣ Forwarding is consistent after convergence- All nodes have the same link-state database

- All nodes forward packets on same paths

Page 30: The  network  layer: routing

Convergence Delay

‣ Time to achieve convergence

‣ Sources of convergence delay?- time to detect failure- time to flood link-state information- time to re-compute forwarding tables

‣ Performance during convergence period?- lost packets due to blackholes- looping packets- out-of-order packets reaching the destination

Page 31: The  network  layer: routing

Link State Routing

‣ Are loops possible?- yes, until convergence

‣ Scalability?- O(NE) messages - O(N2) computation time - O(network diameter) convergence time - O(N) entries in forwarding table

‣ Do we have to use Dijkstra’s?

Page 32: The  network  layer: routing

Outline

‣ Least-cost path routing

‣ Approach 1: link-state routing

‣ Approach 2: distance-vector routing

‣ Routing in the Internet

32

Page 33: The  network  layer: routing

Experiment

‣ Your job: find the youngest person in the room

‣ Ground Rules- You may not leave your seat, nor shout loudly across the class - You may talk with your immediate neighbors

(hint: “exchange updates” with them)

‣ At the end of 5 minutes, I will pick a victim and ask: - who is the youngest person in the room? (name , date)- which one of your neighbors first told you this information?

Page 34: The  network  layer: routing

Go!

Page 35: The  network  layer: routing

Example of Distributed Computation

I am one hop away

I am one hop away

I am one hop away

I am two hops away

I am two hops away

I am two hops away

I am two hops awayI am three hops away

I am three hops away

DestinationI am three hops away

Page 36: The  network  layer: routing

36

x z

y

7

2 1

x

xy

0-

y z

z

2 7- -

- - -from

to

2 0 1

x

xy

-

y z

z

- -

- - -

x

xy

--

y z

z

- -- -

7 1 0

This is y’s “distance vector”

Page 37: The  network  layer: routing

2 0 1

37

x z

y

7

2 1

x

xy

y z

z2 0 1

from

tox

xy

0

y z

z

2 7

x

xy

y z

z 7 1 07 1 02 0 1

720

720

7 1 0

Page 38: The  network  layer: routing

720

7 1 02 0 1

38

x z

y

7

2 1

xxy

y z

z

2 0 1from

tox

xy

0

y z

z

2 3

xxy

y z

z 7 1 07 1 02 0 1

720

Page 39: The  network  layer: routing

2 0 1

39

x z

y

7

2 1

xxy

y z

z

2 0 1from

tox

xy

0

y z

z

2 3

xxy

y z

z 3 1 07 1 0

720

7 1 0

2 0 1720

Page 40: The  network  layer: routing

2 0 1

40

x z

y

7

2 1

xxy

y z

z

2 0 1

3 1 0

from

tox

xy

0

y z

z

2 3

xxy

y z

z

3

3 1 03 1 0

320

202 0 1

Page 41: The  network  layer: routing

41

xxy

0-

y v

v

1 2- -

- - -from

to

y

2

1 3

z

v

1x

z

---

xxy

-1

y v

- -0 -

z - - -

z

-3-

xyv

--

y v

z

- -- -

- 3 1

z

--0

xx -

y v

v- -

2 - 0z - - -

z

-1-

Page 42: The  network  layer: routing

42

xxy

01

y v

v

1 20 -

2 - 0from

to

y

2

1 3

z

v

1x

z

-31

xyv

y v z

z - 3 1

0

xxy 1

y v

0 -z

z

3

xx

y v

v 2 - 0z

z

1

1 0 -2 - 0

31

0 1 2 -

- 3 1

0

- 3 1 0

0 1 2 -

Page 43: The  network  layer: routing

43

xxy

01

y v

v

1 20 -

2 - 0from

to

y

2

1 3

z

v

1x

z

331

xyv

y v z

z - 3 1 0

xxy 1

y v

0 -z

z

3

xx

y v

v 2 - 0z

z

1

1 0 -2 - 0

310

0 1 2 -

- 3 1

- 3 1 0

0 1 2 -

Page 44: The  network  layer: routing

44

xxy

01

y v

v

1 20 -

2 - 0from

to

y

2

1 3

z

v

1x

z

331

xyv

1

y v

z

0 -2 - 0

z

31

3 3 1 0

xxy 1

y v

0 -z

z

3

xx

y v

v 2 - 0z

z

1

0

0 1 2 -

- 3 1

- 3 1 0

0 1 2 -

Page 45: The  network  layer: routing

45

xxy

01

y v

v

1 20 -

2 - 0from

to

y

2

1 3

z

v

1x

z

331

xyv

1

y v

z

0 -2 - 0

z

31

3 3 1 0

xxy 1

y v

0 3z

z

3

xx

y v

v 2 - 0z

z

1

0

0 1 2 -

- 3 1

- 3 1 0

0 1 2 -

Page 46: The  network  layer: routing

46

xxy

01

y v

v

1 20 -

2 - 0from

to

y

2

1 3

z

v

1x

z

331

xyv

1

y v

z

0 -2 - 0

z

31

3 3 1 0

xxy 1

y v

0 3z

z

3

xx

y v

v 2 3 0z

z

1

0

0 1 2 -

- 3 1

- 3 1 0

0 1 2 -

Page 47: The  network  layer: routing

47

xxy

01

y v

v

1 20 3

2 3 0from

to

y

2

1 3

z

v

1x

z

331

xyv

1

y v

z

0 32 3 0

z

31

3 3 1 0

xxy 1

y v

0 3z

z

3

xx

y v

v 2 3 0z

z

1

0

0 1 2 3

3 3 1

3 3 1 0

0 1 2 3

Page 48: The  network  layer: routing

Distance-vector routing

‣ Input to each router: local link costs & neighbor

messages

‣ Output of each router: least-cost path to every other

router

48

Page 49: The  network  layer: routing

‣ Distributed algorithm‣ All routers run it “together”

- each router runs its own instance- neighbors exchange and react to each

other’s messages

49

Distance-vector routing

Page 50: The  network  layer: routing

Bellman-Ford algorithm

‣ All neighbors exchange information- Each router checks whether it can improve current

paths by leveraging the new information‣ Ends when no improvement is possible

50

Page 51: The  network  layer: routing

51

x z

y

7

2 1

2 0 1from

tox

xy

0

y z

z

2 7

7 1 0

dx(z) = cost(x,z),

cost(x,y) + dy(z)

min{

}

Page 52: The  network  layer: routing

52

y

7

2

dx(z) = cost(x,y) + dy(z),

cost(x,u) + du(z),

min{

}

w

x u

1

z

cost(x,w) + dw(z)

Page 53: The  network  layer: routing

53

y

7

2

cost(x,n) + dn(z)minn{ }

w

x u

1

z

for all neighbors n

dx(z) =

Bellman-Ford equation

Page 54: The  network  layer: routing

Bellman-Ford equation

‣ Formalizes the following decision:

- pick as the next hop for destination z the neighbor that results in the least-cost path to z.

Page 55: The  network  layer: routing

x z

y

7

2 1

2 0 1

x

y

y z

z 3 1 0

x

y

y z

z 3 1 02 0 1

Page 56: The  network  layer: routing

0 1

56

x z

y

7

1

x

y

y z

z 3 1 0

x

y

y z

z 3 1 02 0 1

4routing loop!

Page 57: The  network  layer: routing

0 1

57

x z

y

7

1

x

y

y z

z 3 1 0

x

y

y z

z 3 1 04 0 1

4routing loop!

Page 58: The  network  layer: routing

0 1

58

x z

y

7

1

x

y

y z

z 3 1 0

x

y

y z

z 5 1 04 0 1

4routing loop!

Page 59: The  network  layer: routing

0 1

59

x z

y

7

1

x

y

y z

z 5 1 0

x

y

y z

z 5 1 04 0 1

4routing loop!

Page 60: The  network  layer: routing

0 1

60

x z

y

7

1

x

y

y z

z 5 1 0

x

y

y z

z 5 1 04 0 1

6routing loop!

Page 61: The  network  layer: routing

0 1

61

x z

y

7

1

x

y

y z

z 5 1 0

x

y

y z

z 5 1 06 0 1

6routing loop!

Page 62: The  network  layer: routing

0 1

62

x z

y

7

1

x

y

y z

z 5 1 0

x

y

y z

z 7 1 06 0 1

6routing loop!

Page 63: The  network  layer: routing

0 1

63

x z

y

7

1

x

y

y z

z 7 1 0

x

y

y z

z 7 1 06 0 1

6routing loop!

Page 64: The  network  layer: routing

0 1

64

x z

y

7

1

x

y

y z

z 7 1 0

x

y

y z

z 7 1 06 0 1

8routing loop!

Page 65: The  network  layer: routing

0 1

65

x z

y

7

1

x

y

y z

z 7 1 0

x

y

y z

z 7 1 08 0 1

8routing loop!

Page 66: The  network  layer: routing

0 1

66

x z

y

7

1

x

y

y z

z 7 1 0

x

y

y z

z 7 1 08 0 1

8routing loop!

count-to-infinity scenario

Page 67: The  network  layer: routing

Problems with Bellman-Ford

‣ Routing loops- z routes through y, y routes through x

- y loses connectivity to x

- y decides to route through z

‣ Can take a very long time to resolve- Count-to-infinity scenario

Page 68: The  network  layer: routing

68

x z

y

7

2 1

2 0 1

x

y

y z

z ∞ 1 0

x

y

y z

z 3 1 02 0 1

poisoned reverse

Page 69: The  network  layer: routing

69

x z

y

7

1

0 1

x

y

y z

z 1 0

x

y

y z

z 3 1 02 0 1

∞poisoned reverse∞

Page 70: The  network  layer: routing

70

x z

y

7

1

0 1

x

y

y z

z 1 0

x

y

y z

z 3 1 00 1

∞poisoned reverse∞

Page 71: The  network  layer: routing

71

x z

y

7

1

0 1

x

y

y z

z 1 0

x

y

y z

z 7 1 00 1

∞poisoned reverse∞

Page 72: The  network  layer: routing

72

x z

y

7

1

0 1

x

y

y z

z 1 0

x

y

y z

z 7 1 00 1

poisoned reverse∞

7

Page 73: The  network  layer: routing

73

x z

y

7

1

0 1

x

y

y z

z 1 0

x

y

y z

z 7 1 00 1poisoned reverse ∞

78

Page 74: The  network  layer: routing

Solution

‣ Poisoned reverse- If z routes to x through y,

z advertises to y that its cost to x is infinite

- y never decides to route to x through z

‣ Often avoids the count-to-infinity problem

Page 75: The  network  layer: routing

Distance Vector Routing

‣ Are loops possible?- yes, until convergence - convergence slower than in Link-State

‣ Scalability?- requires fewer messages than Link-State- O(N) update time on arrival of a new DV from neighbor- O(network diameter) convergence time - O(N) entries in forwarding table

‣ RIP is a protocol that implements DV (IETF RFC 2080)

Page 76: The  network  layer: routing

Does Poison-Reverse Completely Solve the Count-to-Infinity Problem?

A C1

B

D

1

1 11 1

2 2

∞ ∞

100

100 100

3∞

4

∞ 4

56

Page 77: The  network  layer: routing

Outline

‣ Least-cost path routing

‣ Approach 1: link-state routing

‣ Approach 2: distance-vector routing

‣ Routing in the Internet (next time)