TCP/IP Three Way Handshake

OSI Model Chart
OSI Model Description

 

Introduction
TCP connections are made using a process known as a three-way handshake. This document describes how this process works.

Passive Open and Active Open

The server will perform a passive open by letting TCP know that it may receive connections on a certain port. In most cases, the server will not know which client will be trying to connect.

The TCP connection is initiated by the client by sending a SYN message to a server. This is called an Active Open and starts the three-way handshake process.


TCP Sequence Numbers
Each device in a TCP connection uses a separate sequence number. Sequence numbers are used to confirm the receipt of all the packets and that they have been put in the right order. Each device determines for itself what initial (first) sequence number it wants to use for a specific TCP connection. The sequence numbers must be a 32 bit number, which means 4,294,967,295 or less. Sequence numbers are finalized during the three-way handshake.

The Three-Way Handshake Process
A simplified example of the three-way handshake steps using hypothetical Sequence Numbers

1. Connection Request by Client: The client chooses an ISN of 5,678 and sends a SYN with the Sequence Number field set to 5,678.

2. Acknowledgement and Connection Request by Server: The server chooses an ISN of 18,765 for its transmission. Once it receives the client's SYN, it send a SYN+ACK with sequence number field 18,765 and an Acknowledgement Number one greater than that sent by the client (5,679 in this example)

3. Acknowledgement by Client: The client sends an ACK with the Acknowledgement Number one greater than the server's sequence number (18,766 in this example)

The connection is now established with sequence numbers starting as established during the 3-way handshake.


References
Primary Source: RFC 793
Secondary source:






OSI Model Chart
OSI Model Description