Understanding the TCP 3-Way Handshake and Reliable Connections

🌍 Introduction

When two computers talk over the internet, they need to make sure that:

  1. Both are ready to communicate

  2. Data won’t get lost

  3. Messages arrive in the correct order

That’s where TCP (Transmission Control Protocol) comes in. Unlike UDP, TCP builds a reliable connection before sending data.

The secret behind this reliability is something called the 3-Way Handshake.

In this blog, we’ll explore:

  • What a TCP handshake is

  • How the 3-way handshake works

  • Why sequence numbers and acknowledgments (ACKs) make communication reliable


🤝 What Is a TCP Handshake?

A TCP handshake is how two devices say “Hello” before sending real data.
It ensures both sides:

  • Agree to start a connection

  • Synchronize their sequence numbers

  • Confirm they are ready

Without the handshake, data could get lost or misordered.


🔄 The TCP 3-Way Handshake

The 3-way handshake is the process used by TCP to establish a reliable connection.

Here’s how it works step by step:

  1. SYN (Synchronize)

    • The client says: “Hello, I want to connect. Here’s my starting sequence number.”
  2. SYN-ACK (Synchronize + Acknowledge)

    • The server replies: “Got it. Here’s my sequence number, and I acknowledge yours.”
  3. ACK (Acknowledge)

    • The client confirms: “Thanks, I acknowledge your number too. Let’s start sending data!”

After these three steps, the connection is established, and data transfer can begin.


📦 Example in Real Life

Imagine you are calling a friend on the phone:

  1. You: “Hello, can you hear me?” (SYN)

  2. Friend: “Yes, I can hear you. Can you hear me?” (SYN-ACK)

  3. You: “Yes, I hear you. Let’s talk.” (ACK)

Only after this short exchange does the real conversation start.


🔐 Why Sequence Numbers and ACKs Matter

Every TCP packet has a sequence number and an acknowledgment number (ACK).

  • Sequence Number → Identifies the order of bytes sent.

  • Acknowledgment Number → Confirms receipt of data.

This ensures:
✅ Data arrives in the correct order
✅ Missing packets can be detected and resent
✅ Duplicate packets are ignored


🖼 Visual Guide

Diagram idea:

  • A timeline showing Client → Server: SYN → SYN-ACK → ACK

  • Packets labeled with sequence and acknowledgment numbers


🆚 TCP vs UDP (Handshake)

  • TCP → Uses handshakes, sequence numbers, ACKs → reliable but slower

  • UDP → No handshake, no sequence numbers → faster but less reliable


✅ Conclusion

The TCP 3-way handshake is the foundation of reliable internet communication.

  • It establishes trust between devices

  • Synchronizes sequence numbers

  • Ensures both sides are ready before data transfer

Combined with ACKs, TCP makes sure that your WhatsApp messages, emails, and web pages arrive safely and in the right order.

So next time you load a website, remember: before the content appears, your computer and the server just exchanged a polite “Hello, ready to talk?” 🤝


📌 Key Takeaways

  • TCP handshake = how computers say “Hello” before sending data

  • 3 steps: SYN → SYN-ACK → ACK

  • Sequence numbers + ACKs = ordered, reliable communication

  • TCP = reliability, UDP = speed

0
Subscribe to my newsletter

Read articles from prashant chouhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

prashant chouhan
prashant chouhan