Computer Networks and Internet Basics (9hrs) · Computer Fundamentals & Emerging Technologies

User Datagram Protocol (UDP)

Watch lectures

User Datagram Protocol (UDP)

1. Definition

UDP (User Datagram Protocol) is the connectionless, unreliable, best-effort transport-layer protocol of the Internet (RFC 768). It simply takes an application's message, adds a small 8-byte header carrying source and destination ports, and hands it to IP as a datagram. There is no handshake, no acknowledgement, no retransmission, no ordering and no congestion control — UDP does not promise delivery; it just tries. Its virtue is minimum overhead and minimum delay, which is exactly what real-time traffic needs.

2. Header — Only 8 Bytes

 ┌──────────────────────────────┬──────────────────────────────┐
 │ Source port (16 bits)        │ Destination port (16 bits)   │
 ├──────────────────────────────┼──────────────────────────────┤
 │ Length (16 bits)             │ Checksum (16 bits, optional) │
 └──────────────────────────────┴──────────────────────────────┘
        Total = 8 bytes  (compare TCP: 20-60 bytes)

3. Characteristics

  • Connectionless — no setup or teardown; each datagram is independent and may even take a different path.
  • Unreliable / best-effort — datagrams may be lost, duplicated or arrive out of order; the sender is not informed.
  • Message-oriented — the boundaries of each message are preserved (unlike TCP's byte stream).
  • No flow or congestion control — a UDP sender can blast data as fast as the application allows; useful for real-time, dangerous on a congested network.
  • Low latency and high efficiency — small header, no ACK round-trips, minimal state in the host and no per-connection buffers.
  • Supports broadcast and multicast — one datagram can reach many receivers; TCP's point-to-point connections cannot.
  • Simple demultiplexing by port — 16-bit ports let many applications share one IP address.

4. Where UDP Is Used (and Why)

Application Port Why UDP
DNS 53 One short question and one short answer — a handshake would triple the delay
DHCP 67/68 Must work before an IP address exists; broadcast-based
VoIP / SIP / RTP 5060, dynamic Late speech is worthless — retransmission would be worse than loss
Video streaming / live broadcast dynamic A dropped frame is better than a stalled stream
Online gaming / VR dynamic Player positions must be fresh; old data is useless
SNMP 161 Simple monitoring queries
NTP 123 Time synchronisation
TFTP 69 Small file transfer with application-level reliability
IoT (CoAP, some MQTT modes) 5683 Tiny devices, low overhead, loss-tolerant
QUIC / HTTP-3 443 Uses UDP with reliability implemented in the application layer, avoiding TCP's head-of-line blocking

5. TCP vs UDP

Basis TCP UDP
Connection Connection-oriented (handshake) Connectionless
Reliability Guaranteed delivery with ACKs and retransmission Best effort — no guarantee
Ordering In-order reassembly Order not preserved
Speed / latency Slower (setup + ACKs) Faster (no setup, no waiting)
Header size 20-60 bytes 8 bytes
Flow/congestion control Yes No
Error checking Checksum + recovery Checksum only (corrupt datagram is dropped)
Broadcast/multicast Not supported Supported
Message boundaries Byte stream (no boundaries) Preserves datagram boundaries
Typical use Web, e-mail, file transfer, SSH, banking DNS, DHCP, VoIP, streaming, gaming, IoT
Analogy A phone call with confirmation and repetition A postcard — fast, cheap, no confirmation

6. Overhead Comparison (numerical)

Sending a 100-byte payload:

  • TCP: 100 bytes payload ÷ (100 + 20 header) = 83% efficiency (plus ACK traffic and handshake).
  • UDP: 100 bytes payload ÷ (100 + 8 header) = 92.6% efficiency (no ACK traffic).

For a voice call sending 50 packets per second, TCP's handshake and retransmissions would add variable delay (jitter) that no listener tolerates — hence RTP/UDP. Where reliability is still needed over UDP, the application adds its own sequence numbers, timers and FEC (forward error correction), as QUIC does.

7. Advantages and Limitations

Advantages Limitations
Minimal overhead (8-byte header, no state) No guarantee of delivery, order or duplicate suppression
Lowest latency — ideal for real-time traffic Loss affects quality directly (choppy audio/video)
Supports broadcast and multicast No congestion control — an aggressive app can harm the network
Simple to implement on tiny devices Firewalls often block UDP; NAT traversal is harder
Application can add exactly the reliability it needs No acknowledgement means failures are invisible to the sender

8. Exam Points

  • Define UDP and list its features — 5 marks, almost certain.
  • Draw the UDP header and explain each field — 5 marks.
  • Differentiate TCP and UDP with a table (and give two applications of each) — 5-7 marks, almost certain.
  • Why is UDP preferred for voice and video? — 3-5 marks, frequent.
  • Why is DNS implemented over UDP? — 3 marks.
  • Compare the overhead/efficiency of TCP and UDP headers — 3 marks.
Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.

← All Computer Fundamentals & Emerging Technologies modules