Skip to main content

UDP

User Datagram Protocol

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/udp

In short

UDP is a lightweight internet protocol that sends small, independent messages called datagrams without a connection, favoring speed over guaranteed delivery.

What is UDP?

UDP, the User Datagram Protocol, is a simple transport protocol that sends data as independent messages called datagrams. It does not set up a connection first, and it does not confirm that a message arrived, resend lost messages, or put them back in order. Like TCP, it runs on top of IP and uses port numbers to deliver each datagram to the right program.

Because UDP skips handshakes, acknowledgments, and retransmissions, it has very little overhead and low latency. Each datagram carries a small header with the source port, destination port, length, and a checksum used to detect corrupted data. If an application needs reliability, it must add its own rules on top, which is exactly what newer protocols such as QUIC do.

An everyday analogy is sending postcards: each one travels on its own, might arrive out of order, and occasionally gets lost, but you don't wait for a reply before sending the next. UDP is used where fresh data matters more than perfect data, such as live voice and video calls, online multiplayer games, DNS lookups, and HTTP/3, which runs over QUIC.

A common confusion is thinking UDP is simply a worse TCP. It is a different trade-off: in a video call, a late packet is useless, so waiting for a retransmission as TCP does would cause more stutter than just skipping it. Because it is connectionless, UDP also supports sending one message to many receivers at once through broadcast and multicast, which TCP cannot do.

At a glance

UDP: the sender sends datagrams 1 to 4 straight away with no handshake; datagram 2 is lost on the way, datagram 4 arrives before 3, and the receiver sends no acknowledgements back.SenderReceiverno handshake1123344lostout of orderno acknowledgements, nothing resent
No setup and no replies keep UDP fast and simple. The price is that datagrams can go missing or arrive out of order.

Key takeaways

  • UDP is connectionless: there is no handshake before data is sent.
  • It does not guarantee delivery or order, and it does not prevent duplicates.
  • Low overhead makes it fast and well suited to real-time applications.
  • DNS, voice and video calls, online games, and QUIC (used by HTTP/3) rely on UDP.
  • Applications that need reliability over UDP must implement it themselves.

Example

Sending a UDP datagram in Pythonpython
import socket

# Create a UDP socket (SOCK_DGRAM means datagrams)
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# Send a message with no connection or handshake
sock.sendto(b"player:42 x=10 y=20", ("127.0.0.1", 9999))

# Wait up to 1 second for a reply; it may never come
sock.settimeout(1.0)
try:
    data, sender = sock.recvfrom(1024)
    print("Reply from", sender, data)
except TimeoutError:
    print("No reply: UDP does not guarantee delivery")

Readers ask

Why would anyone use UDP if it is unreliable?

Because it is faster and simpler. In real-time uses like video calls or games, getting new data quickly matters more than recovering old data, and applications can add only the reliability they actually need.

Does DNS use UDP or TCP?

Most DNS queries use UDP on port 53 because they are small and need quick answers. DNS falls back to TCP for large responses and for transfers between DNS servers, and encrypted variants such as DNS over HTTPS use TCP or QUIC.

Is UDP faster than TCP?

Usually, yes, because it skips the handshake, acknowledgments, and retransmissions. The real difference depends on the network, and on an unreliable network an application may still need to add its own recovery logic.

Often compared

See also

Sources

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings