TCP Working: 3-Way Handshake & Reliable Communication
What Happens When Data Is Sent Without Rules
At the lowest level, the internet simply moves packets from one machine to another. There are no guarantees. Packets can be lost, duplicated, delayed, or arrive out of order. For things like video streaming, this chaos is acceptable. For passwords, payments, or database queries, it’s a nightmare.This is why we need rules.
Introducing TCP: Reliable Communication Over an Unreliable Network
TCP(Transmission Control Protocol) exists to bring order to this chaos. It turns an unreliable network into a reliable communication channel.
TCP doesn’t trust the network. Instead, it verifies everything. It keeps track of what was sent, what was received, and what needs to be resent. From the application’s point of view, TCP feels like a clean pipe where bytes flow smoothly and predictably.
But before any data flows, TCP does something important, it establishes a connection.

The TCP 3-Way Handshake: Starting a Proper Conversation
First, the client sends a message called SYN. This is the client saying, “I want to talk, and this is where I’ll start counting my data.” That number is the initial sequence number, and it acts like the first page number in a book.
Next, the server replies with SYN-ACK. This response means, “I heard you, I’m ready, and here’s my own starting number. I also acknowledge yours.” At this point, the server confirms both readiness and understanding.
Finally, the client sends ACK, acknowledging the server’s response. With this final message, both sides agree on the rules of communication. The connection is now established.
Only after these three steps does TCP allow data to flow.
How Data Transfer Works in TCP
Once connected, TCP sends data in chunks called segments. Each segment is labeled with a sequence number so the receiver knows exactly where it belongs.
Instead of acknowledging every single packet individually, the receiver usually responds with, “I’ve received everything up to this point.” This cumulative acknowledgement keeps communication efficient while still being precise.
To the application, this entire process is invisible. It simply writes bytes and reads bytes, unaware of the careful bookkeeping happening underneath.
How TCP Ensures Reliability and Order
When packets are lost, TCP notices. Missing acknnowledgements signal a problem, and the sender retransmits only the data that didn’t arrive. If packets arrive out of order, TCP buffers them and delivers the data to the application in the correct sequence.


How a TCP Connection Is Closed Gracefully
Ending a TCP connection follows the same discipline as starting one. When one side is done sending data, it sends a FIN message. The other side acknowledges it, finishes its own work, and then sends a FIN in return. A final acknowledgement completes the closure.