Upload
sys4400
View
9.871
Download
0
Embed Size (px)
DESCRIPTION
data com tutorials on sliding window protocol and error checking and flow control.
Citation preview
1
Module 15Sliding Windows Protocol, and
Error Control
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
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
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
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.
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)
7
1.0 Sliding Windows - Terminology
Send Sequence Space
1 2 3 4------------|------------------|------------------|--------------
SND.UNA SND.NXT SND.UNA + SND.WND
SND.UNA: Send unacknowledgedSND.NXT: Send nestSND.WND: Send window size
1 – 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 allowed
The send window is the portion of the sequence space labeled 3.
8
1.0 Sliding Windows - Terminology
Receive Sequence Space
1 2 3
------------|------------------|----------------
RCV.NXT RCV.NXT + RCV.WND
RCV.NXT: receive next
RCV.WND: receive window size
1 – old sequence numbers which have been acknowledged
2 – sequence numbers allowed for new reception
3 – future sequence numbers which are not yet allowed
The receive window is the portion of the sequence space labeled 2.
9
Sliding Window
1.0 Sliding Windows - The sliding of sliding window
10
Sender Sliding Window
1.0 Sliding Windows - The sliding of sliding window
Note: • ACK controls the right boundary of the send window• Sending frames controls the left boundary of the send window
11
Receiver Sliding Window
1.0 Sliding Windows - The sliding of sliding window
Note:• ACK controls the right boundary of the receive window• Receiving frames controls the left boundary of the receive window
12
Sliding Window Example
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
14
2. Error Control
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
16
2. Error Control
• For each type of ARQ, four scenarios are considered:– Normal scenario
– Abnormal scenarios:
• Damaged frame
• Lost frame
• Lost ACK
17
Packet sequence
Error-free packet
sequence
Informationframes
Control frames
Transmitter Receiver
CRC
Informationpacket
Header
Station A Station B
Information Frame
Control frame
CRC Header
LG Figure 5.8 Basic elements of ARQ
2. Error Control
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 Events
1 Station A transmit frame 0 and then waits for an ACK frame from the receiver
2 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 action
6 The time-out period expires, and frame 1 is retransmitted
19
(a) Frame 1 lost
A
B
frame 0
frame1
ACK
frame1
ACK
timeTime-out
frame2
(b) ACK lost
A
B
frame 0
frame1
ACK
frame1
ACK
timeTime-out
frame2
ACK
In parts (a) and (b) transmitting station A acts the same way, but part (b) receiving station B accepts frame 1 twice.
LG Figure 5.9 Possible ambiguities when frames are unnumbered
2. Error Control – Stop-and-Wait ARQ
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.
21
A
B
frame 0 frame
0ACK
frame1
ACK
timetime-out
frame2
Transmitting station A misinterprets duplicate ACKs
Figure 5.10 Possible ambiguities when ACKs are unnumbered
2. Error Control – Stop-and-Wait ARQ
22
Transmitter Receiver
SlastRnext
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
(0,0) (0,1)
(1,0) (1,1)
Timer
Global State:(Slast, Rnext)
Error-free frame 0arrives at receiver
ACK forframe 0arrives attransmitter
ACK forframe 1arrives attransmitter Error-free frame 1
arrives at receiver
Station A Station BRnext
Slast
Figure 5.11 System state information in Stop-and-wait ARQ
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.
24
Stop and Wait
2. Error Control – Stop-and-Wait ARQ
EOT: End of Transmission
25
Damaged Framesequence space consists of 0 and 1
2. Error Control – Stop-and-Wait ARQ
0
1
0
Error in Frame 0
0
0
26
Lost Frame
1.0 Sliding Windows
0
0
00
27
Lost ACK
1.0 Sliding Windows
second0
0
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.
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 2m
• 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
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.
31
A
B
fr0
timefr1
fr2
fr3
fr4
fr5
fr6
fr3
ACK1 error
Out-of-sequence frames
Go-Back-4: 4 frames are outstanding; so go back 4
fr5
fr6
fr4
fr7
fr8
fr9
ACK2
ACK3
ACK4
ACK5
ACK6
ACK7
ACK8
ACK9
LG Figure 5.13 Basic Go-Back-N ARQ
2. Error Control – Go-Back-N(GBN) ARQ
32
Timer Slast
Slast+1
Srecent
Slast+Ws-1
Timer
Timer
Transmitter Receiver
...
Receive Window
Buffers
Slast Slast+Ws-1
...Send Window
Srecent
Framestransmittedand ACKed
Rnext
framesreceived
The receiver will only accepta frame that is error-free and that has sequence number Rnext
...
LG Figure 5.15 Go-Back-N ARQ
2. Error Control – Go-Back-N(GBN) ARQ
33
A
B
fr0
timefr1
fr2
fr3
fr0
fr1
fr2
fr3
ACK1
M =22 = 4, Go-Back - 4:
ACK4
ACK2
ACK3
Transmitter goes back 4
Receiver has Rnext=0, but it does not know whether its ACK for frame 0 was received, so it does not know whether this is the old frame 0 or a new frame 0
A
B
fr0
timefr1
fr2
fr0
fr1
fr2
ACK1
M=22=4, Go-Back-3:
ACK2
ACK3
Transmitter goes back 3
Receiver has Rnext=3 , so it rejects the old frame 0
LG Figure 5.16 The window size should be less then 2m
34
A
B
fr0
timefr1
fr2
fr3
fr4
fr5
fr1
fr2
ACK1
error
Out-of-sequenceframes
Go-Back-7:
fr4
fr5
fr3
fr6
fr7
fr0
NAK1
ACK3
ACK4
ACK5
ACK6
ACK7
ACK2
Transmitter goes back to frame 1
LG Figure 5.17 NAK error recovery
2. Error Control – Go-Back-N(GBN) ARQ
35
Transmitter Receiver
TransmitterReceiver
ACKs are piggybacked in headers
Station A Station B
RA next
“A” Receive Window
RB next
“B” Receive Window
SA last
SA last
SA last+1
SArecent
SA last+WA s-1Timer
SA last+WA s-1
...
...
Buffers
“A” Send Window
...
SB last
SB last
SBlast+1
SBrecent
SB last+WB s-1
SB last+WB s-1
...
...
Buffers
“B” Send Window
...
SArecent RA next
SBrecent RB next
Timer
Timer
Timer
Timer
Timer
Timer
Timer
LG Figure 5.18 System parameters in bidirectional Go-Back-N ARQ
36
Damaged Data Frame
2. Error Control – Go-Back-N(GBN) ARQ
37
Lost Data Frame
2. Error Control – Go-Back-N(GBN) ARQ
38
Lost ACK
2. Error Control – Go-Back-N(GBN) ARQ
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
40
2. Error Control – Selective Repeat ARQ
Transmitter’s events and actions
Event Action
Data received from upper layer
When data is received from above, the transmitter checks the next available 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 received
• When the transmitter receives a NAK frame, it retransmits the specific frame.
• When a packet’s logical timer timed-out, it will be retransmitted
41
Receiver’s Events and Actions
Event Action
Packet with sequence number in receive window is correctly received
• ACK packet is returned to the transmitter
• If the packet was not previously received, it is buffered
• If this packet has a sequence number equal to Rnext, then this packet and any 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 Rnex
Packet with sequence number between Rnex –1 and
Rnex –WR is correctly received
An ACK must be generated, even though this is a packet that the receiver has previously acknowledged.
Otherwise Ignore the packet
2. Error Control – Selective Repeat ARQ
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
43
Transmitter Receiver
Buffers
Slast Slast+Ws-1
...Send Window
Srecent
Framestransmittedand ACKed
Timer Slast
Slast+1
Srecent
Slast+Ws-1
Timer
Timer
...
...
Receive Window
Rnext
Framesreceived Rnext +Wr-1
Rnext+1
Rnext+2
Rnext+Wr-1
...
Buffers
LG Figure 5.20 Selective Repeat ARQ
44
A
B
fr0
timefr1
fr2
fr3
fr4
fr5
fr6
fr2
ACK1 error
fr8
fr9
fr7
fr10
fr11
fr12
ACK2
NAK2
ACK7
ACK8
ACK9
ACK10
ACK11
ACK12
ACK2
ACK2
ACK2
LG Figure 5.21 Error recovery in Selective Repeat ARQ
2. Error Control – Selective Repeat ARQ
45
Selective Reject
1.0 Sliding Windows
46
A
B
fr0
timefr1
fr2
fr0
ACK1
M=22=4, Selective Repeat: Send Window = Receive Window = 3
ACK2
ACK3
Receive Window {3,0,1}
Frame 0 resent
A
B
fr0
timefr1
fr0
ACK1
Send Window = Receive Window = 2
ACK2
Receive Window {2,3}
Frame 0 resent
frame 0 rejected
LG Figure 5.22 Maximum window size in Selective Repeat ARQ