Skip to main content

Command Palette

Search for a command to run...

TCP vs UDP, Driving Your Data in a Thar

Updated
4 min read
TCP vs UDP, Driving Your Data in a Thar

Introduction

Welcome back to the "From Wire to Web" series!

  • Part 1: We built the road (Undersea Cables).

  • Part 2 & 3: We found the address using the GPS (DNS).

Now, we need to actually drive to the destination to deliver the message. We are driving the heavy-duty SUV of the internet: The Thar.

But here is the catch: This car has two driving modes.

  1. TCP Mode (Safe & Reliable & Normal mode)

  2. UDP Mode (Fast & Furious & 4X4 mode)

Which one should you use? Let's find out.

1. TCP: "City Drive"

TCP (Transmission Control Protocol) is like taking my family on a trip in my Thar. Safety is the #1 priority.

How it works (The 3-Way Handshake):

Before you even start the engine, you call your friend at the destination.

  • You (SYN): "Hello! I am coming over. Are you home?"

  • Server (SYN-ACK): "Yes, I am home! Come over."

  • You (ACK): "Okay, starting the car now."

The Journey:

You drive carefully. The data packets are your family members.

  • Numbering: Everyone has a specific seat number.

  • Reliability: If "Chintu" (Packet #5) falls out of the car, the whole car stops. You go back, pick him up (Retransmission), and then continue.

  • Conclusion: The data always arrives perfectly, exactly in order.

When to use TCP?

  • Websites (HTTP/HTTPS): You don't want a webpage to load with missing text.

  • Emails: You don't want half a letter.

  • File Downloads: You don't want a corrupted game file.

In chat infrastructure, TCP is always used to make sure to delivery each message in order.

2. UDP: "Off-Road"

UDP (User Datagram Protocol) is like entering your Thar in a desert rally. Speed is the only thing that matters.

How it works (No Handshake):

You don't call. You don't check if the friend is home. You just drive towards home.

The Journey:

You are flying over speed bumps at 120 km/h.

  • No Order: The packets arrive whenever they arrive.

  • Unreliable: If a suitcase falls off the roof rack? Forget it. We don't stop. The show must go on.

When to use UDP?

  • Video Calls (Zoom/Meet): Have you ever seen a video call glitch for a second? That was a lost packet. The app didn't pause to find it; it just skipped to the next frame.

  • Online Gaming (BGMI/Valorant): If a bullet is fired, you need to know now. You don't care about the bullet fired 3 seconds ago.

3. Comparison Table

FeatureTCP (City Mode)UDP (4X4 Mode)
PriorityReliabilitySpeed
ConnectionHandshake (Call first)No Handshake (Just go)
If Packet LostResend itForget it
Best ForWebsites, Emails, Files..Gaming, Streaming..

4. Where does HTTP fit? (The Passenger)

A common confusion for beginners is: "Is HTTP better than TCP?"

That’s like asking: "Is the family member better than the Car?"

  • TCP is the Thar (The vehicle transporting the goods).

  • HTTP is the Family member inside (The actual message/content).

HTTP relies on TCP to get it there safely. HTTP says, "I have this HTML file. Please drive it to the user's laptop safely." TCP says, "Don't worry, I will wear my seatbelt."

Conclusion

So, next time you are building an app, ask yourself:

  • Do I need Safety (TCP)? (Like sending a bank transfer).

  • Do I need Speed (UDP)? (Like live streaming a cricket match).

Both modes are useful. You just need to know when to switch gears.

We decided that for web browsing, we almost always use the safe TCP Mode. But how exactly does the driver ensure safety? How does it number the seats? And how does it politely say goodbye when the trip is over?

In the next blog, we will go behind the scenes and look at the system of the 3-Way Handshake and Reliability.

From Wire to Web

Part 3 of 6

Grab a chai ☕. We trace a data packet from the ocean floor to your screen. Master the "invisible" stack: Modems, Routers, DNS, and cURL. Networking explained for humans, not robots.

Up next

How DNS Resolution Works

We know that google.com has an A Record (IP address). But... who actually finds it?

More from this blog

T

The Engineering Log

18 posts

Documenting the journey from bits to architecture. A technical archive exploring internals, engineering, infrastructure, and the systems that power modern software. Written by Mayur Badgujar.