TodayTools

User Datagram Protocol

How UDP works

Fast and simple, no promise of delivery

Donate
L4TransportIP
What brings you here?

Watch it happen

How much detail

A DNS lookup: one small question, one small answer, no setup at all.

Your laptop
Home router
Internet
DNS resolver
Wi-FiInternetLookup

2 steps, 2 packets

First up: Just send it. Press Play to watch it happen, one step at a time.

0 of 20/2

What is UDP?

UDP sends single messages, called datagrams, from one port to another. It adds just 8 bytes: source port, destination port, length and a checksum. There is no handshake, no acknowledgment and no resending.

That thin design is a feature. DNS, voice and video calls, online games, time sync and QUIC (the base of HTTP/3) all use UDP, because they either need speed more than perfection or build their own reliability on top.

Think of it like this. UDP is like dropping postcards in a mailbox. Each one goes on its own, with no tracking number. Most arrive, some may come out of order, and a few get lost without anyone telling you. If it matters, you have to ask the friend whether it arrived.

Step by step

Normal

2 steps

A DNS lookup: one small question, one small answer, no setup at all.

  1. 1

    Just send it

    No handshake

    The laptop wraps its question in a UDP datagram and sends it. There is no connection to open first, so the question leaves at once.

  2. 2

    The answer

    One datagram back

    The resolver replies from port 53 to the laptop's source port. The app matches the reply by port and by the DNS transaction ID. The whole lookup took one round trip.

Datagram lost

3 steps

The question is dropped on the way. UDP does nothing about it; the app has to notice and ask again.

  1. 1

    Question sent

    Into the void

    The datagram leaves the laptop, but a congested link drops it. Nobody tells the laptop: UDP has no acknowledgments.

  2. 2

    Silence

    The app waits

    UDP itself will never resend. The DNS client in the operating system started a timer when it asked, and only that timer notices the missing answer.

  3. 3

    The app retries

    Same question, again

    When the timer runs out, the DNS client sends the question again, often to a second resolver. This is the key point: with UDP, reliability is the app's job, not the protocol's.

Voice call

3 steps

A live call sends a small datagram every 20 ms. A lost one is skipped, because late sound is useless.

  1. 1

    Steady stream

    One datagram every 20 ms

    The laptop records 20 ms of Ravi's voice, compresses it to about 80 bytes and sends it in its own UDP datagram. That is 50 datagrams a second.

  2. 2

    One is lost

    A tiny gap

    One datagram never arrives. Resending it would take a full round trip, so by the time it came back, its moment would be gone.

  3. 3

    Play on

    Hide the gap and keep going

    Kenji's phone notices the missing sequence number and fills 20 ms with a smoothed guess. He hears nothing, or a tiny click. With TCP the whole call would pause until the lost piece came back.

Closed port

2 steps

Nothing listens on the port. The only hint comes from ICMP, and a firewall may hide even that.

  1. 1

    Datagram to a closed port

    Port 27960 has no program

    The game client sends its join message, but the server program is not running.

  2. 2

    ICMP port unreachable

    The operating system complains

    UDP has no reset like TCP. Instead the server's operating system may send an ICMP Destination unreachable (Port unreachable). Many servers rate-limit or block these, so often the client just hears silence and times out.

Myths and mix-ups

  • UDP is not unreliable in the sense of broken; most datagrams arrive fine, it just does not promise.
  • UDP is not only for games; DNS, NTP, DHCP, voice calls and HTTP/3 all use it.
  • UDP does not mean unsafe; QUIC, WireGuard and DTLS encrypt everything over UDP.
  • Sending faster with UDP does not make a network faster; with no congestion control, it can make loss worse for everyone.

Try it yourself

Run these on your own computer to see UDP at work.

  • Listen on a UDP port (macOS or Linux)

    nc -u -l 9999

    Open a second terminal and run the next command. Some older Linux versions of nc need -p: nc -u -l -p 9999.

  • Send a datagram (macOS or Linux)

    nc -u 127.0.0.1 9999

    Type a line and press Enter. It appears in the listener at once, with no handshake.

  • List UDP sockets (Linux)

    ss -uan

    Shows every UDP port open on your machine, like 53 or 5353.

  • List UDP sockets (Windows or macOS)

    netstat -an -p udp

    UDP has no state column worth reading: there is no connection to track.

  • A real UDP exchange

    nslookup example.com

    Works on Windows, macOS and Linux. The lookup is one UDP question and one answer.

UDP at a glance

Layer
Transport (4)
IP protocol number
17
Header size
8 bytes, always
Connection
None, each datagram stands alone
Reliability
None built in; the app adds it if needed
Max payload
65,507 bytes over IPv4
Defined in
RFC 768 (1980)

Defined inRFC 768RFC 8085

Header fields

What UDP puts in its messages, with example values from the stories above.

UDP

Source port
50123Where the answer should come back to.
Destination port
27960
Length
38 bytesHeader (8 bytes) plus data. That is the whole header: no sequence numbers, no ACKs.
Checksum
verifiedCatches damaged data. A damaged datagram is simply thrown away.

Test yourself

Question 1 of 5Score 0

How big is the UDP header?

Questions people ask

What is the difference between TCP and UDP?

TCP opens a connection and makes sure every byte arrives in order. UDP sends independent datagrams with no setup, no acknowledgments and no resending. UDP is lighter and quicker; TCP is reliable.

Is UDP faster than TCP?

It starts faster because there is no handshake, and a lost packet never stalls the rest. For a big download, TCP is usually just as fast and far simpler to use.

What uses UDP?

DNS lookups, DHCP, NTP time sync, voice and video calls, online games, live streams, VPNs like WireGuard and HTTP/3 through QUIC.

Can UDP packets arrive out of order?

Yes. UDP does not number datagrams, so they can arrive out of order, twice or not at all. Apps that care add their own sequence numbers, like RTP does for calls.

How do I check if a UDP port is open?

It is hard to be sure, because a closed UDP port may say nothing. Tools send a datagram and treat an ICMP Port unreachable as closed and silence as open or filtered.

Donate