What is UDP (User Datagram Protocol)?

A connectionless transport-layer protocol. Its header is 8 bytes and holds only port numbers, a length and a checksum. It has no connection setup, no acknowledgments or retransmission and no ordering, so it adds little delay. It is used for DNS queries, voice and video calls, online games, DHCP and QUIC, among others.

Japanese name: UDP

UDP (User Datagram Protocol) appears in 4 practice questions across 2 topics, including Computer Networking Basics, Web Technology Basics.

Field: Computer Networking Basics

Header and datagrams

The UDP header consists of four 16-bit fields, the source port, destination port, length and checksum, for 8 bytes in total. Each block of data the application sends becomes one datagram, and the receiver gets it with the same boundaries, unlike TCP's byte stream. The checksum is optional over IPv4 but mandatory over IPv6. Large datagrams are fragmented at the IP level and are more easily lost, so applications normally keep them small enough to fit within the MTU.

When UDP is the right choice

In calls and live streaming, data that arrives late is useless, and waiting for retransmissions makes sound and video stutter. For exchanges made of a single question and answer, such as DNS queries, skipping connection setup cuts the waiting time. UDP can also be used for one-to-many broadcast and multicast, which is why DHCP, used by devices that do not yet have an IP address, runs over UDP. Applications that need reliability build retransmission and ordering on top of UDP themselves, as QUIC does.

Things to watch out for

UDP datagrams can be lost, duplicated or reordered, so the application has to cope, for example by numbering its data. UDP itself has no congestion control, so an application sending a lot of data must pace itself. NAT mappings disappear after a period without traffic, so applications sometimes send small keepalive packets to hold them open. Because there is no handshake and the source address is easy to forge, UDP services such as DNS that return large answers to small queries are abused in reflection and amplification DDoS attacks.

Try it: questions about UDP (User Datagram Protocol)

In the four-layer TCP/IP model, which layer do TCP and UDP belong to?

  1. AApplication layer
  2. BInternet layer
  3. CTransport layer
Show answer and explanation

Answer: C. Transport layer

The TCP/IP model is described with four layers, from the bottom: the link layer (network interface layer), the internet layer, the transport layer and the application layer. TCP and UDP are transport-layer protocols, and they use port numbers to tell which application on a host the traffic is for. IP, in the internet layer, is responsible for delivering packets from one host to another. HTTP and DNS are application-layer protocols. Mapped onto the OSI reference model, the transport layer corresponds to layer 4 and the internet layer to layer 3.

Which correctly describes UDP?

  1. AIt does not establish a connection or control retransmission and ordering, so its header is small and there is no wait before sending
  2. BIt establishes a connection, retransmits data that did not arrive and puts data back in order at the receiver
  3. CIt delivers data to the destination host using only MAC addresses, without IP addresses
Show answer and explanation

Answer: A. It does not establish a connection or control retransmission and ordering, so its header is small and there is no wait before sending

UDP is a lightweight protocol that adds only port numbers and a simple error check (checksum) on top of IP; its header is 8 bytes (TCP's is 20 bytes without options). With no connection setup, no delivery confirmation and no retransmission, it is used for voice calls and live video, where a little loss is better than delay, and for DNS, which needs just one query and one response. If reliability is needed, the application provides it; QUIC, used by HTTP/3, implements retransmission and encryption on top of UDP. Connection setup, retransmission and ordering are what TCP does.

FAQ

Why use UDP if it is unreliable?

It does not wait for connection setup or retransmissions, so it adds little delay, and its header is small. That suits calls and games, where low delay matters more than a little missing data, and DNS queries, which finish in one round trip. When reliability is needed, protocols such as QUIC implement retransmission on top of UDP.

Does UDP data arrive in the order it was sent?

That is not guaranteed. Datagrams may be reordered, for example by taking different paths, and may also be lost or duplicated. If order matters, the application numbers its data and reorders it.

UDP (User Datagram Protocol) in the explanations

Questions that mention UDP (User Datagram Protocol) (4)

  1. In the four-layer TCP/IP model, which layer do TCP and UDP belong to?
  2. Which correctly describes UDP?
  3. What is the main role of DNS (Domain Name System)?
  4. Which of the following correctly describes HTTP/2 and HTTP/3?

Books on Computer Networking Basics Ad

As an Amazon Associate I earn from qualifying purchases.

Comparisons that include this term

Related terms

TCP (Transmission Control Protocol) HTTP (Hypertext Transfer Protocol) DNS (Domain Name System) IP (Internet Protocol) Packet QUIC OSI reference model ARQ (automatic repeat request) IP address URL (Uniform Resource Locator)

Back to the glossary