UDP PDUs- Understanding Datagrams in Networking
What the Heck is a UDP PDU?
Let's cut through the noise. A UDP PDU is just a UDP datagram. PDU stands for Protocol Data Unit — it's networking jargon for "a chunk of data with some headers attached." That's it. Nothing fancy.
UDP (User Datagram Protocol) is one of the core protocols running on top of IP. It doesn't mess around with handshakes, acknowledgments, or retransmissions. You send data, and you hope it arrives. Sometimes it does. Sometimes it doesn't.
The UDP Datagram Structure
UDP is brutally simple. Every UDP datagram has exactly four fields in its header. Eight bytes total. That's nothing compared to TCP's 20+ byte overhead.
| Field | Size | Purpose |
|---|---|---|
| Source Port | 16 bits | Which port the data came from (optional, can be 0) |
| Destination Port | 16 bits | Which port the data is going to |
| Length | 16 bits | Total size of the UDP header + payload |
| Checksum | 16 bits | Error-checking (optional in IPv4) |
The payload is everything else. It can be anything — DNS queries, VoIP audio, video game packets. UDP doesn't care.
UDP vs TCP: Stop Confusing Them
People constantly mix these up. Here's the reality:
- TCP is connection-oriented. Three-way handshake before any data moves. Guaranteed delivery. Packets arrive in order or you get an error.
- UDP is connectionless. No handshake. No guarantees. Fire and forget. Packets might arrive out of order, duplicated, or not at all.
UDP is faster because it skips all that overhead. TCP is more reliable because it actually cares whether your data arrives.
When Each Protocol Makes Sense
Use TCP when:
- You need every single byte to arrive
- Order matters
- You're transferring files, emails, web pages
Use UDP when:
- Speed matters more than completeness
- You can tolerate some lost packets
- Real-time delivery is the goal (voice calls, live video)
How UDP PDUs Actually Work
Here's what happens when you send data over UDP:
- Your application creates a datagram with data
- UDP adds its 8-byte header (source port, dest port, length, checksum)
- IP wraps that in its own header and sends it
- The network delivers it (or doesn't)
- The receiving UDP layer strips the headers and hands data to the app
No waiting. No retransmission requests. If the packet gets lost, the sender never knows. The application has to handle that itself if it cares.
Where You Actually Encounter UDP
UDP isn't obscure academic stuff. You use it every day whether you realize it or not:
- DNS queries — When you type a URL, your computer asks a DNS server "what's the IP for this?" That's UDP port 53. Fast resolution matters here.
- VoIP calls — Skype, Zoom, Discord voice. A few dropped packets means a tiny audio glitch. Waiting for retransmission would cause noticeable lag.
- Online gaming — Your position updates need to be constant and fast. One lost packet out of hundreds? Nobody notices.
- DHCP — Getting an IP address from a DHCP server uses UDP. Same reason as DNS — speed wins.
- Streaming media — Live video. If you miss a frame, you skip it. You don't want the whole stream to freeze while it waits.
The Checksum: UDP's Half-Hearted Error Check
UDP's checksum covers the pseudo-header (source IP, destination IP, protocol number, UDP length) plus the UDP header and payload. It's optional for IPv4, mandatory for IPv6.
But here's the thing — if the checksum fails, UDP just drops the packet. It doesn't request a retransmit. It doesn't notify the sender. The checksum is more of a "probably corrupted" flag than actual error correction.
Some applications disable the checksum entirely to squeeze out a tiny bit more performance. This is technically legal in IPv4. Most modern systems leave it on because hardware offloading handles it anyway.
Ports: How UDP Keeps Things Separate
Like TCP, UDP uses 16-bit port numbers (0-65535). The source port is optional — if you don't need a response, you can set it to 0.
- Well-known ports (0-1023) — Reserved for standard services (DNS on 53, DHCP on 67/68)
- Registered ports (1024-49151) — Applications register these
- Dynamic/private ports (49152-65535) — Ephemeral ports for client-side connections
When your browser connects to a web server, it typically grabs an ephemeral port. The server responds to that port. Your machine routes it back to the right application based on the port number.
Getting Started: Capturing UDP Traffic
Want to see UDP PDUs in action? Here's how to capture and inspect them:
Using Wireshark
- Install Wireshark
- Start a capture on your network interface
- Filter with
udpto see only UDP traffic - Or filter by port:
udp.port == 53for DNS - Click on any UDP packet to see the header breakdown
Quick Linux Command Line Check
Use netstat -u or ss -u to see active UDP sockets on your machine. This shows you which applications are listening or connected via UDP.
Python Example
Here's minimal code to send and receive a UDP datagram:
Sender:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b"Hello, world", ("192.168.1.1", 12345))
Receiver:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("", 12345))
data, addr = sock.recvfrom(1024)
print(f"Got: {data} from {addr}")
No connection setup. No accept(). Just send and receive.
The Brutal Truth About UDP
UDP is not a "worse" TCP. It's a different tool. If you're building something where speed and responsiveness matter more than guaranteed delivery, UDP is your answer. If you need reliability, use TCP or build your own acknowledgment system on top of UDP.
Most developers never touch UDP directly. But understanding how it works helps you debug network issues, choose the right protocol for your application, and make sense of packet captures when things go wrong.
That's the reality of UDP PDUs. Eight bytes of header, fire and forget, and let the application figure out the rest.