TCP Connection Establishment: Three-way Handshake
In this lesson, we'll discuss how a TCP connection is established!
A TCP connection is established by using a three-way handshake, which we briefly touched upon in a previous lesson. The connection establishment phase uses the sequence number, the acknowledgment number, and the SYN flag.
Initiating a Connection
When a client host wants to open a TCP connection with a server host, it creates and sends a TCP segment with:
- The SYN flag set
- The sequence number set to a random initial value. So the sequence numbers do not start with 0! Can you guess why?
Responding to an Initial Connection Message
Upon reception of this segment (which is often called a SYN segment), the server host replies with a segment containing:
- the SYN flag set
- the sequence number set to a random number.
- The ACK flag set
- The acknowledgment number set to the sequence number of the received SYN segment incremented by 1 mod