TCP Working: 3-Way Handshake & Reliable Communication
When data travels over the internet, it doesn’t move magically.
It moves in small pieces, across many networks, and through many devices.
Now imagine sending data without any rules:
Some data arrives
Some gets lost
Some arrives in the wrong order
That would be chaos.
This is why we need TCP (Transmission Control Protocol).
Why TCP is Needed
TCP exists to make sure that:
Data reaches the correct destination
Data arrives completely
Data arrives in the correct order
Without TCP, important things like:
Web pages
Emails
File downloads
would break very easily.
TCP focuses on reliability, not speed.
Problems TCP is Designed to Solve
TCP was created to solve real problems in network communication:
❌ Data loss
❌ Duplicate packets
❌ Wrong packet order
❌ No confirmation of delivery
TCP adds rules and checks so communication becomes trustworthy.
What is the TCP 3-Way Handshake?
Before sending any real data, TCP first establishes a connection.
This process is called the 3-Way Handshake.
Think of it like starting a phone call:
One person says: “Can you hear me?”
Other replies: “Yes, I can hear you. Can you hear me?”

Step-by-Step: SYN, SYN-ACK, ACK
Let’s break the handshake into simple steps.
SYN (Synchronize)
Client sends a SYN message to the server
This means: “I want to connect”
Client also sends an initial sequence number
SYN-ACK (Synchronize + Acknowledge)
Server replies with SYN-ACK
This means:
“I received your request”
“I’m ready to connect”
Server also sends its own sequence number.
ACK (Acknowledge)
Client sends ACK
This confirms:
“I received your response”
“Connection is established”
Now both sides are ready to exchange data.
How Data Transfer Works in TCP
After the handshake:
Data is sent in small packets
Each packet has a sequence number
Receiver sends an ACK for received packets
This helps TCP:
Track what was sent
Know what was received
Detect missing data

How TCP Ensures Reliability and Order
TCP uses a few smart techniques:
Sequence Numbers
Each packet has a number so data can be reordered correctly.
Acknowledgements (ACKs)
Receiver confirms which packets arrived.
Retransmission
If ACK is not received, TCP resends the packet.
Flow Control
Prevents sending too much data at once.
This is why TCP is trusted for important communication.
What Happens If a Packet is Lost?
If a packet is lost:
Sender waits for ACK
ACK does not arrive
Sender retransmits the packet
This happens automatically — applications don’t need to worry about it.
How a TCP Connection is Closed
When communication is complete, TCP closes the connection properly.
This also follows a controlled process.
One side sends FIN (Finish)
Other side replies with ACK
Then sends its own FIN
Final ACK confirms closure
This ensures:
No data is lost
Resources are released properly

Final Thoughts
TCP may look complex at first, but its goal is simple:
Make communication reliable
Because of TCP:
Websites load correctly
Files download safely
Backend systems trust the network
Understanding TCP gives you a strong foundation for:
HTTP
APIs
Backend systems
Real-world production networking