TCP Working: 3-Way Handshake & Reliable Communication
Understand TCP connection setup, sequence numbers, acknowledgements, retransmission and connection termination.
On this page 21
When you open a website, send an email, or download a file, your data travels across thousands of miles of cables, routers, and servers. Yet it reaches your device perfectly, in the correct order, without corruption.
This reliability isn’t an accident. It comes from a foundational internet protocol:
TCP — Transmission Control Protocol.
This guide will help you understand:
- what TCP is
- why the internet needs it
- how the TCP 3-way handshake works
- how TCP keeps data ordered and reliable
- how a TCP connection ends safely
Why the Internet Needs TCP
Imagine sending a 500-page book by mailing each page separately.
What could go wrong?
- some pages might get lost
- some might arrive out of order
- some might be damaged
- some might never arrive
- and you wouldn’t even know what happened
Without rules, the early internet would behave exactly like this chaotic postal system.
TCP fixes this chaos.
What is TCP? (Simple Explanation)
TCP (Transmission Control Protocol) ensures:
- reliable delivery
- ordered delivery
- complete delivery
- error-free communication
- controlled, non-overwhelming flow
Think of TCP as:
“Guaranteed, verified, in-order delivery for all internet data.”
TCP was designed to solve real problems:
- Packet Loss → resend missing data
- Out-of-Order Arrival → rearrange data correctly
- Overloaded Devices → slow the sender down automatically
But before reliable transfer begins, TCP performs a setup process.
This is the 3-way handshake.
The TCP 3-Way Handshake (Beginner-Friendly Explanation)
Before two computers exchange real data, they must:
- confirm they can communicate
- agree on starting sequence numbers
- prepare for reliable transfer
You can imagine it as a phone call:
Client: “Hey, can you hear me?” Server: “Yes, I hear you.” Client: “Great, let’s talk.”
Now both sides are synchronized.
Here’s the computer version.
Step 1 — Client → Server: SYN
The client sends a packet with:
- SYN flag = 1
- a random initial sequence number
Meaning:
“I want to start a connection. Here’s my starting number.”
Step 2 — Server → Client: SYN-ACK
The server responds with:
- SYN flag = 1
- ACK flag = 1
- its own sequence number
- an acknowledgement of the client’s number
Meaning:
“I heard you. I’m ready. Here’s my number.”
Step 3 — Client → Server: ACK
The client sends back:
- ACK flag = 1
- acknowledges the server’s number
Meaning:
“Great, we’re synced. Begin sending data.”
At this point, the connection is established.
How TCP Transfers Data Reliably
Once the handshake is complete, real data starts flowing. TCP uses two powerful mechanisms:
- Sequence Numbers
- Acknowledgements (ACKs)
These ensure data arrives perfectly.
1. Sequence Numbers (Keeping Order)
When TCP sends a file, it splits it into smaller chunks called segments.
Example:
- Packet A: bytes 1–100
- Packet B: bytes 101–200
- Packet C: bytes 201–300
Even if packets arrive in the wrong order (like C → A → B), TCP uses the sequence numbers to reorder them correctly.
Just like reconstructing pages of a book.
2. Acknowledgements & Retransmissions (Ensuring Delivery)
Every time the receiver gets data, it sends an ACK:
“I’ve received everything up to byte 200. Send the next part.”
If the sender doesn’t receive an ACK within a certain time window:
- it assumes the packet is lost
- it resends the missing data
This is why downloads sometimes pause or retry — TCP is quietly fixing lost packets behind the scenes.
How TCP Closes a Connection Safely
Just like beginning, closing also happens politely.
TCP uses a 4-step termination process:
1. Client → Server: FIN
“I’m done sending.”
2. Server → Client: ACK
“Got it.”
3. Server → Client: FIN
“I’m done too.”
4. Client → Server: ACK
“Goodbye.”
The connection closes only after both sides finish sending their final data.
Summary (Easy Revision)
What is TCP?
A protocol that ensures reliable, ordered, correct communication.
Why do we need it?
Because the internet naturally loses, scrambles, or duplicates data.
What is the 3-way handshake?
A setup phase using SYN → SYN-ACK → ACK.
How does TCP keep data reliable?
- sequence numbers
- acknowledgements
- retransmissions
- ordering
- flow control
How does TCP close the connection?
FIN → ACK → FIN → ACK
Final Takeaway
TCP is the hidden backbone of the modern internet. It turns an unpredictable network into a reliable communication system.
Without TCP:
- banking would fail
- downloads would corrupt
- messages would be incomplete
- websites would break frequently
Thanks to TCP’s handshake, numbering, acknowledgements, and graceful shutdown, our digital world feels smooth and trustworthy.
Comments 00
Got something to say? Leave a comment.
Join the discussion ↗