The easiest way to understand UDP is to ask:

What if we remove almost everything that makes TCP reliable?

The answer is UDP.

UDP (User Datagram Protocol)

Why Do We Need UDP?

TCP is reliable, but reliability comes with a cost.

Before sending data, TCP:

All of this adds overhead and latency.

Now imagine you're on a video call.

If one video packet is lost, do you want to stop the video and wait for that packet?

No.

You'd rather continue with the next frame.

For real-time communication, speed is more important than perfect reliability.

That's why UDP exists.

What is UDP?

UDP is a connectionless transport layer protocol that sends data without guaranteeing delivery, order, or retransmission.

Think of UDP like sending a postcard.

You drop it in the mailbox and hope it reaches the destination.

You don't wait for confirmation.

Connectionless

Unlike TCP:

Client
    │
3-Way Handshake
    │
Server

UDP does this:

Client
   │
Send Data
   │
Server

No handshake.

No connection setup.

Data is sent immediately.

What UDP Does NOT Do

UDP does not provide:

It simply sends the packet.

Example

Suppose you send three packets:

Packet 1
Packet 2
Packet 3

The receiver might get:

Packet 1
Packet 3

Packet 2 may be lost.

UDP doesn't resend it.

It also doesn't care if packets arrive out of order.

Why Would Anyone Use UDP?

Because it's fast.

There's no waiting for:

This makes UDP ideal when low latency matters more than perfect reliability.

Real-Life Examples

Video Calls (Zoom, Google Meet)

If one video frame is lost:


Online Games

Player positions are updated many times every second.

If one update is lost:

Retransmitting old position data isn't useful.

Live Streaming

Missing one frame is better than buffering for several seconds.

DNS

DNS queries are usually very small.

Using TCP would require a connection setup for each lookup.

UDP lets the client send a query and get a response quickly.

(There are exceptions—DNS can use TCP in some cases—but for most lookups, UDP is used.)

Interview Notes

UDP (User Datagram Protocol)


Interview Question

Why is UDP faster than TCP?

Because UDP:

This reduces overhead and allows data to be sent immediately.