32
Queuing and Queue Management Reading: Sec1ons 6.2, 6.4, 6.5 COS 461: Computer Networks Spring 2011 Mike Freedman hEp://www.cs.princeton.edu/courses/archive/spring11/cos461/ 1

Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Embed Size (px)

Citation preview

Page 1: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

QueuingandQueueManagementReading:Sec1ons6.2,6.4,6.5

COS461:ComputerNetworksSpring2011

MikeFreedmanhEp://www.cs.princeton.edu/courses/archive/spring11/cos461/

1

Page 2: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

GoalsofToday’sLecture

•  RouterQueuingModels– Limita1onsofFIFOandDropTail

•  SchedulingPolicies– FairQueuing

•  Droppolicies– RandomEarlyDetec1on(ofconges1on)

– ExplicitConges1onNo1fica1on(fromrouters)

•  Someaddi1onalTCPmechanisms

2

Page 3: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

RouterDataandControlPlanes3

Switching Fabric

Processor

Line card

Line card

Line card

Line card

Line card

Line card

data plane

control plane

Page 4: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

LineCards(InterfaceCards,Adaptors)•  Interfacing

–  Physicallink–  Switchingfabric

•  Packethandling–  Packetforwarding– Decrement1me‐to‐live–  Buffermanagement–  Linkscheduling–  Packetfiltering–  Ratelimi1ng–  Packetmarking– Measurement

4

to/from link

to/from switch

lookup

Rec

eive

Transmit

Page 5: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

PacketSwitchingandForwarding5

R1 Link 1

Link 2

Link 3

Link 4

Link 1, ingress Link 1, egress

Link 2, ingress Link 2, egress

Link 3, ingress Link 3, egress

Link 4, ingress Link 4, egress

Choose Egress

Choose Egress

Choose Egress

Choose Egress

“4”

“4”

Page 6: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

RouterDesignIssues

•  Schedulingdiscipline – Whichpackettosend?

– Someno1onoffairness?Priority?

•  Droppolicy– Whenshouldyoudiscardapacket?– Whichpackettodiscard?

•  Needtobalancethroughputanddelay– Hugebuffersminimizedrops,butaddtoqueuingdelay(thushigherRTT,longerslowstart,…)

6

Page 7: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

FIFOSchedulingandDrop‐Tail•  Accesstothebandwidth:first‐infirst‐outqueue

– Packetsonlydifferen1atedwhentheyarrive

•  Accesstothebufferspace:drop‐tailqueuing–  Ifthequeueisfull,droptheincomingpacket

7

Page 8: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Problemswithtaildrop

•  Understablecondi1ons,queuealmostalwaysfull–  Leadstohighlatencyforalltraffic

•  Possiblyunfairforflowswithsmallwindows–  Largerflowsmayfastretransmit(detec1nglossthroughTripDupACKs),smallflowsmayhavetowaitfor1meout

•  Windowsynchroniza1on– Moreonthislater…

8

Page 9: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

SchedulingPolicies

(Weighted)FairQueuing(andClass‐basedQualityofService)

9

Page 10: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

FairQueuing(FQ)•  Maintainsseparatequeueperflow

•  Ensuresnoflowconsumesmorethanits1/nshare–  Varia1on:weightedfairqueuing(WFQ)

•  Ifallpacketsweresamelength,wouldbeeasy

•  Ifnon‐work‐conserving(resourcescangoidle),alsowouldbeeasy,yetloweru1liza1on

10

RoundRobinService

Egress Link

Flow 1

Flow 2

Flow 3

Flow 4

Page 11: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

FairQueuingBasics

•  Trackhowmuch1meeachflowhasusedlink

– Compute1meusedifittransmitsnextpacket

•  Sendpacketfromflowthatwillhavelowestuseifittransmits– Whynotflowwithsmallestusesofar?

– Becausenextpacketmaybehuge!

11

Page 12: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

FQAlgorithm

•  Imagineclock1ckperbit,thentx1me~length

Finish1meFi=max(Fi‐1,Arrive1meAi)+LengthPi

•  Calculatees1matedFiforallqueuedpackets

•  TransmitpacketwithlowestFinext

12

Page 13: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

FQAlgorithm(2)

•  Problem:Can’tpreemptcurrenttxpacket

•  Result:Inac1veflows(Ai>Fi‐1)arepenalized– Standardalgorithmconsidersnohistory

– Eachflowgetsfairshareonlywhenpacketsqueued

13

Page 14: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

FQAlgorithm(3)

•  Approach:givemorepromptnesstoflowsu1lizinglessbandwidthhistorically

•  BidBi=max(Fi‐1,Ai–δ)+Pi–  Intui1on:withlargerδ,schedulingdecisionscalculatedbylasttx1meFi‐1morefrequently,thuspreferringslowerflows

•  FQachievesmax‐minfairness–  Firstpriority:maximizetheminimumrateofanyac1veflows

–  Secondpriority:maximizethesecondminrate,etc.

14

Page 15: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Usesof(W)FQ

•  Scalability– #queuesmustbeequalto#flows

– But,canbeusedonedgerouters,lowspeedlinks,orsharedendhosts

•  (W)FQcanbeforclassesoftraffic,notjustflows– UseIPTOSbitstomark“importance”

– Partof“Differen1atedServices”architecturefor“Quality‐of‐Service”(QoS)

15

Page 16: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

DropPolicy

DropTailRandomEarlyDetec1on(RED)

ExplicitConges1onNo1fica1on(ECN)

16

Page 17: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

BurstyLossFromDrop‐TailQueuing

•  TCPdependsonpacketloss–  Packetlossisindica1onofconges1on– AndTCPdrivesnetworkintolossbyaddi1verateincrease

•  Drop‐tailqueuingleadstoburstyloss–  Iflinkiscongested,manypacketsencounterfullqueue–  Thus,losssynchroniza1on:

• Manyflowsloseoneormorepackets•  Inresponse,manyflowsdividesendingrateinhalf

17

Page 18: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

SlowFeedbackfromDropTail•  Feedbackcomeswhenbufferiscompletelyfull

– …eventhoughthebufferhasbeenfillingforawhile

•  Plus,thefillingbufferisincreasingRTT– …makingdetec1onevenslower

•  MightbebeEertogiveearlyfeedback– Andget1‐2connec1onstoslowdownbeforeit’stoolate

18

Page 19: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

RandomEarlyDetec1on(RED)•  BasicideaofRED

–  Routerno1cesthatqueueisgesngbacklogged– …andrandomlydropspacketstosignalconges1on

•  Packetdropprobability– Dropprobabilityincreasesasqueuelengthincreases–  Else,setdropprobabilityasfunc1onofavgqueuelengthand1mesincelastdrop

19

Average Queue Length

Dro

p Pr

obab

ility

0

1

Page 20: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Proper1esofRED•  Dropspacketsbeforequeueisfull

–  Inthehopeofreducingtheratesofsomeflows

•  Dropspacketinpropor1ontoeachflow’srate– High‐rateflowshavemorepackets– …and,hence,ahigherchanceofbeingselected

•  Dropsarespacedoutin1me– WhichshouldhelpdesynchronizetheTCPsenders

•  Tolerantofburs1nessinthetraffic– Bybasingthedecisionsonaveragequeuelength

20

Page 21: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

ProblemsWithRED•  Hardtogettunableparametersjustright

– Howearlytostartdroppingpackets?– Whatslopeforincreaseindropprobability?– What1mescaleforaveragingqueuelength?

•  REDhasmixedadop1oninprac1ce–  Ifparametersaren’tsetright,REDdoesn’thelp– Hardtoknowhowtosettheparameters

•  Manyothervaria1onsinresearchcommunity– Nameslike“Blue”(self‐tuning),“FRED”…

21

Page 22: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Feedback:Fromlosstono1fica1on

•  Earlydroppingofpackets– Good:givesearlyfeedback– Bad:hastodropthepackettogivethefeedback

•  ExplicitConges1onNo1fica1on– RoutermarksthepacketwithanECNbit– Sendinghostinterpretsasasignofconges1on

22

Page 23: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

ExplicitConges1onNo1fica1on•  Mustbesupportedbyrouter,sender,ANDreceiver

–  End‐hostsdetermineifECN‐capableduringTCPhandshake

•  ECNinvolvesallthreepar1es(and4headerbits)1.  Sendermarks“ECN‐capable”whensending

2.  Ifroutersees“ECN‐capable”andexperiencingconges1on,routermarkspacketas“ECNconges1onexperienced”

3.  Ifreceiversees“conges1onexperienced”,marks“ECNecho”flaginresponsesun1lconges1onACK’d

4.  Ifsendersees“ECNecho”,reducescwndandmarks“conges1onwindowreduced”flaginnextTCPpacket

•  WhyextraECNflag?Conges1oncouldhappenineitherdirec1on,wantsendertoreacttoforwarddirec1on

•  WhyCRWACK?ECN‐echocouldbelost,butweideallyonlyrespondtoconges1oninforwarddirec1on

23

Page 24: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

OtherTCPMechanisms

Nagle’sAlgorithmandDelayedACK

24

Page 25: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Nagle’sAlgorithm•  Waitiftheamountofdataissmall

– SmallerthanMaximumSegmentSize(MSS)

•  Andsomeotherpacketisalreadyinflight–  I.e.,s1llawai1ngtheACKsforpreviouspackets

•  Thatis,sendatmostonesmallpacketperRTT– …bywai1ngun1lalloutstandingACKshavearrived

•  Influenceonperformance–  Interac1veapplica1ons:enablesbatchingofbytes– Bulktransfer:transmitsinMSS‐sizedpacketsanyway

25

vs.

ACK

Page 26: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Nagle’sAlgorithm•  Waitiftheamountofdataissmall

– SmallerthanMaximumSegmentSize(MSS)

•  Andsomeotherpacketisalreadyinflight–  I.e.,s1llawai1ngtheACKsforpreviouspackets

•  Thatis,sendatmostonesmallpacketperRTT– …bywai1ngun1lalloutstandingACKshavearrived

•  Influenceonperformance–  Interac1veapplica1ons:enablesbatchingofbytes– Bulktransfer:transmitsinMSS‐sizedpacketsanyway

26

vs.

ACK

TurningNagleOff void tcp_nodelay (int s) { int n = 1; if (setsockopt (s, IPPROTO_TCP, TCP_NODELAY, (char *) &n, sizeof (n)) < 0) warn ("TCP_NODELAY: %m\n"); }

Page 27: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Mo1va1onforDelayedACK

•  TCPtrafficisotenbidirec1onal– Datatravelinginbothdirec1ons– ACKstravelinginbothdirec1ons

•  ACKpacketshavehighoverhead– 40bytesfortheIPheaderandTCPheader– …andzerodatatraffic

•  Piggybackingisappealing– HostBcansendanACKtohostA– …aspartofadatapacketfromBtoA

27

Page 28: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

TCPHeaderAllowsPiggybacking

28

Source port Destination port

Sequence number

Acknowledgment

Advertised window HdrLen Flags 0

Checksum Urgent pointer

Options (variable)

Data

Flags: SYN FIN RST PSH URG ACK

Page 29: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

ExampleofPiggybacking29

Data

Data+ACK

Data

A B

ACK

Data

Data + ACK

B has data to send

A has data to send

B doesn’t have data to send

Page 30: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

IncreasingLikelihoodofPiggybacking

•  Example:sshorevenHTTP– HostAtypescommand– HostBreceivesandexecutesthecommand

– …andthendataaregenerated– WouldbeniceifBcouldsendtheACKwiththenewdata

•  Increasepiggybacking–  TCPallowsthereceivertowaittosendtheACK

– …inthehopethatthehostwillhavedatatosend

30

Data

Data+ACK

Data

A B

ACK

Data

Data + ACK

Page 31: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

DelayedACK

•  DelaysendinganACK– Uponreceivingapacket,thehostBsetsa1mer

•  Typically,200msecor500msec

–  IfB’sapplica1ongeneratesdata,goaheadandsend•  AndpiggybacktheACKbit

–  Ifthe1merexpires,senda(non‐piggybacked)ACK

•  Limi1ngthewait– Timerof200msecor500msec– ACKeveryotherfull‐sizedpacket

31

Page 32: Queuing and Queue Management - Computer Science … · Queuing and Queue Management ... Detecon (of congeson) ... Fabric Processor Line card Line card Line card Line card data plane

Conclusions

•  Conges1onisinevitable–  Internetdoesnotreserveresourcesinadvance–  TCPac1velytriestopushtheenvelope–  TCPcanreacttoconges1on(mul1plica1vedecrease)

•  Ac1veQueueManagementcanfurtherhelp–  RandomEarlyDetec1on(RED)–  ExplicitConges1onNo1fica1on(ECN)

•  Fundamentaltensions–  Feedbackfromthenetwork?–  Enforcementof“TCPfriendly”behavior?Otherschedulingpolicies(FQ)cangivenstrongerguarantees

32