Sender and
receiver
are initialized with the
sameFrame#
The Stop-and-Wait protocol:
Sender:
Start:
Transmit frame with send seq no = Frame#;
Set a timeout;
Wait:
// Wait for an ACK frame to arrive before time out...
while ( not timeout && ACK not received )
{
Wait for ACK frame;
}
if ( timeout expired )
{
go to Start;
}
// ACK was received... Check for correct ACK
if ( ACK seq no ≠ Frame# )
{
go to Wait; // Wrong ACK !
}
Frame# = Frame# + 1;
Done;
Receiver:
// Receiver is ready to receive frame number R
Receive frame;
if ( CRC check is OK )
{
if ( send seq no == R )
{
Send ACK frame with recv seq no = R to sender;
Deliver frame;
R = R + 1; // Accept next new frame
}
else
{
// Received an OLD data frame
Send ACK frame with recv seq no = (R-1) to sender;
Discard frame; // because it's an old frame
}
}
else
{
// Bit errors !!!
Discard frame;
}
Special attention::
When the receiver
receives an old frame:
the receivermust send
an ACK frame to
recover the
ACK frame loss
To distinguish an
old ACK frame and
the current ACK frame (= R),
the receiver can use
the value:
(R-1)
After making these
2 modification
to the (my) basic protocol:
Add a Send
Sequence Number to
the data frames (messages) to:
Identify a
data frameuniquely
Add a Receive Sequence Number to
the ACK frames to:
Identify a
ACK frameuniquely
the resulting protocol is the called:
Stop-and-Wait
protocol.
(Stop-and-Wait is one of the "classic" reliable communication protocols).
The Stop-and-Wait protocol recovers from a
delayed ACK
Note:
I will skip the
following scenarios:
Error-free
Data frame is
lost
ACK frame is
lost
because:
the operation of
the Stop-and-Wait protocol
is similar to that of
the modified basic protocol
Example:
when there are
no erros,
the
the sender and receiver will operate like this:
How
the Stop-and-Wait
protocol solves the
delayed ACK problem:
Explanation:
When the receiver receives the
2nd frame #4,
the receiver will
detect that:
this
frame #4 is
a re-transmissionbecause:
Send sequence no = 4
R = 5 !!!!
The receiver will
transmit:
ACK 4 // (R-1) = 5-1 = 4
When the sender receives
the ACK 4, the
sender finds:
ACK no = 4
Frame# = 5
The sender can tell
the the
ACK 4
is
notacknowlodging
the
data frame 5
The sender will continue
waiting for
ACK 5
In fact, the sender will
timeout and
retranmits
the
lostframe #5
again (and recovers correctly)
Postscript: full name
The complete name of the
Stop-and-Wait protocol is: