I'm reading Tanenbaum's and Wheterall's book on Computer Networks. I'm trying out some examples of situations that can occur in the one bit sliding window protocol for a datalink layer.
The code for the protocol can be found here on page 214.
The situation I was investigating was the following: Let's say client A successfully sends a frame to client B. Client B then sends his frame containing data along with the acknowledgement (ACK) that he received client A's frame correctly (piggybacking). Now somewhere along the way this frame gets damaged. Therefore, in the code, a chksum_err event occurs. Then the exact same frame client A sent before is sent again. Why? Shouldn't it be the case that client A now sends a frame with the sequence number inverted, new data but the acknowledgement is not inverted? This way, assuming nothing special happens along the way, client B correctly receives a new frame (instead of a duplicate) and client B knows that the frame he sent was damaged so he needs to send it again.
Isn't this the beauty of the protocol? Is the code wrong or what am I missing?