computer networks lecture 6: network layer – part ii based on slides from d. choffnes northeastern...

69
Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn 2015 by S. Laki

Upload: octavia-carter

Post on 17-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Computer Networks

Lecture 6: Network Layer – Part II

Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University

Revised Autumn 2015 by S. Laki

Page 2: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

2

Network Layer

Function: Route packets end-to-end

on a network, through multiple hops

Key challenge: How to represent addresses How to route packets

Scalability Convergence

Application

Presentation

SessionTransportNetworkData LinkPhysical

Page 3: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

3

Addressing Class-based CIDR

IPv4 Protocol Details Packed Header Fragmentation

IPv6

Outline

Page 4: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

4

IP Datagrams

IP Datagrams are like a letter Totally self-contained Include all necessary addressing information No advanced setup of connections or circuits

VersionHLe

nDSCP/ECN Datagram Length

0 8 16 24 314 12 19

Identifier Flags OffsetTTL Protocol Checksum

Source IP AddressDestination IP Address

Options (if any, usually not)

Data

Page 5: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

5

IP Header Fields: Word 1

Version: 4 for IPv4 Header Length: Number of 32-bit words (usually 5) Type of Service: Priority information (unused) Datagram Length: Length of header + data in bytes

VersionHLe

nDSCP/ECN Datagram Length

0 8 16 24 314 12 19

Identifier Flags OffsetTTL Protocol Checksum

Source IP AddressDestination IP Address

Options (if any, usually not)

Data

Limits packets to

65,535 bytes

Page 6: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

6

IP Header Fields: Word 3

Time to Live: decremented by each router Used to kill looping packets

Protocol: ID of encapsulated protocol 6 = TCP, 17 = UDP

Checksum

VersionHLe

nDSCP/ECN Datagram Length

0 8 16 24 314 12 19

Identifier Flags OffsetTTL Protocol Checksum

Source IP AddressDestination IP Address

Options (if any, usually not)

Data

Used to implement trace route

Page 7: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

7

IP Header Fields: Word 4 and 5

Source and destination address In theory, must be globally unique In practice, this is often violated

VersionHLe

nDSCP/ECN Datagram Length

0 8 16 24 314 12 19

Identifier Flags OffsetTTL Protocol Checksum

Source IP AddressDestination IP Address

Options (if any, usually not)

Data

Page 8: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

8

Problem: Fragmentation

Problem: each network has its own MTU DARPA principles: networks allowed to be

heterogeneous Minimum MTU may not be known for a given path

IP Solution: fragmentation Split datagrams into pieces when MTU is reduced Reassemble original datagram at the receiver

MTU = 2000MTU = 4000 MTU = 1500

DatagramDgram

1Dgram

21 2 3 4

Page 9: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

9

IP Header Fields: Word 2

Identifier: a unique number for the original datagram Flags: M flag, i.e. this is the last fragment Offset: byte position of the first byte in the fragment

Divided by 8

VersionHLe

nTOS Datagram Length

0 8 16 24 314 12 19

Identifier Flags OffsetTTL Protocol Checksum

Source IP AddressDestination IP Address

Options (if any, usually not)

Data

Page 10: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

10

Fragmentation Example

MTU = 2000MTU = 4000 MTU = 1500

Data

Data

Data

IP Hdr

IP

IP

Length = 3820, M = 0

380020

Length = 2000, M = 1Offset = 0

Length = 1840, M = 0Offset = 1980

198020

182020

1980+ 1820= 3800

Page 11: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

11

Fragmentation Example

MTU = 2000 MTU = 1500

Data

Data

IP

IP

Data

Data

IP

IP

Length = 2000, M = 1Offset = 0

Length = 1840, M = 0Offset = 1980

198020

182020

20

20 1480

500

Length = 520, M = 1Offset = 1480

Length = 1500, M = 1Offset = 0

Data

Data

IP

IP20

20 1480

340

Length = 360, M = 0Offset = 3460

Length = 1500, M = 1Offset = 1980

1480+ 500

= 1980

Page 12: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

12

IP Fragment Reassembly

Performed at destination

M = 0 fragment gives us total data size 360 – 20 + 3460 =

3800 Challenges:

Out-of-order fragments

Duplicate fragments Missing fragments

Basically, memory management nightmare

DataIP20 1480

Data

IP20 500

Length = 520, M = 1, Offset = 1480

Length = 1500, M = 1, Offset = 0

DataIP20 1480

Data

IP20 340

Length = 360, M = 0, Offset = 3460

Length = 1500, M = 1, Offset = 1980

Page 13: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

13

Fragmentation Concepts

Highlights many key Internet characteristics Decentralized and heterogeneous

Each network may choose its own MTU Connectionless datagram protocol

Each fragment contains full routing information Fragments can travel independently, on different

paths Best effort network

Routers/receiver may silently drop fragments No requirement to alert the sender

Most work is done at the endpoints i.e. reassembly

Page 14: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

14

Fragmentation in Reality

Fragmentation is expensive Memory and CPU overhead for datagram reconstruction Want to avoid fragmentation if possible

MTU discovery protocol Send a packet with “don’t fragment” bit set Keep decreasing message length until one arrives May get “can’t fragment” error from a router, which will

explicitly state the supported MTU Router handling of fragments

Fast, specialized hardware handles the common case Dedicated, general purpose CPU just for handling

fragments

Page 15: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

15

Addressing Class-based CIDR

IPv4 Protocol Details Packed Header Fragmentation

IPv6

Outline

Page 16: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

16

The IPv4 Address Space Crisis

Problem: the IPv4 address space is too small 232 = 4,294,967,296 possible addresses Less than one IP per person

Parts of the world have already run out of addresses IANA assigned the last /8 block of addresses in 2011

RegionRegional Internet Registry (RIR) Exhaustion Date

Asia/Pacific APNIC April 19, 2011

Europe/Middle East RIPE September 14, 2012

North America ARIN 13 Jan 2015 (Projected)

South America LACNIC 13 Jan 2015 (Projected)

Africa AFRINIC 17 Jan 2022(Projected)

Page 17: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

17

IPv6

IPv6, first introduced in 1998(!) 128-bit addresses 4.8 * 1028 addresses per person

Address format 8 groups of 16-bit values, separated by ‘:’ Leading zeroes in each group may be omitted Groups of zeroes can be omitted using ‘::’

2001:0db8:0000:0000:0000:ff00:0042:8329

2001:0db8:0:0:0:ff00:42:8329

2001:0db8::ff00:42:8329

Page 18: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

18

IPv6 Trivia

Who knows the IP for localhost? 127.0.0.1

What is localhost in IPv6? ::1

Page 19: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

19

IPv6 Header

Double the size of IPv4 (320 bits vs. 160 bits)

Version DSCP/ECN Flow Label0 8 16 24 314 12 19

Datagram Length Next Header Hop Limit

Source IP Address

Destination IP Address

Version = 6 Groups packets

into flows, used for

QoS

Same as IPv4

Same as Protocol in

IPv4

Same as TTL in IPv4

Same as IPv4

Page 20: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

20

Differences from IPv4 Header

Several header fields are missing in IPv6 Header length – rolled into Next Header field Checksum – was useless, so why keep it Identifier, Flags, Offset

IPv6 routers do not support fragmentation Hosts are expected to use path MTU discovery

Reflects changing Internet priorities Today’s networks are more homogeneous Instead, routing cost and complexity dominate

Page 21: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

21

Performance Improvements

No checksums to verify No need for routers to handle fragmentation Simplified routing table design

Address space is huge No need for CIDR (but need for aggregation) Standard subnet size is 264 addresses

Simplified auto-configuration Neighbor Discovery Protocol Used by hosts to determine network ID Host ID can be random!

Page 22: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

22

Additional IPv6 Features

Source Routing Host specifies the route to wants packet to take

Mobile IP Hosts can take their IP with them to other

networks Use source routing to direct packets

Privacy Extensions Randomly generate host identifiers Make it difficult to associate one IP to a host

Jumbograms Support for 4Gb datagrams

Page 23: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

23

Deployment Challenges

Switching to IPv6 is a whole-Internet upgrade All routers, all hosts ICMPv6, DHCPv6, DNSv6

2013: 0.94% of Google traffic was IPv6, 2.5% today

IPv4

TCP, UDP, ICMP

HTTP, FTP, SMTP, RTP, IMAP, …

Ethernet, 802.11x, DOCSIS, …

Fiber, Coax, Twisted Pair, Radio, …

Page 24: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

24

Transitioning to IPv6

How do we ease the transition from IPv4 to IPv6? Today, most network edges are IPv6 ready

Windows/OSX/iOS/Android all support IPv6 Your wireless access point probably supports IPv6

The Internet core is hard to upgrade … but a IPv4 core cannot route IPv6 traffic

CoreInternet

BusinessNetwork

HomeNetwork

IPv6 Ready

IPv6 Ready

IPv4 Only :

(IPv6 Packets

Page 25: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

25

Transition Technologies

How do you route IPv6 packets over an IPv4 Internet?

Transition Technologies Use tunnels to encapsulate and route IPv6

packets over the IPv4 Internet Several different implementations

6to4 IPv6 Rapid Deployment (6rd) Teredo … etc.

Page 26: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

26

Network Layer, Control Plane

Function: Set up routes within a single network

Key challenges: Distributing and updating routes Convergence time Avoiding loops

Application

Presentation

SessionTransportNetworkData LinkPhysical

BGPRIP OSPF Control Plane

Data Plane

Page 27: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Internet Routing

Internet organized as a two level hierarchy First level – autonomous systems (AS’s)

AS – region of network under a single administrative domain

Examples: Comcast, AT&T, Verizon, Sprint, etc. AS’s use intra-domain routing protocols internally

Distance Vector, e.g., Routing Information Protocol (RIP) Link State, e.g., Open Shortest Path First (OSPF)

Connections between AS’s use inter-domain routing protocols Border Gateway Routing (BGP) De facto standard today, BGP-4

27

Page 28: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

AS Example28

AS-1

AS-2

AS-3

Interior Routers

BGP Routers

Page 29: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

29

Why Do We Need ASs?

Routing algorithms are not efficient enough to execute on the entire Internet topology

Different organizations may use different routing policies

Allows organizations to hide their internal network structure

Allows organizations to choose how to route across each other (BGP)

• Easier to compute routes• Greater flexibility• More autonomy/independence

Page 30: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Routing on a Graph

Goal: determine a “good” path through the network from source to destination

What is a good path? Usually means the shortest path Load balanced Lowest $$$ cost

Network modeled as a graph Routers nodes Link edges

Edge cost: delay, congestion level, etc.

A

B C

D E

F

5

23

5

21

1

23

1

30

Page 31: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

31

Networks: Routing

Shortest Path Routing1. Bellman-Ford Algorithm [Distance

Vector]2. Dijkstra’s Algorithm [Link State]

What does it mean to be the shortest (or optimal) route?

a. Minimize mean packet delayb. Maximize the network throughputc. Mininize the number of hops along

the path

Page 32: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

32

Networks: Routing

Dijkstra’s Shortest Path Algorithm

Initially mark all nodes (except source) with infinite distance.

working node = source nodeSink node = destination nodeWhile the working node is not equal to the sink 1. Mark the working node as permanent. 2. Examine all adjacent nodes in turn

If the sum of label on working node plus distance from working node to adjacent node is less than current labeled distance on the adjacent node, this implies a shorter path. Relabel the distance on the adjacent node and label it with the node from which the probe was made.

3. Examine all tentative nodes (not just adjacent nodes) and mark the node with the smallest labeled value as permanent. This node becomes the new working node.

Reconstruct the path backwards from sink to source.

Page 33: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s AlgorithmDijkstra(graph (G,w), vertex s)

InitializeSingleSource(G, s)S Q V[G]while Q 0 do

u ExtractMin(Q)S S {u}for u Adj[u] do

Relax(u,v,w)

InitializeSingleSource(graph G, vertex s)for v V[G] do

d[v] p[v] 0

d[s] 0

Relax(vertex u, vertex v, weight w)if d[v] > d[u] + w(u,v) then

d[v] d[u] + w(u,v)p[v] u

(V)

(1) ?

(E) times in total

executed (V) times

Page 34: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

10

1

5

2

649

7

2 3

Page 35: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

10

1

5

2

649

7

2 3

Page 36: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

10

10

1

5

2

649

7

2 3

Page 37: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

10

10

1

5

2

649

7

2 3

Page 38: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

8

7

1410

1

5

2

649

7

2 3

Page 39: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

8

7

1410

1

5

2

649

7

2 3

Page 40: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

8

7

1310

1

5

2

649

7

2 3

Page 41: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

8

7

1310

1

5

2

649

7

2 3

Page 42: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

8

7

910

1

5

2

649

7

2 3

Page 43: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Dijkstra’s Algorithm - Example

0

5

8

7

910

1

5

2

649

7

2 3

Page 44: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm

BellmanFord(graph (G,w), vertex s)InitializeSingleSource(G, s)for i 1 to |V[G] 1| do

for (u,v) E[G] doRelax(u,v,w)

for (u,v) E[G] doif d[v] > d[u] + w(u,v) then

return falsereturn true

Page 45: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Example

6

7

7

-3

2

8

-4

9

5

-2

Page 46: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Example

0

6

7

7

-3

2

8

-4

9

5

-2

Page 47: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Example

0

7

6

6

7

7

-3

2

8

-4

9

5

-2

Page 48: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Example

0

7

6

2

46

7

7

-3

2

8

-4

9

5

-2

Page 49: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Example

0

7

2

2

46

5

7

7

-3

2

8

-2

-4

9

Page 50: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Example

0

7

2

-2

46

5

7

7

-3

2

8

-2

-4

9

Page 51: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Bellman-Ford Algorithm - Complexity

BellmanFord(graph (G,w), vertex s)InitializeSingleSource(G, s)for i 1 to |V[G] 1| do

for (u,v) E[G] doRelax(u,v,w)

for (u,v) E[G] doif d[v] > d[u] + w(u,v) then

return falsereturn true

executed (V) times

(E)

(E)

(1)

Page 52: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

52

Networks: Routing

Internetwork Routing [Halsall]

Adaptive Routing

Centralized Distributed

Intradomain routing Interdomain routing

Distance Vector routing Link State routing

[IGP] [EGP]

[BGP,IDRP]

[OSPF,IS-IS,PNNI][RIP]

[RCC]

InteriorGateway Protocols

ExteriorGateway Protocols

Page 53: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Routing Problems

Assume A network with N nodes Each node only knows

Its immediate neighbors The cost to reach each

neighbor How does each node

learn the shortest path to every other node?

A

B C

D E

F

5

23

5

21

1

23

1

53

Page 54: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

Intra-domain Routing Protocols

Distance vector Routing Information Protocol (RIP), based on

Bellman-Ford Routers periodically exchange reachability

information with neighbors Link state

Open Shortest Path First (OSPF), based on Dijkstra Each network periodically floods immediate

reachability information to all other routers Per router local computation to determine full

routes54

54

Page 55: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

55

Distance Vector Routing RIP

Link State Routing OSPF IS-IS

Outline

Page 56: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

56

Distance Vector Routing

What is a distance vector? Current best known cost to reach a destination

Idea: exchange vectors among neighbors to learn about lowest cost paths

Routing Information Protocol (RIP)

Destination

Cost

A 7

B 1

D 2

E 5

F 1

DV Tableat Node C

No entry for C Initially, only has info

for immediate neighbors Other destinations cost

= ∞ Eventually, vector is

filled

Page 57: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

57

Distance Vector Routing Algorithm

1. Wait for change in local link cost or message from neighbor

2. Recompute distance table

3. If least cost path to any destination has changed, notify neighbors

Page 58: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

58

Distance Vector Initialization

Dest.

Cost Next

B 2 B

C 7 C

D ∞

2

3

1

A

B

C

D

1

7

Node ADest.

Cost Next

A 2 A

C 1 C

D 3 D

Node B

Dest.

Cost Next

A 7 A

B 1 B

D 1 D

Node CDest.

Cost Next

A ∞

B 3 B

C 1 C

Node D1. Initialization: 2. for all neighbors V

do3. if V adjacent to A 4. D(A, V) = c(A,V); 5. else 6. D(A, V) = ∞; …

Page 59: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

60

Distance Vector: End of 3rd Iteration

Dest.

Cost Next

B 2 B

C 3 B

D 4 B

2

3

1

A

B

C

D

1

7

Node ADest.

Cost Next

A 2 A

C 1 C

D 2 C

Node B

Dest.

Cost Next

A 3 B

B 1 B

D 1 D

Node CDest.

Cost Next

A 4 C

B 2 C

C 1 C

Node D

…7. loop: …12. else if (update D(V, Y) received from V) 13. for all destinations Y do14. if (destination Y through V)15. D(A,Y) = D(A,V) + D(V, Y);16. else17. D(A, Y) =

min(D(A, Y),D(A, V) + D(V, Y));

18. if (there is a new min. for dest. Y)19. send D(A, Y) to all neighbors 20. forever

• Nothing changes, algorithm terminates• Until something changes…

Page 60: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

614 1

A

B

C50

7. loop: 8. wait (link cost update or update message)9. if (c(A,V) changes by d) 10. for all destinations Y through V do 11. D(A,Y) = D(A,Y) + d 12. else if (update D(V, Y) received from V) 13. for all destinations Y do14. if (destination Y through V)15. D(A,Y) = D(A,V) + D(V, Y);16. else17. D(A, Y) = min(D(A, Y), D(A, V) + D(V, Y));18. if (there is a new minimum for destination Y)19. send D(A, Y) to all neighbors 20. forever

1

Node B

Node C

Time

D C N

A 4 A

C 1 B

D C N

A 5 B

B 1 B

D C N

A 1 A

C 1 B

D C N

A 5 B

B 1 B

D C N

A 1 A

C 1 B

D C N

A 2 B

B 1 B

D C N

A 1 A

C 1 B

D C N

A 2 B

B 1 B

Link Cost Changes,

Algorithm Starts

Algorithm Terminates

Good news travels fast

Page 61: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

62

Count to Infinity Problem

4 1

A

B

C50

60

Node B

Node C

Time

D C N

A 4 A

C 1 B

D C N

A 5 B

B 1 B

D C N

A 6 C

C 1 B

D C N

A 5 B

B 1 B

D C N

A 6 C

C 1 B

D C N

A 7 B

B 1 B

D C N

A 8 C

C 1 B

D C N

A 7 B

B 1 B

• Node B knows D(C, A) = 5

• However, B does not know the path is C B A

• Thus, D(B,A) = 6 !

Bad news travels slowly

Page 62: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

63

Poisoned Reverse

4 1

A

B

C50

60

Node B

Node C

Time

D C N

A 4 A

C 1 B

D C N

A 5 B

B 1 B

D C N

A 60 A

C 1 B

D C N

A 5 B

B 1 B

D C N

A 60 A

C 1 B

D C N

A 50 A

B 1 B

D C N

A 51 C

C 1 B

D C N

A 50 A

B 1 B

If C routes through B to get to A C tells B that D(C, A) = ∞ Thus, B won’t route to A via C

Page 63: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

64

Distance Vector Routing RIP

Link State Routing OSPF IS-IS

Outline

Page 64: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

65

Each node knows its connectivity and cost to direct neighbors

Each node tells every other node this information

Each node learns complete network topology

Use Dijkstra to compute shortest paths

Link State Routing

Page 65: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

66

Flooding Details

Each node periodically generates Link State Packet ID of node generating the LSP List of direct neighbors and costs Sequence number (64-bit, assumed to never

wrap) Time to live

Flood is reliable (ack + retransmission) Sequence number “versions” each LSP Receivers flood LSPs to their own neighbors

Except whoever originated the LSP LSPs also generated when link states change

Page 66: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

67

Dijkstra’s Algorithm

Step Start S B C D E F

0 A 2, A 5, A 1, A ∞ ∞

1 AD 4, D 2, D ∞

2 ADE 3, E 4, E

3 ADEB

4 ADEBC

5 ADEBCF

A

B C

D E

F

5

23

5

21

1

23

1

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

…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. D(v) = min( D(v), D(w) +

c(w,v) );13. until all nodes in S;

Page 67: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

68

OSPF vs. IS-IS

Favored by companies, datacenters

More optional features

Built on top of IPv4 LSAs are sent via IPv4 OSPFv3 needed for IPv6

Favored by ISPs

Less “chatty” Less network overhead Supports more devices

Not tied to IP Works with IPv4 or IPv6

OSPF IS-IS

Two different implementations of link-state routing

Page 68: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

69

Different Organizational Structure

OSPF IS-IS

Area 0

Area 1 Area 2

Area 3Area 4

Organized around overlapping areas

Area 0 is the core network

Organized as a 2-level hierarchy

Level 2 is the backbone

Level 2

Level 1

Level 1

-2

Page 69: Computer Networks Lecture 6: Network Layer – Part II Based on slides from D. Choffnes Northeastern U. and P. Gill from StonyBrook University Revised Autumn

70

Link State vs. Distance Vector

Link State Distance Vector

Message Complexity

O(n2*e) O(d*n*k)

Time Complexity O(n*log n) O(n)

Convergence Time O(1) O(k)

Robustness • Nodes may advertise incorrect link costs

• Each node computes their own table

• Nodes may advertise incorrect path cost

• Errors propagate due to sharing of DV tables

n = number of nodes in the graphd = degree of a given nodek = number of rounds

• Which is best?• In practice, it depends.• In general, link state is more popular.