Skip to main content

Command Palette

Search for a command to run...

TCP: Reliable Communication on the Internet

Updated
•4 min read•View as Markdown
TCP: Reliable Communication on the Internet
S

I learn things, break them, fix them, and write about it so you don’t have to.

Why Data Needs Rules Before Being Sent

Imagine sending important documents across a city without:

  • Knowing if the receiver is ready

  • Knowing if anything gets lost

  • Knowing if pages arrive in order

That’s exactly what would happen on the internet without rules.

Networks are unpredictable:

  • Packets can be dropped

  • Paths can change

  • Receivers can be slower than senders

This is why TCP exists.

TCP - Connection Oriented Protocol - Electronics Post

What Is TCP and Why It Is Needed

TCP (Transmission Control Protocol) is a transport-layer protocol designed to provide reliable communication between applications.

Its job is to make sure that:

  • Data reaches the correct destination

  • Data arrives in the correct order

  • Missing data is retransmitted

  • Communication happens smoothly between sender and receiver

TCP is used whenever correctness matters more than speed.

Problems TCP Is Designed to Solve

TCP exists to solve these core problems:

  • No guarantee of delivery → TCP adds acknowledgements

  • Out-of-order packets → TCP uses sequencing

  • Packet loss → TCP retransmits

  • Overwhelming the receiver → TCP uses flow control

  • Network congestion → TCP slows down intelligently

Without TCP, applications would need to solve all of this themselves.

Understand TCP/IP model using Wireshark! | by Sampad Adhikary |  cyberforgeacademy | Medium

TCP Is Connection-Oriented

Before sending data, TCP establishes a connection between the sender and receiver.

This connection:

  • Reserves resources (buffers, bandwidth)

  • Synchronizes both sides

  • Confirms both are ready to communicate

Think of it like a phone call:

  • You don’t start talking until the other person says “hello”

Transmission Control Protocol (TCP) - GeeksforGeeks

What Is the TCP 3-Way Handshake?

The 3-way handshake is how TCP establishes a connection.

It ensures:

  • Both sides are alive

  • Both sides agree to communicate

  • Initial sequence numbers are synchronized

It consists of three steps:

  1. SYN

  2. SYN-ACK

  3. ACK

TCP_3_way_handshaking - Wireshark Wiki

Step-by-Step: SYN, SYN-ACK, ACK

Step 1: SYN (Client → Server)

The client says:

“I want to talk, and here’s my starting point.”

  • Client sends a SYN packet

  • Includes an initial sequence number

  • Tells the server it wants to establish a connection

Analogy:
Dialing a phone number.

Step 2: SYN-ACK (Server → Client)

The server replies:

“I hear you, and I’m ready too.”

  • Server acknowledges the client’s SYN

  • Sends its own SYN

  • Shares its own sequence number

Analogy:
The other person picks up and says “Hello”.

Step 3: ACK (Client → Server)

The client responds:

“Got it. Let’s start talking.”

  • Client acknowledges the server’s SYN

  • Connection is now established

Analogy:
You reply “Hello” back.

At this point, both sides are synchronized.

How Data Transfer Works in TCP

Once the connection is established:

  • Data is sent as a byte stream

  • Each byte is numbered using sequence numbers

  • Receiver sends acknowledgements for received data

TCP doesn’t send data blindly—it waits for confirmation.

How TCP Ensures Reliability, Order, and Correctness

TCP achieves this using:

Sequence Numbers

  • Every byte has a number

  • Receiver knows the correct order

  • Missing bytes are detected easily

Acknowledgements (ACKs)

  • Receiver confirms what it received

  • Sender knows what was successful

Retransmission

  • If data is missing, TCP resends it

Flow Control

  • Receiver advertises how much data it can handle

  • Sender slows down if needed

Together, these guarantee:

  • No data loss

  • Correct ordering

  • Stable communication

How a TCP Connection Is Closed

TCP closes connections gracefully, not abruptly.

This is done using FIN and ACK messages.

Simple View:

  1. One side says: “I’m done sending” (FIN)

  2. Other side acknowledges (ACK)

  3. Other side sends its own FIN

  4. Final ACK confirms closure

This ensures:

  • All remaining data is delivered

  • No data is cut off mid-transfer

TCP and UDP in Transport Layer - GeeksforGeeks

Why TCP Is So Widely Used

TCP is used by:

  • HTTP / HTTPS

  • APIs

  • File transfers

  • Emails

  • Databases

Anywhere data must be correct, TCP is the default choice.

Final Takeaway

TCP turns an unreliable network into a reliable communication channel.

By:

  • Establishing connections

  • Tracking data

  • Handling loss

  • Closing cleanly

It allows applications to focus on logic instead of networking problems.

More from this blog

Learn With Sneha

23 posts

Learn with Sneha is a personal tech blog focused on learning in public. Breaking down concepts, sharing mistakes, and explaining things clearly once they finally make sense.