100% found this document useful (1 vote)
5K views

Go Back N - Selective Reject

The document discusses error control techniques using selective repeat and go-back-N protocols in sliding window protocols. It explains how the sender and receiver maintain sliding windows to keep track of sequence numbers and control the number of unacknowledged frames. It describes scenarios where frames are damaged, lost, or acknowledgments are lost and how the sender and receiver handle each case through retransmissions, timeouts, and negative acknowledgments to ensure reliable data transfer.

Uploaded by

kayani299636
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
5K views

Go Back N - Selective Reject

The document discusses error control techniques using selective repeat and go-back-N protocols in sliding window protocols. It explains how the sender and receiver maintain sliding windows to keep track of sequence numbers and control the number of unacknowledged frames. It describes scenarios where frames are damaged, lost, or acknowledgments are lost and how the sender and receiver handle each case through retransmissions, timeouts, and negative acknowledgments to ensure reliable data transfer.

Uploaded by

kayani299636
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

ERROR CONTROL – GO BACK

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

• Advance LAR when ACK arrives SWS



• Buffer up to SWS frames
… …
LAR LFS
Sliding Window on Receiver
• Maintain three state variables
receive window size (RWS)
largest frame acceptable (LFA)
last frame received (LFR)
• Maintain invariant: LFA - LFR <= RWS

• Frame SeqNum arrives:  RWS

…< = LFA accept


if LFR < SeqNum …
if SeqNum < = LFR or SeqNum
LFR> LFA discarded
LFA

• Send cumulative ACKs


Example
•LFR = 5
 RWS = 4
•RWS = 4 … …
LFR = 5 LFA = 9
LFA = 9
•If frame 7 and 8 are received
•if LFR < SeqNum < = LFA accept
 5 < 7 <= 9
Accept
5 < 8 <= 9
Accept
Example
•LFR = 5  RWS = 4

•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

• Transmitter retransmits i+1


frame i and all
subsequent frames RR i + 2
Scenario 2: Lost Frame (1)
• Frame i lost
Sender Receiver
• Transmitter sends i+1 i

• Receiver gets frame i+1 i+1

• Receiver sends reject i Discard


Rej i
Out of order frames not
acceptable i

• Transmitter goes back i+1


to frame i and
retransmits it and all RR i + 2

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

• Acknowledgments are i+1


RR i + 1
cumulative
RR i + 2
• Before transmitter times
i+2
out on frame i , if next
acknowledgement (i+n)
arrives
 NO PROBLEM
Scenario 3: Lost Ack (2)
• 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

Receiver must keep track


of “holes” in the sequence
of delivered frames

Sender must maintain one


timer per outstanding
packet
Piggy 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
BETWEEN SEQ # SIZE
AND WINDOW SIZE
Maximum Sequence Number
•It is a control field in the frame
•Must be of some bounded size
•Sequence number field of size 3
Range 0 … 7
•Sequence number field of size n
Range 0 … 2n – 1
 Frames are numbered modulo- 2n
Maximum 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 Number
012301230123 012301230123
Sender Receiver
1
2
3
Ti

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

You might also like