How the TCP Handshake Works
SYN, SYN-ACK, ACK — the three words that start every reliable connection.
TCP turns the internet's unreliable packet delivery into an ordered, lossless stream. Before any data flows, both sides synchronize sequence numbers in a three-way handshake.
Legend — how to read this diagram
Three-way handshake
- SYN. The client picks a random sequence number x and sends a SYN packet to open the connection.
- SYN-ACK. The server picks its own y, acknowledges x+1, and sends both back.
- ACK. The client acknowledges y+1. Both sides now agree on starting sequence numbers.
- Data flows. Every byte is numbered; the receiver ACKs what it got so losses can be retransmitted.
What sequence numbers buy you
Ordering. Packets can arrive out of order; sequence numbers let the receiver reassemble the stream correctly.
Reliability. Unacknowledged bytes are resent after a timeout.
Flow & congestion control. Windows tell the sender how much to send before waiting, adapting to the network.
Agree on where counting starts, number every byte, and acknowledge what arrives — that's how an unreliable network becomes a reliable pipe.
No comments:
Post a Comment