TCP three-way handshake

Definition of TCP three-way handshake in The Network Encyclopedia.

What is TCP three-way handshake?

A method of initializing a Transmission Control Protocol (TCP) session between two hosts on a TCP/IP network. The handshake establishes a logical connection between the hosts by synchronizing the sending and receiving of packets and communicating TCP parameters between the hosts.

How TCP Three-way Handshake Works

All TCP communication is connection oriented. A TCP session must be established before the hosts in the connection exchange data. Packets that are transferred between hosts are accounted for by assigning a sequence number to each packet. An ACK, or acknowledgment, is sent after every packet is received. If no ACK is received for a packet, the packet is re-sent. The three-way handshake ensures that the initial request is acknowledged, that the data is sent, and that the data is acknowledged.

These are the three stages of a TCP three-way handshake:

  1. The initiating host sends a TCP packet requesting a new session. This packet contains the initiating host’s sequence number for the connection. The packet includes information such as a set SYN (synchronization) flag and data about the size of the window buffer on the initiating host.

    Graphic T-5. TCP three-way handshake.

  2. The target host sends a TCP packet with its own sequence number and an ACK of the initiating host’s sequence number.
  3. The initiating host sends an ACK containing the target sequence number that it received.

A similar three-way process is used to terminate a TCP session between two hosts. Using the same type of handshake to end the connection ensures that the hosts have completed their transactions and that all data is accounted for.