"Stop-and-Wait" protocol
"stop-n-wait" (sometimes known as "positive acknowledgement with retransmission") is the fundamental technique to provide reliable transfer under unreliable packet delivery system.
2. How this protocol works..
1) Normal operation
|
After transmitting one packet, the sender waits for an acknowledgment (ACK) from the receiver before transmitting the next one. In this way, the sender can recognize that the previous packet is transmitted successfuly and we could say "stop-n-wait" guarantees reliable transfer between nodes. To support this feature, the sender keeps a record of each packet it
sends.
|
2) Timeout
|
If the sender doesn't receive ACK for previous sent packet after a
certain period of time, the sender times out and retransmits
that packet again. There are two cases when the sender doesn't receive
ACK; One is when the ACK is lost and the other is when the frame itself
is not transmitted.
To support this feature, the sender keeps timer per each packet. |
3. How it is shown in nam (network animator)..
"stop-n-wait" protocol can be shown as below in nam.
1. Packet_0 is sent and ACK_0 is received |
|
2. Packet_1 is sent and ACK_1 is received |
|
3. Packet_2 will be sent and be received and so on.. |
Here is ns script for this simulation. You can download ns script and nam file and run it by yourself.
4. Shortcoming
The main shortcoming of the stop-and-wait algorithm is that it allows the sender to have only one outstanding frame on the link at a time. The sender should wait till it gets an ACK of previous frame before it sends next frame. As a result, it wastes a substantial amount of network bandwidth. To improve efficiency while providing reliability, "sliding window" protocol is appeared. The detail comparison will be discussed with an example here.