go back n - selective reject
TRANSCRIPT
ERROR CONTROL – GO BACK ERROR CONTROL – GO BACK N N SELECTIVE REPEATSELECTIVE REPEAT
ReferencesReferences•Computer Networks
Andrew S. Tanenbaum
4th Edition
Chapter 3
•Data and Computer Communications William Stalling
6th Edition
Chapter 7
Sliding Window ProtocolSliding Window Protocol•Servers many purposes
Flow control
Error Control
Ordered delivery
Sliding Window Flow ControlSliding Window Flow Control
Sliding Window Flow ControlSliding Window Flow Control
SenderSender Receiver Receiver
U = N2*α + 1
U = NtFrame
2*tprop + tFrame
•A sends 2,3 and 4
•But B withholds acknowledgement until frame 4 is received
•B then returns Acknowledgment with a single ACK frame having sequence number 5
•This is also an indication that B is now ready to accept three more frames
•A maintains a list of sequence numbers that it is allowed to send
•B maintains a list of sequence numbers that it is prepared to receive
ExampleExample
Sender Window
Receiver Window
Sliding Window on SenderSliding Window on Sender• Assign sequence number to each frame (SeqNum)
• Maintain three state variables:send window size (SWS)last acknowledgment received (LAR)last frame sent (LFS)
• LFS - LAR <= SWS
• Advance LAR when ACK arrives
• Buffer up to SWS frames
SWS
LAR LFS
… …
• Maintain three state variablesreceive window size (RWS)largest frame acceptable (LFA)last frame received (LFR)
• Maintain invariant: LFA - LFR <= RWS
• Frame SeqNum arrives:if LFR < SeqNum < = LFA acceptif SeqNum < = LFR or SeqNum > LFA discarded
• Send cumulative ACKs
Sliding Window on ReceiverSliding Window on Receiver
RWS
LFR LFA
… …
•LFR = 5
•RWS = 4
LFA = 9
•If frame 7 and 8 are received
•if LFR < SeqNum < = LFA accept 5 < 7 <= 9
Accept
5 < 8 <= 9Accept
ExampleExample
RWS = 4
LFR = 5 LFA = 9
… …
•Frames 7 and 8 are received out of order, so will not be handed over to network layer
•Receiver now has to decide whether or not to send the acknowledgment
•SeqNumToAck: largest sequence number such that all frames <= SeqNumToAck have been received
ExampleExample
RWS = 4
LFR = 5 LFA = 9
… …
•LFR = 5
•RWS = 4
LFA = 9
•SeqNumToAck: largest sequence number such that all frames <= SeqNumToAck have been received
•LFR = SeqNumToAck•LFR = 5
•LFA = LFR + RWS•LFA = 9
ExampleExample
RWS = 4
LFR = 5 LFA = 9
… …
•LFR = 5
•RWS = 4
LFA = 9
•If frame 6 is received now
•5 < 6 <= 9 Accept
•SeqNumToAck = 8
•LFR = SeqNumToAck•LFR = 8
•LFA = LFR + RWS•LFA = 12
ExampleExample
RWS = 4
LFR = 5 LFA = 9
… …
•If frame 6 is received now
•5 < 6 <= 9 Accept
•SeqNumToAck = 8
•LFR = SeqNumToAck•LFR = 8
•LFA = LFR + RWS•LFA = 12
ExampleExample
RWS = 4
LFR =8 LFA = 12
… …
ExampleExample•Receiver will now Acknowledge with SeqNumToAck = 8
•This means the receiver is now ready to receive frames 9 ... 12
A single ACK for multiple frames
Sliding Window: Error ControlSliding Window: Error Control
Automatic Repeat Request (ARQ)Automatic Repeat Request (ARQ)• Automatic repeat request (ARQ) mechanism
componentsError detection
Positive acknowledgment
Retransmission after timeout
Negative acknowledgement and retransmission
• Stop-and-wait ARQ
• Go-back-N ARQ
• Selective-reject (selective retransmission) ARQ
Stop and WaitStop and Wait
Go-Back-N Go-Back-N • If no error, ACK as usual with next frame expected
ACKi means “I am ready to receive frame i” and “I received all frames between i and my previous ack”
• Sender uses window to control the number of unacknowledged frames
• If error, reply with rejection (negative ack)Discard that frame and all future frames until error
frame received correctly
Transmitter must go back and retransmit that frame and all subsequent frames
Time outsTime outs•The sender will keep a timer for each sent but
unacknowledged packet
•If the timer times out, then the sender will transmit an RR with a bit set to 1
This is actually a command for ACK request
•The receiver will respond, and inform the transmitter about the frame it is waiting for.
Possible ScenariosPossible Scenarios1.Damaged Frame
2.Lost Frame
3.Lost Acknowledgment (ACK)
ACK is also called Receiver Ready( RR i)
4.Lost Negative Acknowledgement (NACK)
NACK is also called Reject (Rej i)
Scenario 1: Damaged FrameScenario 1: Damaged Frame• Receiver detects error in
frame i
• Receiver sends rejection-i
• Transmitter gets rejection-i
• Transmitter retransmits frame i and all subsequent frames
Sender Receiver
i (Damaged)
Discard
Rej ii+1
Discard
i
i+1
RR i + 2
Scenario 2: Lost Frame (1)Scenario 2: Lost Frame (1)• Frame i lost
• Transmitter sends i+1
• Receiver gets frame i+1
• Receiver sends reject iOut of order frames not
acceptable
• Transmitter goes back to frame i and retransmits it and all subsequent frames
Sender Receiver
i
Rej i
i+1
Discard
i
i+1
RR i + 2
• Frame i lost and no additional frame sent
• Receiver gets nothing and returns neither RR nor rejection
• Transmitter times out and sends RR with a bit set to 1 (ack request)
• Receiver interprets this as an ack request command which it acknowledges with the number of the next frame it expects (frame i )
• Transmitter then retransmits frame i
Scenario 2: Lost Frame (2)Scenario 2: Lost Frame (2)
Sender Receiver
i
i
RR i
RR bit = 1
Time O
ut
Scenario 3: Lost Ack (1)Scenario 3: Lost Ack (1)• Receiver gets frame i and
send acknowledgment (i+1) which is lost
• Acknowledgments are cumulative
• Before transmitter times out on frame i , if next acknowledgement (i+n) arrives
NO PROBLEM
Sender Receiver
i
RR i + 1i+1
RR i + 2
i+2
Scenario 3: Lost Ack (2)Scenario 3: Lost Ack (2)• Receiver gets frame i and
send acknowledgment (i+1) which is lost
• If transmitter times out
• It sends acknowledgment request with P bit set as before
Sender Receiver
i
RR i + 1
i+1
RR i+1
RR bit = 1
Time O
ut
Scenario 4: Lost RejectionScenario 4: Lost Rejection• As for lost frame (2)
sender asks the receiver the last frame received and continue by retransmitting next frame
Sender
i
i
RR i
RR bit = 1
Time O
ut
i (Damaged)
DiscardRej i
Receiver
Selective RejectSelective Reject• Also called selective retransmission
• Only rejected frames are retransmitted
• Subsequent frames are accepted by the receiver and buffered
• Minimizes retransmission
• Receiver must maintain large enough buffer
• Complex system
Selective Reject - DiagramSelective Reject - Diagram
Frame 5 & 6 will be
buffered on receiver
Another Example of Selective Another Example of Selective RejectReject
Sender must maintain one timer per outstanding packet
Receiver must keep track of “holes” in the sequence of delivered frames
Piggy BackingPiggy Backing•Consider the case, when two stations have to
exchange data
•Both have to send as well as receive data
•Both will maintain 2 windows one for sending and one for receiving
•Instead of sending a separate acknowledgement frame
•Each data frame contains its own sequence number
•As well as an ACK field, that contains the sequence number of the acknowledged frame
•If there is no data to be sent then, a normal ACK packet will be sent.
WHAT IS THE RELATIONSHIP WHAT IS THE RELATIONSHIP BETWEEN SEQ # SIZEBETWEEN SEQ # SIZE
AND WINDOW SIZE AND WINDOW SIZE
Maximum Sequence NumberMaximum Sequence Number•It is a control field in the frame
•Must be of some bounded size
•Sequence number field of size 3Range 0 … 7
•Sequence number field of size nRange 0 … 2n – 1
Frames are numbered modulo- 2n
Maximum Window SizeMaximum Window Size•Suppose max sequence number is 7
•The sender sends 0…7
•Receiver receives 0-7 (one at a time) and sends an acknowledgement with next expected frame 0
•The ACK is lost
•Message 0 times out and is retransmitted
•Receiver accepts frame 0, because that is next frame
•And passes it to Network layer
•Problem???
•?
Example : 2-bit Sequence NumberExample : 2-bit Sequence Number
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3Sender Receiver
123
RR 0
Time O
ut
123
AcceptedAcceptedDiscarded since out
of window
RR 0
0Adjacent Windows on receiver, should not have Adjacent Windows on receiver, should not have
overlapping Sequence Numbersoverlapping Sequence Numbers
Window Size RuleWindow Size Rule•The sender window size must be <=
MaxSeqNum/2
•Sliding window protocol alternates between the two halves of the sequence number space.
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3Sender Receiver
12
RR 3
Time O
ut
12
Discarded since out
of window
RR 3
3
Discarded since out
of window
Issues – Window SizeIssues – Window Size• Given n-bit sequence numbers, what is Max
window size?go-back-n ARQ 2n-1
Why?
what about receiver’s window size?
It is 1, why?
selective-reject(repeat) 2n-1
Why?
Issues – Buffer SizeIssues – Buffer Size• Go-back-n ARQ
sender needs to keep a buffer equal to window sizefor possible retransmissions
receiver does not need any bufferwhy?
• Selective rejectsender needs to keep a buffer of window size for
retransmissions
receiver keeps a buffer equal to window size
Discarded since out
of windowDiscarded since out
of window
Go-Back NGo-Back N
Receiver windows size is 1, Adjacent Windows on Receiver windows size is 1, Adjacent Windows on receiver will never have overlapping Sequence Numbersreceiver will never have overlapping Sequence Numbers
0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3Sender Receiver
123
RR 0
Time O
ut
123
Discarded since out
of window
RR 0
0