Flow Control Refers to a set of procedures used to restrict the amount of data the sender can send before waiting for for ackno acknowl wled edge geme ment nt.. Flow Flow cont contro roll is, is, thwa thwart rtin ing g a fast fast send sender er so that that the the rece receiv iver er is not not overwhelmed with data. Any receiving device has a limited speed at which it can process incoming data, and limited amount of memory, in which to store the incoming data. The receiving device must inform the sending device before those limits are reached and to request that the transmitting device send fewer frames or stop temporarily. Incoming data must be checked and processed it can be used. The rate of such processing is slower than rate of transmission. For this reason, each receiving device has a block of memory, called a buffer, reserved for storing incoming data until the data is processed. If the buffer begins to fill-up, the receiver must be able tell the sender to halt transmission until it is once again able to receive. As frames come in, they are acknowledged, acknowledged, either frame by frame or several frames at a time. If a frame arrives damaged, the receiver sends an error message (a NAK frame). Two methods have been developed to control flow of data across communication links: a. Stop-and-wai Stop-and-waitt flow flow control control protocol protocol – Send one frame frame at a time. time. b. Sliding Sliding Window Window flow flow control control protocol protocol.. – Send several several frames frames at a time. time. Stop-and-wait flow control protocol
In this method the sender sends one frame and waits for an acknowledgement before sending the next frame. WT = Wait time.
WT
Data ACK Data
WT ACK EOT
Time
Time
Figure shows Stop-and-wait flow control protocol. Advantage is, its simplicity: each frame is checked and acknowledged before the next frame is sent. The disadvantage is inefficiency: Stop-and-wait is slow. Each frame must travel all the way to the 1
receiver and an acknowledgement must travel all the way back before the next frame can be sent. If the distance between the devices is long, the time spent waiting for acknowledgements (ACKs) between each frame can add significantly to the total transmission time. Although the transmission rate allows multiple frames to be in transit, only one frame is in transit at any time and hence, the transmission line capacity is under utilized. Sliding Window
Several frames can be in transit at a time, i.e. allows sender to transmit several frames before waiting for an acknowledgement. The link can carry several frames at a time and its capacity can be used efficiently. The receiver acknowledges only some of the frames, using single ACK to confirm the receipt of multiple data frames. The word window in the term “sliding window” refers to an extra buffer, created by both the Sender and Receiver. The window can hold frames at either end and provides the upper limit on the number of fram frames es that that can can be trans transmi mitt tted ed befor beforee requ requir irin ing g an ackn acknowl owled edgem gement ent.. Fram Frames es may may be acknowledged at any point without waiting for the window to fill up and may be transmitted as long as the window is not yet full. To keep track of which frames have been transmitted and which have been received, sliding window introduces an identification scheme based on the size of the window. The frames are numbered modulo-n, which means they are numbered from 0 to (n-1). For example, if n = 8, the frames are numbered 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, … i.e. the size of the window is “n – 1 = 7” in this case. When the receiver sends an ACK, it includes the number of the next frame it expects to receive. In other words, to acknowledge the receipt of a string of frames ending in frame 4, the receiver sends an ACK containing the number 5. When the sender sees an ACK 5, it knows that all frames up through number 4 have been received. 0
1
2
3
4
5
6
7
0
Window Figure Sliding window.
2
1
2
3
4
5
6
Sender’s sliding window
0
1
2
3
4
5
6 7 Direction
0
1
2
t n e s s m a r f a n e h w i e
g i r r f y b e m a r f , t h , e m a w e h T e h t o t s e v o m l l a The sliding window of the sender shrinks from the left when frames of data are sent. The sliding window of the sender expands to the right when acknowledgements are received.
3
4 5 Direction
6
This wall moves to the right, the size of the several frames at a time, when an ACK is received . The length of the movement is the difference between the present and the last ACK number (modulo n).
Receiver’s sliding window
0
1
2
3
4
5
6 7 Direction
0
1
2
3
4 5 Direction
6
e v i e c e r . d r f a n e h w s i e m a g i r f y b e m a r f , t h , e m a r w e h T e h t o t s e v o m l l a
This wall moves to the right, the size of the several frames at a time, when an ACK is sent. The length of the movement is the The sliding window of the receiver shrinks from the left when frames difference between the present of data are received. The sliding window of the sender expands to the and the last ACK number (modulo n). right when acknowledgements are sent. Example of Sliding window protocol – Please refer to the class notes.
Error Control – Any time an error is detected in an exchange, a negative acknowledgement (NAK)
is returned and the specified frames are retransmitted. This process is called Automatic Repeat Request (ARQ). Retransmission of data may occur in three cases: i.
Damaged frame
ii.
Lost frame
iii.
Lost Ac Acknowledgement
Error control protocols may be classified as two types: i.
Stop –and-wait ARQ
ii.
Sliding window ARQ a. Go-back-n AR A RQ b. Sele Select ctiv ivee Rej Rejec ectt ARQ ARQ
3
Stop-and wait ARQ - a form of stop-and-wait flow control extended to include retransmission of
data in case of lost or damaged frames. For retransmission to work, four features are added to the basic flow control mechanism: i.
Sendin Sending g device device keeps keeps a copy of the the last last frame frame trans transmit mitted ted until until an an ACK recei received ved for for that that frame, frame, which allows sender to retransmit lost or damaged frames u ntil they arrived correctly.
ii.
For ident identifi ificat cation ion purpos purposes es both both data frame framess and ACK ACK frames frames are are numbere numbered d altern alternati ativel vely y “0” and “1”. A data 1 frame is acknowledged by an ACK 0 frame, indicating that the receiver has received data 1 and is now expecting data 0. This numbering allows for identification of data frames in case of duplicate transmission (in case of lost ACKs).
iii. iii.
If an error error is is discove discovered red in in a data fram frame, e, indica indicati ting ng that that it has has been corru corrupte pted d in trans transit it,, a NAK frame is returned. NAK frames, which are not numbered, tell the sender to retransmit the last frame sent. Stop-and-wait ARQ requires that the sender wait until it receives an ACK for the last frame transmitted before the next frame transmitted before it transmits the next one. When the sendin sending g device device receiv receives es a NAK, NAK, it resend resendss the frame transmit transmitted ted after after the last last ACK, ACK, regardless of number.
iv. iv.
Send Sendin ing g device device is equip equippe ped d with with a time timerr so that if an ACK ACK is not rece receiv ived ed withi within n an allot allotte ted d time period, sender assumes that the last data frame was lost in transit and sends it again.
Damaged frames - When a frame is discovered by the receiver to contain an error, it returns a
NAK frame and the sender retransmits the last frame.
Data 1
WT ACK 0 Data 0 WT
ACK 1
WY
Data 1 NAK Data 1 ACK 0 . . .
Figure shows Stop-and-wait ARQ damaged frame 4
Data 1
WT
ACK 0 Data 1
Frame lost
WT
Data 1
WT
ACK 0 . . .
Figure shows Stop-and-wait ARQ lost frame
Data 1
WT ACK 0 Data 0 WT
ACK lost
ACK 1
Previous copy
Data 0
is discarded. WT
ACK 1 Data 1 ACK 0 . . .
Figure shows Stop-and-wait ARQ lost ACK frame 5
Sliding Window ARQ
Among the several popular mechanisms for continuous transmission error control, two protocols are most popular: Go-back-n ARQ and Selective-Reject ARQ, both based on sliding window flow control. To extend sliding window to cover retransmission of lost or damaged frames, three features are added to the basic ba sic flow control mechanism: •
The sending device keeps copies copies of all transmitte transmitted d frames frames until they have been acknowledged. acknowledged. For example, if frames 0 through 6 have been transmitted and the last acknowledgement was for frame 2 (expecting frame 3), the sender will keep copies of frames 3 through 6 until it knows that they have been received and acknowledged.
•
In addition to ACK frames, the receiver has the option of returning a NAK frame if the data have been received damaged. The NAK frame tells the sender to retransmit a damaged frame. Because sliding window is a continuous transmission mechanism, both ACK and NAK frames must be numbered for identification. While ACK frames carry the number of the next frame expected, NAK frames on the other hand carry the number of the damaged frame itself. Hence, in both the cases the message to the sender is the number of the frame that the receiver expects next. If data frames 4 and 5 have been received damaged, both NAK 4 and NAK 5 must be returned. However, a NAK 4 tells the sender that all frames received before data 4 have arrived without error.
•
Like stop-and-wait ARQ, the sending device in sliding window ARQ is equipped with a timer to enable it to handle lost acknowledgements. In sliding window ARQ, (n-1) frames may be sent before an ACK must be received. If (n-1) frames are awaiting ACK the sender starts a timer and waits before sending any more. If the allotted time has run out with no ACK, the sender assumes that the frames were not received and retransmits one or all of the frames depending upon the protocol. The sender has no way of knowing whether the lost frames are data, ACK or NAK frames. By retransmitting the data frames two possibilities are covered: lost data and lost NAK. If the lost frame was an ACK frame, the receiver receiver can recognize recognize the redundancy by the number on the frame and discard the redundant data.
6
Go-back-n ARQ
In this sliding window go-back-n ARQ method, if one frame is lost or damaged, all frames sent since the last frame acknowledged are, retransmitted. Go-back-n ARQ (Damaged Frame)
Data
0
Data
1
Data
2
Data
Data
1
Data
2
Data
3
Data
4
NAK 3
Data
5
Data
4
Discarded
Data
3
Data
5
Discarded
Data
4
Data
3
Data
5
Data
4
Data
5
0
ACK 3 Error in frame 3
Figure shows Go-back-n damaged data frame If the receiver receives a frame in error, it transmits a NAK frame indicating the frame number in the NAK frame, which was received in error. The sender will transmit that frame again and also will transmit all the subsequent numbered frames from the one for which NAK is received. The receiver if it has received any subsequent numbered frames after sending the NAK frame will reject all those frames until it receives the frame correctly for which it has previously sent a NAK. Since sender will transmit all the frames starting with the frame for which a NAK is received received and the receiver discards discards all the subsequent subsequent frames after sending a NAK frame until it receives the frame correctly for which a NAK sent, the protocol is referred to as “Go-back-n ARQ” protocol.
7
Go-back-n ARQ (Lost frame)
Data
0
Data
1
Data
3
Data
1
Data
2
Data
3
Data
4
NAK 2
Data
2
Data
4
Data
3
Data
2
Data
4
Data
3
Data
4
Data
0
Lost Discarded Error in frame 3
Figure shows Go-back-n lost data frame
If the receiver receives a frame out of sequence, it transmits a NAK frame indicating the frame number in the NAK frame, which was not received by it and it discards the frame that it has received. The sender will transmit that frame (which was not received by the receiver) again and also will retransmit all the subsequent numbered frames from the one for which NAK is received. The receiver if it has received any subsequent numbered frames after sending the NAK frame will reject all those frames until it receives the frame correctly for which it has previously sent a NAK. Since sender will transmit all the frames starting with the frame for which a NAK is received and the receiver discards all the subsequent frames after sending a NAK frame until it receives the frame correctly for which a NAK sent, the protocol is referred to as “Go-back-n ARQ” protocol.
8
Discarded
Go-back-n ARQ (lost ACK)
Time out
Data
1
Data
2
Lost
Data
0
Data
1
Data
2
Data
0
Data
1
Data
2
ACK 3
Data
0
Data
1
Data
2
Figure shows Go-back-n lost ACK
If the sender does not receive an ACK for the frames it had sent (although the receiver had sent ACK for all the frames the sender had sent and that ACK has been lost in transit) and exhausted exhausted its window size, the sender after waiting waiting for predetermined predetermined amount of time called “Time-out”, will transmit all the frames it had previously transmitted. The receiver when receives all these frames again will recognize that the new transmission is a repeat of an earlier one, sends another ACK indicating that it has received all these frames, and discards the redundant data.
9
Data
0
Selective reject ARQ
Data
1
Data
2
Data
3
Data
0
Data
1
Data
2
NAK 3 Data Data Data Data
4 Data
4
Data
5
Data
6
Data
2
5 6 2
Resent Figure shows Selective Reject damaged data frame
If the receiver receives a frame in error, it transmits a NAK frame indicating the frame number in the NAK frame, which was received in error. The sender will transmit only that frame again. The receiver if it has received any subsequent numbered frames after sending the NAK frame will accept all those frames and put them in the buffer. When it receives the fram framee corr correc ectl tly y for for whic which h it had had prev previo ious usly ly sent sent a NAK NAK it rein reinse sert rtss this this fram framee in the the appropriate order in the buffer. Since the receiver selectively discards only the damaged frame(s) and accepts all subsequent frames the protocol is referred to as “Selective Reject ARQ” protocol.
10
Data
0