The Fundamentals of Routing - EECS Instructional...

130
1 The Fundamentals of Routing EE122 Fall 2011 Scott Shenker http://inst.eecs.berkeley.edu/~ee122/ Materials with thanks to Jennifer Rexford, Ion Stoica, Vern Paxson and other colleagues at Princeton and UC Berkeley

Transcript of The Fundamentals of Routing - EECS Instructional...

Page 1: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

1

The Fundamentals of Routing

EE122 Fall 2011

Scott Shenker

http://inst.eecs.berkeley.edu/~ee122/

Materials with thanks to Jennifer Rexford, Ion Stoica, Vern Paxsonand other colleagues at Princeton and UC Berkeley

Page 2: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Announcements

• 194 is set up: 4 units: CCN: 25571– Everyone should be off wait list by now….

– Waiting for more accountso Send me email if you need one….

– Will set up bspace for 194 to hand in homework

• Open today with questions about project 1

• Hope you all handed in HW1– HW2 out on Wednesday

• Survey will be available after Wednesday’s class 2

Page 3: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Questions about Project 1 (for Shaddi)

3

Page 4: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Warning….

• This lecture contains detailed calculations

• Prolonged exposure may induce drowsiness

• Do not operate heavy machinery while listening

4

Page 5: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Where Are We?

• Motivated our basic design decisions– Best-effort, packet-switching, blah, blah, blah

• Last lecture: how to build reliable transport on top

• This lecture: how to build the network itself

• Basic Task: deliver packets– Need to route them, from anywhere to anywhere

• Today, we focus on routing 5

Page 6: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

The Traditional Routing Curriculum

• Learning switches

• Link-state routing– Dijkstra’s Algorithm

• Distance-vector routing– Bellman-Ford

6

Page 7: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

I have some bad news…..

• Don’t have anything interesting to say about routing

• Will follow standard curriculum– Much of it covered in the text

• But will focus more on principles than details

• Will work through two algorithms, but details may

wait until Wednesday…..134 slides!– Let’s just see how timing goes

– If you don’t want to be bored, ask questions!7

Page 8: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Remember….

• Goal of the first portion of course is conceptual

• Ignore real networks

• Think about the basic concepts

• That’s where we are. Later will deal with reality…

8

Page 9: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

9

Basics of Routing and Forwarding

Page 10: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Addressing (at a conceptual level)

• Assume all hosts have unique IDs

• No particular structure to those IDs

• Later in course will talk about real IP addressing

10

Page 11: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Packets (at a conceptual level)

• Assume packet headers contain:– Source ID, Destination ID, and perhaps other information

11

Destination

Identifier

Source

Identifier

Payload

Why include

this?

Page 12: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Switches/Routers

• Multiple ports (attached to other switches or hosts)

• Ports are typically duplex (incoming and outgoing)

12

incoming links outgoing linksSwitch

Page 13: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example of Network Graph

13

Six ports, incoming/outgoing

Four ports, incoming/outgoing

Page 14: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

A Variety of Networks

• ISPs: carriers– Backbone

– Edge

– Border (to other ISPs)

• Enterprises: companies, universities– Core

– Edge

– Border (to outside)

• Datacenters: massive collections of machines– Top-of-Rack

– Aggregation and Core

– Border (to outside) 14

Page 15: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

UUNET’s North American Network

15

Page 16: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Level3’s American Network

16

Page 17: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Enterprise Network

17

Page 18: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Partial Datacenter Network

18

Page 19: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Switches

• Enterprise/Edge: typically 24 to 48 ports

• Aggregation switches: 192 ports or more

• Backbone: typically fewer ports

• Border: typically very few ports

19

Page 20: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Forwarding Decisions

• When packet arrives, must choose outgoing port

• Decision is based on routing state (table) in switch

20

incoming links outgoing linksSwitch

Consider packet header

and routing table

Page 21: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Forwarding Decisions

• When packet arrives..– Must decide which outgoing port to use

– In single transmission time

– Forwarding decisions must be simple

• Routing state dictates where to forward packets– Assume decisions are deterministic

• Global routing state means collection of routing

state in each of the routers– Will focus on where this routing state comes from

– But first, a few preliminaries…. 21

Page 22: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Forwarding vs Routing

• Forwarding: “data plane”– Directing a data packet to an outgoing link

– Individual router using routing state

• Routing: “control plane”– Computing paths the packets will follow

– Routers talking amongst themselves

– Jointly creating the routing state

• Two very different timescales….

22

Page 23: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

23

Validity of Routing State

Page 24: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

“Valid” Routing State

• Global routing state is “valid” if it produces

forwarding decisions that always deliver packets to

their destinations– Valid is my terminology, not standard

• Goal of routing protocols: compute valid state– But how can you tell if routing state if valid?

24

Page 25: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Necessary and Sufficient Condition

• Global routing state is valid if and only if:– There are no dead ends (other than destination)

– There are no loops

• A dead end is when there is no outgoing port– A packet arrives, but the forwarding decision does not

yield any outgoing port

• A loop is when a packet cycles around the same

set of nodes forever

25

Page 26: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Necessary: Obvious

• If you run into a deadend before hitting destination,

you’ll never reach the destination

• If you run into a loop, you’ll never reach destination– With deterministic forwarding, once you loop, you’ll loop

forever (assuming routing state is static)

26

Page 27: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Wandering Packets

27

Packet reaches deadend and stopsPacket falls into loop and never reaches destination

Page 28: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Sufficient: Easy

• Assume no deadends, no loops

• Packet must keep wandering, without repeating– If ever enter same switch from same port, will loop

– Because forwarding decisions are deterministic

• Only a finite number of possible ports for it to visit– It cannot keep wandering forever without looping

– Must eventually hit destination

28

Page 29: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

The “Secret” of Routing

• Avoiding deadends is easy

• Avoiding loops is hard

• The key difference between routing protocols is

how they avoid loops!– Don’t focus on details of mechanisms

– Just ask “how are loops avoided?”

• Will return to this later….

29

Page 30: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Making Forwarding Decisions

• Map PacketState+RoutingState into OutgoingPort– At line rates…..

• Packet State:– Destination ID

– Source ID

– Incoming Port (from switch, not packet)

– Other packet header information?

• Routing State:– Stored in router

30

Page 31: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Forwarding Decision Dependencies

• Must depend on destination

• Could also depend on :– Source: requires n2 state

– Input port: not clear what this buys you

– Other header information: let’s ignore for now

• We will focus only on destination-based routing– But first consider the alternative

31

Page 32: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Source/Destination-Based Routing

32

Paths from two different sources (to

same destination) can be very different

Page 33: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Destination-Based Routing

33

Paths from two different sources (to same

destination) must coincide once they overlap

Page 34: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Destination-Based Routing

• Paths to same destination never cross

• Once paths to destination meet, they never split

• Set of paths to destination create a “delivery tree”– Must cover every node exactly once

– Spanning Tree rooted at destination

34

Page 35: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

A “Delivery Tree” for a Destination

35

Page 36: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Checking Validity of Routing State

• Focus only on a single destination– Ignore all other routing state

• Mark outgoing port with arrow– There can only be one at each node

• Eliminate all links with no arrows

• Look at what’s left….

36

Page 37: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example 1

37

Page 38: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Pick Destination

38

Page 39: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Put Arrows on Outgoing Ports

39

Page 40: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Remove Unused Links

40

Leaves Spanning Tree: Valid

Page 41: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Second Example

41

Page 42: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Second Example

42

Is this valid?

Page 43: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Lesson….

• Very easy to check validity of routing state for a

particular destination

• Deadends are obvious– Node without outgoing arrow

• Loops are obvious– Disconnected from rest of graph

43

Page 44: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

44

Computing Routing State

Page 45: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Forms of Route Computation

• Learn from observing….– Not covered in your reading

• Centralized computation– One node has the entire network map

• Pseudo-centralized computation– All nodes have the entire network map

• Distributed computation– No one has the entire network map

45

Page 46: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

How Can You Avoid Loops?

• Restrict topology to spanning tree– If the topology has no loops, packets can’t loop!

• Central computation– Can make sure no loops

• Minimizing metric in distributed computation– Loops are never the solution to a minimization problem

46

Page 47: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

47

Self-Learning on Spanning Tree

Page 48: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Easiest Way to Avoid Loops

• Use a topology where loops are impossible!

• Take arbitrary topology

• Build spanning tree (algorithm covered later)– Ignore all other links (as before)

• Only one path to destinations on spanning trees

• Use “learning switches” to discover these paths– No need to compute routes, just observe them 48

Page 49: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Consider previous graph

49

Page 50: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

A Spanning Tree

50

Page 51: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Another Spanning Tree

51

Page 52: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Yet Another Spanning Tree

52

Page 53: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Flooding on a Spanning Tree

• If you want to send a packet that will reach all

nodes, then switches can use the following rule:– Ignoring all ports not on spanning tree!

• Originating switch sends “flood” packet out all

ports

• When a “flood” packet arrives on one incoming

port, send it out all other ports

53

Page 54: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Flooding on Spanning Tree

54

Page 55: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Flooding on Spanning Tree (Again)

55

Page 56: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Flooding on a Spanning Tree

• This works because the lack of loops prevents the

flooding from cycling back on itself

• Eventually all nodes will be covered, exactly once

56

Page 57: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

This Enables Learning!

• There is only one path from source to destination

• Each switch can learn how to reach a another

node by remembering where its flooding packets

came from!

• If flood packet from Node A entered switch from

port 4, then to reach Node A, switch sends packets

out port 4

57

Page 58: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Learning from Flood Packets

58

Node A

Node A can be reachedthrough this port

Node A can be reachedthrough this port

Once a node has sent a flood message, all other switches know how to reach it….

Page 59: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

General Approach

• Flood first packet

• All switches learn where you are

• When destination responds, all switches learn

where it is…

• Done.

59

Page 60: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

60

Self-Learning Switch

When a packet arrives

• Inspect source ID, associate with incoming port

• Store mapping in the switch table

• Use time-to-live field to eventually forget mapping

A

B

C

D

Packet tells switch how to reach A.

Page 61: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

61

Self Learning: Handling Misses

When packet arrives with unfamiliar destination

• Forward packet out all other ports

• Response will teach switch about that destination

A

B

C

D

When in doubt, shout!

Page 62: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

62

General Rule

When switch receives a packet:

index the switch table using destination ID

if entry found for destination {

if dest on port from which packet arrivedthen drop packet

else forward packet on port indicated

}

else flood

forward on all but the interface

on which the frame arrived

Why do this?

Page 63: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Summary of Learning Approach

• Avoids loop by restricting to spanning tree

• This makes flooding possible

• Flooding allows packet to reach destination

• And in the process switches learn how to reach

source of flood

• No route “computation”

63

Page 64: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Weaknesses of This Approach?

• Requires loop-free topology (Spanning Tree)

• Slow to react to failures (entries time out)

• Very little control over paths

• Spanning Trees suck.

64

Page 65: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

On to other routing techniques…

65

Page 66: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

66

A Little Test

How many of you did the reading?

Page 67: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

The Task

• Remove sheet of paper from beanbag, but do not

look at sheet of paper until I say so

• You will have five minutes to complete this task

• Each sheet says:

You are node X You are connected to nodes Y,Z

• Your job: find route from source (node 1) to

destination (node 40) in five minutes67

Page 68: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Ground Rules

• You may not:– Leave your seat (but you can stand)

– Pass your sheet of paper

– Let anyone copy your sheet of paper

• You may:– Ask nearby friends for advice

– Shout to other participants (anything you want)

– Curse your instructor (sotto voce)

• You must: Try

68

Page 69: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Go!

69

Page 70: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

1 16 36 7 25

10 19 5 34 38

29 33 15 39 23

14 9 2 35 11

22 32 26 21 37

3 28 12 30 4

27 20 31 18 24

40 8 17 6 13

Page 71: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

71

5 Minute Break

Questions Before We Proceed?

Page 72: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

How Can You Avoid Loops?

• Restrict topology to spanning tree

• Central computation (can make sure no loops)

• Minimizing metric in distributed computation

• Any other techniques?

72

Page 73: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Organization for Rest of Lecture

• Link-state routing

• Distance-vector routing

• Goal of today: basic idea– May review details on Wednesday

– Definitely go over details in section

73

Page 74: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

74

Link-State

Details in Section

Page 75: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Another Approach to Loop-Avoidance

• If one has a picture of the entire network, can

compute routing state that does not produce loops

• This route computation can be done in many ways– Here we will review Dijkstra’s algorithm briefly

– But that’s just because it is expected from such courseso Snore…..

• The real question is, how do you get picture of

entire network?

75

Page 76: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

76

Link-State Routing Is Conceptually Simple

• Each router keeps track of its incident links

• Each router broadcasts the link state– To give every router a complete view of the graph

• Each router runs Dijkstra’s algorithm– Compute shortest paths, then construct forwarding table

• Example protocols– Open Shortest Path First (OSPF)

– Intermediate System – Intermediate System (IS-IS)

• Challenges: scaling, transient disruptions

Page 77: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

77

Link State Routing

• Each node floods its local information

• Each node then knows entire network topology

Host A

Host BHost E

Host D

Host C

N1N2

N3

N4

N5

N7N6

Page 78: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

78

Link State: Each Node Has Global View

Host A

Host BHost E

Host D

Host C

N1N2

N3

N4

N5

N7N6

A

BE

D

C

A

BE

D

CA

BE

D

C

A

BE

D

C

A

BE

D

C

A

BE

D

C

A

BE

D

C

Page 79: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

How to Compute Routes

• Each node should have same global view

• They each compute their own routing tables

• Using exactly the same algorithm

• Can use any algorithm that avoids loops

• Computing shortest paths is one such algorithm– Associate a “cost” with each link

– Don’t worry what it stands for….

79

Page 80: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Dijkstra’’’’s Shortest Path Algorithm

• INPUT:– Network topology (graph), with link costs

• OUTPUT:– Least cost paths from one node to all other nodes

– Produces “tree” of routeso Different from what we talked about before

o Previous tree was rooted at destination

o This is rooted at source

o But shortest paths are reversible!

80

Page 81: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

“Least Cost” Routes

• No sensible cost metric will be minimized by

traversing a loop

• “Least cost” routes an easy way to avoid loops

• Least cost routes are also “destination-based”– i.e., do not depend on the source

– Why is this?

• Therefore, least-cost paths form a spanning tree

81

Page 82: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

82

Example

A

ED

CB

F

2

2

13

1

1

2

5

3

5

Page 83: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

83

Notation

• c(i,j): link cost from node ito j; cost infinite if not direct neighbors; ≥ 0

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

• p(v): predecessor node along path from source to v, that is next to v

• S: set of nodes whose least cost path definitively known

A

ED

CB

F

2

2

13

1

1

2

5

3

5

Source

Page 84: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

84

Dijsktra’’’’s Algorithm

1 Initialization:2 S = {A};3 for all nodes v4 if v adjacent to A5 then D(v) = c(A,v); 6 else D(v) = ;7 8 Loop9 find w not in S such that D(w) is a minimum; 10 add w to S; 11 update D(v) for all v adjacent to w and not in S: 12 if D(w) + c(w,v) < D(v) then

// w gives us a shorter path to v than we’ve found so far

13 D(v) = D(w) + c(w,v); p(v) = w;14 until all nodes in S;

• c(i,j): link cost from node i to j

• D(v): current cost source → v

• p(v): predecessor node along path from source to v, that is next to v

• S: set of nodes whose least cost path definitively known

Page 85: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

85

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

D(B),p(B)2,A

D(C),p(C)5,A

D(D),p(D)1,A

D(E),p(E) D(F),p(F)

A

ED

CB

F

2

2

13

1

1

2

53

5

∞ ∞

1 Initialization:2 S = {A};3 for all nodes v4 if v adjacent to A5 then D(v) = c(A,v); 6 else D(v) = ;…

Page 86: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

86

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

D(B),p(B)2,A

D(C),p(C)5,A

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

A

ED

CB

F

2

2

13

1

1

2

53

5

D(D),p(D)1,A

D(E),p(E) D(F),p(F)∞ ∞

Page 87: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

87

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

AD

D(B),p(B)2,A

D(C),p(C)5,A

D(D),p(D)1,A

D(E),p(E) D(F),p(F)

A

ED

CB

F

2

2

13

1

1

2

53

5

∞ ∞

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

Page 88: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

88

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

AD

D(B),p(B)2,A

D(C),p(C)5,A4,D

D(D),p(D)1,A

D(E),p(E)

2,D

D(F),p(F)

A

ED

CB

F

2

2

13

1

1

2

53

5

∞ ∞

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

Page 89: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

89

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

ADADE

D(B),p(B)2,A

D(C),p(C)5,A4,D3,E

D(D),p(D)1,A

D(E),p(E)

2,D

D(F),p(F)

4,E

∞ ∞

A

ED

CB

F

2

2

13

1

1

2

53

5…

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

Page 90: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

90

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

ADADE

ADEB

D(B),p(B)2,A

D(C),p(C)5,A4,D3,E

D(D),p(D)1,A

D(E),p(E)

2,D

D(F),p(F)

4,E

∞ ∞

A

ED

CB

F

2

2

13

1

1

2

53

5…

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

Page 91: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

91

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

ADADE

ADEBADEBC

D(B),p(B)2,A

D(C),p(C)5,A4,D3,E

D(D),p(D)1,A

D(E),p(E)

2,D

D(F),p(F)

4,E

∞ ∞

A

ED

CB

F

2

2

13

1

1

2

53

5…

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

Page 92: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

92

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

ADADE

ADEBADEBC

ADEBCF

D(B),p(B)2,A

D(C),p(C)5,A4,D3,E

D(D),p(D)1,A

D(E),p(E)

2,D

D(F),p(F)

4,E

∞ ∞

A

ED

CB

F

2

2

13

1

1

2

53

5…

8 Loop

9 find w not in S s.t. D(w) is a minimum;

10 add w to S;

11 update D(v) for all v adjacent

to w and not in S:

12 If D(w) + c(w,v) < D(v) then

13 D(v) = D(w) + c(w,v); p(v) = w;

14 until all nodes in S;

Page 93: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

93

Example: Dijkstra’’’’s Algorithm

Step012345

start SA

ADADE

ADEBADEBC

ADEBCF

D(B),p(B)2,A

D(C),p(C)5,A4,D3,E

D(D),p(D)1,A

D(E),p(E)

2,D

D(F),p(F)

4,E

∞ ∞

A

ED

CB

F

2

2

13

1

1

2

53

5

To determine path A → C (say),

work backward from C via p(v)

Page 94: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

94

• Running Dijkstra at node A gives the shortest path from A to all destinations

• We then construct the forwarding table

The Forwarding Table

A

ED

CB

F

2

2

13

1

1

2

53

5Destination Link

B (A,B)

C (A,D)

D (A,D)

E (A,D)

F (A,D)

Page 95: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Complexity

• How much processing does running the Dijkstra

algorithm take?

• Assume a network consisting of N nodes– Each iteration: check all nodes w not in S

– N(N+1)/2 comparisons: O(N2)

– More efficient implementations: O(N log(N))

95

Page 96: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

96

Flooding the Topology Information

• Each router sends information out its ports

• The next node sends it out through all of its ports– Except the one where the information arrived

– Need to remember previous msgs, suppress duplicates!

X A

C B D

(a)

X A

C B D

(b)

X A

C B D

(c)

X A

C B D

(d)

Page 97: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Making Flooding Reliable

• Reliable flooding– Ensure all nodes receive link-state information

– Ensure all nodes use the latest version

• Challenges– Packet loss

– Out-of-order arrival

• Solutions– Acknowledgments and retransmissions

– Sequence numbers

• How can it still fail?

97

Page 98: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

When to Initiate Flood?

• Topology change– Link or node failure

– Link or node recovery

• Configuration change– Link cost change

– Potential problems with making cost dynamic!

• Periodically– Refresh the link-state information

– Typically (say) 30 minutes

– Corrects for possible corruption of the data

98

Page 99: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

99

Convergence

• Getting consistent routing information to all nodes– 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 100: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

100

Convergence Delay

• Time elapsed before every router has a consistent picture of the network

• Sources of convergence delay– Detection latency

– Flooding of link-state information

– Recomputation of forwarding tables

– Storing forwarding tables

• Performance during convergence period– Lost packets due to blackholes and TTL expiry

– Looping packets consuming resources

– Out-of-order packets reaching the destination

• Very bad for VoIP, online gaming, and video

Page 101: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

101

• Inconsistent link-state database– Some routers know about failure before others

– The shortest paths are no longer consistent

– Can cause transient forwarding loops

Transient Disruptions

A

ED

CB

F A

ED

CB

F

A and D think that thisis the path to C

E thinks that thisis the path to C

Loop!

Page 102: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

102

Reducing Convergence Delay

• Faster detection– Smaller hello timers

– Link-layer technologies that can detect failures

• Faster flooding– Flooding immediately

– Sending link-state packets with high-priority

• Faster computation– Faster processors on the routers

– Incremental Dijkstra algorithm

• Faster forwarding-table update– Data structures supporting incremental updates

Page 103: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

103

Scaling Link-State Routing

• Overhead of link-state routing– Flooding link-state packets throughout the network– Running Dijkstra’s shortest-path algorithm– Becomes unscalable when 100s of routers

• Introducing hierarchy through “areas”

Area 0

Area 1 Area 2

Area 3 Area 4

area

border

router

Page 104: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

104

Distance-Vector

Details in Section

Page 105: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Distributed Computation of Routes

• More scalable than Link-State– No global flooding

• Each node computing the outgoing port based on:– Local information (who it is connected to)

– Paths advertised by neighbors

105

Page 106: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Distributed Computation

106

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 away

I am three hops away

I am three hops away

Page 107: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Loops in a Distributed Computation

• If the nodes choose their paths according to

different criterion, then loops can occur

• Example– Node A is minimizing hop count

– Node B is minimizing latency

– Node C is maximizing capacity

– Node D is minimizing price

• Any of those goals are fine, if globally adopted– Only a problem when nodes use different criteria

• Any criteria that results in destination-based

routing is fine….107

Page 108: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

108

Distance Vector Routing

• Each router knows the links to its neighbors– Does not flood this information to the whole network

• Each router has provisional “shortest path”– E.g.: Router A: “I can get to router B with cost 11 via

next hop router D”

• Routers exchange this information with their neighboring routers– Again, no flooding the whole network

• Routers update their idea of the best path using info from neighbors

• This iterative process converges with set of shortest paths

Page 109: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

109

Information Flow in Distance Vector

Host A

Host BHost E

Host D

Host C

N1 N2

N3

N4

N5

N7N6

Page 110: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

110

Information Flow in Distance Vector

Host A

Host BHost E

Host D

Host C

N1 N2

N3

N4

N5

N7N6

Page 111: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

111

Information Flow in Distance Vector

Host A

Host BHost E

Host D

Host C

N1 N2

N3

N4

N5

N7N6

Page 112: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Why Is This Different From Flooding?

112

Page 113: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Bellman-Ford Algorithm

• INPUT:– Link costs to each neighbor

– Not full topology

• OUTPUT:– Next hop to each destination and the corresponding cost

– Does not give the complete path to the destination

113

Page 114: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

114

Bellman-Ford - Overview

• Each router maintains a table– Best known distance from X to Y,

via Z as next hop = DZ(X,Y)

• Each local iteration caused by: – Local link cost change – Message from neighbor

• Notify neighbors only if least cost path to any destination changes– Neighbors then notify their neighbors if

necessary

wait for (change in local link

cost or msg from neighbor)

recompute distance table

if least cost path to any dest

has changed, notifyneighbors

Each node:

Page 115: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Bellman-Ford - Overview

• Each router maintains a table– Row for each possible destination– Column for each directly-attached

neighbor to node– Entry in row Y and column Z of node X ⇒ best known distance from X to Y, via

Z as next hop = DZ(X,Y)

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 4 8

Node A

Neighbor (next-hop)

Destinations DC(A, D)

Page 116: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Bellman-Ford - Overview

• Each router maintains a table– Row for each possible destination– Column for each directly-attached

neighbor to node– Entry in row Y and column Z of node X ⇒ best known distance from X to Y, via

Z as next hop = DZ(X,Y)

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 4 8

Node A

Smallest distance in row Y = shortestDistance of A to Y, D(A, Y)

Page 117: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

117

Distance Vector Algorithm (cont’’’’d)

1 Initialization:2 for all neighbors V do3 if V adjacent to A

4 D(A, V) = c(A,V);

5 else6 D(A, V) = ∞;

7 send D(A, Y) to all neighbors

loop:8 wait (until A sees a link cost change to neighbor V /* case 1 */

9 or until A receives update from neighbor V) /* case 2 */

10 if (c(A,V) changes by ±d) /* ⇐ case 1 */11 for all destinations Y that go through V do

12 DV(A,Y) = DV(A,Y) ± d13 else if (update D(V, Y) received from V) /* ⇐ case 2 */

/* shortest path from V to some Y has changed */

14 DV(A,Y) = DV(A,V) + D(V, Y); /* may also change D(A,Y) */

15 if (there is a new minimum for destination Y)

16 send D(A, Y) to all neighbors

17 forever

• c(i,j): link cost from node i to j

• DZ(A,V): cost from A to V via Z

• D(A,V): cost of A’’’’s best path to V

Page 118: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example:1st Iteration (C ���� A)

A C

12

7

B D3

1

B C

B 2 8

C ∞ 7

D ∞ 8

Node A

A C D

A 2 ∞ ∞

C ∞ 1 ∞

D ∞ ∞ 3

Node B

Node C

A B D

A 7 ∞ ∞

B ∞ 1 ∞

D ∞ ∞ 1

B C

A ∞ ∞

B 3 ∞

C ∞ 1

Node D7 loop:

13 else if (update D(A, Y) from C)

14 DC(A,Y) = DC(A,C) + D(C, Y);

15 if (new min. for destination Y)

16 send D(A, Y) to all neighbors

17 forever

DC(A, B) = DC(A,C) + D(C, B) = 7 + 1 = 8

DC(A, D) = DC(A,C) + D(C, D) = 7 + 1 = 8

Page 119: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example: 1st Iteration (B ���� A)

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 5 8

Node A

A C D

A 2 ∞ ∞

C ∞ 1 ∞

D ∞ ∞ 3

Node B

Node C

A B D

A 7 ∞ ∞

B ∞ 1

D ∞ ∞ 1

Node D7 loop:

13 else if (update D(A, Y) from B)

14 DB(A,Y) = DB(A,B) + D(B, Y);

15 if (new min. for destination Y)

16 send D(A, Y) to all neighbors

17 forever

DB(A, C) = DB(A,B) + D(B, C) = 2 + 1 = 3

DB(A, D) = DB(A,B) + D(B, D) = 2 + 3 = 5

B C

A ∞ ∞

B 3 ∞

C ∞ 1

Page 120: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example: End of 1st Iteration

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 5 8

Node A Node B

Node C

A B D

A 7 3 ∞

B 9 1 4

D ∞ 4 1

Node D

B C

A 5 8

B 3 2

C 4 1

End of 1st Iteration

All nodes knows the

best two-hop paths

A C D

A 2 3 ∞

C 9 1 4

D ∞ 2 3

Page 121: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example: 2nd Iteration (A ���� B)

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 5 8

Node A Node B

Node C

A B D

A 7 3 ∞

B 9 1 4

D ∞ 4 1

Node D

B C

A 5 8

B 3 2

C 4 1

A C D

A 2 3 ∞

C 5 1 4

D 7 2 3

7 loop:…

13 else if (update D(B, Y) from A)

14 DA(B,Y) = DA(B,A) + D(A, Y);

15 if (new min. for destination Y)

16 send D(B, Y) to all neighbors

17 forever

DA(B, C) = DA(B,A) + D(A, C) = 2 + 3 = 5

DA(B, D) = DA(B,A) + D(A, D) = 2 + 5 = 7

Page 122: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example: End of 2nd Iteration

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 4 8

Node A

A C D

A 2 3 11

C 5 1 4

D 7 2 3

Node B

Node C

A B D

A 7 3 6

B 9 1 4

D 12 4 1

Node D

B C

A 5 4

B 3 2

C 4 1

End of 2nd Iteration

All nodes knows the

best three-hop paths

Page 123: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Example: End of 3rd Iteration

A C

12

7

B D3

1

B C

B 2 8

C 3 7

D 4 8

Node A

A C D

A 2 3 6

C 5 1 4

D 7 2 3

Node B

Node C

A B D

A 7 3 5

B 9 1 4

D 11 4 1

Node D

B C

A 5 4

B 3 2

C 4 1

End of 2nd Iteration:

Algorithm

Converges!

Page 124: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Intuition

• Initial state: best one-hop paths

• One round: best two-hop paths

• Two rounds: best three-hop paths

• …

• Kth round: best (k+1) hop paths

• This must eventually converge….but how does it

respond to changes in cost?

124

Page 125: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

125

Distance Vector: Link Cost Changes

A C

14

50

B

1

“goodnews

travels

fast”

A C

A 4 6

C 9 1

Node B

A B

A 50 5

B 54 1

Node C

Link cost changes heretime

Algorithm terminates

loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) /

10 if (c(A,V) changes by ±d) /* ⇐ case 1 */11 for all destinations Y that go through V do

12 DV(A,Y) = DV(A,Y) ± d13 else if (update D(V, Y) received from V) /* ⇐ case 2 */14 DV(A,Y) = DV(A,V) + D(V, Y); 15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever

A C

A 1 6

C 9 1

A B

A 50 5

B 54 1

A C

A 1 6

C 9 1

A B

A 50 2

B 51 1

A C

A 1 3

C 3 1

A B

A 50 2

B 51 1

Page 126: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

126

DV: Count to Infinity Problem

A C

14

50

B

60

“badnews

travels

slowly”

Node B

Node C

Link cost changes heretime

loop:8 wait (until A sees a link cost change to neighbor V9 or until A receives update from neighbor V) /

10 if (c(A,V) changes by ±d) /* ⇐ case 1 */11 for all destinations Y that go through V do

12 DV(A,Y) = DV(A,Y) ± d13 else if (update D(V, Y) received from V) /* ⇐ case 2 */14 DV(A,Y) = DV(A,V) + D(V, Y); 15 if (there is a new minimum for destination Y)16 send D(A, Y) to all neighbors 17 forever

A C

A 4 6

C 9 1

A B

A 50 5

B 54 1

A C

A 60 6

C 9 1

A B

A 50 5

B 54 1

A C

A 60 6

C 9 1

A B

A 50 7

B 101 1

A C

A 60 8

C 9 1

A B

A 50 7

B 101 1

Page 127: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

127

Distance Vector: Poisoned Reverse

A C

14

50

B

60• If B routes through C to get to A:- B tells C its (B’s) distance to A is infinite

(so C won’t route to A via B)

- Will this completely solve count to infinityproblem?

Node B

Node C

Link cost changes here; C updates D(C, A) = 60 as

B has advertised D(B, A) = ∞

time

Algorithm terminates

A C

A 4 6

C 9 1

A B

A 50 5

B ∞ 1

A C

A 60 6

C 9 1

A B

A 50 5

B ∞ 1

A C

A 60 6

C 9 1

A B

A 50 ∞

B ∞ 1

A C

A 60 51

C 9 1

A B

A 50 ∞

B ∞ 1

A C

A 60 51

C 9 1

A B

A 50 ∞

B ∞ 1

Page 128: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Aside: Another Way to Avoid Loops?

• In Distributed Computation?

• Exchange entire paths, not just cost of paths

• Nodes can use arbitrary metrics to choose paths– No need to agree on single metric

• No loops, but algorithm might not converge

• Will discuss later in semester…128

Page 129: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Routing: Just the Beginning

• Link state and distance-vector (and path vector)

are the deployed routing paradigms

• But we know how to do much, much better…

• Stay tuned for a later lecture where we:– Reduce convergence time to zero

– Respond to failures instantly!

129

Page 130: The Fundamentals of Routing - EECS Instructional …inst.eecs.berkeley.edu/~ee122/fa11/notes/06-Routing.pdfThe Fundamentals of Routing ... Necessary and Sufficient Condition ... –Spanning

Next Lecture

• Review computations (if needed)

• What pieces are we missing?– Naming

– Security

– Content retrieval

– ???

130