professor yashar ganjali department of computer …yganjali/resources/course... · professor yashar...

44
Professor Yashar Ganjali Department of Computer Science University of Toronto [email protected] http://www.cs.toronto.edu/~yganjali

Upload: lediep

Post on 22-Mar-2018

228 views

Category:

Documents


3 download

TRANSCRIPT

ProfessorYasharGanjaliDepartmentofComputerScienceUniversityofToronto

[email protected]://www.cs.toronto.edu/~yganjali

Announcements� ProblemSet2

� Willbepostednextweek� Due:Nov.18th at5pm� Submitelectronicallyasps2.pdf

� ProgrammingAssignment2� Postedonclasswebsite� Due:Dec.2nd at5pm

CSC458/CSC2209– ComputerNetworks 2UniversityofToronto– Fall2016

Announcements� ProblemSet1

� Markshavebeenemailedtoyou� PleasecontactJosephforremarkrequests

� Midterm� Willbemarkedtomorrow.� AnemailwillbesenttoyourCDFaccount.� Youcanpickupthepapersduringthenextlecture.

CSC458/CSC2209– ComputerNetworks 3UniversityofToronto– Fall2016

Today’sLecture� Principlesofcongestioncontrol

� Learningthatcongestionisoccurring� Adaptingtoalleviatethecongestion

� TCPcongestioncontrol� Additive-increase,multiplicative-decrease� Slowstartandslow-startrestart

� RelatedTCPmechanisms� Nagle’salgorithmanddelayedacknowledgments

� ActiveQueueManagement(AQM)� RandomEarlyDetection(RED)� ExplicitCongestionNotification(ECN)

CSC458/CSC2209– ComputerNetworks 4UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 5UniversityofToronto– Fall2016

WhatisCongestion?

H1

H2

R1 H3

A1(t)10Mb/s

D(t)1.5Mb/s

A2(t)100Mb/s

A1(t)

A2(t)X(t)

D(t)

A1(t)

A2(t)

D(t)

X(t)

Cumulativebytes

t

FlowControlvs.CongestionControl� Flowcontrol

� Keepingonefastsenderfromoverwhelmingaslowreceiver

� Congestioncontrol� Keepasetofsendersfromoverloadingthenetwork

� Differentconcepts,butsimilarmechanisms� TCPflowcontrol:receiverwindow� TCPcongestioncontrol:congestionwindow� TCPwindow:min{congestionwindow,receiverwindow}

CSC458/CSC2209– ComputerNetworks 6UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 7UniversityofToronto– Fall2016

TimeScalesofCongestionToomanyusersusingalinkduringapeakhour

TCPflowsfillingupallavailablebandwidth

Twopacketscollidingatarouter– alsoreferredtoascontention

7:00 8:00 9:00

1s 2s 3s

100µs 200µs 300µs

CSC458/CSC2209– ComputerNetworks 8UniversityofToronto– Fall2016

DealingwithCongestionExample:twoflowsarrivingatarouter

StrategyDroponeoftheflows

Bufferoneflowuntiltheotherhasdeparted,thensendit

Re-Scheduleoneofthetwoflowsforalatertime

Askbothflowstoreducetheirrates

R1?

A1(t)

A2(t)

CongestionisUnavoidable� Twopacketsarriveatthesametime

� Thenodecanonlytransmitone� …andeitherbufferordroptheother

� Ifmanypacketsarriveinashortperiodoftime� Thenodecannotkeepupwiththearrivingtraffic� …andthebuffermayeventuallyoverflow

CSC458/CSC2209– ComputerNetworks 9UniversityofToronto– Fall2016

ArguablyCongestionisGood!� Weusepacketswitchingbecauseitmakesefficientuseofthelinks.Therefore,buffersintheroutersarefrequentlyoccupied.

� Ifbuffersarealwaysempty,delayislow,butourusageofthenetworkislow.

� Ifbuffersarealwaysoccupied,delayishigh,butweareusingthenetworkmoreefficiently.

� Sohowmuchcongestionistoomuch?

CSC458/CSC2209– ComputerNetworks 10UniversityofToronto– Fall2016

CongestionCollapse� Definition:Increaseinnetworkloadresultsinadecreaseofusefulworkdone

� Manypossiblecauses� Spuriousretransmissionsofpacketsstillinflight

� Classicalcongestioncollapse� Solution:bettertimersandTCPcongestioncontrol

� Undeliveredpackets� Packetsconsumeresourcesandaredroppedelsewhereinnetwork

� Solution:congestioncontrolforALLtraffic

CSC458/CSC2209– ComputerNetworks 11UniversityofToronto– Fall2016

WhatDoWeWant,Really?� Highthroughput

� Throughput:measuredperformanceofasystem� E.g.,numberofbits/secondofdatathatgetthrough

� Lowdelay� Delay:timerequiredtodeliverapacketormessage� E.g.,numberofmsectodeliverapacket

� Thesetwometricsaresometimesatodds� E.g.,supposeyoudrivealinkashardaspossible� …then,throughputwillbehigh,butdelaywillbe,too

CSC458/CSC2209– ComputerNetworks 12UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 13UniversityofToronto– Fall2016

Load,Delay,andPower

AveragePacketdelay

Load

Typicalbehaviorofqueuingsystemswithrandomarrivals:

Power

Load

Asimplemetricofhowwellthenetworkisperforming:

LoadPowerDelay

=

“optimalload”

Goal: maximize power

Fairness� Effectiveutilizationisnottheonlygoal

� Wealsowanttobefairtothevariousflows� …butwhattheheckdoesthatmean?

� Simpledefinition:equalsharesofthebandwidth� Nflowsthateachget1/Nofthebandwidth?� But,whatiftheflowstraversedifferentpaths?

CSC458/CSC2209– ComputerNetworks 14UniversityofToronto– Fall2016

ResourceAllocationvs.CongestionControl� Resourceallocation

� Hownodesmeetcompetingdemandsforresources� E.g.,linkbandwidthandbufferspace� Whentosayno,andtowhom

� Congestioncontrol� Hownodespreventorrespondtooverloadconditions� E.g.,persuadehoststostopsending,orslowdown� Typicallyhasnotionsoffairness(i.e.,sharingthepain)

CSC458/CSC2209– ComputerNetworks 15UniversityofToronto– Fall2016

SimpleResourceAllocation� Simplestapproach:FIFOqueueanddrop-tail� Linkbandwidth:first-infirst-outqueue

� Packetstransmittedintheordertheyarrive

� Bufferspace:drop-tailqueuing� Ifthequeueisfull,droptheincomingpacket

CSC458/CSC2209– ComputerNetworks 16UniversityofToronto– Fall2016

SimpleCongestionDetection� Packetloss

� Packetgetsdroppedalongtheway� Packetdelay

� Packetexperienceshighdelay

� HowdoesTCPsenderlearnthis?� Loss

� Timeout� Triple-duplicateacknowledgment

� Delay� Round-triptimeestimate

CSC458/CSC2209– ComputerNetworks 17UniversityofToronto– Fall2016

OptionsforCongestionControl� Implementedbyhostversusnetwork� Reservation-based,versusfeedback-based� Window-basedversusrate-based.

CSC458/CSC2209– ComputerNetworks 18UniversityofToronto– Fall2016

TCPCongestionControl� TCPimplementshost-based,feedback-based,window-basedcongestioncontrol.

� TCPsourcesattemptstodeterminehowmuchcapacityisavailable

� TCPsendspackets,thenreactstoobservableevents(loss).

CSC458/CSC2209– ComputerNetworks 19UniversityofToronto– Fall2016

IdeaofTCPCongestionControl� Eachsourcedeterminestheavailablecapacity

� …soitknowshowmanypacketstohaveintransit� Congestionwindow

� Maximum#ofunacknowledgedbytestohaveintransit� Thecongestion-controlequivalentofreceiverwindow� MaxWindow=min{congestionwindow,receiverwindow}� Sendattherateoftheslowestcomponent:receiverornetwork

� Adaptingthecongestionwindow� Decreaseuponlosingapacket:backingoff� Increaseuponsuccess:optimisticallyexploring

CSC458/CSC2209– ComputerNetworks 20UniversityofToronto– Fall2016

AdditiveIncrease,MultiplicativeDecrease� Howmuchtoincreaseanddecrease?

� Increaselinearly,decreasemultiplicatively� AnecessaryconditionforstabilityofTCP� Consequencesofover-sizedwindowaremuchworsethanhavinganunder-sizedwindow� Over-sizedwindow:packetsdroppedandretransmitted� Under-sizedwindow:somewhatlowerthroughput

� Multiplicativedecrease� Onlossofpacket,dividecongestionwindowinhalf

� Additiveincrease� Onsuccessforlastwindowofdata,increaselinearly

CSC458/CSC2209– ComputerNetworks 21UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 22UniversityofToronto– Fall2016

AdditiveIncrease

D A D D A A D D A AD A

Src

Dest

Actually,TCPusesbytes,notsegmentstocount:WhenACKisreceived:

MSScwnd MSScwndæ ö+ = ç ÷è ø

CSC458/CSC2209– ComputerNetworks 23UniversityofToronto– Fall2016

LeadstotheTCP“Sawtooth”

t

Window

halved

Loss

CSC458/CSC2209– ComputerNetworks 24UniversityofToronto– Fall2016

RuleforadjustingW• IfanACKisreceived: W←W+1/W• Ifapacketislost: W←W/2

CongestionWindowEvolution

OnlyW packetsmaybeoutstanding

CSC458/CSC2209– ComputerNetworks 25UniversityofToronto– Fall2016

CongestionWindowEvolution

PracticalDetails� Congestionwindow

� Representedinbytes,notinpackets(Why?)� PacketshaveMSS(MaximumSegmentSize)bytes

� Increasingthecongestionwindow� IncreasebyMSSonsuccessforlastwindowofdata� Inpractice,increaseafractionofMSSperreceivedACK

� #packetsperwindow:CWND/MSS� IncrementperACK:MSS*(MSS/CWND)

� Decreasingthecongestionwindow� Neverdropcongestionwindowbelow1MSS

CSC458/CSC2209– ComputerNetworks 26UniversityofToronto– Fall2016

TCPSendingRate� WhatisthesendingrateofTCP?� AcknowledgementforsentpacketisreceivedafteroneRTT

� AmountofdatasentuntilACKisreceivedisthecurrentwindowsizeW

� ThereforesendingrateisR=W/RTT

� IstheTCPsendingratesawtoothshapedaswell?

CSC458/CSC2209– ComputerNetworks 27UniversityofToronto– Fall2016

TCPSendingRateandBuffers

CSC458/CSC2209– ComputerNetworks 28UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 29UniversityofToronto– Fall2016

GettingStarted

t

Window

But,couldtakealongtimetogetstarted!

NeedtostartwithasmallCWNDtoavoidoverloadingthenetwork.

“SlowStart”Phase� Startwithasmallcongestionwindow

� Initially,CWNDis1MSS� So,initialsendingrateisMSS/RTT

� Thatcouldbeprettywasteful� Mightbemuchlessthantheactualbandwidth� Linearincreasetakesalongtimetoaccelerate

� Slow-startphase(really“faststart”)� Senderstartsataslowrate(hencethename)� …butincreasestherateexponentially� …untilthefirstlossevent

CSC458/CSC2209– ComputerNetworks 30UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 31UniversityofToronto– Fall2016

SlowStartinAction

DoubleCWNDperround-triptime=

IncreaseCWNDby1foreachACKreceived

D A D D A A D D

A A

D

A

Src

Dest

D

A

1 2 4 8

CSC458/CSC2209– ComputerNetworks 32UniversityofToronto– Fall2016

SlowStartandtheTCPSawtooth

Loss

Exponential“slowstart” t

Window

Whyisitcalledslow-start?BecauseTCPoriginallyhadnocongestioncontrolmechanism.Thesourcewouldjust

startbysendingawholewindow’sworthofdata.

TwoKindsofLossinTCP� TripleduplicateACK

� Packetnislost,butpacketsn+1,n+2,etc.arrive� Receiversendsduplicateacknowledgments� …andthesenderretransmitspacketnquickly� Doamultiplicativedecreaseandkeepgoing

� Timeout� Packetnislostanddetectedviaatimeout� E.g.,becauseallpacketsinflightwerelost� Afterthetimeout,blastingawayfortheentireCWND� …wouldtriggeraverylargeburstintraffic� So,bettertostartoverwithalowCWND

CSC458/CSC2209– ComputerNetworks 33UniversityofToronto– Fall2016

CSC458/CSC2209– ComputerNetworks 34UniversityofToronto– Fall2016

RepeatingSlowStartAfterTimeout

t

Window

Slow-startrestart:GobacktoCWNDof1,buttakeadvantageofknowingthepreviousvalueofCWND.

Slowstartinoperationuntilitreacheshalfofprevious

cwnd.

timeout

RepeatingSlowStartAfterIdlePeriod� SupposeaTCPconnectiongoesidleforawhile

� E.g.,Telnetsessionwhereyoudon’ttypeforanhour� Eventually,thenetworkconditionschange

� Maybemanymoreflowsaretraversingthelink� E.g.,maybeeverybodyhascomebackfromlunch!

� Dangeroustostarttransmittingattheoldrate� Previously-idleTCPsendermightblastthenetwork� …causingexcessivecongestionandpacketloss

� So,someTCPimplementationsrepeatslowstart� Slow-startrestartafteranidleperiod

CSC458/CSC2209– ComputerNetworks 35UniversityofToronto– Fall2016

OtherTCPMechanisms� Nagle’sAlgorithmandDelayedACK

CSC458/CSC2209– ComputerNetworks 36UniversityofToronto– Fall2016

MotivationforNagle’sAlgorithm� Interactiveapplications

� Telnet,ssh andrlogin� Generatemanysmallpackets(e.g.,keystrokes)

� Smallpacketsarewasteful� Mostlyheader(e.g.,40bytesofheader,1ofdata)

� Appealingtoreducethenumberofpackets� Couldforceeverypackettohavesomeminimumsize� …but,whatifthepersondoesn’ttypemorecharacters?

� Needtobalancecompetingtrade-offs� Sendlargerpackets� …butdon’tintroducemuchdelaybywaiting

CSC458/CSC2209– ComputerNetworks 37UniversityofToronto– Fall2016

Nagle’sAlgorithm� Waitiftheamountofdataissmall

� SmallerthanMaximumSegmentSize(MSS)� Andsomeotherpacketisalreadyinflight

� I.e.,stillawaitingtheACKsforpreviouspackets� Thatis,sendatmostonesmallpacketperRTT

� …bywaitinguntilalloutstandingACKshavearrived

� Influenceonperformance� Interactiveapplications:enablesbatchingofbytes� Bulktransfer:transmitsinMSS-sizedpacketsanyway

CSC458/CSC2209– ComputerNetworks 38UniversityofToronto– Fall2016

vs.

ACK

MotivationforDelayedACK� TCPtrafficisoftenbidirectional

� Datatravelinginbothdirections� ACKstravelinginbothdirections

� ACKpacketshavehighoverhead� 40bytesfortheIPheaderandTCPheader� …andzerodatatraffic

� Piggybackingisappealing� HostBcansendanACKtohostA� …aspartofadatapacketfromBtoA

CSC458/CSC2209– ComputerNetworks 39UniversityofToronto– Fall2016

TCPHeaderAllowsPiggybacking

CSC458/CSC2209– ComputerNetworks 40UniversityofToronto– Fall2016

Source port Destination port

Sequence number

Acknowledgment

Advertised windowHdrLen Flags0

Checksum Urgent pointer

Options (variable)

Data

Flags: SYNFINRSTPSHURGACK

CSC458/CSC2209– ComputerNetworks 41UniversityofToronto– Fall2016

ExampleofPiggybacking

A B

B has data to send

A has data to send

B doesn’t have data to send

IncreasingLikelihoodofPiggybacking� Increasepiggybacking

� TCPallowsthereceivertowaittosendtheACK

� …inthehopethatthehostwillhavedatatosend

� Example:rloginortelnet� HostAtypescharactersataUNIXprompt

� HostBreceivesthecharacterandexecutesacommand

� …andthendataaregenerated� WouldbeniceifBcouldsendtheACKwiththenewdata

CSC458/CSC2209– ComputerNetworks 42UniversityofToronto– Fall2016

A B

DelayedACK� DelaysendinganACK

� Uponreceivingapacket,thehostBsetsatimer� Typically,200msecor500msec

� IfB’sapplicationgeneratesdata,goaheadandsend� AndpiggybacktheACKbit

� Ifthetimerexpires,senda(non-piggybacked)ACK� Limitingthewait

� Timerof200msecor500msec� ACKeveryotherfull-sizedpacket

CSC458/CSC2209– ComputerNetworks 43UniversityofToronto– Fall2016

Conclusions� Congestionisinevitable

� Internetdoesnotreserveresourcesinadvance� TCPactivelytriestopushtheenvelope

� Congestioncanbehandled� Additiveincrease,multiplicativedecrease� Slowstart,andslow-startrestart

� ActiveQueueManagementcanhelp� RandomEarlyDetection(RED)� ExplicitCongestionNotification(ECN)

CSC458/CSC2209– ComputerNetworks 44UniversityofToronto– Fall2016