LABS · PROTOCOLS · NET PATH

UDP: fast, simple and with no guarantees

UDP sends datagrams without opening a connection or confirming anything. See its 8-byte header, how ports keep conversations apart and what happens when a datagram is lost.

Level: beginner · 10 minutes

Interactive simulation

The animation needs JavaScript. The full lesson is written out below.

Download the capture and open it in Wireshark to keep exploring.

What UDP is

UDP (User Datagram Protocol, RFC 768) is a connectionless transport protocol. It takes an application's data, adds an 8-byte header with the ports and hands it to IP. There's no handshake, no sequence numbers, no acknowledgments and no congestion control.

That's why it's fast and lightweight. It's used by applications that care more about arriving quickly than arriving complete (real-time voice and video) and by those that ask short questions and repeat if there's no answer (DNS, DHCP, NTP, SNMP).

The UDP header

FieldBitsIn the DNS query
Source port1641853: ephemeral, chosen by the laptop
Destination port1653: the DNS server
Length16Header + data: 59 bytes
Checksum16Covers header, data and a pseudo-header with the IPs

In IPv4, the UDP checksum is optional (0 = no checksum), although it's almost always used. In IPv6 it's mandatory.

How it works: connectionless datagrams

Five steps: a DNS query and its response, a Syslog message, another that gets lost and the ports R1 listens on.

  1. A DNS query in a UDP datagram

    The laptop asks for the IP of intranet.canada-logistica.example. The system picks an ephemeral source port, 41853, and sends the datagram to port 53 on the DNS server. The UDP header has only four fields: source port, destination port, length and checksum. There's no handshake first: the very first packet already carries the question.

  2. The response, with the ports swapped

    The DNS server answers from port 53 to 41853. The laptop hands the datagram to the program that opened that port: that's how one device's conversations are kept apart (multiplexing). The IP and port pair is called a socket. UDP confirms nothing: if the response doesn't arrive, the DNS client asks again.

  3. Syslog: fire and forget

    Someone configured R1 and the router logs it: it sends a Syslog message to server 10.20.30.51, UDP port 514. Its priority, <189>, combines facility local7 (23) and severity 5 (notice). The server neither answers nor confirms: UDP has no acknowledgments.

  4. A datagram that gets lost

    Eight seconds later, R1 reports that Gi0/0/2 went down. The message crosses the WAN link, but R2's output queue toward the server is full and R2 drops it. R1 never finds out and doesn't resend it: UDP doesn't number datagrams or confirm they arrived. If an application needs guaranteed delivery, it must handle it itself or use TCP.

  5. The UDP ports R1 listens on

    A server listens on a well-known port and the client uses an ephemeral one. R1 listens too: on 67 because it's a DHCP server and on 123 because it uses NTP. Ports 0 to 1023 are well-known, 1024 to 49151 are registered and 49152 to 65535 are dynamic or ephemeral (Linux uses 32768 to 60999).

Ports and sockets

The port identifies the program inside the device. The combination of IP and port is called a socket, and a conversation is defined by both sockets: 192.168.10.12:41853 with 10.20.30.53:53. That way one device can hold many conversations at once (multiplexing).

UDP portService
53DNS (also uses TCP 53)
67 and 68DHCP: server and client
69TFTP
123NTP
161 and 162SNMP and SNMP traps
514Syslog
16384–32767Voice RTP on Cisco

UDP versus TCP

UDPTCP
ConnectionNo: send and doneYes: three-way handshake
Header8 bytes20 bytes or more
Acknowledgment and resendNoYes
OrderingNot guaranteedGuaranteed
Flow and congestion controlNoYes
UsesDNS, DHCP, NTP, SNMP, Syslog, voice and videoWeb, email, SSH, file transfer

See it on Cisco IOS XE

CommandWhat it shows or does
logging host 10.20.30.51Sends log messages to a Syslog server (UDP 514).
show loggingThe logging configuration and how many messages were sent.
show control-plane host open-portsThe TCP and UDP ports the device listens on.
show interfaces Gi0/0/1Input and output drops, where datagrams get lost.
ip name-server 10.20.30.53The DNS server the router itself uses.

What happens when it fails

  • A lost datagram isn't recovered: the application has to notice (through a timeout) and repeat.
  • Closed port: if nothing listens on the destination port, the device answers with an ICMP Port Unreachable.
  • An ACL or firewall blocking a UDP port cuts the service with no warning to the client.
  • Large responses: if a DNS response doesn't fit, the server sets TC and the client repeats the query over TCP.
  • UDP has no congestion control: an intense UDP flow can fill the queues and cause drops, as on R2.

Frequently asked questions

Why does DNS use UDP?

Because most queries fit in a single datagram and it's faster than opening a TCP connection. If no answer comes, the client repeats; if the response is too large, TCP 53 is used.

Is UDP unreliable?

UDP doesn't guarantee delivery, but that doesn't make it bad: it leaves reliability to the application when needed, and for voice or video it's better to lose a packet than to wait for it.

What is an ephemeral port?

A temporary port the system assigns to the client for a conversation. The server uses a well-known port and answers to the ephemeral one.

What is a socket?

The combination of an IP address and a port, like 192.168.10.12:41853. A conversation is defined by the socket at each end.

Does UDP have sequence numbers?

No. If an application needs them, it adds them itself, like RTP in voice over IP.

Key takeaways

  • UDP is connectionless: no handshake, no acknowledgments, no resends and no guaranteed ordering.
  • Its header is 8 bytes: source port, destination port, length and checksum.
  • The client uses an ephemeral port and the server a well-known one; the response swaps the ports.
  • It's used by DNS (53), DHCP (67/68), TFTP (69), NTP (123), SNMP (161/162) and Syslog (514).
  • If a datagram is lost, nobody resends it: the application decides whether to repeat.

NEXT STEP

From this lesson to the Canadá Logística network

In the CCNA 2.0 Course you configure Syslog, NTP and SNMP on Canadá Logística's devices and troubleshoot services with captures, in Packet Tracer or CML. We'll let you know when it opens.

Upcoming labs

Sources

Lesson prepared with AI assistance and checked against the sources cited. The bytes of every packet are generated according to the standard and verified with an independent tool.