TCP 3-Way Handshake Process

Transmission Control Protocol (TCP) provides a secure and reliable connection between two devices using the 3-way handshake process. TCP uses a full-duplex connection to synchronize (SYN) and acknowledge (ACK) each other on both sides. There are three steps for both establishing and closing a connection: SYN, SYN-ACK, and ACK.

The 3-way handshake ensures that both client and server are ready for data transmission and agree on initial sequence numbers for reliable data ordering and flow control.

Connection Establishment Process

The following diagram illustrates how a reliable connection is established using the 3-way handshake between a client and server:

TCP 3-Way Handshake Connection Establishment Client Server 1. SYN (seq=100) Client requests connection 2. SYN-ACK (seq=300, ack=101) Server acknowledges & requests connection 3. ACK (ack=301) Client acknowledges server Connection Established

Step 1: Synchronization (SYN) − Client Initiates Connection

  • The client sends a SYN segment to the server with the SYN flag set to 1.

  • The segment includes an initial sequence number (ISN) − a 32-bit random number used for ordering data segments.

  • The ACK flag is set to 0, and the client advertises its maximum segment size (MSS) and window size for flow control.

Step 2: Synchronization-Acknowledgment (SYN-ACK) − Server Responds

  • The server acknowledges the client's SYN by setting the ACK flag to 1 and acknowledgment number to client's sequence number + 1.

  • The server also sets its SYN flag to 1 with its own initial sequence number if it wants to establish the connection.

  • The server advertises its window size and maximum segment size to negotiate connection parameters.

Step 3: Acknowledgment (ACK) − Client Confirms

  • The client sends an ACK segment to acknowledge the server's SYN.

  • The acknowledgment number is set to server's sequence number + 1.

  • Once the server receives this ACK, the connection is fully established and data transmission can begin.

Connection Termination Process

TCP uses a 4-way handshake to properly close connections, ensuring all data is transmitted before termination:

  • FIN from Client: The client sends a FIN (finish) segment to request connection termination.

  • ACK from Server: The server acknowledges the FIN request with an ACK segment.

  • FIN from Server: The server sends its own FIN segment when ready to close its side of the connection.

  • ACK from Client: The client acknowledges the server's FIN, and the connection is fully closed.

Key Benefits

  • Reliability: Ensures both parties are ready for communication before data transmission begins.

  • Sequence Number Synchronization: Establishes initial sequence numbers for proper data ordering.

  • Flow Control: Negotiates window sizes and maximum segment sizes for optimal data transfer.

Conclusion

The TCP 3-way handshake is a fundamental process that ensures reliable connection establishment between client and server. This mechanism synchronizes sequence numbers, negotiates connection parameters, and confirms both parties are ready for data transmission, forming the foundation of reliable TCP communication.

Updated on: 2026-03-16T23:36:12+05:30

80K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements