Lost data, lost ACKs
The simplest reliable protocol: send a chunk, wait for its ACK, resend on timeout. But if the *ACK* is lost, the sender resends a chunk the receiver already has — so each chunk carries an alternating bit (0, 1, 0, …) and the receiver ignores a repeat of the bit it just accepted.
The four cases
Stop-and-wait has to handle four situations. The chunk arrives and its ACK arrives: move on. The chunk is lost: the sender times out and resends. The chunk arrives but the ACK is lost: the sender resends, and the receiver must recognise the duplicate. Both are fine but slow: just a delay. The alternating bit is what makes the third case safe.
- Data OK, ACK OK → next chunk, flip the bit.
- Data lost → timeout → resend the same chunk and bit.
- ACK lost → resend; receiver sees the old bit, ignores the data but ACKs again.
- Receiver only accepts the bit it's expecting, then flips its expectation.
Simulate on paper with a list of which transmission numbers get lost — the project's test cases do exactly that.