TCP Working: 3-Way Handshake & Reliable Communication
TCP
Every time you open a website, send a message, or download a file, data moves across the internet.
But the internet itself is unreliable.
That’s where TCP (Transmission Control Protocol) comes in.
Why TCP Exists (The Core Problem)
If data was sent without rules:
Packets could arrive out of order
Some packets might never arrive
Some packets could arrive multiple times
The receiver wouldn’t know what’s missing
👉 TCP exists to bring order, reliability, and correctness to data transfer.
What TCP Does (In Simple Terms)
TCP ensures:
Data reaches the right destination
Data arrives in the correct order
Lost data is re-sent automatically
No duplicate data is accepted
Communication starts and ends cleanly
Think of TCP as:
A disciplined conversation, not random shouting.
Problems TCP Is Designed to Solve
❌ Packet loss
❌ Out-of-order delivery
❌ Duplicate packets
❌ Network congestion
❌ Unclear connection start/end
TCP handles all of these behind the scenes.
TCP 3-Way Handshake (Connection Setup)
Before sending data, TCP confirms both sides are ready.
Step-by-step:
SYN → “Can we talk?”
SYN-ACK → “Yes, I’m ready. Are you?”
ACK → “Yes. Let’s start.”
✅ Connection established.
How Data Transfer Works in TCP


Data is broken into small packets
Each packet gets a sequence number
Receiver sends ACKs (acknowledgements)
ACK means:
“I received data up to this point”
How TCP Ensures Reliability & Order
TCP uses:
Sequence numbers → keep packets in order
ACKs → confirm received data
Retransmission → resend missing packets
Checksums → detect corrupted data
If something goes wrong, TCP fixes it automatically.
What Happens When a Packet Is Lost?

Receiver notices a missing sequence number
ACKs stop progressing
Sender re-sends the missing packet
Data transfer continues normally
User never notices.
How a TCP Connection Is Closed

TCP closes connections gracefully:
FIN → “I’m done sending”
ACK → “Received”
FIN → “I’m also done”
ACK → “Connection closed”
No data is cut off suddenly.
TCP Connection Lifecycle (Big Picture)


Handshake → Data Transfer → Connection Close
Where TCP Is Used
TCP is used where accuracy matters:
Web browsing (HTTP / HTTPS)
Emails
File downloads
Secure communication
Final Takeaway
The internet is unreliable
TCP makes it reliable
It ensures data is:
Delivered
Ordered
Verified
Completed properly
Without TCP, the modern internet wouldn’t work.