600 likes | 1.08k Views
Data Link Layer Flow and Error Control. Flow Control. Flow Control Specifies the amount of data can be transmitted by sender before receiving permission to continue from receiver Error Control Allows receiver To find damaged or lost frames during transmission
E N D
Data Link Layer Flow and Error Control
Flow Control • Flow Control Specifies the amount of data can be transmitted by sender before receiving permission to continue from receiver • Error Control Allows receiver To finddamaged or lost frames during transmission To coordinate re-transmission of those frames by sender • Flow Control & Error Control Flow control must acknowledge the correctly-received frames, So it is closely linked to error control
Flow Control • Flow control • Sender transmits Faster than receiver can process them • Receiver will be forced to Drop some frames • Signaling • Signaling the sender to Slow Down to a rate acceptable to the receiver • Signaling can be Explicit or Implicit • e.g. , delay in sending back ACK to sender
ARQ • Automatic Repeat reQuest • A flow and error control mechanism which uses: • Error detection • Timers • Acknowledgements • Retransmissions
Automatic Repeat Request • If error(s) is detected in received Frame, return NAK to sender • NAK can be explicit or implicit (Expiration of sender Timer) • Sender starts a timerfor each frame • Timeout value = Expected delayfor sender to receive ACK for frame
Automatic Repeat Request • Sender keepsa copy of each un-ACKed frame to re-transmit if required • If ACK is received, discarding the copy • If NAK is received (timer expired), re-transmit frame • ACK can be a separate frame or a control fieldPiggybacked in data frame going from receiver to sender
Automatic Repeat Request • Flow and error control techniques at link layer • Stop-and-wait Protocol • Go-back-N Protocol • Selective-reject Protocol (A.K.A. selective repeat) • Sliding window Protocol
Stop-and-Wait Protocol • Each frame is assigned a Sequence Number • Source transmitsA Frame (e.g., frame SN= i) and waits for ACKnowledgement • Receiver acknowledges the receipt by sending back ACK • ACK includes the Request Number(RN) of next frame (i+1) • This implicitlysays that frame i is Error-Free • If frame iis in error, receiver discards it and sends ACK including RN=i
Stop-and-Wait Protocol • Source waits for ACK until timer expires • Timeout =Tfram+2Tprop+Tack=2(Ttrans+Tprop)
Stop-and-Wait Protocol • Retransmission, if timer expires &ACK not received • Frames are sequenced as 0, 1, 2, …, m • It is shown that for m>=1, transmissions have no conflict • Minimum possible frame sequence m=1 (0, 1, 0, 1, 0, 1, 0,) • Transmission Errors • Lost data frame • Damaged data frameat destination • Lost ACK
Stop-and-Wait ARQ • Lost Frame • Source sends Data Frame and waits for ACK • Data Frame is lost • No ACK is replied by receiver • Timer expires • Source Retransmits the frame
Stop-and-Wait ARQ • Damaged Frame at destination • Destination receives frame 1 in error • NACKis sent back (No ACK & Timer expires) • Sender knows Frame 1 is in error • Source Retransmitsframe 1
Stop-and-Wait ARQ • Lost ACK • Frame1 is received at destination • Destination sends ACK 0 • Source does not receive ACK 0 • Timer expires • Source RetransmitsFrame 1 • Destination Discardsduplicated • Frmae1
Stop-and-Wait Link Utilization • Source sends a single frame and waits for Tfram+2Tprop+Tack=2(Ttrans+Tprop) • Tpropislarge relative to Ttrans • Propagation delay is long relative to transmission time • Transmission of only one frame at a time • Waiting for a long time to receive ACK • Link is mostly idle • Stop-and-Wait Protocol ReducesLink Utilization
Sliding Window Protocol • Allows Multiple Framesto be Transmittedat the same time • Transmitter and receiver have sequence numbers nt and nr • Frames and ACKs must be numbered • ntdenotes the next frame to be transmitted • i.e. the sequence number of the first frame not yet transmitted • nr is the first packet not yet received (Expected)
Sliding Window Protocol • Transmitter and receiver have a window size wt and wr • Window size = # of frames that can be transmitted without an ACK • Transmitter sends wt frames continuously and wait for ACK • ACK Includes sequence nr • Receiver can ACK frames without permitting further transmission (Receive Not Ready=RNR) • Receiver must send a normal ACK to resume • Sliding window becomes stop-and-wait if window size is One
Sliding Window Protocol Transmitter Operation • Transmitter needs to buffer so that if data is lost, it can be resent • Transmitter may transmit up to wt frame ahead of the latest acknowledgment na • It may transmit frame number nt, where nt < na+wt • It keeps the sent packets in buffer until ACK arrives
Sliding Window Protocol Receiver Operation • Receiver needs to buffer so that if data is received out of order, it can be held until all packets are received • When a frame arrives • Receiver checks to see if the frame number falls in the receive window • If so, receiver accepts it and updates nr • If not, receiver discards it • Receiver sends ACK including current nr
Sliding Window Protocol Sliding Window in a nutshell • Sender can transmit several framescontinuously before needing an ACK • If ACK received by sender before transmission is finished, sender can continue transmitting • An ACK can acknowledge the correct receipt of multiple frames at the Receiver • Frames may be ACKedby receiver at any time, and may be transmitted by sender as long as the window hasn’t filled up
Sliding Window Example RR = Receive Ready window size = 7 segments
Go-Back-N Protocol • Most common form of error control based on Sliding Window • Window size W = N • Out of order (window) frames are discarded. • If frame F is in error • Receiver replies with rejection (REJ F / NACK) • Receiver discards frame F and all subsequent framesuntil it receives frame F correctly
Go-Back-N Protocol • Upon receiving a NAK for frame F, transmitter must Go Back and retransmit frame F and all subsequent frames • Sender resends frame F (and all subsequent frames) when timer expires too • If window W is selected large enough, sender can transmit continuously if there are no transmission errors
Go-Back-N Protocol • NAK 3 means Retransmit Frame 3 (also tells sender that all frames before frame 3 were received correctly) • Receiver discards all subsequent frames • Receiver only accepts Correct Frames received in Correct Order • So, receiver doesn’t need to Buffer any frames (to reorder them)
Go-Back-N Protocol • Frame 2 is lost • Receiver is expecting Frame 2, But receives Frame 3 • Frame 3 (4,5,…) is discarded (even though correctly received) • NAK is sent for Frame 2 • Frame 2 and All Subsequences are Retransmitted
Go-Back-N Protocol • Piggybacking • When traffic is Bi-Directional , ACK can be piggybacked on packets going in other direction • Each packet contains a • SNfield indicating the packet sequence number • RN field ACKs the packet in the other direction • If there is no packet before timeout, acknowledge RN is sent
Selective Repeat Protocol • SR attempts to retransmit only those packets that are actually lost • Receiver does not discard the frames received after an error-frame • Receiver must be able to accept good frames out of order • Receiver stores the correct frames in a buffer and waits for error-frame (Buffering)
Selective Repeat Protocol • Receiver sends all frames to higher layer in order • Window protocol just like Go-Back-N • Window size W
Selective Repeat Protocol Need for Buffer Sender must buffer all frames until they are ACKed • Up to W un-ACKed frames • Receiver must buffer frames until they can be delivered in order • Up to Wframes may have to be buffered at receiver • If the first frame is received in error
Selective Repeat Protocol When Frame 2 received correctly, receiver can sends Frames 2-5 to its Network layer and send ACK 6 back to Sender
Selective Repeat Protocol Retransmission Strategy • Receiver ACKs the correct frames • Not ACKed frames before time-out are assumed lost or in error • An explicit NAK (selective reject) can request retransmission of just one frame • NAK can expedite retransmission but is not strictly needed • Sender retransmits un-ACKed frame after a timeout or upon a NAK
Link Utilization (Efficiency) Link Utilization is defined as the ratioof portion of communication link used for sending user data To bandwidth of the link User data rate Link data rate
ARQ Performance:Error-Free Stop-and-Wait T = Tframe + Tprop+Tproc+Tack +Tprop+ Tproc Tframe= Time to transmit Frame(Ttrans) Tprop= Propagation time Tproc= Processing time at station Tack = Time to transmit ACK Assume TprocandTack relatively small
Error-Free Stop and Wait T ≈ Tframe + 2Tprop (time required to send a frame) Throughput = 1/T = 1/(Tframe + 2Tprop) frames/sec Normalize to link data rate (frames/sec): 1/ Tframe U= 1/(Tframe + 2Tprop) = Tframe= 1 1/ TframeTframe + 2Tprop 1 + 2a where a = Tprop/ Tframe
Parameter a a = Propagation Time = d/V = Rd Transmission TimeL/R VL where d = Distance (m) V = Propagation speed (m/s) L = Frame length (b) R = Link data rate (b/s)
Stop-and-Wait Timing tframe = 1, tprop = a
Stop-and-Wait Performance a = Rd/VL
Utilization (Example) Satellite Link Propagation Delay tprop = 270 ms Frame Size = 500 Bytes = 4 kb Data rate = 56 kbps ⇒ tframe = 4kb/56kb = 71 ms ⇒ a = tprop/tframe= 270/71 = 3.8 U = 1/(2a+1) = 0.12 Short Link Propagation Delay tprop = 5 μs Data Rate = 10 Mbps Frame = 500 bytes ⇒ tframe = 4k/10M = 400 μs ⇒ a=tprop/tframe= 5/400 = 0.012 U=1/(2a+1)=0.98
Stop-and-Wait ARQwith Errors P = probability a single frame is in error Nt= 1 1 - P = average number of times each frame must be transmitted due to errors U= 1 = 1 – P Nt(1 + 2a) 1 + 2a
Error-Free Sliding Window ARQ • Case 1: W ≥ 2a + 1 Ack for frame 1 reaches A before A has exhausted its window
Error-Free Sliding Window ARQ • Case 2: W 2a +1 A exhausts its window at time t = W and cannot send additional frames until t = 2a + 1
Normalized Throughput Error-Free Sliding Window ARQ 1 ; W ≥ 2a + 1 U = W ; W 2a +1 1 + 2a W times stop-and-wait throughput
Selective Repeat ARQ 1 - P ; W ≥ 2a + 1 U = W(1 - P) ; W 2a +1 2a + 1 W times stop-and-wait (error) throughput
Go-Back-N ARQ 1 - P W ≥ 2a + 1 1 + 2aP U = W(1 - P) W 2a +1 (2a + 1)(1 – P + WP) Why?