Download presentation
Presentation is loading. Please wait.
Published byDonald Rich Modified over 8 years ago
1
Data Link Layer Flow and Error Control
2
Flow Control Flow Control Flow Control Specifies the amount of data can be transmitted by sender before receiving permission to continue from receiver Error Control Error Control Allows receiver damaged or lost To find damaged or lost frames during transmission re-transmission To coordinate re-transmission of those frames by sender Flow Control & Error Control Flow Control & Error Control correctly- received Flow control must acknowledge the correctly- received frames, So it is closely linked to error control
3
Flow Control Flow control Flow control Faster than ◦ Sender transmits Faster than receiver can process them Drop ◦ Receiver will be forced to Drop some frames Signaling Signaling Slow Down rate acceptable ◦ Signaling the sender to Slow Down to a rate acceptable to the receiver Explicit or Implicit ◦ Signaling can be Explicit or Implicit ◦ e.g., delay in sending back ACK to sender
4
ARQ ARQ Automatic Repeat reQuest A flow and error control mechanism which uses: ◦ Error detection ◦ Timers ◦ Acknowledgements ◦ Retransmissions
5
NAK If error(s) is detected in received Frame, return NAK to sender NAKexplicit or implicit NAK can be explicit or implicit (Expiration of sender Timer) timer Sender starts a timer for each frame Timeout value Expected delay ACK Timeout value = Expected delay for sender to receive ACK for frame Automatic Repeat Request
6
keeps Sender keeps a copy of each un-ACKed frame to re-transmit if required ACK ◦ If ACK is received, discarding the copy NAK ◦ If NAK is received (timer expired), re-transmit frame ACK Piggybacked ACK can be a separate frame or a control field Piggybacked in data frame going from receiver to sender Automatic Repeat Request
7
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
8
Stop-and-Wait Protocol
9
Sequence Number Each frame is assigned a Sequence Number transmitsA FrameSN= iwaits ACK Source transmits A Frame (e.g., frame SN= i ) and waits for ACKnowledgement ACK Receiver acknowledges the receipt by sending back ACK ACK Request Number RN (i+1) ACK includes the Request Number (RN) of next frame (i+1) implicitlyframe iError-Free This implicitly says that frame i is Error-Free frame i ACK RN= i If frame i is in error, receiver discards it and sends ACK including RN= i
10
Stop-and-Wait Protocol ACK Source waits for ACK until timer expires Timeout =T fram +2T prop +T ack =2(T trans +T prop ) Timeout =T fram +2T prop +T ack =2(T trans +T prop )
11
Stop-and-Wait Protocol Retransmission& ACK Retransmission, if timer expires & ACK not received 0, 1, 2, …, m Frames are sequenced as 0, 1, 2, …, m m >=1conflict It is shown that for m >=1, transmissions have no conflict m=10, 1, 0, 1, 0, 1, 0, Minimum possible frame sequence m=1 (0, 1, 0, 1, 0, 1, 0,) Transmission Errors ◦ Lost data frame ◦ Damaged data frame ◦ Damaged data frame at destination ◦ Lost ACK
12
Stop-and-Wait ARQ Lost Frame ACK Source sends Data Frame and waits for ACK Data Frame is lost ACK No ACK is replied by receiver Timer expires Retransmits Source Retransmits the frame
13
Stop-and-Wait ARQ Damaged Frame Damaged Frame at destination Destination receives frame 1 in error NACK NACK is sent back (No ACK & Timer expires) in error Sender knows Frame 1 is in error Retransmits Source Retransmits frame 1
14
Stop-and-Wait ARQ Lost ACK Frame1 is received at destination ACK 0 Destination sends ACK 0 ACK 0 Source does not receive ACK 0 Timer expires RetransmitsFrame 1 Source Retransmits Frame 1 Discards Destination Discards duplicated Frmae1
15
Stop-and-Wait Link Utilization T fram +2T prop +T ack =2(T trans +T prop ) Source sends a single frame and waits for T fram +2T prop +T ack =2(T trans +T prop ) T prop T trans T prop is large relative to T trans Propagation delay is long relative to transmission time one frame Transmission of only one frame at a time ACK Waiting for a long time to receive ACK Link is mostly idle Link is mostly idle Reduces Stop-and-Wait Protocol Reduces Link Utilization
16
Sliding Window Protocol
17
Multiple FramesTransmitted Allows Multiple Frames to be Transmitted at the same time n t n r Transmitter and receiver have sequence numbers n t and n r Frames and ACKs must be numbered n t next frame n t denotes the next frame to be transmitted i.e. the sequence number of the first frame not yet transmitted n r n r is the first packet not yet received (Expected)
18
Sliding Window Protocol w t w r Transmitter and receiver have a window size w t and w r # of frames ACK Window size = # of frames that can be transmitted without an ACK w t ACK Transmitter sends w t frames continuously and wait for ACK ACK n r ACK Includes sequence n r ACK Receiver can ACK frames without permitting further transmission (Receive Not Ready=RNR) ACK Receiver must send a normal ACK to resume One Sliding window becomes stop-and-wait if window size is One
19
Sliding Window Protocol
20
Transmitter Operation Transmitter needs to buffer so that if data is lost, it can be resent w t n a Transmitter may transmit up to w t frame ahead of the latest acknowledgment n a n t It may transmit frame number n t, where n t < n a +w t ACK It keeps the sent packets in buffer until ACK arrives
21
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 n r If so, receiver accepts it and updates n r If not, receiver discards it ACKn r Receiver sends ACK including current n r
22
Sliding Window Protocol Sliding Window in a nutshell continuously ACK Sender can transmit several frames continuously before needing an ACK ACK If ACK received by sender before transmission is finished, sender can continue transmitting ACK multiple frames An ACK can acknowledge the correct receipt of multiple frames at the Receiver Frames may be ACKed by receiver at any time, and may be transmitted by sender as long as the window hasn’t filled up
23
Sliding Window Operation
24
Sliding Window Example RR = Receive Ready window size = 7 segments
25
Go-Back-N Protocol
26
Most common form Sliding Window Most common form of error control based on Sliding Window N Window size W = N Out of order (window) frames are discarded. F If frame F is in error F NACK ◦ Receiver replies with rejection (REJ F / NACK) F all subsequent framesF ◦ Receiver discards frame F and all subsequent frames until it receives frame F correctly
27
Go-Back-N Protocol NAKF Go Back F Upon receiving a NAK for frame F, transmitter must Go Back and retransmit frame F and all subsequent frames resends frame F (and all subsequent frames) timer expires too Sender resends frame F (and all subsequent frames) when timer expires too W If window W is selected large enough, sender can transmit continuously if there are no transmission errors
28
Go-Back-N Protocol NAK 3Frame 3 NAK 3 means Retransmit Frame 3 (also tells sender that all frames before frame 3 were received correctly) Receiver discards all subsequent frames Correct Frames Correct Order Receiver only accepts Correct Frames received in Correct Order Buffer So, receiver doesn’t need to Buffer any frames (to reorder them)
29
Go-Back-N Protocol Frame 2 is lost is expecting Receiver is expecting Frame 2, But receives Frame 3 Frame 3 (4,5,…) is discarded (even though correctly received) NAK NAK is sent for Frame 2 Frame 2 and All Subsequences are Retransmitted
30
Go-Back-N Protocol Piggybacking Bi-DirectionalACK When traffic is Bi-Directional, ACK can be piggybacked on packets going in other direction Each packet contains a SNsequence number SN field indicating the packet sequence number RN the other direction RN field ACKs the packet in the other direction RN If there is no packet before timeout, acknowledge RN is sent
31
Selective Repeat Protocol
32
SR 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 (Buffering) Receiver stores the correct frames in a buffer and waits for error-frame (Buffering)
33
Selective Repeat Protocol in order Receiver sends all frames to higher layer in order Window protocol just like Go-Back-N W Window size W
34
Selective Repeat Protocol Need for Buffer ACK Sender must buffer all frames until they are ACKed W ◦ Up to W un-ACKed frames in order Receiver must buffer frames until they can be delivered in order W Up to W frames may have to be buffered at receiver ◦ If the first frame is received in error
35
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
36
Selective Repeat Protocol Retransmission Strategy ACK Receiver ACKs the correct frames ACKtime-outlost in error Not ACKed frames before time-out are assumed lost or in error NAK An explicit NAK (selective reject) can request retransmission of just one frame NAK can expedite retransmission but is not strictly needed ACK Sender retransmits un-ACKed frame after a timeout or upon a NAK
37
Link Utilization
38
Link Utilization (Efficiency) Link Utilization is defined as the ratio of portion of communication link used for sending user data To bandwidth of the link User data rate Link data rate
39
Stop-and-Wait Link Utilization
40
ARQ Performance: Error-Free Stop-and-Wait T frame T prop T prop T = T frame + T prop + T proc + T ack + T prop + T proc T frame = Time to transmit Frame (T trans ) T prop = Propagation time T proc = Processing time at station T ack = Time to transmit ACK Assume T proc and T ack relatively small
41
Error-Free Stop and Wait T ≈ T frame + 2T prop T ≈ T frame + 2T prop (time required to send a frame) Throughput Throughput = 1/T = 1/(T frame + 2T prop ) frames/sec Normalize to link data rate (frames/sec): 1/ T frame U1 U = 1/(T frame + 2T prop ) = T frame = 1 1 + 2a 1/ T frame T frame + 2T prop 1 + 2a a = T prop / T frame where a = T prop / T frame
42
Parameter a a = Propagation Time = d/V = Rd Transmission Time L/R VL where d d = Distance (m) V V = Propagation speed (m/s) L L = Frame length (b) R R = Link data rate (b/s)
43
Stop-and-Wait Timing t frame = 1, t prop = a
44
Stop-and-Wait Performance a = Rd/VL
45
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 ⇒ 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 ⇒ a=tprop/tframe = 5/400 = 0.012 U=1/(2a+1)=0.98
46
Stop-and-Wait ARQ with Errors P = probability a single frame is in error N t = 1 1 - P = average number of times each frame must be transmitted due to errors U1 – P U = 1 = 1 – P 1 + 2a N t (1 + 2a) 1 + 2a
47
Error-Free Sliding Window ARQ Case 1: W ≥ 2a + 1 Ack for frame 1 reaches A before A has exhausted its window
48
Error-Free Sliding Window ARQ Case 2: W 2a +1 t = W t = 2a + 1 A exhausts its window at time t = W and cannot send additional frames until t = 2a + 1
49
Normalized Throughput Normalized Throughput Error-Free Sliding Window ARQ 1 ; W ≥ 2a + 1 U = W ; W 2a +1 1 + 2a W times stop-and-wait throughput
50
Selective Repeat ARQ 1 - P ; W ≥ 2a + 1 U = W(1 - P) ; W 2a +1 2a + 1 W times stop-and-wait (error) throughput
51
Go-Back-N ARQ 1 - P W ≥ 2a + 1 1 + 2aP U = W(1 - P) W 2a +1 (2a + 1)(1 – P + WP) Why?
52
Sliding Window Utilization a Utilization decreases as a increases window size Utilization increases as window size increases Larger window is better, specifically for larger a
53
ARQ Utilization (P = 10 -3 )
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.