Go Back N - Selective Reject
Go Back N - Selective Reject
N
SELECTIVE REPEAT
References
•Computer Networks
Andrew S. Tanenbaum
4th Edition
Chapter 3
•Data and Computer Communications
William Stalling
6th Edition
Chapter 7
Sliding Window Protocol
•Servers many purposes
Flow control
Error Control
Ordered delivery
Sliding Window Flow Control
Sliding Window Flow Control
Sender Receiver
U = NtFrame
2*tprop + tFrame
U = N
2*α + 1
Example
•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 wnow ready to
d o
accept three more frames Wi
n
der
en
•A maintains a list of sequence
S numbers that it is
w
allowed to send i ndo
rW
ve
ei
•B maintains a list of c
sequence
Re numbers that it is
prepared to receive
Sliding 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
•RWS = 4 … …
LFR = 5 LFA = 9
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
Example
•LFR = 5 RWS = 4
•RWS = 4 … …
LFR = 5 LFA = 9
LFA = 9
•SeqNumToAck: largest sequence number such
that all frames <= SeqNumToAck have been
received
•LFR = SeqNumToAck
•LFR = 5
•LFA = LFR + RWS
•LFA = 9
Example
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
Example
RWS = 4
… …
LFR =8 LFA = 12
•If frame 6 is received now
•5 < 6 <= 9 Accept
•SeqNumToAck = 8
•LFR = SeqNumToAck
•LFR = 8
•LFA = LFR + RWS
•LFA = 12
Example
•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 Control
Automatic Repeat Request (ARQ)
• Automatic repeat request (ARQ) mechanism
components
Error 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 Wait
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 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 Scenarios
1.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 Frame
• Receiver detects error in
Sender Receiver
frame i
i (Damaged)
• Receiver sends rejection-i
i+1 Discard
• Transmitter gets rejection- Rej i
Discard
i i
subsequent frames
Scenario 2: Lost Frame (2)
• Frame i lost and no
additional frame sent Sender Receiver
• Receiver gets nothing and i
returns neither RR nor
rejection
Ti
m
e
• Transmitter times out and
O
ut
sends RR with a bit set to 1 RR bit = 1
(ack request)
• Receiver interprets this as an
ack request command which RR i
it acknowledges with the
number of the next frame it i
expects (frame i )
• Transmitter then retransmits
frame i
Scenario 3: Lost Ack (1)
• Receiver gets frame i and
Sender Receiver
send acknowledgment
(i+1) which is lost i
Ti
• If transmitter times out
m
e
RR i + 1
O
ut
• It sends acknowledgment RR bit = 1
request with P bit set as
before RR i+1
i+1
Scenario 4: Lost Rejection
• As for lost frame (2)
Sender Receiver
sender asks the receiver
ii (Damaged)
the last frame received
Ti
and continue by Discard
m
Rej i
e
retransmitting next frame
O
ut
RR bit = 1
RR i
i
Selective 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 - Diagram
Frame 5 & 6
will be
buffered on
receiver
Another Example of Selective
Reject
RR 0
m
e
O
ut
1
2
Accepted
3
Accepted
RR 0 Discarded
since out
0 of window
Adjacent Windows on receiver, should not have
overlapping Sequence Numbers
Window Size Rule
•The sender window size must be <=
MaxSeqNum/2
•Sliding window protocol alternates between the
two halves of the sequence number space.
012301230123 012301230123
Sender Receiver
1
2
Ti
RR 3
m
e
O
ut
Discarded
1
since out
2
of window
Discarded
RR 3 since out
of window
3
Issues – 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 Size
• Go-back-n ARQ
sender needs to keep a buffer equal to window size
for possible retransmissions
receiver does not need any buffer
why?
• Selective reject
sender needs to keep a buffer of window size for
retransmissions
receiver keeps a buffer equal to window size
Go-Back N
012301230123 012301230123
Sender Receiver
1
2
3
Ti
RR 0
m
e
O
ut
Discarded
1
since out
2
of window
3 Discarded
since out
RR 0 Discarded
of window
since out
0
of window
Receiver windows size is 1, Adjacent Windows on
receiver will never have overlapping Sequence Numbers