TCP: connections and reliability
IP delivers packets on a best-effort basis: some get lost, some arrive out of order. TCP builds a reliable, ordered stream of bytes on top of that. Follow one connection from 192.0.2.7 to 203.0.113.10: the handshake, numbered bytes, the receive window, one lost segment and how it is recovered, and the polite goodbye.
5 quick questions
Pick an answer to see why. Your score saves with your progress.
01The client's SYN has sequence number 1000. What ack number does the server's SYN-ACK carry?
The SYN itself uses one sequence number, so the next number the server expects from the client is 1000 + 1 = 1001.
02Why does each side pick an unpredictable starting sequence number instead of always starting at 0?
If every connection started at 0, a delayed segment from an earlier connection between the same ports, or one an attacker guessed, could fit right in. Unpredictable starting numbers (RFC 9293 §3.4.1, RFC 6528) prevent that.
03The client sends a segment with sequence number 1001 carrying 100 bytes. If it arrives safely and nothing is missing, what ACK number does the server send back?
Sequence numbers count bytes, and an ACK names the next byte the receiver expects: 1001 + 100 = 1101.
04Segment 1101 is lost, but 1201, 1301 and 1401 arrive. What do the server's ACKs say?
An ACK is cumulative: it can only name the next byte in order. While 1101 is missing, every reply says ACK 1101 again. These are duplicate ACKs.
05What does the receive window control?
The receiver advertises how much room it has. The sender keeps its unacknowledged bytes within that window, so it cannot flood a slow receiver. This is flow control.
Glossary
- TCP
- Transmission Control Protocol: turns IP's best-effort packets into a reliable, ordered stream of bytes between two programs.
- Segment
- One TCP message: a header of at least 20 bytes plus any data. It travels inside an IP packet.
- Three-way handshake
- SYN, SYN-ACK, ACK: how two sides open a connection and learn each other's starting sequence numbers.
- Sequence number
- The number of the first byte in a segment. TCP numbers every byte it sends.
- ACK (acknowledgment)
- The next byte number the receiver expects, which also means it has every byte before it (a cumulative ACK).
- Receive window
- How many bytes the receiver can still take. The sender keeps its unacknowledged data within it (flow control).
- Fast retransmit
- Resending a segment as soon as three duplicate ACKs arrive, instead of waiting for the retransmission timer.
- FIN
- The flag that says "I have no more data to send". Each direction is closed with its own FIN and ACK.
Notes and sources
- Illustrative numbers: real initial sequence numbers are random 32-bit values (RFC 6528), segments usually carry up to 1460 bytes on Ethernet, and windows are many kilobytes.
- 192.0.2.7 and 203.0.113.10 are RFC 5737 documentation addresses, the same connection the HTTPS lesson opens.
- Events are grouped for clarity: on a real link the ACKs for 1201 and 1301 leave as soon as each segment arrives, before 1401 is even sent.
- Real senders are also held back by a congestion window (RFC 5681) and often use selective acknowledgments (SACK, RFC 2018); this lesson shows only the receive window.
- Every segment carries a TCP header of at least 20 bytes (up to 60 with options): ports, sequence and acknowledgment numbers, flags and the window.
Quiz Unlocks after the last step.