data link layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-flow… ·...

8
Computer Networks Lecture 26: Flow Control and ARQ Data Link Layer The Data Link layer can be further subdivided into: 1. Logical Link Control (LLC): provides flow and error control different link protocols may provide different services, e.g., Ethernet doesn’t provide reliable delivery (error recovery) 2. Media Access Control (MAC): framing and media access application transport network LLC MAC physical Link Layer Services Flow Control: pacing between adjacent sending and receiving nodes Error Control: errors caused by signal attenuation, noise ARQ: receiver detects presence of errors and asks sender for retransmission FEC: receiver identifies and corrects bit error(s), without resorting to retransmission Reliable delivery between adjacent nodes seldom used on low bit error links (fiber, some twisted pair) plays an important role in wireless links with high error rates Q: why do we need both link-level and end-end reliability? Flow Control What is flow control? receiver telling sender to slow down Why do you need flow control? Flow control protocols at data link layer (single hop): XON/XOFF Stop & Wait Protocol Sliding Window Protocol Similar issues and mechanisms apply at the transport layer (end-to-end)

Upload: others

Post on 04-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

Computer Networks

Lecture26:FlowControlandARQ

DataLinkLayer

TheDataLinklayercanbefurthersubdividedinto:1.  LogicalLinkControl(LLC):provides

flowanderrorcontrol•  differentlinkprotocolsmayprovidedifferentservices,e.g.,Ethernetdoesn’tprovidereliabledelivery(errorrecovery)

2.  MediaAccessControl(MAC):framingandmediaaccess

application

transport

network

LLC MAC

physical

LinkLayerServicesFlowControl:• pacingbetweenadjacentsendingandreceivingnodes

ErrorControl:• errorscausedbysignalattenuation,noise• ARQ:receiverdetectspresenceoferrorsandaskssenderforretransmission

•  FEC:receiveridentifiesandcorrectsbiterror(s),withoutresortingtoretransmission

Reliabledeliverybetweenadjacentnodes•  seldomusedonlowbiterrorlinks(fiber,sometwistedpair)• playsanimportantroleinwirelesslinkswithhigherrorrates• Q:whydoweneedbothlink-levelandend-endreliability?

FlowControl

Whatisflowcontrol?• receivertellingsendertoslowdown

Whydoyouneedflowcontrol?

Flowcontrolprotocolsatdatalinklayer(singlehop):• XON/XOFF• Stop&WaitProtocol• SlidingWindowProtocol

Similarissuesandmechanismsapplyatthetransportlayer(end-to-end)

Page 2: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

XON/XOFF

Algorithm:• Ssendsstreamofdata• RsendsXOFF,Sstopstransmission• RsendsXON,SresumestransmissionWorksOKifτissmall,otherwisesendercanoverrunreceiver(Why?)

sender receiver

S R

! : propagationdelay

StopandWait(S&W)ProtocolAftersendingapacket,sendermustwaitforacknowledgment(ACK)beforesendingthenextpacket

Time

SenderS

ReceiverR

t

t+ 2!

t+ !

! : propagationdelay

2!

round-triptime (rtt)

ACK

pkt

Stop&WaitPerformanceDisadvantages:• slow• mustwaitforACKevenifnooverrun• maxtransmissionbandwidth1packet/round-triptime(rtt)Performanceisokifτissmall,otherwiseinefficientExample1:•  linkbandwith(µ) =1Mbps,withpacketsize(L)=1Kbits,transmissiontimeisL/µ =1ms•  ifrtt(2τ )=9ms,wecansend100pkts/sec• thethroughput(Tg)is100Kbps(10%ofcapacity)

Example2:•  linkbandwidth(µ )=1Gbps,propagationdelay(τ ) = 15ms, packetsize(L)=8Kbits,transmissiontimeisL/µ =8µs•  senderutilization(Us),fractionoftimesenderissending:

firstpacketbittransmitted, t = 0 sender receiver

RTT (2τ )

lastpacketbittransmitted, t = L/µ

firstpacketbitarriveslastpacketbitarrives,sendACK

ACKarrives,sendnextpacket,t = RTT + L/µ

Us =L / µ

2τ + L / µ=8·103 /109

30 + 8·10−6 = 0.00027

Stop&WaitPerformance

Page 3: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

SlidingWindow:PipelinedFlowControl

Pipelining:senderallowsmultiple“in-flight,”yet-to-be-acknowledged,packets

SlidingWindowSendwnumberofpacketsbeforewaitingforanACK(canhavewoutstanding,unACKed,packets)ForeveryreceivedACK,slidewindow(overdata)by1packet(S&Wisslidingwindowwithw = 1)

Throughputoftheslidingwindowprotocol(Tw):Tw = Tg*w

sendwindowsizewlimitedbybuffersizeatreceiver(wR):Tw = Tg*MIN(w,wR)

[Stevens]

Example3:•  linkbandwidth(μ)=1Gbps,propagationdelay(τ ) = 15 ms, packetsize(L) = 8Kbits,transmissiontimeisL/µ =8µs,windowsize(w) = 3•  senderutilization(Us),fractionoftimesenderissending:

Pipelining:IncreasedUtilizationfirstpacketbittransmitted,t = 0

sender receiver

RTT (2τ )

lastbittransmitted,t = L/µ

firstpacketbitarriveslastbitof1stpktarrives,sendACK

ACKarrives,sendnextpacket,t = RTT + L/µ

lastbitof2ndpktarrives,sendACKlastbitof3rdpktarrives,sendACK

increasedutilizationbyafactorof3!Us =

w * L / µ2τ + L / µ

=3*8·103 /109

30 + 8·10−6 = 0.0008

SlidingWindow:MaxWindowSize

Whatistheoptimalwindowsize?i.e.,what’sthemaximumnumberofpacketsoncanhaveoutstanding(to“fillthepipe”)?Letμbethelinkbandwidth,pipesize=RTT*μ=2τ *μ(commonlycalledthebandwidth-delayproduct)Normallyyoudon’twantto,andcan’t,fillthepipecompletely(morewhenwediscussreliabletransportprotocol)

Page 4: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

ErrorControlErrorsareunavoidable,causedbynoiseonchannel:• electricalinterference,thermalnoise,cosmicrays,etc.

Threekindsoftransmissionerrors:1.  sentsignaldestroyed(datanotreceived)2.  sentsignalchanged(receivedwrongdata)3.  spurioussignalcreated(receivedrandomdata)

AutomaticRepeatreQuest(ARQ):senderretransmitslostorcorruptedpackets

AutomaticRepeatreQuest(ARQ)Howdoessenderknowwhenandwhichpktstoretransmit?• bytheuseofACKsandtimeout

Generalalgorithm:• receiveracknowledges(ACKs)receiptofpkts• senderretransmitspacketsnotACKedbytimeout• a.k.a.PAR:PositiveAcknowledgementwithRetransmissionReliabilityprotocols:• AlternatingBitProtocol(ABP)• Go-Back-N(GBN,withorwithoutNAK)• SelectiveRepeatProtocol(SRP)

Time

SenderS

ReceiverR

t

t+ 2τ

t+ τ

τ : propagationdelay

round-triptime (rtt)

pktX

pkt lost

pktrexmitted

AlternatingBitProtocol(ABP)S&Wwithun-numberedpacketsandACKscausesconfusiononretransmission:• howtodifferentiatearetransmittedframefromthenextframe?

ABP:uses1bittonumberpacketsandACKs

Time

SenderS

ReceiverR

t

t+ 2τ

t+ τ

τ : propagationdelay

round-triptime (rtt)

ACK

pkt

XACK lost

how to detectduplicate?

ABPinAction

Page 5: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

ABPinActionABPworks,butperformanceisbadExample:•  linkbandwidth(µ )=1Gbps•  propagationdelay(τ ) = 15 ms•  packetsize(L)=8Kbits,transmissiontimeisL/µ =8µs•  senderutilization(Us)isthesameasS&W:

•  about1packetevery30ms•  33KBpsor264Kbpsthroughputovera1Gbpslink!

PerformanceofABP

Us =L / µ

2τ + L / µ=8·103 /109

30 + 8·10−6 = 0.00027

Go-Back-N(Link-layer)Sender:•  putsk-bitsequencenumber(seq#)inpacketheader•  sendsa“window”ofuptoNpackets•  consecutiveunACKed(una)packetsallowed

• notation:ACK(n)meansACKspacketwithseq#n

snd_una snd_next

Go-Back-N(Link-layer)Sender:• associatesatimerwitheachin-flightpacket•  timeout(n):retransmitspacketwithseq#nandallhigherseq#inwindow•  resetssnd_nexttosnd_una (n)

•  resetstimerforallretransmittedpackets

snd_una snd_next

Page 6: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

Go-Back-N(Link-layer)Receiver:• onlyneedstoremembernextexpectedseq#(next_seqn)• ACKsanddeliverstoapppacketsthatarrivedinorder• discardsout-of-orderpackets�nobuffering!• ACKsout-of-orderpacketsifseq#issmallerthannext_seqn(why?)

round-triptime (rtt)

rexmissiontimeout (rto)

SenderS

ReceiverR

ACK(1)

Pkts

X

1234

1234

5

2345

2345

discardall these

5

ACK(3)ACK(4)

ACK(5)

ACK(3)ACK(4)

ACK(2)

ACK(5)

SenderS

ReceiverR

PktsX

1234

134

5

2345

2345

discardthese

5discard

ACK(1)

ACK(3)ACK(4)

ACK(2)

ACK(5)

next_seqn= 5

next_seqn= 6

next_seqn= 2

next_seqn= 2

snd_una snd_next

Go-Back-N[K&R]Sender:• ACK(n)iscumulative:ACKsallpacketsuptoandincludingseq#n• maintainsonlyoneactivetimer,forsnd_una•  timeout(snd_una):retransmitssnd_unaandallhigherseq#sinwindow•  resetssnd_nexttosnd_una

•  resetstimerforsnd_una

Go-Back-N[K&R]Receiver:• onlyneedstoremembernextexpectedseq#(next_seqn)• cumulativeACKacknowledgesallpacketsreceivedin-order• out-of-orderpacketsrepeatthelastACK

round-triptime (rtt)

SenderS

ReceiverR

ACK(1)

Pkts

X

1234

1234

5678

678

5

ACK(3)ACK(4)

ACK(5)

ACK(6)ACK(7)ACK(8)

SenderS

ReceiverR

PktsX

1234

134

5

2345

2345

discardthese

5discard

ACK(1)

ACK(3)ACK(4)

ACK(2)

ACK(5)

ACK(1)

ACK(1)

rexmissiontimeout (rto)

next_seqn= 5

next_seqn= 9

next_seqn= 2

next_seqn= 2

Go-Back-NwithNegativeACK(NAK)

sender

receiver

Walrand

Receiver:• ACKsanddeliversin-orderpackets• sendsNAKforfirstoutoforderpacketanddiscardspacket• ACKsanddiscardssubsequentoutoforderpacketsSender:retransmitsonreceivingNAKorifRTOexpires

Page 7: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

SelectiveRepeatProtocol(SRP)

wR

wR

snd_una snd_next

next_seqn

Receiver:• buffersout-of-orderpackets(uptowR),forin-orderdelivery• ACKsallcorrectly(noerror,butmaybeout-of-order)receivedpacketsindividually,notcumulatively

Sender:• keepstrackofwRandensuresthatwR>(snd_next−snd_una)• keepsaretransmittimerforeachpacket• retransmitsonlyunACKedpackets

SelectiveRepeatProtocol(SRP)Receiver:• buffersout-of-orderpackets(uptowR),forin-orderdelivery• ACKsallcorrectlyreceivedpacketsindividually

Sender:• keepstrackofwRandensuresthatwR>(snd_next−snd_una),intheexample,wR=4

• keepsaretransmittimerforeachpacket• retransmitsonlyunACKedpackets

SelectiveAcknowledgement:Piggy-backNAKwithACK.,e.g.[ACK2,NAK1],[ACK4,NAK3]

cannotsendpkt5(why?)

oktosendpkt6(why?)

1 2 3 4 5 6 71 2 3 4 5 6 7

Walrand

SelectiveRepeatinAction

non-cumulativeACK

SelectiveRepeatSummary

• datafromupperlayer:•  ifnextavailableseq#inwindow,sendpacket

• timeout(n):•  resendpacketn,restarttimer

• receivedACK(n)in[snd_una,snd_next]:• markpktnasreceived•  ifnissmallestunACKedpacket,advancesnd_unatonextunACKedseq#

sender

• packetnin[next_seqn,next_seqn+wR�1]•  sendACK(n)•  out-of-order:buffer•  in-order:deliver(alsodeliverbuffered,in-orderpackets),advancewindowtonextnot-yet-receivedpacket

• packetn<next_seqn•  sendACK(n)

• otherwise:•  ignore

receiver

Page 8: Data Link Layerweb.eecs.umich.edu › ~sugih › courses › eecs489 › lectures › 26-Flow… · Why do you need flow control? Flow control protocols at data link layer (single

ARQProtocolsSummaryGo-Back-N[K&R]:• sender:allowsuptoNunACKedpacketsinpipeline• receiver:sendscumulativeACKs•  repeatlastACKifthere’sagap• sender:keepstimeronlyforoldestunACKedpkt•  iftimerexpires:retransmitsallunACKedpackets

SelectiveRepeat• sender:allowsuptoNunACKedpacketsinpipeline• receiver:ACKsindividualpackets• sender:maintainstimerforeachunACKedpkt•  iftimerexpires:retransmitsonlyunACKedpacket

SimplifyingAssumptionInfinitesequence#space

Supposeyouhaveonlya2-bitsequencespace:Q:what’stherelationshipbetweenseq#spaceandwindowsize?

SenderS

ReceiverR

ACKs

Pkts

rexmissiontimeout (rto)

1234

1234

1

X

1st or5th pkt?

Ethernet:ConnectionlessServiceNohandshakingbetweensendingandreceivingadaptor

Receivingadaptordoesn’tsendACKsorNACKstosendingadaptor•  streamofdatagramspasseduptonetworklayercanhavegaps•  gapswillbefilledifapplicationusesreliabletransportlayer•  otherwise,applicationwillseethegaps

Otherdatalinkprotocolsmayprovideerrorcorrectionandflowcontrol

OtherIssuesatTransportLayerConnectionlessnetworklayermeanseachpacketcan:• takeadifferentpath• experiencedifferentcongestion

Implications:• non-deterministicround-triptime• out-of-orderpacketsmustbebufferedforGo-Back-N(soasnottomistakelatepacketsaslostpackets)• complicatescomputationofreceiver’swindow(w)