TCP Working: 3-Way Handshake & Reliable Communication
A Simple Explanation of the TCP 3-Way Handshake

Introduction: What if the Internet Had No Rules?
Imagine you want to send a message to your friend.
You shout the message.
Your friend may or may not hear it.
Even if they hear, they might hear it in the wrong order.
Some words may be lost.
Some words may be repeated.
That’s exactly what would happen on the internet if there were no rules.
The internet is just millions of computers sending data to each other.
To make sure this data reaches the correct destination, in the correct order, and without loss, we need proper rules.
These rules are called protocols.
One of the most important protocols is TCP.
What is TCP and Why Is It Needed?
TCP stands for Transmission Control Protocol.
TCP is a communication protocol that makes sure:
Data reaches the correct destination
Data is not lost
Data arrives in the correct order
Data is not duplicated
Sender and receiver both agree before talking
In simple words:
TCP makes the internet reliable.
Whenever you:
Open a website
Log in to an app
Submit a form
Send an email
TCP is working silently in the background.
Problems TCP Is Designed to Solve
Before understanding how TCP works, let’s understand what problems exist without TCP.
1. Data Loss
Packets can get lost due to:
Network congestion
Weak connections
Hardware failures
2. Wrong Order of Data
Data is broken into small packets.
Packets can arrive out of order.
Example:
Sent: Hello World
Received: World Hello
3. Duplicate Data
Sometimes the same packet can arrive multiple times.
4. No Confirmation
Sender doesn’t know:
Did the receiver get the data?
Should I resend?
TCP solves all these problems.
Introducing TCP as a Reliable Protocol
TCP works like a formal conversation.
Before sending data:
TCP checks if the other side is ready
Both sides agree to talk
Rules are decided
Only then does actual data transfer begin.
This agreement process is called the TCP 3-Way Handshake.
What Is the TCP 3-Way Handshake?
The 3-Way Handshake is the process by which:
A TCP connection is established
Both client and server confirm:
“I am ready”
“I can hear you”
“Let’s start communication”
It has three steps:
SYN
SYN-ACK
ACK
Think of it as a polite conversation.
Working of TCP 3-Way Handshake (Clear Explanation)
Before two computers can send data to each other on the internet, they must first establish a connection.
They cannot start sending data randomly. Both sides need to confirm that the other is ready.
TCP does this using a process called the 3-Way Handshake.

Step 1: Hey, Are You There? - SYN

Imagine you want to talk to your friend using a walkie-talkie.
Before you start speaking, you press the button and say:
Hey, are you there?
This is exactly what happens in the first step of TCP.
The client sends a message to the server
This message is called SYN (Synchronize)
It means:
I want to start a connection with you.
Along with SYN, the client also sends a sequence number, usually starting from SEQ = 0.
You can think of this sequence number as:
A starting page number of a notebook
Or a reference point for future messages
At this stage:
No real data is sent
Only a connection request is made
Step 2: Yes, I’m Here! - SYN + ACK

Now imagine your friend hears your message and replies:
Yes, I’m here. I heard you. Can you hear me too?
This is the second step of the TCP handshake.
The server replies to the client
It sends a message with SYN + ACK
This means two things:
ACK: I received your SYN
SYN: I also want to start communication with you
The server also sends:
Its own sequence number (for example, SEQ = 0)
An acknowledgment number ACK = 1, meaning:
I received your sequence number 0, now I expect 1 next
Now both sides know:
The other system exists
The connection path works
Sequence numbers are exchanged
Step 3: Yes, Let’s Start Talking - ACK

Finally, you reply to your friend:
Yes, I can hear you too. Let’s talk.
This is the last step of the TCP handshake.
The client sends an ACK message to the server
It confirms:
I received your SYN and your sequence number
The client now sends:
ACK = 1
SEQ = 1
At this point:
Both client and server fully trust the connection
Both know the starting sequence numbers
The connection is officially established
TCP 3-Way Handshake Completed
After these three steps:
SYN
SYN-ACK
ACK
The TCP connection is successfully established, and now:
Actual data transfer can begin
Data can be sent reliably
Packets can be tracked using sequence numbers
Why This Handshake Is Important
The TCP 3-Way Handshake ensures that:
Both computers are ready
Data won’t be sent into the void
Sequence numbers are synchronized
Communication starts in a controlled and reliable way
Without this handshake:
Data could be lost
Messages could arrive out of order
Communication would be unreliable
How Data Transfer Works in TCP
Once the connection is established:
Data is broken into small packets
Each packet has:
Sequence number
Data
Receiver sends ACK for received packets
Example:
Packet 1 → ACK 1
Packet 2 → ACK 2
Packet 3 → ACK 3
If ACK is missing → sender knows something went wrong.
What Are Sequence Numbers ?
Sequence numbers help TCP:
Keep data in correct order
Detect missing packets
Example:
Sent packets: 1, 2, 3, 4
Received: 1, 2, 4
Missing: 3
TCP notices packet 3 is missing and asks for it again.
How TCP Ensures Reliability
TCP is reliable because it uses:
1. Acknowledgements (ACKs)
Receiver confirms each packet.
2. Retransmission
If ACK is not received, packet is sent again.
3. Ordered Delivery
Sequence numbers ensure correct order.
4. Error Checking
Corrupted packets are discarded and resent.
Handling Packet Loss
Let’s say:
Packet 5 is lost
Receiver keeps sending ACK for packet 4
Sender understands:
Packet 5 did not reach
Sender resends packet 5.
This is called retransmission.
As a web developer, TCP matters because:
HTTP runs on top of TCP
Login systems depend on TCP reliability
APIs require ordered, correct data
Databases depend on TCP connections
Without TCP:
Forms would submit incorrectly
Pages would load half-broken
APIs would fail randomly
Want More…?
I write articles on blog.prakashtsx.com and also post development-related content on the following platforms:




