Module15: Sliding Windows Protocol and Error Control

29,712 views

Published on

data com tutorials on sliding window protocol and error checking and flow control.

1 Comment
17 Likes
Statistics
Notes
No Downloads
Views
Total views
29,712
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
922
Comments
1
Likes
17
Embeds 0
No embeds

No notes for slide

Module15: Sliding Windows Protocol and Error Control

  1. 1. Module 15Sliding Windows Protocol, and Error Control 1
  2. 2. • Textbook sections – LG Section 5.2 ARQ Protocols• Topics 1. Sliding Window • Overview • Terminology • The sliding of sliding window • Considerations 2. Error Control • Stop-and-wait ARQ • Go-back-N ARQ • Selective Repeat ARQ 2
  3. 3. 1.0 Sliding Windows - Overview• Sliding window protocol (SWP): – A protocol that allows several data units to be in transition before receiving an acknowledgement. SWP is used in TCP for error control and flow Control – Send window • Maintain by the sender • A set of sequence number • Represents a range of permissible sequence numbers for transmitted but not-yet-acknowledged frames • As the protocol operates, the window slides forward over the sequence number space. – Receive window: • Maintain by the receiver • A set of sequence number • Represents a range of frames it is permitted to accept • As the protocol operates, the window slides forward over the sequence number space. – Microsoft Windows NT use 8760 as the default window size 3
  4. 4. 1.0 Sliding Windows - Overview– Typical scenario • TCP sender accepts a data stream from the upper layers, breaks large streams of data into smaller segments, sequence each segment, and places this stream in a send window • TCP sender adds this information in the transport layers header, and then hands it down to IP to be formed into packets • When TCP transmits each segment to IP, the TCP protocol sets a retransmission timer, specifying how long it’ll wait for an acknowledgement (an ACK) before the segment is retransmitted. A copy of each segment remains inside the send window until an acknowledgement is received 4
  5. 5. 1.0 Sliding Windows - Overview– Typical scenario (continue) • The sequence number that TCP adds to each segment are used to put the segments back together at the receiver. • An acknowledge for each segment is sent back to the sender. • When the acknowledge is returned from the receiver and received by the sender, the send window slides (hence the name sliding windows) pass the acknowledged data to the remaining data stream waiting to be sent. • If the sender does not receive an acknowledgment with the time originally set, the segment will be resent. • Retransmitting segments takes up precious bandwidth on the network. 5
  6. 6. 1.0 Sliding Windows - Overview– Highlights • Each byte of data is assigned a sequence number • The sequence number of the first byte of data in a segment is transmitted with that segment and is called the segment sequence number • Segment also carry an acknowledgement number which is the sequence number of the next expected data byte of transmission in the reverse direction. • When the TCP transmits a segment containing data, it puts a copy on a retransmission queue and starts a timer. – When the acknowledgement for that data is received, the segment is deleted from the queue. – If the acknowledgement is not received before the timer runs out, the segment is retransmitted. • The TCP receiver reports a “window” to the TCP sender. This window specifies the number of bytes, starting with the acknowledge number, that the TCP receiver is currently prepared to receive. (Note: This is the value in the window size field from the receiver) 6
  7. 7. 1.0 Sliding Windows - Terminology Send Sequence Space 1 2 3 4 ------------|------------------|------------------|-------------- SND.UNA SND.NXT SND.UNA + SND.WNDSND.UNA: Send unacknowledgedSND.NXT: Send nestSND.WND: Send window size1 – old sequence numbers which have been acknowledged2 – sequence numbers of unacknowledged data3 – sequence numbers allowed for new data transmission4 – future sequence numbers which are not yet allowedThe send window is the portion of the sequence space labeled 3. 7
  8. 8. 1.0 Sliding Windows - Terminology Receive Sequence Space 1 2 3 ------------|------------------|---------------- RCV.NXT RCV.NXT + RCV.WNDRCV.NXT: receive nextRCV.WND: receive window size1 – old sequence numbers which have been acknowledged2 – sequence numbers allowed for new reception3 – future sequence numbers which are not yet allowedThe receive window is the portion of the sequence space labeled 2. 8
  9. 9. 1.0 Sliding Windows - The sliding of sliding window Sliding Window 9
  10. 10. 1.0 Sliding Windows - The sliding of sliding window Sender Sliding WindowNote:• ACK controls the right boundary of the send window• Sending frames controls the left boundary of the send window 10
  11. 11. 1.0 Sliding Windows - The sliding of sliding window Receiver Sliding WindowNote:• ACK controls the right boundary of the receive window• Receiving frames controls the left boundary of the receive window 11
  12. 12. Sliding Window Example 12
  13. 13. 1.0 Sliding Windows - Considerations• Considerations – Sliding Window Protocol (SWP) mechanisms • Acknowledgement (ACK): A response sent by the receiver to indicate the successful receipt and acceptance of data. • Negative acknowledgement (NAK): A message sent to indicate the rejection of received data. • Retransmission timer • Sender application programs, receiver application programs, sequence number, acknowledgement number, window size. – The relationship between sequence number space and maximum window size 13
  14. 14. 2. Error Control 14
  15. 15. 2. Error Control• Purpose – A technique used to ensure that a data stream is delivered accurately to the user despite errors that occur during transmission – Automatic Repeat Request (ARQ) forms the basis for peer-to-peer protocols – For both hop-by-hop and end-to-end approaches – Information flow can be in one direction or both directions• Assumptions – Frames arrive at the receiver in the same order in which they are sent• Types – Stop-and-wait ARQ – Go-back-N ARQ – Selective Repeat ARQ 15
  16. 16. 2. Error Control• For each type of ARQ, four scenarios are considered: – Normal scenario – Abnormal scenarios: • Damaged frame • Lost frame • Lost ACK 16
  17. 17. 2. Error Control LG Figure 5.8 Basic elements of ARQ Information Error-free Packet frames packetsequence sequence Transmitter Receiver Station A Control Station B framesCRC CRC Header Header Control frame Information packet Information Frame 17
  18. 18. 2. Error Control – Stop-and-Wait ARQ • Stop-and-Wait ARQ – Sender uses: ACK, retransmission timer, and sequence number – Scenario 1 (normal and Frame 1 lost)Steps Events1 Station A transmit frame 0 and then waits for an ACK frame from the receiver2 Frame 0 is transmitted without error, so station B transmits an ACK frames.3 The ACK from station B is also received without error, so station A knows the frame 0 has been received correctly.4 Station A now proceeds to transmit frame 1 and then resets the timer.5 Frame 1 undergoes errors in transmission. It is possible that station B receives frame 1 and detects the errors through the CRC check; it is also possible that frame 1 was so badly garbled that station is unaware of the transmission. In either case station B does not take any action6 The time-out period expires, and frame 1 is retransmitted 18
  19. 19. 2. Error Control – Stop-and-Wait ARQ LG Figure 5.9 Possible ambiguities when frames are unnumbered(a) Frame 1 lost Time-out time A frame frame frame frame 0 1 1 2 ACK ACK B(b) ACK lost Time-out time A frame frame frame frame 0 1 1 2 ACK ACK ACK B In parts (a) and (b) transmitting station A acts the same way, but part (b) receiving station B accepts frame 1 twice. 19
  20. 20. 2. Error Control – Stop-and-Wait ARQ– Scenario 2 (ambiguity due to ACK not received) • Figure 5.9 (b) • Problem: Loss of an ACK can result in the delivery of duplicated packet to station B • Solution: Include a sequence number in the header of each frame– Scenario 3 (ambiguity due to premature time-out and loss of frame) • Figure 5.10 • Problem: Premature time-outs combined with loss of I-frame can result in gaps in the delivered packet sequence • Solution: Provide a sequence number in the acknowledgement frame that enables the transmitter to determine which frames have been received. 20
  21. 21. 2. Error Control – Stop-and-Wait ARQ Figure 5.10 Possible ambiguities when ACKs are unnumbered time-out timeA frame 0 frame frame frame 0 1 2 ACK ACKB Transmitting station A misinterprets duplicate ACKs 21
  22. 22. Figure 5.11 System state information in Stop-and-wait ARQ0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Slast Rnext Timer Slast Transmitter Receiver Station A Rnext Station B (0,0) Error-free frame 0 (0,1) arrives at receiver Global State: ACK for (Slast, Rnext) ACK for frame 0 frame 1 arrives at arrives at transmitter transmitter Error-free frame 1 arrives at receiver (1,0) (1,1) 22
  23. 23. 2. Error Control – Stop-and-Wait ARQ• Delay-bandwidth product – The product of the bit rate and the delay that elapses before an action can take place – A key performance parameter – In stop-and-wait the delay-bandwidth product can be viewed as a measure of lost opportunity in terms of transmitted bits. 23
  24. 24. 2. Error Control – Stop-and-Wait ARQ Stop and Wait EOT: End of Transmission 24
  25. 25. 2. Error Control – Stop-and-Wait ARQ Damaged Frame sequence space consists of 0 and 1 0 1 0 Error in Frame 0 00 25
  26. 26. 1.0 Sliding Windows Lost Frame 0 0 0 0 26
  27. 27. 1.0 Sliding Windows Lost ACK 0 0 second 27
  28. 28. 2. Error Control – Go-Back-N(GBN) ARQ• Go-Back-N(GBN) ARQ – Pipeline • A procedure where the processing of a new task is begun before the completion of the previous task • In the context of ARQ, the sender will have to buffer packets that have been transmitted, but not yet acknowledged. Buffering of received packets may also be needed at the receiver. – Description: • In a GBN protocol, the sender is allowed to transmit multiple packets (when available) without waiting for an acknowledgement, but is constrained to have no more than some maximum allowable number, N, of unacknowledged packets in the pipeline. 28
  29. 29. 2. Error Control – Go-Back-N(GBN) ARQ• Examples – Example 1 • Figure 5.13 Basic Go-Back-N ARQ • Typical case when N = WS = 4 – Example 2 • Figure 5.15 Go-Back-N ARQ • Use timer – Example 3 • Figure 5.16 The window size should be less than 2 m • The receiver can determine the correct frame if the window size is smaller than 2m where m is the number of bits in the header which are allotted to the sequence number representation 29
  30. 30. 2. Error Control – Go-Back-N(GBN) ARQ– Example 4 • Figure 5.17 NAK error recovery • The NAK procedure results in having the transmitter go back less than WS frames– Example 5 • Figure 5.18 System parameter in bidirectional Go-Back-N ARQ • Piggybacking: The inclusion of acknowledgement on a data frame. When a data frame arrives, instead of immediately sending a separate control frame, the receiver restrains itself and wait until the network layer passes it the next packet. The acknowledgement is attached to the outgoing data frame (using the ACK field in the frame header). In effect, the acknowledgement gets a free ride on the next outgoing data gram. 30
  31. 31. 2. Error Control – Go-Back-N(GBN) ARQ LG Figure 5.13 Basic Go-Back-N ARQ Go-Back-4: 4 frames are outstanding; so go back 4 fr fr fr fr fr fr fr fr fr fr fr fr fr fr time 0 1 2 3 4 5 6 3 4 5 6 7 8 9AB A A A Out-of-sequence frames A A A A A A C C C C C C C C C K K K K K K K K K 1 2 3 error 4 5 6 7 8 9 31
  32. 32. 2. Error Control – Go-Back-N(GBN) ARQ LG Figure 5.15 Go-Back-N ARQ Transmitter Receiver Send Window ... Receive Window Framestransmitted S last Srecent Slast+Ws-1and ACKed frames Buffers Rnext received Timer Slast Timer Slast+1 The receiver will only accept ... a frame that is error-free and that has sequence number Rnext Timer Srecent ... Slast+Ws-1 32
  33. 33. LG Figure 5.16 The window size should be less then 2 m M =22 = 4, Go-Back - 4: Transmitter goes back 4 fr fr fr fr fr fr fr fr time 0 1 2 3 0 1 2 3 A A A B A C C C A C Receiver has Rnext=0, but it does not K K K 2 3 K know whether its ACK for frame 0 1 4 was received, so it does not know whether this is the old frame 0 or a new frame 0M=22=4, Go-Back-3: Transmitter goes back 3 fr fr fr fr fr fr time 0 1 2 0 1 2 A A A B A C C C K K K Receiver has Rnext=3 , so it rejects the old 1 2 3 frame 0 33
  34. 34. 2. Error Control – Go-Back-N(GBN) ARQ LG Figure 5.17 NAK error recovery Transmitter goes back to frame 1 Go-Back-7: fr fr fr fr fr fr fr fr fr fr fr fr fr fr time 0 1 2 3 4 5 1 2 3 4 5 6 7 0AB A N Out-of-sequence A A A A A A C A frames C C C C C C K K K K K K K K 1 1 2 3 4 5 6 7 error 34
  35. 35. LG Figure 5.18 System parameters in bidirectional Go-Back-N ARQ Station A Station B SArecent RA next Transmitter Receiver Receiver Transmitter SBrecent RB next ACKs are piggybacked in headers “A” Receive Window “B” Receive Window RA next RB next “A” Send Window “B” Send Window ... ... SA last SA last+WA s-1 SB last SB last+WB s-1 Buffers Buffers Timer SA last Timer SB last Timer SA last+1 Timer SBlast+1 ... ... Timer SArecent Timer SBrecent ... ... Timer SA last+WA s-1 Timer 35 +W S B last B -1 s
  36. 36. 2. Error Control – Go-Back-N(GBN) ARQ Damaged Data Frame 36
  37. 37. 2. Error Control – Go-Back-N(GBN) ARQLost Data Frame 37
  38. 38. 2. Error Control – Go-Back-N(GBN) ARQ Lost ACK 38
  39. 39. 2. Error Control – Selective Repeat ARQ• Selective Repeat ARQ – Two new features • The receiver windows is made larger than one frame so that the receiver can accept frames that are out of order but error free • The retransmission mechanism is modified so that only individual frames are retransmitted – Algorithm 39
  40. 40. 2. Error Control – Selective Repeat ARQ Transmitter’s events and actionsEvent ActionData received from When data is received from above, the transmitter checks the next availableupper layer sequence number for the packet. If the sequence number is within the transmitter’s send window, the data is packetized and sent. Otherwise it is either buffered or returned to the upper layer for later transmission.Ack received If an ACK is received, the transmitter marks that packet as having been received. If the packet’s sequence number is equal to Slast,the send window is moved to the unacknowledged packet with the smallest sequence number. If the window moves and there are un-transmitted packets with sequence numbers that now fall within the send window, these packets are transmitted.Timeout or NAK • When the transmitter receives a NAK frame, it retransmits the specific frame.received • When a packet’s logical timer timed-out, it will be retransmitted 40
  41. 41. 2. Error Control – Selective Repeat ARQ Receiver’s Events and ActionsEvent ActionPacket with • ACK packet is returned to the transmittersequence number in • If the packet was not previously received, it is bufferedreceive window is • If this packet has a sequence number equal to Rnext, then this packet and anycorrectly received previously buffered and consecutively numbered packets are delivered to the upper layer. • The receive window is then moved forward by the number of packets delivered to the upper layer. • If an out-of –sequence frame is observed at the receiver, A NAK can be sent with sequence number RnexPacket with An ACK must be generated, even though this is a packet that the receiver hassequence number previously acknowledged.between Rnex –1 andRnex –WR is correctlyreceivedOtherwise Ignore the packet 41
  42. 42. 2. Error Control – Selective Repeat ARQ• Selective Repeat ARQ • Retransmission mechanism – Timer: When the timer expires, only the corresponding frame is retransmitted. – NAK: Whenever an out-of-sequence frame is observed at the receiver, a NAK frame is sent with sequence number Rnext. When the transmission receives such a NAK frame, it retransmits the specific frame, Rnext. – Figure 5.21 Error recovery in Selective Repeat ARQ – Maximum send window size • WS = WR = 2m-1 = (2m)/2 = half the sequence number space • Example: Figure 5.22 Maximum window size in Selective Repeat ARQ 42
  43. 43. LG Figure 5.20 Selective Repeat ARQ Transmitter Receiver Receive Window Send Window ... Framestransmitted S Frames last Srecent Slast+Ws-1and ACKed received Rnext Rnext +Wr-1 Buffers Buffers Timer Slast Rnext+1 Timer Slast+1 Rnext+2 ... ... Timer Srecent Rnext+Wr-1 ... Slast+Ws-1 43
  44. 44. 2. Error Control – Selective Repeat ARQ LG Figure 5.21 Error recovery in Selective Repeat ARQ fr fr fr fr fr fr fr fr fr fr fr fr fr fr time 0 1 2 3 4 5 6 2 7 8 9 10 11 12AB A A N A A A A A A A A A C C A C C C C C C C C C K K K K K K K K K K K K 1 2 2 2 2 2 7 8 9 1 1 1 error 0 1 2 44
  45. 45. 1.0 Sliding Windows Selective Reject 45
  46. 46. LG Figure 5.22 Maximum window size in Selective Repeat ARQM=22=4, Selective Repeat: Send Window = Receive Window = 3 Frame 0 resent fr fr fr fr time 0 1 2 0 A A A A B C C C K K K Receive Window {3,0,1} 1 2 3Send Window = Receive Window = 2 Frame 0 resent fr fr fr time 0 1 0 A A B A C C frame 0 rejected K 1 K 2 46 Receive Window {2,3}

×