Top Banner
Computer Networks: Architecture and Protocols CS4450 Lecture 23 TCP and Conges3on Control Spring 2018 Rachit Agarwal
91

lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Aug 18, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

ComputerNetworks:ArchitectureandProtocols

CS4450

Lecture23TCPandConges3onControl

Spring2018RachitAgarwal

Page 2: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Recap:WHYsbehindTCPdesign

• Startedfromfirstprinciples

• Correctnessconditionforreliabletransport

• …tounderstandingwhyfeedbackfromreceiverisnecessary(sol-v1)

• …tounderstandingwhytimersmaybeneeded(sol-v2)

• …tounderstandingwhywindow-baseddesignmaybeneeded(sol-v3)

• …tounderstandingwhycumulativeACKsmaybeagoodidea

• VeryclosetomodernTCP

2

Page 3: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Recap:Transportlayer

• Transportlayeroffera“pipe”abstractiontoapplications• Datagoesinoneendofthepipeandemergesfromother

• Pipesarebetweenprocesses,nothosts

• Twobasicpipeabstractions:• Unreliablepacketdelivery(UDP)

• Unreliable(applicationresponsibleforresending)• Messageslimitedtosinglepacket

• Reliablebytestreamdelivery

• Bytesinsertedintopipebysender• Theyemerge,inorderatreceiver(totheapp)

Page 4: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Recap:TransmissionControlProtocol(TCP)

• Reliable,in-orderdelivery• Ensuresbytestream(eventually)arrivesintact

• Inthepresenceofcorruption,delays,reordering,loss

• Connectionoriented• Explicitset-upandtear-downofTCPsession

• Fullduplexstreamofbyteservice

• Sendsandreceivesstreamofbytes,notmessages

• Flowcontrol• Ensuresthesenderdoesnotoverwhelmthereceiver

• Congestioncontrol• Dynamicadaptationtonetworkpath’scapacity

Page 5: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AnyQuestions?

Page 6: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Fromdesigntoimplementation:majornotationchange

• Previouslywefocusedonpackets• Packetshadnumbers

• ACKsreferredtothosenumbers

• Windowsizesexpressedintermsof#ofpackets

• TCPfocusesonbytes,thus• Packetsidentifiedbythebytestheycarry• ACKsrefertothebytesreceived• Windowsizeexpressedintermsof#ofbytes

Page 7: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

BasicComponentsofTCP

• Segments,Sequencenumbers,ACKs

• TCPusesbytesequencenumberstoidentifypayloads

• ACKsreferredtosequencenumbers

• Windowsizesexpressedintermsof#ofbytes

• Retransmissions

• Can’tbecorrectwithoutretransmittinglost/corrupteddata

• TCPretransmitsbasedontimeoutsandduplicateACKs

• TimeoutsbasedonestimateofRTT

• FlowControl

• CongestionControl

Page 8: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Segments,SequenceNumbersandACKs

Page 9: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCP“StreamofBytes”Service

Byte 0Byte 1Byte 2Byte 3

Byte 80

Byte 0Byte 1Byte 2Byte 3

Byte 80

Application @ Host A

Application @ Host B

Page 10: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCP“StreamofBytes”Service

Byte 0Byte 1Byte 2Byte 3

Byte 80

Byte 0Byte 1Byte 2Byte 3

Byte 80

Application @ Host A

Application @ Host B

TCP Data

TCP Data

Segment sent when 1) Segment full (Max Segment Size)2) Not full, but times out

Page 11: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPSegment

• IPPacket• NobiggerthanMaximumTransmissionUnit(MTU)

• E.g.,upto1500byteswithEthernet

• TCPPacket• IPpacketwithaTCPheaderanddatainside• TCPheader>=20byteslong

• TCPSegment

• NomorethanMSS(MaximumSegmentSize)bytes

• E.g.,upto1460consecutivebytesfromthestream

• MSS=MTU-IPheader-TCPheader

IP HdrIP data (datagram)

TCP HdrTCP data (segment)

Page 12: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SequenceNumbers

Host A

K bytes

Sequence number = 1st byte in segment

= ISN + k

Initial Sequence Number (ISN)

TCP DataTCP Hdr

Host B

TCP DataTCP Hdr

ACK Sequence number = next expected byte

= seqno + length(data)

Page 13: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

ACKingandSequenceNumbers

• Sendersendssegments(bytestream)

• DatastartswithInitialSequenceNumber(ISN):X

• PacketcontainsBbytes• X,X+1,X+2,…,X+B-1

• Uponreceiptofasegment,receiversendsanACK

• IfalldatapriortoXalreadyreceived:• ACKacknowledgesX+B(becausethatisnextexpectedbyte)

• IfhighestcontiguousbytereceivedissmallervalueY

• ACKacknowledgesY+1• EvenifthishasbeenACKedbefore

Page 14: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPHeader

Source Port Destination Port

Sequence Number

Acknowledgement

HdrLen

Checksum

Options (variable)

Data

Urgent Pointer

0 Flags Advertised Window

Starting byte offset of data carried in

this segment

Page 15: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPHeader

Source Port Destination Port

Sequence Number

Acknowledgement

HdrLen

Checksum

Options (variable)

Data

Urgent Pointer

0 Flags Advertised Window

Acknowledgement gives sequence

number just beyond highest

sequence number received in order

(“What byte is next”)

Page 16: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPConnectionEstablishment

andInitialSequenceNumbers

Page 17: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

InitialSequenceNumber(ISN)

• Sequencenumberfortheveryfirstbyte

• E.g.,WhynotjustuseISN=0?

• Practicalissue• IPaddressesandport#suniquelyidentifyaconnection• Eventually,though,theseport#sdogetusedagain• …smallchanceanoldpacketisstillinflight

• TCPthereforerequireschangingISN• Setfrom32-bitclockthatticksevery4microseconds

• …onlywrapsaroundonceevery4.55hours

• Toestablishaconnection,hostsexchangeISNs• Howdoesthishelp?

Page 18: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

EstablishingaTCPConnection

• Three-wayhandshaketoestablishconnection• HostAsendsaSYN(open;“synchronizesequencenumbers”)tohostB

• HostBreturnsaSYNacknowledgement(SYNACK)

• HostsendsanACKtoacknowledgetheSYNACK

SYN

ACK

DataData

SYN + ACK

A B

Each host tells its ISN to the other host.

Page 19: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPHeader

Source Port Destination Port

Sequence Number

Acknowledgement

HdrLen

Checksum

Options (variable)

Data

Urgent Pointer

0 Flags Advertised Window

Flags:SYNACKFINRSTPSHURG

See /usr/include/netinet/tcp.h on Unix Systems

Page 20: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Step1:A’sInitialSYNPacket

A’s port B’s port

A’s Initial Sequence Number

(Irrelevant since ACK not set)

5 = 20B

Checksum

Options (variable)

Urgent Pointer

0 Flags Advertised Window

Flags:SYNACKFINRSTPSHURG

A tells B it wants to open a connection…

Page 21: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Step2:B’sSYN-ACKPacket

B’s port A’s port

A’s Initial Sequence Number

ACK = A’s ISN plus 1

20B

Checksum

Options (variable)

Urgent Pointer

0 Flags Advertised Window

Flags:SYNACKFINRSTPSHURG

B tells A it accepts and is ready to hear the next byte…

… upon receiving this packet, A can start sending data

Page 22: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Step3:A’sACKoftheSYN-ACK

A’s port B’s port

A’s Initial Sequence Number

ACK = B’s ISN plus 1

20B

Checksum

Options (variable)

Urgent Pointer

0 Flags Advertised Window

Flags:SYNACKFINRSTPSHURG

A tells B it’s likewise okay to start sending

… upon receiving this packet, B can start sending data

Page 23: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TimingDiagram:3-WayHandshaking

SYN, SeqNum = x

ACK, ACK = y+1

SYN + ACK, SeqNum = y, Ack = x + 1

Active Open Passive OpenClient (initiator) Server

listen()

connect()

accept()

Page 24: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AnyQuestions?

Page 25: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPRetransmission

Page 26: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TwoMechanismsforRetransmissions

• DuplicateACKs

• Timeouts

Page 27: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

LosswithCumulativeACKs

• Sendersendspacketswith100Bandseqnos• 100,200,300,400,500,600,700,800,900

• Assume5thpacket(seqno500)islost,butnoothers

• StreamofACKswillbe

• 200,300,400,500,500,500,500,500

Page 28: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

LosswithCumulativeACKs

• DuplicateACKsareasignofanisolatedloss• ThelackofACKprogressmeans500hasn’tbeendelivered

• StreamofACKsmeanssomepacketsarebeingdelivered

• Therefore,couldtriggerresenduponreceivingkduplicateACKs• TCPusesk=3

• Wewillrevisitthisincongestioncontrol

Page 29: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TimeoutsandRetransmissions

• Reliabilityrequiresretransmittinglostdata

• Involvessettingtimersandretransmittingontimeouts

• TCPonlyhasasingletimer

• TCPresetstimerwhenevernewdataisACKed

• Retxpacketcontaining“nextbyte”whentimerexpires

• RTO(RetransmitTimeOut)isthebasictimeoutvalue

Page 30: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

RTT

SettingtheTimeoutValue(RTO)

1

1

Timeout

Timeout too long -> inefficient

RTT

1

1Timeout

Timeout too short -> duplicate packets

Page 31: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SettingRTOvalue

• Manyideas

• Seebackupslidesforsomeexamples(notneededforexams)

• Implementationsoftenuseacoarser-grainedtimer

• 500msecistypical

• Incurringatimeoutisexpensive

• SowerelyonduplicateACKs

Page 32: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPFlowControl

Page 33: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

FlowControl(SlidingWindow)

• AdvertisedWindow:W

• CansendWbytesbeyondthenextexpectedbyte

• ReceiverusesWtopreventsenderfromoverflowingbuffer

• Limitsnumberofbytessendercanhaveinflight

Page 34: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPHeader

Source Port Destination Port

Sequence Number

Acknowledgement

HdrLen

Checksum

Options (variable)

Data

Urgent Pointer

0 Flags Advertised Window

Page 35: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

ImplementingSlidingWindow

• Sendermaintainsawindow

• DatathathasbeensentoutbutnotyetACK’ed

• Leftedgeofwindow:• Beginningofunacknowledgeddata• MoveswhendataisACKed

• Windowsize=maximumamountofdatainflight

• Receiversetsthisamount,basedonitsavailablebufferspace

• Ifithasnotyetsentdatauptotheapp,thismightbesmall

Page 36: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AdvertisedWindowLimitsRate

• SendercansendnofasterthanW/RTTbytes/sec

• InoriginalTCP,thatwasthesoleprotocolmechanismcontrolling

sender’srate

• What’smissing?

• CongestioncontrolabouthowtoadjustWtoavoidnetworkcongestion

Page 37: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AnyQuestions?

Page 38: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPCongestionControl

Page 39: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPcongestioncontrol:high-levelidea

• Endhostsadjustsendingrate

• Basedonimplicitfeedbackfromthenetwork

• Implicit:routerdropspacketsbecauseitsbufferoverflows,notbecauseit’stryingtosendmessage

• Hostsprobenetworktotestlevelofcongestion• Speedupwhennocongestion(i.e.,nopacketdrops)• Slowdownwhenwhencongestion(i.e.,packetdrops)

• Howtodothisefficiently?• ExtendTCP’sexistingwindow-basedprotocol…• Adaptthewindowsizebasedinresponsetocongestion

Page 40: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AllTheseWindows…

• Flowcontrolwindow:AdvertisedWindow(RWND)

• Howmanybytescanbesentwithoutoverflowingreceiversbuffers

• Determinedbythereceiverandreportedtothesender

• CongestionWindow(CWND)

• Howmanybytescanbesentwithoutoverflowingrouters

• Computedbythesenderusingcongestioncontrolalgorithm

• Sender-sidewindow=minimum{CWND,RWND}

• AssumeforthislecturethatRWND>>CWND

Page 41: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Note

• ThislecturewilltalkaboutCWNDinunitsofMSS

• RecallMSS:MaximumSegmentSize,theamountofpayloaddata

inaTCPpacket

• Thisisonlyforpedagogicalpurposes

• KeepinmindthatrealimplementationsmaintainCWNDinbytes

Page 42: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

BasicsofTCPCongestion

• CongestionWindow(CWND)

• Maximum#ofunacknowledgedbytestohaveinflight

• Rate~CWND/RTT

• Adaptingthecongestionwindow• Increaseuponlackofcongestion:optimisticexploration

• Decreaseupondetectingcongestion

• Buthowdoyoudetectcongestion?

Page 43: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

NotAllLossestheSame

• DuplicateACKs:isolatedloss• StillgettingACKs

• Timeout:possibledisaster

• NotenoughduplicateACKs• Musthavesufferedseverallosses

Page 44: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

HowtoAdjustCWND?

• Consequencesofover-sizedwindowmuchworsethanhavinganunder-sizedwindow

• Over-sizedwindow:packetsdroppedandretransmitted

• Under-sizedwindow:somewhatlowerthroughput

• Approach• Gentleincreasewhenun-congested(exploration)• Rapiddecreasewhencongested

Page 45: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AdditiveIncrease,MultiplicativeDecrease(AIMD)

• Additiveincrease• Onsuccessoflastwindowofdata,increasebyoneMSS

• IfWpacketsinarowhavebeenACKed,increaseWbyone

• i.e.,+1/WperACK

• Multiplicativedecrease

• OnlossofpacketsbyDupACKs,dividecongestionwindowbyhalf• Specialcase:whentimeout,reducecongestionwindowtooneMSS

Page 46: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AIMD

• ACK:CWND->CWND+1/CWND

• WhenCWNDismeasuredinMSS

• Note:afterafullwindow,CWNDincreaseby1MSS

• Thus,CWNDincreasesby1MSSperRTT

• 3rdDupACK:CWND->CWND/2

• Specialcaseoftimeout:CWND->1MSS

Page 47: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

LeadstotheTCPSawtooth

Loss

Halved

Window

t

Page 48: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AnyQuestions?

Page 49: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SlowStart

Page 50: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

AIMDStartsTooSlowlyWindow

tIt could take a long time to get started!

Need to start with a small CWND to avoid overloading the network

Page 51: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

BandwidthDiscoverywithSlowStart

• Goal:estimateavailablebandwidth

• Startslow(forsafety)• Butrampupquickly(forefficiency)

• Consider• RTT=100ms,MSS=1000bytes

• Windowsizetofill1MbpsofBW=12.5MSS

• Windowsizetofill1Gbps=12,500MSS

• WithjustAIMD,ittakesabout12500RTTstogettothis

windowsize!

• ~21mins

Page 52: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

“SlowStart”Phase

• Startwithasmallcongestionwindow

• Initially,CWNDis1MSS

• So,initialsendingrateisMSS/RTT

• Thatcouldbeprettywasteful• Mightbemuchlessthantheactualbandwidth

• Linearincreasetakesalongtimetoaccelerate

• Slow-startphase(actually“faststart”)• Senderstartsataslowrate(hencethename)

• …butincreasesexponentiallyuntilfirstloss

Page 53: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SlowStartinAction

Src

Dst

1 2 3 4 8

Double CWND per round-trip time

Simple implementation: on each ACK, CWND += MSS

D A D AD A DA

DA

DA

DA

Page 54: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SlowStartandtheTCPSawtoothWindow

tExponential “slow start”

Why is it called slow-start? Because TCP originally had no congestion control mechanism. The source would just start by sending a whole window’s worth of data.

Page 55: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Slow-StartvsAIMD

• WhendoesasenderstopSlow-StartandstartAdditiveIncrease?

• Introducea“slowstartthreshold”(ssthresh)• Initializedtoalargevalue• Ontimeout,ssthresh=CWND/2

• WhenCWND>ssthresh,senderswitchesfromslow-starttoAIMD-style

increase

Page 56: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Timeouts

Page 57: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

LossDetectedbyTimeout

• SenderstartsatimerthatrunsforRTOseconds

• RestarttimerwheneverACKfornewdataarrives

• Iftimerexpires

• SetSSHTHRESH<-CWND/2(“SlowStartThreshold”)

• SetCWND<-1(MSS)

• Retransmitfirstlostpacket

• ExecuteSlowStartuntilCWND>SSTHRESH

• AfterwhichswitchtoAdditiveIncrease

Page 58: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SummaryofIncrease

• “Slowstart”:increaseCWNDby1(MSS)foreachACK

• Afactorof2perRTT

• Leaveslow-startregimewheneither:

• CWND>SSTHRESH

• Packetdropdetectedbydupacks

• EnterAIMDregime

• Increaseby1(MSS)foreachwindow’sworthofACKeddata

Page 59: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SummaryofDecrease

• CutCWNDhalfonlossdetectedbydupacks

• Fastretransmittoavoidoverreacting

• CutCWNDallthewayto1(MSS)ontimeout

• SetssthreshtoCWND/2

• NeverdropCWNDbelow1(MSS)

• Ourcorrectnesscondition:alwaystrytomakeprogress

Page 60: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPCongestionControlDetails

Page 61: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Implementation

• Stateatsender• CWND(initializedtoasmallconstant)

• ssthresh(initializedtoalargeconstant)• dupACKcount• Timer,asbefore

• Eventsatsender• ACK(newdata)• dupACK(duplicateACKforolddata)• Timeout

• Whataboutreceiver?JustsendACKsuponarrival

Page 62: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Event:ACK(newdata)

• Ifinslowstart• CWND+=1 CWND packets per RTT

Hence after one RTT with no drops:

CWND = 2 x CWND

Page 63: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Event:ACK(newdata)

• IfCWND<=ssthresh

• CWND+=1

• Else• CWND=CWND+1/CWND

CWND packets per RTTHence after one RTT with

no drops:CWND = CWND + 1

Slow Start Phase

Congestion Avoidance Phase(additive increase)

Page 64: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Event:Timeout

• OnTimeout

• ssthresh<-CWND/2

• CWND<-1

Page 65: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Event:dupACK

• dupACKcount++

• IfdupACKcount=3/*fastretransmit*/

• ssthresh<-CWND/2

• CWND<-CWND/2

Remains in congestion avoidance after fast

retransmission

Page 66: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TimeDiagramWindow

tSlow start in operation until it

reached half of previous CWND, i.e., SSThresh

Slow-start restart: Go back to CWND of 1 MSS, but take advantage of knowing the previous value of CWND.

Fast Retransmission Timeout SSThresh Set to here

Page 67: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPFlavors

• TCPTahoe• CWND=1ontripledupACK

• TCPReno• CWND=1ontimeout

• CWND=CWND/2ontripledupACK

• TCP-newReno• TCP-Reno+improvedfastrecovery

• TCP-SACK• Incorporatesselectiveacknowledgements

Our default assumption

Page 68: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Done!

Nextlecture:CriticalAnalysisofTCP

Page 69: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPBackupslides

Page 70: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

CouldBaseRTOonRTTEstimation

• UseexponentialaveragingifRTTsamples

SampleRTT = AckRcvdTime - SendPktTimeEstimatedRTT = ⍺ x EstimatedRTT + (1-⍺) x SampledRTT

0 < ⍺ <= 1

EstimatedRTT

Time

SampleRTT

Page 71: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

ExponentialAveragingExample

EstimatedRTT = ⍺ x EstimatedRTT + (1-⍺) x SampledRTT (Assume RTT is constant => SampleRTT = RTT)

RTT

time0 1 2 3 4 5 6 7 8 9

EstimatedRTT (α = 0.8)

EstimatedRTT (α = 0.5)

Page 72: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

ExponentialAveraginginAction

Set Timeout Estimate (ETO) = 2 x EstimatedRTT

From Jacobson and Karels, SIGCOMM 1988

Page 73: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Jacobson/KarelsAlgorithm

• Problem:needtobettercapturevariabilityinRTT

• Directlymeasuredeviation

• Deviation=|SampleRTT-EstimatedRTT|

• EstimatedDeviation:exponentialaverageofDeviation

• ETO=EstimatedRTT+4xEstimatedDeviation

Page 74: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

WithJacobson/Karels

Page 75: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Problem:AmbiguousMeasurements

• HowdowedifferentiatebetweentherealACK,andACKoftheretransmittedpacket?

Sampled RTT

Original TransmissionSampled

RTT

Retransmission

Original Transmission

RetransmissionACK

ACK

Page 76: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPTimers

• Twoimportantquantities

• RTO:valueyousettimertofortimeouts

• ETO:currentestimateofappropriate“raw”timeout

• Useexponentialaveragingtoestimate

• RTT• Deviation=|EstimatedRTT-SampleRTT|

• ETO=EstimatedRTT+4xEstimatedDeviation

Page 77: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

UseOnly“Clean”SamplesforETO

• OnlyupdateETOwhenyougetacleansample

• WherecleanmeansACKincludesnoretransmittedsegments

Page 78: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Example

• Send100,200,300• 100meanspacketwhosefirstbyteis100,lastbyteis199

• ReceiveA200• A200meansbytesupto199rep’d,expecting200next

• Cleansample

• 200timesout,resend200,receiveA300

• Nocleansamples

• Send400,500,receiveA600• Cleansamples

Page 79: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

SettingRTO

• EverytimeRTOtimerexpires,setRTO<-2.RTO

• Uptomaximum>=60sec

• EverytimecleansamplearrivessetRTOtoETO

Page 80: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Example

• FirstarrivingACKexpects100(adv.window=500)• InitializeETP;RTO=ETO• RestarttimerforRTOseconds(newdataACK’ed)

• RememberTCPonlyhasonetimer,nottimerperpacket

• Sendpackets100,200,300,400and500

• ArrivingACKexpects300(A300)• UpdateETO;RTO=ETO• RestarttimerforRTOseconds(newdataACKed)

• Sendpackets600,700

• ArrivingACKexpects300(A300)

Page 81: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Example(cont’d)

• Timergoesoff

• RTO=2*RTO(backofftimer)

• RestarttimerforRTOseconds(ithadexpired)

• Resendpacket300

• ArrivingACKexpects800• Don’tupdateETO(ACKincludesaretransmission)

• RestarttimerforRTOseconds(newdataACKed)

• Sendpackets800,900,1000,1100,1200

Page 82: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Example(cont’d)

• ArrivingACKexpects1000• UpdatesETO;RTO=ETO• RestarttimerforRTOseconds(newdataACKed)

• Sendpackets1300,1400

• …Connectioncontinues…

Page 83: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Example

• ConsideraTCPconnectionwith:• CWND=10packets

• LastACKwasforpacket#101• i.e.,receiverexpectingnextpackettohaveseqno101

• 10packets[101,102,103,…,110]areinflight• Packet101isdropped• WhatACKsdotheygenerate?

• Andhowdoesthesenderrespond?

Page 84: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Timeline

• ACK101(dueto102)CWND=10dupACK#1(noxmit)

• ACK101(dueto103)CWND=10dupACK#2(noxmit)

• ACK101(dueto104)CWND=10dupACK#3(noxmit)

• RETRANSMIT101ssthresh=5CWND=5

• ACK101(dueto105)CWND=5(noxmit)

• ACK101(dueto106)CWND=5(noxmit)

• ACK101(dueto107)CWND=5(noxmit)

• ACK101(dueto108)CWND=5(noxmit)

• ACK101(dueto109)CWND=5(noxmit)

• ACK101(dueto110)CWND=5(noxmit)

• ACK111(dueto101)<-onlynowcanwetransmitnewpackets

• PlusnopacketsinflightsonoACKsforanotherRTT

Note that you do not restart dupACKcounter

on same packet!

Page 85: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Solution:FastRecovery

• Idea:Grantthesendertemporary“credit”foreachdupACKsoasto

keeppacketsinflight(eachACKduetoarrivingpkt)

• IfdupACKcount=3• ssthresh=CWND/2

• CWND=ssthresh+3

• Whileinfastrecovery

• CWND=CWND+1foreachadditionalduplicatepet

• ExitfastrecoveryafterreceivingnewACK• SetCWND=ssthresh(whichhadbeensettoCWND/2afterloss)

Page 86: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Example

• ConsideraTCPconnectionwith:• CWND=10packets

• LastACKwasforpacket#101• i.e.,receiverexpectingnextpackettohaveseqno101

• 10packets[101,102,103,…,110]areinflight• Packet101isdropped

Page 87: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

Timeline

• ACK101(dueto102)CWND=10dupACK#1(noxmit)

• ACK101(dueto103)CWND=10dupACK#2(noxmit)

• ACK101(dueto104)CWND=10dupACK#3(noxmit)

• RETRANSMIT101ssthresh=5CWND=8(5+3)

• ACK101(dueto105)CWND=9(noxmit)

• ACK101(dueto106)CWND=10(noxmit)

• ACK101(dueto107)CWND=11(xmit111)

• ACK101(dueto108)CWND=12(xmit112)

• ACK101(dueto109)CWND=13(xmit113)

• ACK101(dueto110)CWND=14(xmit114)

• ACK111(dueto101)CWND=5(xmit115)<-exitingfastrecovery

• Packets111-114alreadyinflight(andnotsending115)• ACK112(dueto111)CWND=5+1/5<-backtocongestionavoidance

Page 88: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCP“Phases”

• Slow-start• Enterontimeout

• LeavewhenCWND>ssthresh(toCong.Avoid.)

• The>onlyapplieshere…

• CongestionAvoidance• Leavewhentimeout

• Fastrecovery• EnterwhendupACK=3• LeavewhenNewACKorTimeout

Page 89: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPStateMachine

congestn. avoid.

fast recovery

slow start

Timeout

CWND > ssthresh

Timeout

Timeoutnew ACK

dupACK=3 dupACK=3

new ACK

dupACK

dupACK

new ACK

dupACK

Page 90: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPStateMachine

congestn. avoid.

fast recovery

slow start

Timeout

CWND > ssthresh

Timeout

Timeoutnew ACK

dupACK=3 dupACK=3

new ACK

dupACK

dupACK

new ACK

dupACK

Page 91: lecture23-congestion-control - Cornell University€¦ · TCP congestion control: high-level idea • End hosts adjust sending rate • Based on implicit feedback from the network

TCPStateMachine

congestn. avoid.

fast recovery

slow start

Timeout

CWND > ssthresh

Timeout

Timeoutnew ACK

dupACK=3 dupACK=3

new ACK

dupACK

dupACK

new ACK

dupACK