Suppose, for example, that the window has a size of 5 MSS, the sender sends 5 segments to the network, the fifth is lost. Actually the question: how does the recipient behave? It just doesn't acknowledge receipt of 4 segments and waits for the sender to shrink the window and send a smaller window? Or the recipient has some kind of timer by which he concludes that the segment is lost and sends an acknowledgment of 4 segments to the sender
1 Answer
how does the recipient behave?
The recipient ACKs the first four segments = beginning of the fifth segment.
waits for the sender to shrink the window and send a smaller window?
The sender doesn't shrink the transmission window just because of a lost segment. The window shrinks when congestion is detected which is a bit more complex.
When the sender receives the ACK for the beginning of the fifth segment, the previous four are removed from the window, advancing it to segments 5-9. Depending on the exact algorithm and timing, the sender may then send those four segments right away (resending seg 5). Alternatively, it may select to wait a little while longer for the ACK for the fifth segment that might still be in transit (max 1 RTT), and failing that, send segments 5-9 when the short timer expires.
Or the recipient has some kind of timer by which he concludes that the segment is lost and sends an acknowledgment of 4 segments to the sender
Yes, the recipient likely uses cumulative acknowledgment (in contrast to ACKing each segment separately) and has a short timer for when these acknowledgments are sent (restarting the timer after each received segment while watching the window). Accordingly, there might be a short delay between reception of seg 4 and ACK of segs 1-4.