The mechanism put in place to solve this is the Fast Retransmit, and works as follows:
When the receiver receives a packet that it is not expecting, it responds with an acknowledgement of the last correctly received packet. When the transmitter receives the same ACK three consecutive times, it interprets that the next packet has been lost and thus resends the corresponding packet. In this case the selection timeout is set to a long period of time to avoid premature retransmissions.