Skip to main content

Command Palette

Search for a command to run...

TCP Working: 3-Way Handshake & Reliable Communication

Published
3 min read

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.

https://afteracademy.com/images/what-is-a-tcp-3-way-handshake-process-three-way-handshaking-establishing-connection-6a724e77ba96e241.jpg

https://miro.medium.com/0%2AWcbPv9sWlCl6RV4a

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

https://static.wixstatic.com/media/a2409e_aef337e8e53946f383f37bad39fe1028~mv2.jpg/v1/fill/w_566%2Ch_480%2Cal_c%2Clg_1%2Cq_80/a2409e_aef337e8e53946f383f37bad39fe1028~mv2.jpg

https://docs.oracle.com/cd/E18752_01/html/816-4554/figures/ipov.fig88.png

  • 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?

https://assets.extrahop.com/images/infographics/TCP-RTO-Retransmission-Timeout-Diagram.jpg

  • 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

https://upload.wikimedia.org/wikipedia/commons/8/8a/TCP_connection_Termination.png

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)

https://www.ibm.com/support/pages/system/files/inline-images/Flow%20chart%20TCP%20connection_0.jpg

https://media.geeksforgeeks.org/wp-content/uploads/CN.png

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.

More from this blog

C

CHAIAURCODE-->WEBCOHORT

13 posts