top of page

What is UDP (User Datagram Protocol)?

Oct 26
10 min read

Updated: Oct 27

Independent UDP datagrams crossing a network with a missing packet and no retransmission path.

 

UDP, or User Datagram Protocol, is a transport protocol that carries separate messages called datagrams between applications over IP. Its basic service adds port numbers, a length and a checksum to the application’s data. It does not itself promise delivery, preserve arrival order, suppress duplicates or retransmit a missing message.

 

That limited service gives applications control over how they handle delay and loss. It also leaves responsibilities that another protocol or the application must address. UDP is useful for time-sensitive exchanges and as a foundation for more elaborate transports, but choosing UDP does not make a broadband connection faster or remove the need to manage congestion.

 

A datagram is a message, rather than a byte stream

 

An application using ordinary UDP sends a distinct block of bytes to an IP address and destination port. The receiving socket exposes a datagram boundary. Two messages do not become one continuous application byte stream simply because they travel between the same endpoints.

 

The IETF’s UDP transport features document distinguishes this message service from the interface of a connection-oriented stream. An application can place its own record, sequence identifier or timestamp inside the payload. Those fields are part of that application’s protocol, rather than built-in UDP sequence numbers.

 

A successful send operation means that the local system accepted the data under its API rules. It does not establish that a remote program received, validated or acted on it. If the application needs that evidence, it needs a response with the relevant meaning. A transport checksum answers a different question from an acknowledgement of completed work.

 

What is in the UDP header?

 

RFC 768 defines the basic UDP header as eight bytes, divided into four 16-bit fields. It is carried inside the IP packet rather than replacing the IP header. IP identifies the network endpoints; UDP ports help deliver data to the appropriate transport endpoint at the host.

 

Field

Purpose

Source port

Identifies the sending port when used; it can also provide a reply destination.

Destination port

Identifies the intended receiving port at the destination host.

Length

Counts the basic UDP header and user data in bytes. The minimum value is eight.

Checksum

Checks the UDP header and data, together with an IP pseudo-header used in the calculation.

 

The pseudo-header incorporates information such as source and destination IP addresses. It is part of the checksum calculation, not an extra application-visible UDP header appended to every message. A port number is also not a credential: using a familiar port does not establish the sender’s identity or permission.

 

For IPv4, a zero checksum can indicate that the sender omitted the UDP checksum, although the IETF usage guidance recommends enabling it. For IPv6, RFC 8200 requires the checksum by default, with tightly specified exceptions for certain tunnel uses. Neither rule should be flattened into a claim that all UDP traffic either always has, or never has, error checking.

 

A checksum can detect many accidental errors but is not cryptographic authentication or encryption. Valid-looking data may still be malicious, unauthorised or semantically wrong. A receiving application must validate its own message format and security requirements.

 

Connectionless does not mean that nothing keeps state

 

Basic UDP does not perform a transport connection handshake before sending an ordinary datagram. A socket API may nevertheless offer a connect operation. In that context, connect can establish a local association with a peer and simplify later sends; it does not create a TCP-style exchange on the wire.

 

Applications can have sessions, logins and negotiated keys over UDP. NAT routers and firewalls can also maintain per-flow state for UDP traffic, allowing return packets while a mapping or rule remains active. These are different kinds of state at different layers. Calling UDP connectionless does not imply that every inbound packet will be accepted.

 

A stateful intermediary may discard traffic after an idle mapping expires. Its actual behaviour depends on the device, policy and traffic direction; there is no single timeout guaranteed across arbitrary internet paths. Protocol-specific keepalive and recovery mechanisms need to account for that environment rather than relying on an invented universal timer.

 

What our local UDP check showed

 

Techie Broadband checked several socket behaviours on Linux using Python 3.12.14. All UDP sockets were bound to 127.0.0.1 on automatically allocated ports, and all were closed after the check. Our Loopback Address guide explains why this traffic stayed within one computer.

 

The test first sent the three-byte message one and the seven-byte message second!. Two receive operations returned those two messages separately. A further message sent through a locally connected UDP socket also arrived. That is a functional observation about the chosen API and host, not evidence of a remote handshake or authentication.

 

For a controlled fault example, a small application relay received identifiers 1, 2 and 3. We deliberately programmed it to withhold 2 and forward 3 before 1. The receiver saw 3 followed by 1. A subsequent 200 ms receive wait produced no additional message; the underlying UDP service did not manufacture the missing payload or put these application identifiers back in order.

 

Local check

Observed result and limit

Separate sends

one and second! arrived as separate datagrams. This did not test internet delivery rates.

Programmed relay

The receiver saw 3, then 1; 2 was intentionally withheld by our code. This was not naturally occurring network loss.

Small receive buffer

A ten-byte datagram read with a four-byte recvmsg buffer returned 0123 and the Linux MSG_TRUNC flag.

 

The small-buffer check used the bytes 0123456789. The returned four bytes were a truncated application receive, not four IP fragments and not a measurement of router congestion. API details vary by operating system and receive function. Allocate suitable buffers, check the available truncation indication and reject incomplete records rather than treating them as valid messages.

 

These checks are intentionally modest. They do not measure UK broadband speed, loss probability, Wi-Fi performance, encryption or production resilience. Their value is showing which behaviour belongs to the datagram interface and which behaviour our relay supplied itself.

 

Loss, reordering and useful deadlines

 

The Packet Loss guide explains why a message may fail to reach its destination within the time that matters. A UDP application must decide whether to retry, replace, conceal or abandon information. That decision depends on the meaning of the data, not simply the fact that it was carried in a datagram.

 

A newer position update may make an older update irrelevant. A configuration change may instead require a confirmed outcome and protection against a repeated command. Adding sequence identifiers can help detect a gap, but detection does not retrieve the missing content. A replay, snapshot or retry mechanism needs its own contract.

 

Consider a fictional update needed within 100 ms. If the application only discovers its absence after 120 ms, recovering the old update may no longer help that immediate display. Conversely, a record that must be stored correctly cannot be discarded just because it arrived too late for a screen refresh. Reliability and usefulness are related but different design questions.

 

Do not infer that software using UDP never acknowledges or retransmits. The CoAP guide describes acknowledgements and retransmission at the application-protocol layer of its original UDP mapping. Those facilities are supplied by CoAP, not by adding hidden reliability to the base UDP header.

 

Message size: fit the complete path

 

An MTU is a packet-size limit, measured in bytes. The path MTU reflects the limiting link along the route. A UDP user payload that fits a local interface can still be too large once IP headers, a VPN or another encapsulation are included farther along the path.

 

Our original size calculation starts with 1,200 bytes of application data and an ordinary eight-byte UDP header. With a minimum 20-byte IPv4 header, the resulting IP packet is 1,228 bytes. With the 40-byte IPv6 base header instead, it is 1,248 bytes. These are arithmetic totals, not captured packet measurements.

 

Illustrative packet

Bytes before link-layer overhead

Application data

1,200

UDP header and application data

1,208

IPv4 packet with a 20-byte IP header

1,228

IPv6 packet with only the base IP header

1,248

 

These examples exclude IPv4 options, IPv6 extension headers, UDP Options, security overhead and tunnels. On an illustrative 1,500-byte IP path MTU, the corresponding maximum plain UDP user payload is 1,472 bytes for minimum-header IPv4 or 1,452 bytes for base-header IPv6. Neither figure is a universal safe payload size for every path.

 

IP fragmentation can split an oversized packet into fragments. Losing a required fragment prevents reassembly of that packet, so the complete UDP datagram cannot then be delivered. Some paths also filter fragments. Application-level chunking into independent datagrams is a different design, with its own identifiers, recovery and rate-control requirements.

 

The MTU Black Hole guide covers the case where large packets disappear while small exchanges still work. RFC 8899 specifies Datagram Packetization Layer Path MTU Discovery, which can use probe confirmation and loss information instead of depending solely on ICMP feedback. A suitable upper layer must implement and support that machinery; ordinary UDP does not automatically discover a working payload size for every application.

 

A current standards detail: UDP Options

 

The original UDP specification dates from 1980, but it is not the whole current standards picture. RFC 9868, published in October 2025, updates RFC 768 with UDP transport options in a surplus area after the UDP user data and before the end of the enclosing IP datagram.

 

That extension does not make every installed application use options, nor does it turn the basic datagram service into a reliable stream. RFC 9869 separately describes Path MTU Discovery using UDP Options. Check actual implementation and peer support before relying on an optional facility. The local socket checks and plain-packet size calculations in this article did not use UDP Options.

 

What is UDP (User Datagram Protocol) infographic explaining the mechanism, key stages and practical limits.

 

UDP, TCP and protocols built above UDP

 

TCP provides an ordered byte stream with loss recovery and congestion-control mechanisms. UDP provides distinct datagrams with a much smaller basic transport service. That comparison concerns interfaces and guarantees, rather than a universal contest in which one always completes useful work faster.

 

With UDP, an application can choose not to wait for recovery of obsolete data. With a reliable transport, the application can obtain recovery mechanisms without recreating them from scratch. Total delay still includes the route, congestion, scheduling, message processing and any reliability added above UDP. Header length alone cannot predict the result.

 

QUIC is a clear counterexample to the idea that every UDP-based application must expose unreliable delivery. RFC 9000 defines ordered streams, recovery feedback and flow control above UDP, with accompanying security and congestion-control specifications. UDP carries QUIC packets; QUIC supplies the richer transport behaviour. Ordered delivery within one QUIC stream is not a global order across all streams.

 

  • Real-time media and games may use datagrams so that their application can decide how to handle late or missing updates. Implementations differ.

  • DNS supports UDP exchanges, but DNS is not exclusively a UDP protocol; other transport mappings exist.

  • CoAP can add request matching and message-layer reliability over UDP, while QUIC adds reliable streams at a transport layer above UDP.

  • A service using UDP still needs compatible clients, reachable endpoints and appropriate authentication and permissions.

 

Sending responsibly still matters

 

The IETF UDP Usage Guidelines emphasise congestion control because the basic protocol does not regulate an application’s sending rate for it. A sender cannot assume that removing automatic transport recovery creates unlimited capacity. Retries, probes and keepalives also contribute traffic to the path.

 

Separate average rate from bursts. Sending the same volume in a short burst can overload a queue that would handle a steadier flow. A protocol needs appropriate feedback and adaptation for its environment, rather than a fixed high-rate loop that continues despite loss. Receive capacity also matters: an application can fall behind even when the access line has spare bandwidth.

 

For a UK household, traffic still shares Wi-Fi airtime, router queues and upstream capacity with other applications. Latency under load can increase during a large upload even when a game’s messages are small. Calling those messages UDP does not give them automatic priority or bypass the bottleneck.

 

Security is an additional layer

 

Plain UDP does not encrypt message contents or authenticate a sender. DTLS is one standard way to protect datagram communication; QUIC has its own defined integration with cryptographic protection. Use the security mechanism required by the actual application protocol rather than assuming that an obscure port or binary payload provides privacy.

 

A public UDP service must also account for spoofed source addresses, resource limits and unwanted traffic. Avoid designing a service that sends large unsolicited replies based only on an unverified request address. Diagnostic work should not involve opening arbitrary inbound ports or disabling a firewall to see what happens.

 

A lack of reply is ambiguous. The service may be silent by design, the message may be malformed, a rule may block it, or the reply path may fail. A generic UDP port probe without a protocol-valid response cannot establish the same facts as a successful application exchange.

 

A practical UDP diagnostic sequence

 

  1. Identify the application protocol, intended endpoint and traffic direction. Record what a valid request and response should look like.

  2. Confirm the receiver is listening on the intended address and port, and check application permissions and message validity before blaming the network.

  3. Inspect local firewall, NAT, VPN and remote policy with the service owner. Keep existing protections in place and use the application’s supported tests.

  4. Compare small and larger messages where the protocol permits. Investigate the actual path MTU and encapsulation when only larger traffic fails.

  5. Check both network evidence and receive-side counters or logs. Distinguish a missing packet, an expired application deadline and a truncated receive buffer.

  6. Compare a suitable wired path with Wi-Fi and quiet conditions with controlled load. Retest valid application exchanges and confirm recovery after an interruption.

 

An ICMP ping, a TCP web request and a UDP application exchange test different traffic and processing paths. One can succeed while another fails. Preserve timestamps, endpoint details and relevant status without collecting private payloads unnecessarily, then correlate observations at both ends where access permits.

 

Frequently asked questions

 

Is UDP always faster than TCP?

 

No. UDP has a small basic header and no transport handshake, but useful completion time depends on the workload, network and mechanisms added above it. It does not remove congestion or processing delay.

 

Can an application deliver reliable data over UDP?

 

Yes. An upper-layer protocol can provide recovery and ordering. QUIC is a standards-based example with reliable streams carried over UDP; those features belong to QUIC rather than the basic UDP service.

 

Does a successful UDP send prove delivery?

 

No. It reports local acceptance under the socket API. A meaningful remote response or other supported application evidence is needed to confirm receipt or completed work.

 

Is UDP encrypted?

 

Plain UDP is not encrypted. Applications can use suitable protection such as DTLS or a protocol with its own security design, while authenticating and authorising operations separately.

 

What to remember

 

UDP gives applications separate datagrams and a deliberately limited basic service. Good designs make the missing pieces explicit: what must arrive, what can expire, how rate and size adapt to the path, and what evidence confirms the result. Those decisions determine the experience far more reliably than the claim that UDP is simply faster.

 
 
UK Techie Broadband Providers
bottom of page