how/network
What does TCP do when a packet is lost? It does not wait long. Three "duplicate ACKs" in a row, and it resends right away without waiting for the timer.
The network is not perfect: packets sometimes get lost (a full queue on a router, a Wi-Fi glitch, a broken link). And TCP promises "reliable delivery," so it has to recover losses somehow. How exactly?
TCP has two mechanisms for resending:
Press ▶ to see how fast retransmit kicks in when a single packet is lost in the middle of the stream.
The client and server have gone through the three-way handshake (see
tcp-handshake) and are both in ESTABLISHED. They are ready to transfer data.
TCP does not wait for an ACK on each packet. It pipelines them. The send window
cwnd defines how many packets can be "in flight" at once
without an acknowledgment.
recap
What to remember:
netstat -s / /proc/net/snmp) show how many
retransmits occurred. A high percentage means network problemsIf you want to go deeper, there is the [[tcp-handshake|TCP lifecycle]] and
the intermediate-02-tcp-handshake lesson where you can sniff packets
by hand.