26
1 EE 122: Advanced TCP Ion Stoica TAs: Junda Liu, DK Moon, David Zats http://inst.eecs.berkeley.edu/~ee12 2/fa09 (Materials with thanks to Vern Paxson, Jennifer

EE 122: Advanced TCP

  • Upload
    ardith

  • View
    37

  • Download
    0

Embed Size (px)

DESCRIPTION

EE 122: Advanced TCP. Ion Stoica TAs: Junda Liu, DK Moon, David Zats http://inst.eecs.berkeley.edu/~ee122/fa09 (Materials with thanks to Vern Paxson, Jennifer Rexford, and colleagues at UC Berkeley). Goals of Today’s Lecture. Improved TCP algorithms TCP Throughput Computation. - PowerPoint PPT Presentation

Citation preview

Page 1: EE 122:  Advanced TCP

1

EE 122: Advanced TCP

Ion Stoica

TAs: Junda Liu, DK Moon, David Zatshttp://inst.eecs.berkeley.edu/~ee122/fa09

(Materials with thanks to Vern Paxson, Jennifer Rexford,and colleagues at UC Berkeley)

Page 2: EE 122:  Advanced TCP

2

Goals of Today’s Lecture

Improved TCP algorithms

TCP Throughput Computation

Page 3: EE 122:  Advanced TCP

3

Slow Start/AIMD Pseudocode

Initially:cwnd = 1;ssthresh = infinite;

New ack received:if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1;else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd;

Timeout:/* Multiplicative decrease */ssthresh = cwnd/2;cwnd = 1;

Page 4: EE 122:  Advanced TCP

4

The big picture (with timeouts)

Time

cwnd

Timeout

SlowStart

AIMDTimeout

ssthresh

SlowStart

SlowStart

AIMD

Initially:cwnd = 1;ssthresh = infinite;

New ack received:if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1;else /* Congestion Avoidance */ cwnd = cwnd + 1/cwnd;

Timeout:/* Multiplicative decrease */ssthresh = cwnd/2;cwnd = 1;

Page 5: EE 122:  Advanced TCP

5

Congestion Detection Revisited

Wait for Retransmission Time Out (RTO) RTO kills throughput

In BSD TCP implementations, RTO is usually more than 500ms The granularity of RTT estimate is 500 ms Retransmission timeout is RTT + 4 * mean_deviation

Solution: Don’t wait for RTO to expire

Page 6: EE 122:  Advanced TCP

6

Fast Retransmits

Resend a segment after 3 duplicate ACKs Duplicate ACK means

that an out-of sequence segment was received

Notes: ACKs are for next

expected packet Packet reordering can

cause duplicate ACKs Window may be too

small to get enough duplicate ACKs

ACK 2

segment 1cwnd = 1

cwnd = 2 segment 2segment 3

ACK 4cwnd = 4 segment 4

segment 5segment 6segment 7

ACK 3

3 duplicateACKs

ACK 4

ACK 4

ACK 4

Page 7: EE 122:  Advanced TCP

7

Fast Recovery: After a Fast Retransmit

ssthresh = cwnd / 2 cwnd = ssthresh

Instead of setting cwnd to 1, cut cwnd in half (multiplicative decrease)

For each dup ack arrival dupack++ Indicates packet left network, so we may be able to send more MaxWindow = min(cwnd + dupack, AdvWin)

Receive ack for new data (beyond initial dup ack) dupack = 0 Exit fast recovery

But when RTO expires still do cwnd = 1

Page 8: EE 122:  Advanced TCP

8

Fast Retransmit and Fast Recovery

Retransmit after 3 duplicated acks Prevent expensive timeouts

Reduce slow starts At steady state, cwnd oscillates around the

optimal window size

Time

cwnd

Slow Start

AI/MD

Fast retransmit

Page 9: EE 122:  Advanced TCP

9

TCP Congestion Control Summary

Measure available bandwidth Slow start: fast, hard on network AIMD: slow, gentle on network

Detecting congestion Timeout based on RTT

Robust, causes low throughput Fast Retransmit: avoids timeouts when few packets lost

Can be fooled, maintains high throughput

Recovering from loss Fast recovery: don’t set cwnd=1 with fast retransmits

Page 10: EE 122:  Advanced TCP

10

TCP Flavors

TCP-Tahoe cwnd =1 whenever drop is detected

TCP-Reno cwnd =1 on timeout cwnd = cwnd/2 on dupack

TCP-newReno TCP-Reno + improved fast recovery

TCP-SACK

Page 11: EE 122:  Advanced TCP

11

TCP-SACK

SACK = Selective Acknowledgements

ACK packets identify exactly which packets have arrived

Makes recovery from multiple losses much easier

Page 12: EE 122:  Advanced TCP

12

Standards?

How can all these algorithms coexist?

Don’t we need a single, uniform standard?

What happens if I’m using Reno and you are using Tahoe, and we try to communicate?

Page 13: EE 122:  Advanced TCP

13

TCP Throughput

Assume a drop every k’th RTT (for some large k) w, w+1, w+2, ...w+k-1 DROP (w+k-1)/2, (w+k-1)/2+1,...

ww+1

w+2

w+k-1

(w+k-1)/2

win

do

w

TimeRTT

Page 14: EE 122:  Advanced TCP

14

TCP Throughput (cont’d) In steady state: w= (w+k-1)/2 w=k-1 Average window: (w + w + k -1)/2 = 3*w/2 Total packets between drops: n = w+(w+1)+… +2*w = 3*w*(w+1)/2 Drop probability: p = 1/n = 2/(3*w*(w+1)) ~= 2/(3*w2)

ww+1

w+2

w+k-1

(w+k-1)/2

win

do

w

TimeRTT

Page 15: EE 122:  Advanced TCP

15

TCP Throughput (cont’d) Throughput = average_window/RTT = (3*w/2)/RTT Drop probability: p ~= 2/(3*w2) w = sqrt(2/3p) Throughput ~= (1/RTT)*sqrt(3/2p)

ww+1

w+2

2*w

(w+k-1)/2

win

do

w

TimeRTT

Page 16: EE 122:  Advanced TCP

16

Equation-Based CC

Idea: Forget complicated increase/decrease algorithms Use this equation T(p) directly!

Approach: Measure drop rate (don’t need ACKs for this) Send drop rate p to source Source sends at rate T(p)

Good for streaming audio/video that can’t tolerate the high variability of TCP’s sending rate

Page 17: EE 122:  Advanced TCP

17

5 Minute Break

Questions Before We Proceed?

Page 18: EE 122:  Advanced TCP

18

Cheating

Three main ways to cheat: Increasing cwnd faster than 1 per RTT

Using large initial cwnd

Opening many connections

Page 19: EE 122:  Advanced TCP

19

Increasing cwnd Faster

A Bx

D Ey

Limit rates:x = 2y

C

x

y

x increases by 2 per RTTy increases by 1 per RTT

Page 20: EE 122:  Advanced TCP

20

Increasing cwnd Faster

A Bx

D Ey

0

10

20

30

40

50

60

1 28 55 82 109

136

163

190

217

244

271

298

325

352

379

406

433

460

487

Page 21: EE 122:  Advanced TCP

21

Larger Initial cwndA B

x

D Ey

x starts SS with cwnd = 4y starts SS with cwnd = 1

Page 22: EE 122:  Advanced TCP

22

Open Many Connections

A Bx

D Ey

Assume • A starts 10 connections to B• D starts 1 connection to E• Each connection gets about the same throughput

Then A gets 10 times more throughput than D

Page 23: EE 122:  Advanced TCP

23

Cheating and Game Theory

A Bx

D Ey

22, 22 10, 35

35, 10 15, 15

(x, y)A

Increases by 1

Increases by 5

D Increases by 1 Increases by 5

Individual incentives: cheating paysSocial incentives: better off without cheating

Classic Prisoner Dilemma: resolution depends on accountability

Too aggressiveLosses

Throughput falls

Page 24: EE 122:  Advanced TCP

24

Lossy Links

TCP assumes that all losses are due to congestion

What happens when the link is lossy?

Recall that Tput ~ 1/sqrt(p) where p is loss prob.

This applies even for non-congestion losses

Page 25: EE 122:  Advanced TCP

25

Example

0

10

20

30

40

50

60

1 26 51 76 101 126 151 176 201 226 251 276 301 326 351 376 401 426 451 476

p = 0

p = 1%

p = 10%

Page 26: EE 122:  Advanced TCP

26

Summary

Congestion control critical for avoiding collapse AIMD: Additive Increase, Multiplicative Decrease Congestion detected via packet loss (fail-safe) Slow start to find initial sending rate & to restart after

timeout Spectrum of TCP mechanisms to improve TCP

performance Fast Retransmit (avoid RTO stall) Fast Recovery (full AIMD)