Skip to main content

Command Palette

Search for a command to run...

TCP Handshakes and the 3-Way Handshake

Updated
3 min read
TCP Handshakes and the 3-Way Handshake
A

follow: https://x.com/iadityarxj

What is the TCP 3-Way Handshake and Why Does It Matter?

TCP (Transmission Control Protocol) is like the handshake you give before starting a conversation—it ensures both sides are ready and set for smooth communication. Before devices exchange data over the internet, they first establish a reliable connection through the 3-Way Handshake. This process makes sure that both the sender and receiver are on the same page before any actual data gets transmitted.

Breaking Down the 3-Way Handshake

Imagine two people greeting each other before starting a conversation. In networking, it happens like this:

StepMessageWhat’s Happening?
1SYNThe client says, "Hey server, I want to start a conversation!" (Sends a SYN packet with an initial sequence number)
2SYN-ACKThe server replies, "Got it! Let's sync up." (Sends back a SYN-ACK packet with its sequence number)
3ACKThe client confirms, "Great! We’re connected." (Sends an ACK packet to finalize the handshake)

Once this is done, both devices are ready to send and receive data reliably.

How the Internet Says 'Hello': A Simple Visual Guide

Here’s a simple way to visualize the TCP 3-Way Handshake:

This process makes sure:

  1. The client is ready to send data.

  2. The server is ready to receive data.

  3. Both sides agree on how to keep track of the information they exchange.

Making Sure Data Arrives Correctly: Sequence Numbers & Acknowledgments

TCP doesn’t just send data randomly—it ensures that everything arrives in the right order, without missing pieces. This is done using sequence numbers and ACKs (Acknowledgments).

  • Sequence Numbers: Every piece of data is assigned a number so the receiver knows where it fits.

  • Acknowledgments (ACKs): The receiver confirms what it got and what it's expecting next.

Example of a TCP Conversation

StepClient (Sender)Server (Receiver)What’s Happening?
1SYN, SEQ=1000The client starts the handshake with a sequence number of 1000.
2SYN-ACK, SEQ=2000, ACK=1001The server acknowledges and sends its sequence number.
3ACK, SEQ=1001, ACK=2001Client confirms, handshake complete!
4Data SEQ=1001The client begins sending actual data.
5ACK=1002The server acknowledges receipt of data.

This process makes sure that no data is lost and everything arrives in the right order, making it crucial for things like web browsing, downloading files, and secure communication.

Conclusion

The TCP 3-Way Handshake is the backbone of reliable internet communication. It ensures that two devices properly connect before exchanging data. Thanks to sequence numbers and acknowledgments, TCP guarantees that information is delivered accurately, in order, and without errors. Understanding how this works helps with debugging networks, improving security, and optimizing performance!