Peer-to-Peer Protocols ad Data Lik Layer Lecture Sprig 9 Flow otrol
utomatic Repeat Request (RQ) Purpose: to esure a sequece o iormatio packets is delivered i order ad without errors or duplicatios despite trasmissio errors & losses We will look at: Stop-ad-Wait RQ Go-Back N RQ Selective Repeat RQ Basic elemets o RQ: Error-detectig code with high error coverage s (positive ackowledgmets Ns (egative ackowlegmets) Timeout mechaism
Stop-ad-Wait RQ Trasmit a rame, wait or Packet Timer set ater each rame trasmissio Trasmitter (Process ) Iormatio rame otrol rame Receiver (Process B) Error-ree packet Header Iormatio packet Iormatio rame R Header R otrol rame: s 3
Need or Sequece Numbers (a) Frame lost B Frame Time-out Frame Frame Frame Time (b) lost B Frame Time-out Frame Frame Frame Time I cases (a) & (b) the trasmittig statio acts the same way But i case (b) the receivig statio B accepts rame twice Questio: How is the receiver to kow the secod rame is also rame? swer: dd rame sequece umber i header S last is sequece umber o most recet trasmitted rame 4
Sequece Numbers (c) Premature Time-out B Time-out Frame Frame Frame Frame Time The trasmittig statio misiterprets duplicate s Icorrectly assumes secod ackowledges Frame Questio: How is the receiver to kow secod is or rame? swer: dd rame sequece umber i header R ext is sequece umber o ext rame expected by the receiver Implicitly ackowledges receipt o all prior rames 5
-Bit Sequece Numberig Suices S last Timer R ext Trasmitter S last Receiver B R ext Global State: (S last, R ext ) (,) Error-ree rame (,) arrives at receiver or rame arrives at trasmitter Error-ree rame (,) arrives at receiver (,) or rame arrives at trasmitter 6
Stop-ad-Wait RQ Trasmitter Ready state wait request rom higher layer or packet traser Whe request arrives, trasmit rame with updated S last ad R Go to Wait State Wait state Wait or or timer to expire; block requests rom higher layer I timeout expires retrasmit rame ad reset timer I received: I sequece umber is icorrect or i errors detected: igore I sequece umber is correct (R ext = S last +): accept rame, go to Ready state Receiver lways i Ready State Wait or arrival o ew rame Whe rame arrives, check or errors I o errors detected ad sequece umber is correct (S last =R ext ), the accept rame, update R ext, sed rame with R ext, deliver packet to higher layer I o errors detected ad wrog sequece umber discard rame sed rame with R ext I errors detected discard rame 7
pplicatios o Stop-ad-Wait RQ IBM Biary Sychroous ommuicatios protocol (Bisyc): character-orieted data lik cotrol Xmodem: modem ile traser protocol Trivial File Traser Protocol (RF 35): simple protocol or ile traser over UDP 8
Stop-ad-Wait Eiciecy First rame bit eters chael Last rame bit eters chael hael idle while trasmitter waits or arrives t B t First rame bit arrives at receiver Last rame bit arrives at receiver Receiver processes rame ad prepares bit rame @ Mbps takes ms to trasmit I wait or = ms, the eiciecy = /= 9% I wait or = ms, the eiciecy =/3 = 33% 9
Stop-ad-Wait Model t = total time to trasmit rame t proc B t prop rame t time t proc t ack t prop t = t = t prop prop + t + t proc proc + t + R + t ack a + R bits/io rame bits/ rame chael trasmissio rate
S&W Eiciecy o Error-ree chael Eective trasmissio rate: bits or header & R R e = umber o iormatio bits delivered to destiatio total time required to deliver the iormatio bits = t - o, Trasmissio eiciecy: h = R e R = - t R o = + a + - ( t o prop + t proc ) R. Eect o rame overhead Eect o rame Eect o Delay-Badwidth Product
Example: Impact o Delay- Badwidth Product =5 bytes = bits, a = o =5 bytes = bits xdelayxbw Eiciecy ms km Mbps 3 88% Gbps 6 % ms km 4 49% 7.% ms km 5 9% 8.% sec km 6 % 9.% Stop-ad-Wait does ot work well or very high speeds or log propagatio delays
S&W Eiciecy i hael with Errors Let P = probability rame arrives w/o errors vg. # o trasmissios to irst correct arrival is the / ( P ) I -i- get through without error, the avg. tries to success vg. Total Time per rame is the t /( P ) h SW = R e R - o t - P = R = + a - ( t + o prop + t proc ( - P ) R ) Eect o rame loss 3
Example: Impact Bit Error Rate =5 bytes = bits, a = o =5 bytes = bits Fid eiciecy or radom bit errors with p=, -6, -5, -4 - P = ( - p)» e - p or large ad small p P Eiciecy Mbps & ms -6-5 -4.99.95.368 88% 86.6% 79.% 3.% Bit errors impact perormace as p approach 4
Go-Back-N Improve Stop-ad-Wait by ot waitig! eep chael busy by cotiuig to sed rames llow a widow o up to W s outstadig rames Use m-bit sequece umberig I or oldest rame arrives beore widow is exhausted, we ca cotiue trasmittig I widow is exhausted, pull back ad retrasmit all outstadig rames lterative: Use timeout 5
Go-Back-N RQ Go-Back-4: 4 rames are outstadig; so go back 4 r r r r 3 r 4 r 5 r 6 r 3 r 4 r 5 r 6 r 7 r 8 r 9 Time B 3 out o sequece rames 4 5 6 7 8 9 R ext 3 3 4 5 6 7 8 9 Frame trasmissio are pipelied to keep the chael busy Frame with errors ad subsequet out-o-sequece rames are igored Trasmitter is orced to go back whe widow o 4 is exhausted 6
Widow size log eough to cover roud trip time Stop-ad-Wait RQ r Time-out expires r r Time B Receiver is lookig or R ext = Go-Back-N RQ r r r Four rames are outstadig; so go back 4 r 3 r r r r 3 r 4 r 5 r 6 Time B Receiver is lookig or R ext = Out-osequece rames 3 4 5 6 7
Go-Back-N with Timeout Problem with Go-Back-N as preseted: I rame is lost ad source does ot have rame to sed, the widow will ot be exhausted ad recovery will ot commece Use a timeout with each rame Whe timeout expires, resed all outstadig rames 8
Go-Back-N Trasmitter & Receiver Frames trasmitted ad ed Timer Timer Timer Trasmitter Sed Widow... S last S recet S last +W s - Buers S last S last +... S recet... S last +W s - oldest u- ed rame most recet trasmissio max Seq # allowed Receiver Frames received Receive Widow R ext Receiver will oly accept a rame that is error-ree ad that has sequece umber R ext Whe such rame arrives R ext is icremeted by oe, so the receive widow slides orward by oe 9
Slidig Widow Operatio Trasmitter Sed Widow m-bit Sequece Numberig... Frames trasmitted ad ed S last S recet S last +W s - m Trasmitter waits or error-ree rame with sequece umber S last Whe such rame arrives, S last is icremeted by oe, ad the sed widow slides orward by oe i + W s sed widow S last i + i
Maximum llowable Widow Size is W s = m - M = = 4, Go-Back - 4: Trasmitter goes back 4 r r r r 3 r r r r 3 Time B R ext 3 3 Receiver has R ext =, but it does ot kow whether its or rame was received, so it does ot kow whether this is the old rame or a ew rame M = = 4, Go-Back-3: r r r Trasmitter goes back 3 r r r Time B R ext 3 3 Receiver has R ext = 3, so it rejects the old rame
Piggybackig i Bidirectioal GBN Trasmitter S recet R ext Receiver Receiver Trasmitter S B recet R B ext Receive Widow B Receive Widow R ext Sed Widow... R B ext B Sed Widow... S last S last+w s- Timer Buers S last S B last S B last+w B s- Timer Buers S B last Timer Timer Timer S last+... S recet... S last+w s- Note: Out-osequece error-ree rames discarded ater R ext examied Timer Timer Timer S B last+... S B recet... S B last+w B s-
pplicatios o Go-Back-N RQ HDL (High-Level Data Lik otrol): bitorieted data lik cotrol V.4 modem: error cotrol over telephoe modem liks 3
Required Timeout & Widow Size T out T proc T prop T T T prop Timeout value should allow or: Two propagatio times + processig time: T prop + T proc rame that begis trasmissio right beore our rame arrives T Next rame carries the, T W s should be large eough to keep chael busy or T out 4
Required Widow Size or Delay-Badwidth Product Frame = 5 bytes =, bits, R = Mbps (t prop + t proc ) x Delay x BW Widow ms bits ms, bits ms, bits secod,, bits 5
Eiciecy o Go-Back-N GBN is completely eiciet, i W s large eough to keep chael busy, ad i chael is error-ree ssume P rame loss probability, the time to deliver a rame is: t i irst rame trasmissio succeeds ( P ) t + W s t /(-P ) i the irst trasmissio does ot succeed P t h GBN GBN = t ( - P - o tgbn = R ) + P { t s Wst + - P o - = + ( W -) P } = t ( - P + ) P W t s - P ad Delay-badwidth product determies W s 6
Example: Impact Bit Error Rate o GBN =5 bytes = bits, a = o =5 bytes = bits ompare S&W with GBN eiciecy or radom bit errors with p =, -6, -5, -4 ad R = Mbps & ms Mbps x ms = bits = rames? Use W s = Eiciecy -6-5 -4 S&W 8.9% 8.8% 8.% 3.3% GBN 98% 88.% 45.4% 4.9% Go-Back-N sigiicat improvemet over Stop-ad-Wait or large delaybadwidth product Go-Back-N becomes ieiciet as error rate icreases 7
Selective Repeat RQ Go-Back-N RQ ieiciet because multiple rames are reset whe errors or losses occur Selective Repeat retrasmits oly a idividual rame Timeout causes idividual correspodig rame to be reset N causes retrasmissio o oldest u-acked rame Receiver maitais a receive widow o sequece umbers that ca be accepted Error-ree, but out-o-sequece rames with sequece umbers withi the receive widow are buered rrival o rame with R ext causes widow to slide orward by or more 8
9 B r Time r r r 3 r 4 r 5 r 6 r r 8 r 9 r 7 r r r N 7 8 9 Selective Repeat RQ
Selective Repeat RQ Trasmitter Sed Widow... Receiver Receive Widow Frames trasmitted ad ed S last S recet S last + W s - Frames received R ext R ext + W r - Timer Buers S last Buers R ext + Timer S last + R ext + Timer... S recet...... R ext + W r - max Seq # accepted S last + W s - 3
Sed & Receive Widows Trasmitter Receiver m - m - R ext i + W s sed widow S last i + i j + W r receive widow i j Moves k orward whe arrives with R ext = S last + k k =,, W s - Moves orward by or more whe rame arrives with Seq. # = R ext 3
What size W s ad W r allowed? Example: M= =4, W s =3, W r =3 Sed Widow Frame reset {,,} {,} {} {.} r r r r Time B 3 Receive Widow {,,} {,,3} {,3,} {3,,} Old rame accepted as a ew rame because it alls i the receive widow 3
W s + W r = m is maximum allowed Example: M= =4, W s =, W r = Sed Widow {,} {} {.} Frame reset r r r Time B Receive Widow {,} {,} {,3} Old rame rejected because it alls outside the receive widow 33
Why W s + W r = m works Trasmitter seds rames to Ws-; sed widow empty ll arrive at receiver ll s lost Trasmitter reseds rame Receiver widow starts at {,, W r } Widow slides orward to {W s,,w s +W r -} Receiver rejects rame because it is outside receive widow m - m - S last W s +W r - sed widow W s - receive widow R ext W s 34
pplicatios o Selective Repeat RQ TP (Trasmissio otrol Protocol): trasport layer protocol uses variatio o selective repeat to provide reliable stream service Service Speciic oectio Orieted Protocol: error cotrol or sigalig messages i TM etworks 35
Eiciecy o Selective Repeat ssume P rame loss probability, the umber o trasmissios required to deliver a rame is: t / (-P ) h SR = t - R o /( - P ) = ( - o )( - P ) 36
Example: Impact Bit Error Rate o Selective Repeat =5 bytes = bits, a = o =5 bytes = bits ompare S&W, GBN & SR eiciecy or radom bit errors with p=, -6, -5, -4 ad R= Mbps & ms Eiciecy -6-5 -4 S&W 8.9% 8.8% 8.% 3.3% GBN 98% 88.% 45.4% 4.9% SR 98% 97% 89% 36% Selective Repeat outperorms GBN ad S&W, but eiciecy drops as error rate icreases 37
ompariso o RQ Eiciecies ssume a ad o are egligible relative to, ad L = (t prop +t proc )R/ =(W s -), the Selective-Repeat: h SR Go-Back-N: o = ( - P )( - )» ( - P ) For P?, SR & GBN same h Stop-ad-Wait: h GBN SW - P = + ( W -) P = + a S ( - P ( t + prop ) + t - P = + LP proc» ) R - P + L For P?, GBN & SW same 38
RQ Eiciecies RQ Eiciecy om pariso.5 Selective Repeat Eiciecy.5-9 -8-7 -6-5 -4-3 - - -9-8 -7-6 -5-4 -3 - - Go Back N Stop ad Wait Go Back N - LOG(p) p Stop ad Wait Delay-Badwidth product =, 39