Skip to main content

Command Palette

Search for a command to run...

TCP 3-Way Handshake Process

Published
3 min readView as Markdown
TCP 3-Way Handshake Process
C
I'm a full-stack developer who loves turning ideas into real, usable products. I work with React, Node.js, MongoDB, and Tailwind to build clean, scalable web apps. I don’t just build demo projects — I focus on solving real problems with code. Always learning, always shipping.

Transmission Control Protocol (TCP) provides a secure and reliable connection between two devices using the 3-way handshake process. TCP uses the 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. They are − SYN, SYN-ACK, and ACK.

Comparing QUIC and TCP | blabs

3-Way Handshake Connection Establishment Process

The following diagram shows how a reliable connection is established using 3-way handshake. It will support communication between a web browser on the client and server sides whenever a user navigates the Internet.

1. The client starts the process and sets the SYN flag to 1

  • The client sends the message to the server by setting the SYN flag to 1.

  • The message contains some other information like sequence numbers(2000), maximum segment size, window size.

  • A sequence number is a randomly generated 32-bits number.

  • SYN - It stands for synchronization. It sends the message to the server to synchronize with the received sequence number.

  • The window size is used for the flow control. It denotes the capacity of the data that can be received.

  • For example - If the window size is 10000 and the maximum segment size is 1000. Then, the maximum number of data segments that should be transmitted is 10000/1000 = 10.

2. The server replies with (SYN+ACK)

  • After receiving the synchronization request from the client, the server sends the acknowledgment to the client by setting the ACK flag to 1.

  • It sends the Acknowledgment number (ACK) to the client which is just 1 greater than the received sequence number from the client. For example - If the sequence number received from the client is 2000 then the acknowledgment sent by the server will be 2001.

  • It denotes the next sequence expected by the sender.

  • In addition to this, the server also sends a randomly generated sequence number (suppose 4000 ) and sets the SYN flag to 1.

  • The server also sends its window size which is the buffer capacity of the server and maximum segment size to the client for flow control.

  • It is required so that none of the ends need to do the fragmentation of packets.

3 -Way Handshake Closing Connection Process

To close a 3-way handshake connection,

  • First, the client requests the server to terminate the established connection by sending FIN.

  • After receiving the client request, the server sends back the FIN and ACK request to the client.

  • After receiving the FIN + ACK from the server, the client confirms by sending an ACK to the server.

Conclusions:

The TCP 3-Way Handshake is like a polite conversation starter between two computers. Before they exchange any real data, they first greet each other (SYN), acknowledge the greeting (SYN-ACK), and confirm everything is good to go (ACK). This ensures a reliable, secure connection for communication. Likewise, ending the conversation uses a similar back-and-forth to close things gracefully. Understanding this process is essential for anyone diving into how the internet really works under the hood.

More from this blog

coder_nandan

30 posts