80
Chapter 4, slide: 1 ECE/CS 372 – introduction to computer networks Lecture 13 Announcements: wledgement: slides drawn heavily from Kurose & Ross

ECE/CS 372 – introduction to computer networks Lecture 13

Embed Size (px)

DESCRIPTION

Announcements:. ECE/CS 372 – introduction to computer networks Lecture 13. Acknowledgement: slides drawn heavily from Kurose & Ross. network layer protocols run at end systems & routers Sender side: get segments from transport layer encapsulates segments into IP datagrams - PowerPoint PPT Presentation

Citation preview

Page 1: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 1

ECE/CS 372 – introduction to computer networksLecture 13

Announcements:

Acknowledgement: slides drawn heavily from Kurose & Ross

Page 2: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 2

Network layer network layer

protocols run at end systems & routers

Sender side: get segments from

transport layer encapsulates segments

into IP datagrams

router examines header fields in all IP datagrams

Receiver side: delivers segments to

transport layer

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical network

data linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

Page 3: ECE/CS 372 – introduction to computer networks Lecture 13

local forwarding tableheader value

0100010101111001

3221

output link

Chapter 4, slide: 3

routing algorithm

Interplay between routing and forwarding

routing process: find route taken by packets from source to dest.

forwarding table: a lookup table for figuring out output port for each input pkt

routing algorithm: constructs routing tables

forwarding process: move pkts from input to output

1

23

0111

value in arrivingpacket’s header

Destination

Page 4: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 4

Two Key Network-Layer Functions

forwarding: move packets from router’s input to appropriate router output

routing: determine route taken by packets from source to dest.

routing algorithms

analogy:

routing: process of planning trip from source to dest

forwarding: process of getting through single interchange

Page 5: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 5

Network service model

Q: What services are needed/offered to transport datagrams from sender to receiver?

Example services for individual datagrams:

Reliability Guaranteed delivery

End-to-end delay guaranteed delivery

within 40 msec delay

Example services for a flow of datagrams:

In-order in-order datagram delivery

Throughput guaranteed minimum

bandwidth to flow

Jitter delay restrictions on changes in

inter-packet spacing

Page 6: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 6

Network layer: connection and connection-less services Network-layer versus transport-layer services

datagram network provides network-layer connectionless service

Virtual Circuit (VC) network provides network-layer connection service

Transport layer Network layer

Service Process to process

Host to host

Choice Reliable (TCP) and unreliable (UDP)

Unreliable only (Best effort)

Implementation

Edge (Hosts) Core (routers)

Page 7: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 7

Datagram or VC network: why?

Datagram data exchange among

computers (Internet) “elastic” service, no

strict timing req. “smart” end systems

(computers) can adapt, perform

control, error recovery simple inside network,

complexity at “edge” many link types

different characteristics uniform service difficult

Virtual Circuit (VC) evolved from telephony voice conversation:

strict timing, reliability requirements

need for guaranteed service

“dumb” end systems telephones complexity inside

network

Page 8: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 8

Datagram networks no call setup at network layer no state about end-to-end connections is kept in

routers no network-level concept of “connection”

packets forwarded using dest. host address packets (same source-dest pair) may take different paths

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

1. Send data 2. Receive data

Page 9: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 9

Forwarding table

Destination Address Range Link Interface

11001000 00010111 00010000 00000000 through 0 11001000 00010111 00010111 11111111

11001000 00010111 00011000 00000000 through 1 11001000 00010111 00011000 11111111

11001000 00010111 00011001 00000000 through 2 11001000 00010111 00011111 11111111

otherwise 3

4 billion possible entries

Page 10: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 10

Longest prefix matching

Prefix Match Link Interface 11001000 00010111 00010 0 11001000 00010111 00011000 1 11001000 00010111 00011 2 otherwise 3

DA: 11001000 00010111 00011000 10101010

Examples

DA: 11001000 00010111 00010110 10100001 Which interface?

Which interface?

Page 11: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 11

Chapter 4: Network Layer

Introduction

IP: Internet Protocol IPv4 addressing NAT, IPv6

Routing algorithms Link state Distance Vector

Routing in the Internet RIP, OSPF, BGP

Page 12: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 12

The Internet Network layer

forwardingtable

Host, router network layer functions:

Routing protocols•path selection•RIP, OSPF, BGP

IP protocol•addressing conventions•datagram format•packet handling conventions

ICMP protocol•error reporting•router “signaling”

Transport layer: TCP, UDP

Link layer

physical layer

Networklayer

Page 13: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 13

IP Fragmentation & Reassembly network links have MTU

(max.transfer size) - largest possible link-level frame. different link types,

different MTUs large IP datagram divided

(“fragmented”) within net one datagram becomes

several datagrams “reassembled” only at

final destination IP header bits used to

identify, order related fragments

fragmentation: in: one large datagramout: 3 smaller datagrams

reassembly

Page 14: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 14

IP Fragmentation & Reassembly (ctd)

ID=x

offset=0

fragflag=0

length=4000

One large datagram becomesseveral smaller datagrams

Example 4000 byte datagram

= 20 (header) + 3980 (data)

MTU = 1500 bytes

Page 15: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 15

IP Fragmentation & Reassembly (ctd)

ID=x

offset=0

fragflag=0

length=4000

ID=x

offset=0

fragflag=1

length=1500

ID=x

offset=185

fragflag=1

length=1500

ID=x

offset=370

fragflag=0

length=1040

One large datagram becomesseveral smaller datagrams

Example 4000 byte datagram

= 20 (header) + 3980 (data)

MTU = 1500 bytes

1480 bytes in data field

offset =1480/8

1040= 20 (header) + 1020 (data)1020 (data) =3980 – 1480 -1480

Page 16: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 16

IP Addressing: introduction IP address: 32-bit

identifier for host, router interface

interface: connection between host/router and physical link multiple interfaces per

router one interface per host one IP address per

interface

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 11

Page 17: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 17

Subnets IP address:

subnet part (higher bits) host part (lower bits)

What’s a subnet ? device interfaces with

same subnet part of IP address

can physically reach each other without intervening router

network consisting of 3 subnets

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

subnet11001000 00010111 00010000 00000000

subnetpart

hostpart

200.23.16.0/23

Page 18: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 18

Subnets 223.1.1.0/24223.1.2.0/24

223.1.3.0/24

Recipe To determine the

subnets, detach each interface from its host or router, creating islands of isolated networks. Each isolated network is called a subnet. Subnet mask: /24

Page 19: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 19

SubnetsHow many? 223.1.1.1

223.1.1.3

223.1.1.4

223.1.2.2223.1.2.1

223.1.2.6

223.1.3.2223.1.3.1

223.1.3.27

223.1.1.2

223.1.7.0

223.1.7.1223.1.8.0223.1.8.1

223.1.9.1

223.1.9.2

Page 20: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 20

IP addressing: CIDRClassful addressing: A, B, C

A: /8 B: /16 C: /24

CIDR: Classless InterDomain Routing subnet portion of address of arbitrary length address format: a.b.c.d/x, where x is # bits in subnet

portion of address

11001000 00010111 00010000 00000000

subnetpart

hostpart

200.23.16.0/23

(only 28 subnets, but 224 hosts per subnet)

(216 subnets, and 216 hosts per subnet)(224 subnets, but only 28 hosts per

subnet)

Page 21: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 21

IP addresses: how to get one?

Q: How does host get IP address?

hard-coded by system admin in a file

DHCP: Dynamic Host Configuration Protocol: dynamically get IP address from as server when

joining the network IP address can be reused by other hosts if released Can renew IP addresses if stayed connected

Page 22: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 22

DHCP client-server scenario

223.1.1.1

223.1.1.2

223.1.1.3

223.1.1.4 223.1.2.9

223.1.2.2

223.1.2.1

223.1.3.2223.1.3.1

223.1.3.27

A

BE

DHCP server

arriving DHCP client needsaddress in thisnetwork

Page 23: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 23

IP addresses: how to get one?

Q: How does network get subnet part of IP addr?

A: gets allocated portion of its provider ISP’s address space

ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20

Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23 ... ….. …. ….

Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23

Page 24: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 24

IP addressing: the last word...

Q: How does an ISP get block of addresses?

A: ICANN: Internet Corporation for Assigned

Names and Numbers allocates addresses manages DNS assigns domain names, resolves disputes

Page 25: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 25

ECE/CS 372 – introduction to computer networksLecture 14

Announcements:

Lab 4 is posted and is due next Wednesday

Acknowledgement: slides drawn heavily from Kurose & Ross

Page 26: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 26

ExampleSubnet 1

Subnet 2

Subnet 3

Three subnets All interfaces in all these

subnets are required to have prefix: 223.1.13.0/24

Subnet 1 is required to support 125 interfaces

Subnet 2 & 3 are each required to support 60 interfaces

Question: Provide 3 network addresses in the form: a.b.c.d/x

1 , 2 and 3

Page 27: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 27

Chapter 4: Network Layer

Introduction

IP: Internet Protocol IPv4 addressing NAT, IPv6

Routing algorithms Link state Distance Vector

Routing in the Internet RIP, OSPF, BGP

Page 28: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 28

NAT: Network Address Translation

10.0.0.1

10.0.0.2

10.0.0.3

10.0.0.4

138.76.29.7

local network(e.g., home network)

10.0.0/24

rest ofInternet

Datagrams with source or destination in this networkhave 10.0.0/24 address for

source, destination (as usual)

All datagrams leaving localnetwork have same single source

NAT IP address: 138.76.29.7,different source port numbers

Page 29: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 29

NAT: Network Address Translation

Motivation:

local network uses just one IP address as far as outside world is concerned

range of addresses not needed from ISP: just one IP address for all devices

can change addresses of devices in local network without notifying outside world

can change ISP without changing addresses of devices in local network

devices inside local net not explicitly addressable, visible by outside world (a security plus).

Page 30: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 30

NAT: Network Address Translation

10.0.0.1

10.0.0.2

10.0.0.3

S: 10.0.0.1, 3345D: 128.119.40.186, 80

1

10.0.0.4

138.76.29.7

1: host 10.0.0.1 sends datagram to 128.119.40.186, 80

NAT translation tableWAN side addr LAN side addr

138.76.29.7, 5001 10.0.0.1, 3345…… ……

S: 128.119.40.186, 80 D: 10.0.0.1, 3345

4

S: 138.76.29.7, 5001D: 128.119.40.186, 80

2

2: NAT routerchanges datagramsource addr from10.0.0.1, 3345 to138.76.29.7, 5001,updates table

S: 128.119.40.186, 80 D: 138.76.29.7, 5001

3

3: Reply arrives dest. address: 138.76.29.7, 5001

4: NAT routerchanges datagramdest addr from138.76.29.7, 5001 to 10.0.0.1, 3345

Page 31: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 31

IPv6 Initial motivation:

32-bit address space soon to be completely allocated.

Additional motivation: header changes to facilitate QoS

Major changes from IPv4: Fragmentation: no longer allowed; drop packet

if too big; send an ICMP msg back Checksum: removed to reduce processing

time; already done at transport and link layers

Page 32: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 32

Transition From IPv4 To IPv6 Can all routers be upgraded simultaneously ??

Answer: it can’t; no “flag days” Analogy: (IP for Internet) ~ (foundation for House) To change the foundation, you need to tear down the

house!!

Solutiongradually incorporate IPv6 (may take few years)

How will the network operate with mixed IPv4 and IPv6 routers?

Tunneling??

Page 33: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 33

TunnelingA B E F

IPv6 IPv6 IPv6 IPv6

tunnelLogical view:

Physical view:A B E F

IPv6 IPv6 IPv6 IPv6IPv4 IPv4

What is the problem here?

DC

Why can’t B just send an IPv4 packet to C ?

Flow: XSrc: ADest: F

data

A-to-B:IPv6

Problem: D won’t be able to send an IPv6 packet to E? Why?

Be aware that:

• IPv6 nodes have both IPv4 & IPv6 addresses

• Nodes know which nodes are IPv4 and which ones are IPv6 (use for e.g. DNS)

Page 34: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 34

TunnelingA B E F

IPv6 IPv6 IPv6 IPv6

tunnelLogical view:

Physical view:A B E F

IPv6 IPv6 IPv6 IPv6

C D

IPv4 IPv4

Flow: XSrc: ADest: F

data

A-to-B:IPv6

Flow: XSrc: ADest: F

data

E-to-F:IPv6

Flow: XSrc: ADest: F

data

Src:BDest: E

B-to-C:IPv6 inside

IPv4

Flow: XSrc: ADest: F

data

Src:BDest: E

B-to-C:IPv6 inside

IPv4

Be aware that:

• IPv6 nodes have both IPv4 & IPv6 addresses

• Nodes know which nodes are IPv4 and which one are IPv6 (use for e.g. DNS)

Page 35: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 35

Chapter 4: Network Layer

Introduction

IP: Internet Protocol IPv4 addressing NAT, IPv6

Routing algorithms Link state Distance Vector

Routing in the Internet RIP, OSPF, BGP

Page 36: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 36

1

23

0111

value in arrivingpacket’s header

routing algorithm

local forwarding tableheader value output link

0100010101111001

3221

Routing versus forwarding

Page 37: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 37

u

yx

wv

z2

2

13

1

1

2

53

5

Graph: G = (N,E)

N = set of routers = { u, v, w, x, y, z }

E = set of links ={ (u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }

Graph abstraction

Page 38: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 38

Graph abstraction: costs

u

yx

wv

z2

2

13

1

1

2

53

5 • c(x,x’) = cost of link (x,x’)

- e.g., c(w,z) = 5

• cost could always be 1, or inversely related to bandwidth,or inversely related to congestion

Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

Question: What’s the least-cost path between u and z ?

The routing algorithm’s job is to find this least-cost path

Page 39: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 39

Chapter 4: Network Layer

Introduction

IP: Internet Protocol IPv4 addressing NAT, IPv6

Routing algorithms Link state Distance Vector

Routing in the Internet RIP, OSPF, BGP

Page 40: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 40

A Link-State Routing Algorithm

Dijkstra’s algorithm Each node computes least

cost paths from it to all other nodes

Each node knows entire net topology, all link costs

Each node broadcasts “link state” of its neighbors only, but to all

iterative: after k iterations, know least cost path to k dest.’s

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

node x to y; = ∞ if not direct neighbors

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

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

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

Page 41: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 41

Dijkstra’s algorithm: example

Step012345

N'u

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

D(w),p(w)5,u

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

D(y),p(y)∞

D(z),p(z)∞

u

yx

wv

z2

2

13

1

1

2

53

5

\N’-

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

Page 42: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 42

Dijkstra’s algorithm: example

Step012345

N'u

ux

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

D(w),p(w)5,u4,x

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

D(y),p(y)∞2,x

D(z),p(z)∞

\N’-

vwy

8 Loop 9 find c not in N' such that D(c) is a minimum 10 add c to N' 11 update D(b) for all b adjacent to c & not in N' : 12 D(b) = min( D(b), D(c) + c(c,b) ) 15 until all nodes in N'

u

yx

wv

z2

2

13

1

1

2

53

5

Page 43: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 43

Dijkstra’s algorithm: example

Step012345

N'u

uxuxy

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

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

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

D(y),p(y)∞2,x

D(z),p(z)∞ ∞ 4,y

\N’-

vwywz

u

yx

wv

z2

2

13

1

1

2

53

5

8 Loop 9 find c not in N' such that D(c) is a minimum 10 add c to N' 11 update D(b) for all b adjacent to c & not in N' : 12 D(b) = min( D(b), D(c) + c(c,b) ) 15 until all nodes in N'

Page 44: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 44

Dijkstra’s algorithm: example

Step012345

N'u

uxuxy

uxyv

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

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

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

D(y),p(y)∞2,x

D(z),p(z)∞ ∞ 4,y4,y

\N’-

vwywzw

u

yx

wv

z2

2

13

1

1

2

53

5

8 Loop 9 find c not in N' such that D(c) is a minimum 10 add c to N' 11 update D(b) for all b adjacent to c & not in N' : 12 D(b) = min( D(b), D(c) + c(c,b) ) 15 until all nodes in N'

Page 45: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 45

Dijkstra’s algorithm: example

Step012345

N'u

uxuxy

uxyvuxyvw

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

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

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

D(y),p(y)∞2,x

D(z),p(z)∞ ∞ 4,y4,y4,y

\N’-

vwywzwz

u

yx

wv

z2

2

13

1

1

2

53

5

8 Loop 9 find c not in N' such that D(c) is a minimum 10 add c to N' 11 update D(b) for all b adjacent to c & not in N' : 12 D(b) = min( D(b), D(c) + c(c,b) ) 15 until all nodes in N'

Page 46: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 46

Dijkstra’s algorithm: example

Step012345

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

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

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

D(y),p(y)∞2,x

D(z),p(z)∞ ∞ 4,y4,y4,y

\N’-

vwywzwz-

N'u

uxuxy

uxyvuxyvw

uxyvwz

u

yx

wv

z2

2

13

1

1

2

53

5

8 Loop 9 find c not in N' such that D(c) is a minimum 10 add c to N' 11 update D(b) for all b adjacent to c & not in N' : 12 D(b) = min( D(b), D(c) + c(c,b) ) 15 until all nodes in N'

Page 47: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 47

Dijkstra’s Algorithm

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

Page 48: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 48

Dijkstra’s algorithm: example

u

yx

wv

z

Resulting shortest-path tree from u:

vx

y

w

z

(u,v)(u,x)

(u,x)

(u,x)

(u,x)

destination link

Resulting forwarding table in u:

To remember ! Each node must

have complete knowledge of entire network

Broadcast all link states

Each node constructs its own table

Page 49: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 49

Dijkstra’s algorithm, discussion

Algorithm complexity: n nodes each iteration: need to check all nodes, w, not in N’ n(n+1)/2 comparisons: O(n2)

Oscillations possible: e.g., link cost = amount of carried traffic Here: D, C, and B all send to A

A

D

C

B1 1+e

e0

e

1 1

0 0

A

D

C

B2+e 0

001+e1

A

D

C

B0 2+e

1+e10 0

A

D

C

B2+e 0

001+e1

initially… recompute

routing… recompute … recompute

Page 50: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 50

ECE/CS 372 – introduction to computer networksLecture 15

Announcements:

HW3 is posted and is due next Thursday Lab 4 is posted and is due next Thursday

Acknowledgement: slides drawn heavily from Kurose & Ross

Page 51: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 51

Chapter 4: Network Layer

Introduction

IP: Internet Protocol IPv4 addressing NAT, IPv6

Routing algorithms Link state Distance Vector

Routing in the Internet RIP, OSPF, BGP

Page 52: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 52

Distance Vector Algorithm

Bellman-Ford Equation (dynamic programming)

Definedu(z) := cost of least-cost path from u to z

Then

du(z) = min {c(u,a) + da(z) }

where min is taken over all neighbors a of u

a

u

yx

wv

z2

2

13

1

1

2

53

5

Page 53: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 53

Bellman-Ford example

u

yx

wv

z2

2

13

1

1

2

53

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

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

Node that achieves minimum is nexthop in shortest path ➜ forwarding table

B-F equation says:

Page 54: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 54

Distance Vector (DV) Algorithm Node x knows cost to each neighbor v: c(x,v)

Node x estimates least cost Dx(y) from it to each node y

Node x maintains DV Dx = [Dx(y): y є N ] for all nodes

Node x also maintains its neighbors’ DV For each neighbor v, x maintains

Dv = [Dv(y): y є N ]

Page 55: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 55

Distance vector (DV) algorithmBasic idea: Each node periodically sends its own distance

vector estimate to neighbors

When a node x receives new DV estimate from neighbor, it updates its own DV using B-F equation:

Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N

The estimate Dx(y) will eventually converge to the actual least cost after a number of iterations

Page 56: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 56

Distance Vector (DV) AlgorithmIterative, asynchronous:

each local iteration caused by: local link cost change DV update message from

neighbor

Distributed: each node notifies

neighbors only when its DV changes neighbors then notify their

neighbors if necessary

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

recompute estimates

if DV to any dest has

changed, notify neighbors

Each node:

Page 57: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 57

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

time

x z52

1

y

Initialization

w

3

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

Page 58: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 58

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

time

x z52

1

y

Initialization

Exchange

w

3

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yz

∞ 0 2 1

from

cost to

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

3 2 0 5

3 2 0 5

y broadcasts DVto its neighbors x,w,z

Page 59: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 59

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

time

x z52

1

y

Initialization

Exchange

w

3

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yz

∞ 0 2 1

from

cost to

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

3 2 0 5

3 2 0 5

0 ∞ 3 ∞

w broadcasts DVto its neighbors y

Page 60: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 60

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

time

x z52

1

y

Initialization

Exchange

w

3

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yz

∞ 0 2 1

from

cost to

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

from

cost to

3 2 0 5

3 2 0 5

0 ∞ 3 ∞

∞ 0 2 1

∞ 0 2 1

x broadcasts DVto its neighbors y,z

Page 61: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 61

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

timeInitialization

Exchange

x z52

1

y

w

3

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yz

∞ 0 2 1

from

cost to

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

from

cost to

3 2 0 5

3 2 0 5

0 ∞ 3 ∞

∞ 0 2 1

∞ 0 2 1

z broadcasts DVto its neighbors x,y

∞ 1 5 0

∞ 1 5 0

Page 62: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 62

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

timeInitialization

Exchange

x z52

1

y

w

3

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yz

∞ 0 2 1

from

cost to

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

from

cost to

3 2 0 5

3 2 0 5

0 ∞ 3 ∞

∞ 0 2 1

∞ 0 2 1

All neighbor DVbroadcasts are done

∞ 1 5 0

∞ 1 5 0

Page 63: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 63

∞ 0 2 1

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

timeInitialization

Exchange

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yzfr

om

cost to

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

from

cost to

3 2 0 5

3 2 0 5

0 ∞ 3 ∞

∞ 0 2 1

∞ 0 2 1

∞ 1 5 0

∞ 1 5 0

Update

w x y z

y0 5 3 8

3 2 0 5from

cost to

Dw(x) = min{c(w,y) + Dy(x)} = min{3+2} = 5

Dw(y) = min{c(w,y) + Dy(y)} = min{3+0} = 3Dw(z) = min{c(w,y) + Dy(z)} = min{3+5} = 8

x z52

1

y

w

3

Page 64: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 64

x ∞ ∞ ∞ ∞∞ ∞ ∞ ∞

∞ ∞ ∞ ∞

w x y z

y0 ∞ 3 ∞

∞ ∞ ∞ ∞from

cost to

timeInitialization

Exchange

w x y z

yz

∞ 0 2 1

∞ ∞ ∞ ∞

from

cost to

node xtable

∞ ∞ ∞ ∞

w x y z

w3 2 0 5

from

cost to

node ytable

node wtable

z

w x y z

xy

∞ 1 5 0

∞ ∞ ∞ ∞

from

cost to

node ztable

∞ ∞ ∞ ∞

x

w x y z

y0 ∞ 3 ∞

3 2 0 5from

cost to

w x y z

yz

∞ 0 2 1

from

cost to

w x y z

w3 2 0 5

from

cost to

z

w x y z

xy

∞ 1 5 0

from

cost to

3 2 0 5

3 2 0 5

0 ∞ 3 ∞

∞ 0 2 1

∞ 0 2 1

∞ 1 5 0

∞ 1 5 0

Update

w x y z

y0 5 3 8

3 2 0 5from

cost to

Dx(w) = min{c(x,y) + Dy(w), c(x,z) + Dz(w)}

= min{2+3, 1+∞} = 5

w x y z

yz

5 0 2 1

from

cost to

3 2 0 5

∞ 1 5 0

x z52

1

y

w

3

Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}

= min{2+0, 1+5} = 2

Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)}

= min{2+5, 1+0} = 1

Page 65: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 65

Distance Vector: link cost changes

See what happens when link cost changes:

node detects local link cost change updates routing info, recalculates

distance vector if DV changes, notify neighbors

“goodnews travelsfast”

At time t0, y detects the link-cost change, updates its DV, and informs its neighbors. New Dy(x) = min{c(y,x), c(y,z)+Dz(x)} = min{1,1+5}=1

At time t1, z receives the update from y and updates its DV. It computes a new least cost to x and sends its neighbors its DV.New Dz(x) = min{c(z,x), c(z,y)+Dy(x)} = min{5,1+1} = 2

At time t2, y receives z’s update and updates its DV. New Dy(x) = min{c(y,x), c(y,z)+Dz(x)} = min{1,1+2}=1 (no change!)

y’s least costs do not change and hence y does not send any message to z.

x z14

50

y1

Page 66: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 66

Suppose link cost changes from 4 to 60Initially: Dy(x) = 4 and Dz(x) = 5 (focus on distance from y & z to x) Node y:

detects the change, computes its DV what is the new Dy(x) ?

Dy(x) = min{c(y,x), c(y,z)+Dz(x)} = min{60,1+5}=6 sends its new DV to z

Node z: receives the update from y; w/ new Dy(x) = 6

computes its DV. What is the new Dz(x) ?

Dz(x) = min{c(z,x), c(z,y)+Dy(x)} = min{50,1+6}=7 sends its new DV to y

Node y: receives the update from z; w/ new Dz(x) = 7

computes its DV. what is the new Dy(x) ?

Dy(x) = min{c(y,x), c(y,z)+Dz(x)} = min{60,1+7}=8 sends its new DV to z again

Distance Vector: link cost changes

x z14

50

y60

Dz(x) stored in

y’s DV from aPrevious

update“Dz(x) = 5”Can you

guess what will

happen?

Page 67: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 67

Distance Vector: link cost changes

Solution: Poisoned reverse: If z routes via y to get to x, z tells y its (z’s) distance to

x is infinite (so y won’t route to x via z)

“routing loop” problemy reaches x thru z; z reaches x thru y

x z14

50

y60

“count to infinity” problem!44 iterations before algorithm stabilizes: Imagine what happens if c(z,x) has cost of 10000 instead of

50 !and c(y,x) changes from 4 to 10010

Page 68: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 68

Comparison of LS and DV algorithms

Message complexity LS: with n nodes, E links, O(nE) msgs sent;

each link info should be sent to each node DV: exchange between neighbors only

Speed of Convergence LS: computation grows at O(n2);

= (n-1) + (n-2) + … + 1 = n(n+1)/2 may have oscillations

DV: computation grows at O(n3); = iterated n times at most, each iter. done for n-1 nodes, and for each node minimization must be taken at most

over n-1 alternatives may be routing loops and count-to-infinity problem

Page 69: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 69

Chapter 4: Network Layer

Introduction

IP: Internet Protocol IPv4 addressing NAT, IPv6

Routing algorithms Link state Distance Vector

Routing in the Internet RIP, OSPF, BGP

Page 70: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 70

Routing in Internet: Hierarchical Routing

scale: with 200 million destinations:

can’t store all dest’s in routing tables!

routing table exchange would swamp links!

administrative autonomy

internet = network of networks

each network admin may want to control routing in its own network

Our routing study thus far - idealization all routers identical network “flat”… not true in practice

Page 71: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 71

Hierarchical Routing aggregate routers into regions, “autonomous

systems” (AS)

3b

1d

3a

1c2aAS3

AS1

AS21a

2c2b

1b

Intra-ASRouting algorithm

Inter-ASRouting algorithm

Forwardingtable

3c

Page 72: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 72

Hierarchical Routing

Inter-AS routing Use inter-AS routing

to route across ASes

Across different ASes, routing protocol must be agreed upon

Intra-AS routing routers in same AS

run same routing protocol

routers in different AS can run different intra-AS routing protocol

Page 73: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 73

Routing in the Internet: protocolsIntra-AS routing protocols: also known as Interior Gateway Protocols (IGP) most common Intra-AS routing protocols:

RIP: Routing Information Protocol

OSPF: Open Shortest Path First

IGRP: Interior Gateway Routing Protocol (Cisco proprietary)

Inter-AS routing protocols: BGP (Border Gateway Protocol)

Page 74: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 74

Uses Distance Vector routing

distance vectors: exchanged among neighbors every 30 sec via Response Message (also called advertisement)

each advertisement: list of up to 25 destination nets within AS

RIP ( Routing Information Protocol)

Page 75: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 75

RIP: Example

Destination Network Next Router Num. of hops to dest. w A 2

y B 2 z B 7

x -- 1…. …. ....Routing table in D

w x y

z

A

C

D B

Page 76: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 76

RIP: Example

Destination Network Next Router Num. of hops to dest. w A 2

y B 2 z B 7

x -- 1…. …. ....Routing table in D

w x y

z

A

C

D B

Dest Next hops w - 1 x - 1 z C 4 …. … ...

Advertisementfrom A to D

Page 77: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 77

RIP: Example

Destination Network Next Router Num. of hops to dest. w A 2

y B 2 z B A 7 5

x -- 1…. …. ....Routing table in D

w x y

z

A

C

D B

Dest Next hops w - 1 x - 1 z C 4 …. … ...

Advertisementfrom A to D

Page 78: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 78

RIP: Link Failure and Recovery If no advertisement heard after 180 sec --> neighbor/link will be declared dead

new advertisements sent to neighbors

neighbors in turn send out new advertisements (if tables changed)

link failure info quickly propagates to entire net

poison reverse used to prevent ping-pong loops (infinite distance = 16 hops)

Page 79: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 79

OSPF (Open Shortest Path First)

“open”: publicly available

uses Link State algorithm; i.e., Dijkstra’s algorithm

advertisements disseminated to entire AS via flooding

OSPF messages carried directly over IP (rather than TCP or UDP

Page 80: ECE/CS 372 – introduction to computer networks Lecture 13

Chapter 4, slide: 81

Why different Intra- and Inter-AS routing ?

Policy: Inter-AS: admin wants control over how its traffic

routed, who routes through its net. Intra-AS: single admin, so no policy decisions

needed

Scale: hierarchical routing saves table size, reduced

update trafficPerformance: Intra-AS: can focus on performance Inter-AS: policy may dominate over performance