1 network layer overview ece 256 spring 2008 romit roy choudhury dept. of ece and cs

93
1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

Upload: oswald-martin

Post on 29-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

1

Network Layer Overview

ECE 256 Spring 2008

Romit Roy ChoudhuryDept. of ECE and CS

Page 2: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

2

Communication through Layers and Nodes

Transport segment from sending to receiving host

Segment encapsulated with header at each layer

Datagram routed through intermediate nodes (routers)

Segments do not reach higher layers at intermediate nodes

Segment reaches destination and passed to transport and application layer

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

Page 3: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

3

Routing - Why Difficult ?

Several algorithmic problems: Many many paths - which is the best? Each path has changing characteristics

•Queuing time varies, losses happen, router down …

How do you broadcast (find where someone is) How do you multicast (webTV, conference call) How do routers perform routing at GBbps scale

Several management problems: How do you detect/diagnose faults How do you do pricing, accounting

Page 4: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

4

Two types of Network Architecture

Connection-Oriented and Connection-Less

Virtual Circuit Switching

Example:ATM, X.25Analogy: Telephone

Datagram forwarding

Example: IP networksAnalogy: Postal service

Page 5: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

5

1

23

0111

value in arrivingpacket’s header

routing algorithm

local forwarding tableheader value output link

0100010101111001

3221

Interplay between routing and forwarding

Page 6: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

6

Datagram 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 7: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

7

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 8: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

8

IP Addressing: introduction

IP address: 32-bit identifier for host, router interface

interface: connection between host/router and physical link router’s typically have

multiple interfaces host typically has one

interface IP addresses

associated with each 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 9: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

9

Subnets

IP address: subnet part (high

order bits) host part (low order

bits)

What’s a subnet ? device interfaces

with same subnet part of IP address

can physically reach each other without intervening router

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

network consisting of 3 subnets

subnet

Page 10: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

10

Hierarchical addressing: route aggregation

“Send me anythingwith addresses beginning 200.23.16.0/20”

200.23.16.0/23

200.23.18.0/23

200.23.30.0/23

Fly-By-Night-ISP

Organization 0

Organization 7Internet

Organization 1

ISPs-R-Us“Send me anythingwith addresses beginning 199.31.0.0/16”

200.23.20.0/23Organization 2

...

...

Hierarchical addressing allows efficient advertisement of routing information:

Page 11: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

11

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

Remark: Graph abstraction is useful in other network contexts

Example: P2P, where N is set of peers and E is set of TCP connections

Page 12: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

12

Graph abstraction: costs

u

yx

wv

z2

2

13

1

1

2

53

5What factors influence this cost ?What factors influence this cost ?

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 ?

Routing algorithm: algorithm that finds least-cost path

Should costs be only on links ?Should costs be only on links ?

Page 13: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

13

Routing Algorithm classification

2 main classes:

Centralized all routers have complete topology, link cost info “link state” algorithms

Distributed: Each router knows link costs to neighbor routers only “distance vector” algorithms

Page 14: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

14

A Link-State Routing Algorithm

Dijkstra’s algorithm

Link costs known to all nodes

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

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

Page 15: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

15

Dijkstra’s Algorithm

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

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

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

u

yx

wv

z2

21

3

1

1

2

53

5

Page 16: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

16

Dijkstra’s algorithm: example (2)

u

yx

wv

z

Resulting shortest-path tree from u:

vx

y

w

z

(u,v)(u,x)

(u,x)

(u,x)

(u,x)

destination link

Resulting forwarding table in u:

Page 17: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

17

Distributed: Distance Vector

To find D, node S asks each neighbor X How far X is from D X says C(X,D) Node S deduces C(S,D) = C(S,X) + C(X,D) S chooses neighbor Xi that provides min C(S,D)

Later, Xj may find better route to D

Xj advertizes C(Xj,D) All nodes update their cost to D if new min

found

Page 18: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

18

Distance Vector Algorithm

Bellman-Ford Equation (dynamic programming)

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

Then

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

where min is taken over all neighbors v of x

v

x y

v2

v1

Page 19: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

19

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 20: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

20

Distance Vector: link cost changes

Link cost changes: if DV changes, notify neighbors

x z14

50

y1

At time t0, y detects the link-cost change, updates its DV, and informs its neighbors.

At time t1, z receives the update from y and updates its table. It computes a new least cost to x and sends its neighbors its DV.

At time t2, y receives z’s update and updates its distance table. y’s least costs do not change and hence y does not send any message to z.

When can it get complicated ?When can it get complicated ?

Page 21: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

21

Distance Vector: link cost changes

Link cost changes: Y thinks Z’s best cost is 5 Thus C(y,x) = 5 + 1 = 6 Announces this cost Z thinks C(z,x) = 6 + 1 …

Poissoned reverse: If Z routes through Y to get to X :

Z tells Y its (Z’s) distance to X is infinite (so Y won’t route to X via Z) will this completely solve count to infinity problem?

x z14

50

y60

Food for thought …Will this converge ?

If so, after how many rounds ?How can this be solved?

Should Y announce change from 4 to 60?

Food for thought …Will this converge ?

If so, after how many rounds ?How can this be solved?

Should Y announce change from 4 to 60?

Page 22: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

22

Routing in Internet

Similar to international FedEx routing FedEx figures out best route within country

•Uses google maps say

•This is link state -- All info available

USA FedEx does not have international map, also no permission to operate outside USA Gets price quote from Germany FedEx, Japan

FedEx etc. to route to India Chooses minimum price and handles package to

say Germany (Distance Vector) Germany has country map (link state) Germany asks for cost from Egypt, South Africa …

Page 23: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

23

Internet Routing

Think of each country FedEx as ISPs Routing on internet very similar to prior

example

The link state and DV routing protocols used in internet routing RIP (routing information protocol) OSPF (Open shortest path first) BGP (Border gateway protocol)

They utilize the concepts of Link state Distance vector routing

Page 24: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

24

How is this different in wireless?

Page 25: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

25

Routing in wireless Mobile Networks

Imagine hundreds of hosts moving Routing algorithm needs to cope up with

varying wireless channel and node mobility

Where’s RED guy

Page 26: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

26

Questions ?

Page 27: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

27

Networking Primer - Transport Layer

ECE 256 Spring 2008

Romit Roy ChoudhuryDept. of ECE and CS

Page 28: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

28

Recall 1: PHY and MAC

MAC MAC

PHY PHY

• Spread Spectrum radios (DS and FH)• RTS/CTS and Carrier Sensing for Hidden Terminals• Directional antennas to reduce interference• Rate control to extract max capacity from available SINR• Power control for spatial reuse & energy savings – topology control• TDMA scheduling, multi-channel use, encryption security

… and many more

Page 29: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

29

Recall 2: Network Layer

Routing

• The first view of the network

• Coping up with (uncontrolled) user mobility-Flooding the network reactively, or proactive updation

• Mobile IP, coping with handoffs, etc.

• Ad hoc routing – discovery, optimal metric, maintenance, caching• Secure routing – Routes bypassing malicious nodes

Routing

Routing

Routing

Routing

Page 30: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

30

We have a route, now what ?

TCP

Need to ensure that packets are actually going through Need to ensure that packets are actually going through

TCP

NETWORK

Data

Data

Data

Page 31: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

31

Why need additional layer for that?

Why not ensure that over MAC/Routing?

Page 32: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

32

Some transmission methods

Stop & Wait Pipelined

Go Back N Selective Repeat

Page 33: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

33

Stop-and-wait operation

first packet bit transmitted, t = 0

sender receiver

RTT

last packet bit transmitted, t = L / R

first packet bit arriveslast packet bit arrives, send ACK

ACK arrives, send next packet, t = RTT + L / R

U sender

= .008

30.008 = 0.00027

microseconds

L / R

RTT + L / R =

Page 34: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

34

Pipelined protocols

Pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged pkts range of sequence numbers must be increased buffering at sender and/or receiver

Two generic forms of pipelined protocols: go-Back-N, selective repeat

Page 35: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

35

Pipelining: increased utilization

first packet bit transmitted, t = 0

sender receiver

RTT

last bit transmitted, t = L / R

first packet bit arriveslast packet bit arrives, send ACK

ACK arrives, send next packet, t = RTT + L / R

last bit of 2nd packet arrives, send ACKlast bit of 3rd packet arrives, send ACK

U sender

= .024

30.008 = 0.0008

microseconds

3 * L / R

RTT + L / R =

Increase utilizationby a factor of 3!

Page 36: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

36

Go-Back-N

Sender: k-bit seq # in pkt header “window” of up to N, consecutive unack’ed pkts allowed

ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK” may receive duplicate ACKs (see receiver)

timer for each in-flight pkt timeout(n): retransmit pkt n and all higher seq # pkts in window

Page 37: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

37

GBN inaction

Page 38: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

38

Selective Repeat

receiver individually acknowledges all correctly received pkts buffers pkts, as needed, for eventual in-order

delivery to upper layer

sender only resends pkts for which ACK not received sender timer for each unACKed pkt

sender window N consecutive seq #’s again limits seq #s of sent, unACKed pkts

Page 39: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

39

Selective repeat: sender, receiver windows

Page 40: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

40

Selective repeat in action

Page 41: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

41

Ok, now we know how to ensure reliable transmission end to end

But is that enough?

Page 42: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

42

More Questions

At what rate should we transmit?

Is that rate time/traffic independent?Is that rate receiver independent?

Page 43: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

43

TCP: Connection-Oriented Transport

TCP has 3 main components Reliable transmission Congestion Control Flow Control

Page 44: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

44

The TCP Intuition

Pourwater

Collectwater

Page 45: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

45

The Control Problem

Two main components in TCP Flow Control and Congestion Control

Flow Control If receiver’s bucket filling up, pour less water

Congestion Control Don’t pour too much if there are leaks in intermediate

pipes Regulate your flow based on how much is leaking out

• Aggressive pouring calls for retransmission of lost packets

• Conservative pouring lower e2e capacity

Challenge: At what rate(t) should you pour ?Why ?

Page 46: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

46

The TCP Protocol (in a nutshell)

T transmits few packets, waits for ACK Called slow start

R acknowledges all packet till seq #i by ACK i (optimizations possible) ACK sent out only on receiving a packet Can be Duplicate ACK if expected packet not received

ACK reaches T indicator of more capacity T transmits larger burst of packets (self clocking) … so on Burst size increased until packet drops (i.e., DupACK)

When T gets DupACK or waits for longer than RTO Assumes congestion reduces burst size (congestion

window)

Page 47: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

47

TCP Timeline

Host A

one segment

RTT

Host B

time

two segments

four segments

Think of a blindperson trying tostand up in a lowceiling room

Objective:Don’t bang yourhead, but standup quickly

Think of a blindperson trying tostand up in a lowceiling room

Objective:Don’t bang yourhead, but standup quickly

Page 48: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

48

When waited for > RTO

0

5

10

15

20

25

0 3 6 9 12 15 20 22 25

Time (round trips)

Congestion window

(segments)ssthresh = 8 ssthresh = 10

cwnd = 20

After RTO timeout

Page 49: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

49

The TCP Protocol (in a nutshell)

DupACK not necessarily indicator of congestion Can happen due to out of order (OOO) delivery of packets

If 3 OOO pkts, then CW need not be cut drastically The DupACK packet retransmitted Continue with same pace of transmission as before

(fast recovery)

R advertizes its receiver window in ACKs If filling up, T reduces congestion window

Why ?

Page 50: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

50

Fast Recovery on 3 OOO DupACKs

0123456789

0 2 4 6 8 10 12 14

Time (round trips)

Window size (segments)

Receiver’s advertized window

After fast recovery

Page 51: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

51

Timeout -- function of RTT

Q: how to set TCP timeout value?

longer than RTT but RTT varies

too short: premature timeout unnecessary

retransmissions too long: slow

reaction to segment loss

Q: how to estimate RTT? SampleRTT: measured time

from segment transmission until ACK receipt

SampleRTT will vary, want estimated RTT “smoother” average several recent

measurements, not just current SampleRTT

Page 52: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

52

TCP Round Trip Time and Timeout

EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT

Exponential weighted moving average influence of past sample decreases exponentially fast typical value: = 0.125

Page 53: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

53

Example RTT estimation:

RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

100

150

200

250

300

350

1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106

time (seconnds)

RTT (milliseconds)

SampleRTT Estimated RTT

Page 54: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

54

TCP Round Trip Time and Timeout

Setting the timeout EstimtedRTT plus “safety margin”

large variation in EstimatedRTT -> larger safety margin

first estimate of how much SampleRTT deviates from EstimatedRTT:

TimeoutInterval = EstimatedRTT + 4*DevRTT

DevRTT = (1-)*DevRTT + *|SampleRTT-EstimatedRTT|

(typically, = 0.25)

Then set timeout interval:

Page 55: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

55

When waited for > RTO

0

5

10

15

20

25

0 3 6 9 12 15 20 22 25

Time (round trips)

Congestion window

(segments)ssthresh = 8 ssthresh = 10

cwnd = 20

After RTO timeout

double CongWin every RTT

done by incrementing CongWin

for every ACK received

double CongWin every RTT

done by incrementing CongWin

for every ACK received

Page 56: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

56

The TCP Protocol (in a nutshell)

DupACK not necessarily indicator of congestion Can happen due to out of order (OOO) delivery of packets

If 3 OOO pkts, then CW need not be cut drastically The DupACK packet retransmitted Continue with same pace of transmission as before

(fast recovery)

R advertizes its receiver window in ACKs If filling up, T reduces congestion window Why ?

Page 57: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

57

Fast Recovery on 3 OOO DupACKs

0123456789

0 2 4 6 8 10 12 14

Time (round trips)

Window size (segments)

Receiver’s advertized window

After fast recovery

Page 58: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

58

Why is TCP fair?

Two competing sessions: Additive increase gives slope of 1, as throughout increases multiplicative decrease decreases throughput proportionally

R

R

equal bandwidth share

Connection 1 throughputConnect

ion 2

th

roughput

congestion avoidance: additive increaseloss: decrease window by factor of 2

congestion avoidance: additive increaseloss: decrease window by factor of 2

Page 59: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

59

TCP Flow Control

Problem Definition The receiver has limits on buffer If many nodes transmitting to same receiver

•Losses may happen at receiver

Need to avoid such losses

Solution Receiver tells transmitter how much space left Transmitter chooses its congestion window

accordingly

Page 60: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

60

TCP Flow control: how it works

(Suppose TCP receiver discards out-of-order segments)

spare room in buffer= RcvWindow

= RcvBuffer-[LastByteRcvd - LastByteRead]

Rcvr advertises spare room by including value of RcvWindow in segments

Sender limits unACKed data to RcvWindow guarantees receive

buffer doesn’t overflow

Page 61: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

61

If all that did not make sense, or too heavy for “total recall”, then here is a visual example

Thanks to Nitin Vaidya for tutorial slides(Highly recommended for those interested in TCP)

Page 62: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

62

40 39 3738

3533

Cumulative Acknowledgements

A new cumulative acknowledgement is generated only on receipt of a new in-sequence packet

41 40 3839

35 37

3634

3634

i data acki

Page 63: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

63

Delayed Acknowledgements

An ack is delayed until another packet is received, or delayed ack timer expires (200 ms typical)

Reduces ack traffic

40 39 3738

3533

41 40 3839

35 37

New ack not producedon receipt of packet 36,

but on receipt of 37

Page 64: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

64

Duplicate Acknowledgements

A dupack is generated whenever an out-of-order segment arrives at the receiver

40 39 3738

3634

42 41 3940

36 36

Dupack

(Above example assumes delayed acks)On receipt of 38

Page 65: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

65

Duplicate Acknowledgements

Duplicate acks are not delayed Duplicate acks may be generated when

a packet is lost, or a packet is delivered out-of-order (OOO)

40 39 3837

3634

41 40 3739

36 36

DupackOn receipt of 38

Page 66: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

66

Number of dupacks depends on how much OOO a packet is

40 39 3837

3634

41 40 3739

36 36

Dupack

42 41 3940

36 36 38

New Ack

New AckNew Ack

New Ack

34

New Ack

DupackNew Ack

Page 67: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

67

Several flavors of TCP: combines options / optimizations

Reno, Vegas, Eifel, Westwood …

Overall TCP has worked well – proven on the internet

Then why study it again for wireless networks ?

Page 68: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

68

Why is it different in Wireless?

Page 69: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

69

Questions?

Page 70: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

70

Reliable Transmission

TCP is connection-oriented Sender sends control packets (SYN) and

receiver replies (ACK) Receiver also opens a similar connection

Sender sends a small burst of packets Receiver ACKs: ACK contains the next

expected packet (actually byte) Sender receives ACK, and sends a bigger burst

Called “Self-clocking” behavior

Page 71: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

71

TCP seq. #’s and ACKs

Seq. #’s: byte stream

“number” of first byte in segment’s data

ACKs: seq # of next byte

expected from other side

cumulative ACKQ: how receiver handles

out-of-order segments A: TCP spec

doesn’t say, - up to implementor

Host A Host B

Seq=42, ACK=79, data = ‘C’

Seq=79, ACK=43, data = ‘C’

Seq=43, ACK=80

Usertypes

‘C’

host ACKsreceipt

of echoed‘C’

host ACKsreceipt of

‘C’, echoesback ‘C’

timesimple telnet scenario

Page 72: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

72

Reliable Transmission

If train of packets lost Sender will not get any ACKs Will timeout (gets alarmed) Retransmit from first un-ACK-ed packet, Drastically reduces window size

If packet n lost, but (n+1) successful Receiver will send Duplicate ACK If many DupACKs, then receiver not alarmed Resends (n+1) Cuts window size by half

Page 73: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

73

TCP Connection Management (cont.)

After session over,

Both sender and receiver exchange control signals to terminate the connection

client

FIN

server

ACK

ACK

FIN

close

close

closed

tim

ed w

ait

Page 74: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

74

Congstion Control

Page 75: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

75

TCP Congestion Control

Problem Definition How much data should I pump into the network

to ensure• Intermediate router queues not filling up

•Fairness achieved among multiple TCP flows

Why is this problem difficult? TCP cannot have information about the

network Only TCP receiver can give some feedbacks

Page 76: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

76

The TCP Intuition

Pourwater

Collectwater

Page 77: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

77

The TCP Protocol (in a nutshell)

T transmits few packets, waits for ACK Called slow start

R acknowledges all packet till seq #i by ACK i (optimizations possible) ACK sent out only on receiving a packet Can be Duplicate ACK if expected packet not received

ACK reaches T indicator of more capacity T transmits larger burst of packets (self clocking) … so on Burst size increased until packet drops (i.e., DupACK)

When T gets DupACK or waits for longer than RTO Assumes congestion reduces burst size (congestion

window)

Page 78: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

78

TCP Timeline

Host A

one segment

RTT

Host B

time

two segments

four segments

Think of a blindperson trying tostand up in a lowceiling room

Objective:Don’t bang yourhead, but standup quickly

Think of a blindperson trying tostand up in a lowceiling room

Objective:Don’t bang yourhead, but standup quickly

Page 79: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

79

Timeout -- function of RTT

Q: how to set TCP timeout value?

longer than RTT but RTT varies

too short: premature timeout unnecessary

retransmissions too long: slow

reaction to segment loss

Q: how to estimate RTT? SampleRTT: measured time

from segment transmission until ACK receipt

SampleRTT will vary, want estimated RTT “smoother” average several recent

measurements, not just current SampleRTT

Page 80: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

80

TCP Round Trip Time and Timeout

EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT

Exponential weighted moving average influence of past sample decreases exponentially fast typical value: = 0.125

Page 81: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

81

Example RTT estimation:

RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

100

150

200

250

300

350

1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106

time (seconnds)

RTT (milliseconds)

SampleRTT Estimated RTT

Page 82: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

82

TCP Round Trip Time and Timeout

Setting the timeout EstimtedRTT plus “safety margin”

large variation in EstimatedRTT -> larger safety margin

first estimate of how much SampleRTT deviates from EstimatedRTT:

TimeoutInterval = EstimatedRTT + 4*DevRTT

DevRTT = (1-)*DevRTT + *|SampleRTT-EstimatedRTT|

(typically, = 0.25)

Then set timeout interval:

Page 83: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

83

When waited for > RTO

0

5

10

15

20

25

0 3 6 9 12 15 20 22 25

Time (round trips)

Congestion window

(segments)ssthresh = 8 ssthresh = 10

cwnd = 20

After RTO timeout

double CongWin every RTT

done by incrementing CongWin

for every ACK received

double CongWin every RTT

done by incrementing CongWin

for every ACK received

Page 84: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

84

The TCP Protocol (in a nutshell)

DupACK not necessarily indicator of congestion Can happen due to out of order (OOO) delivery of packets

If 3 OOO pkts, then CW need not be cut drastically The DupACK packet retransmitted Continue with same pace of transmission as before

(fast recovery)

R advertizes its receiver window in ACKs If filling up, T reduces congestion window Why ?

Page 85: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

85

Fast Recovery on 3 OOO DupACKs

0123456789

0 2 4 6 8 10 12 14

Time (round trips)

Window size (segments)

Receiver’s advertized window

After fast recovery

Page 86: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

86

Why is TCP fair?

Two competing sessions: Additive increase gives slope of 1, as throughout increases multiplicative decrease decreases throughput proportionally

R

R

equal bandwidth share

Connection 1 throughputConnect

ion 2

th

roughput

congestion avoidance: additive increaseloss: decrease window by factor of 2

congestion avoidance: additive increaseloss: decrease window by factor of 2

Page 87: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

87

TCP Flow Control

Problem Definition The receiver has limits on buffer If many nodes transmitting to same receiver

•Losses may happen at receiver

Need to avoid such losses

Solution Receiver tells transmitter how much space left Transmitter chooses its congestion window

accordingly

Page 88: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

88

TCP Flow control: how it works

(Suppose TCP receiver discards out-of-order segments)

spare room in buffer= RcvWindow

= RcvBuffer-[LastByteRcvd - LastByteRead]

Rcvr advertises spare room by including value of RcvWindow in segments

Sender limits unACKed data to RcvWindow guarantees receive

buffer doesn’t overflow

Page 89: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

89

Announcements

Reviews: Please send as plain text in email No other data in the review email

Class ppt Almost filling up I need to create some more openings Will discuss this next week

Page 90: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

90

Transport services and protocols

logical communication between processes

transport protocols run in end systems breaks app messages into

segments reassembles segments into

messages, passes to app layer

more than one transport protocol available to apps Internet: TCP and UDP

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 91: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

91

TCP, UDP: transport-layer protocols

reliable, in-order delivery (TCP) congestion control flow control connection setup

unreliable, unordered delivery: UDP no-frills extension of

“best-effort” IP

services not available: delay guarantees bandwidth guarantees

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 92: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

92

Agenda

Transport Layer Multiplexing / Demultiplexing

Reliable Transport Stop-and-wait Pipelined

• Go back N

• Selective Request

TCP Congestion Control Flow Control

Page 93: 1 Network Layer Overview ECE 256 Spring 2008 Romit Roy Choudhury Dept. of ECE and CS

93

Need for Transport Layer

Network Layer offers connections Connections not reliable

•Losses, delays due to out-of-order, queue overflow, …

Transport Layer performs End to end reliability Segmentation / Desegmentation (of app data) Error recovery

Advanced operations Congestion control Flow control