Transport Layer · Computer Networks

User Datagram Protocol (UDP)

Watch lectures
SVGVector Architecture Diagram (SVG)
COMPUTER NETWORKS · Module 4★ High PriorityUser Datagram Protocol (UDP)IT Sem 6 · Code 100602 · Connectionless transportMNEMONICUDP = Unreliable Datagram, no handshake, 8-byte header, fast and light.Think DNS, VoIP, streaming: speed beats reliability.Core BreakdownOverviewUDP (RFC 768): connectionless, unreliable, minimal-overhead transport protocol.It adds only ports, length and a checksum on top of IP best-effort delivery.HeaderFixed 8 bytes: source port, destination port, length, checksum (16 bits each).Length counts header + data; the minimum value is 8.StatelessNo handshake, no connection state: each datagram is independent.Datagrams may be lost, duplicated or reordered, and UDP does not notice.No controlNo flow control, no congestion control, no ACK, no retransmission.The application must add reliability itself if it needs it.ChecksumCovers UDP header, data and an IP pseudo-header (src / dst IP, protocol).Optional in IPv4 (0 = none), mandatory in IPv6.UsesDNS, DHCP, SNMP, TFTP, NTP, VoIP, live video, games; multicast / broadcast.Chosen when low delay matters more than perfect delivery.Diagram: UDP DatagramUDP datagram: header = 8 bytesSource Port16 bitsDest Port16 bitsLength16 bitsChecksum16 bitsData (application payload)ClientServerdatagramno handshake · no ACK · no stateConnectionless · unreliable · fastDNS · DHCP · VoIP · TFTP · SNMPChecksum: pseudo-header + data⚠️ Exam Traps & Viva Favorites① Is UDP reliable?No: best effort only. No ACK, no retransmit,no ordering. If needed, the application addsreliability itself (e.g. QUIC, RTP).② UDP header size?Fixed 8 bytes (4 fields x 16 bits). TCP is20 to 60 bytes. Smaller header = loweroverhead and faster processing.③ Why does DNS use UDP?A tiny query / reply fits one datagram, so no3-way handshake delay. TCP is used only forlarge replies and zone transfers.Tip: UDP = fast, light, no promisesMaster Revision Table(learn it row by row!)FeatureUDPTCPWhy it mattersConnectionConnectionless3-way handshakeUDP starts sending at onceReliabilityBest effortACK + retransmitTCP guarantees deliveryHeader8 bytes20 - 60 bytesLess overhead for UDPFlow / congestionNoneYes (rwnd, cwnd)UDP can flood a networkData unitDatagram (boundaries kept)Byte streamApp reads whole messagesTypical useDNS, VoIP, video, DHCPHTTP, FTP, SMTP, SSHPick by need: speed or safetyQUICK FACTSUDP header: Source port (16) · Dest port (16) · Length (16) · Checksum (16) = 8 bytesPorts: DNS 53 · DHCP 67/68 · TFTP 69 · NTP 123 · SNMP 161 · IP protocol number = 17Max UDP payload about 65,507 bytes (65,535 minus 8 UDP minus 20 IP)VERIFIED★ Golden rule: UDP trades reliability forspeed: 8 bytes, no handshake, no ACK.

User Datagram Protocol (UDP)


1. Overview and Core Philosophy

The User Datagram Protocol (UDP) (RFC 768) is a lightweight, connectionless Transport Layer protocol in the TCP/IP protocol suite.

While TCP provides guaranteed, highly regulated delivery, UDP is designed with a minimalist philosophy: it provides the absolute minimum transport service required—process-to-process multiplexing via port numbers and basic optional error detection—without adding connection handshakes, retransmissions, or flow throttling.

MermaidDiagram
Rendering diagram…

2. Key Characteristics of UDP

  1. Connectionless:
    • Transmits data immediately without performing a handshake (zero round-trip setup delay).
  2. Unreliable (Best-Effort Delivery):
    • Does not acknowledge receipt of packets (No ACKs).
    • Packets may be dropped, duplicated, delayed, or arrive out of order. If reliability is needed, the application layer itself must implement sequence tracking.
  3. No Flow Control or Congestion Control:
    • The UDP sender transmits datagrams at whatever rate the application generates them. It never slows down in response to network congestion or receiver buffer exhaustion.
  4. Message-Oriented (Preserves Message Boundaries):
    • Unlike TCP's byte-stream model, UDP packages each write call into an independent datagram. If an application writes 500 bytes, UDP sends a 500-byte datagram; the receiver reads exactly 500 bytes in a single read operation.
  5. Supports Multicast and Broadcast:
    • Because UDP is connectionless, a single packet can be addressed to a broadcast or multicast group (TCP only supports 1-to-1 unicast connections).

3. UDP Datagram Format

The UDP header is exceptionally compact, consisting of only 8 bytes (64 bits) divided into four 16-bit fields:

SVGVector Architecture Diagram (SVG)
0 8 16 24 31 Source Port (16 bits) Destination Port (16 bits) Length (16 bits) Checksum (16 bits) DATA PAYLOAD UDP Header = 8 bytes = 64 bits, no options

Field Breakdown:

  1. Source Port (16 bits): Port of the sending process on the client or server. Optional (set to 0 if no reply is expected).
  2. Destination Port (16 bits): Port of the target process on the destination machine (mandatory for demultiplexing).
  3. Length (16 bits): Total length of the UDP segment in bytes (Header + Data). Minimum value is 8 (a datagram with zero payload bytes).
  4. Checksum (16 bits): One's complement checksum covering the UDP header, UDP payload, and an imaginary IP Pseudo-Header. (Optional in IPv4, but mandatory in IPv6).

4. The UDP Pseudo-Header

To verify that the packet was not delivered to the wrong IP destination due to a corrupted IP header, UDP computes its checksum over an imaginary Pseudo-Header prepended to the segment during calculation:

SVGVector Architecture Diagram (SVG)
Source IP Address (32 bits) Destination IP Address (32 bits) All Zeros (8) Protocol: 17 (8) UDP Length (16 bits) IP Pseudo-Header prepended during checksum calculation
  • If the computed checksum does not match at the receiver, the damaged UDP datagram is silently discarded.

5. When is UDP Preferred over TCP?

Application Category Why UDP is Ideal Examples
Real-Time Multimedia Retransmitting a dropped audio/video frame 200 ms200\text{ ms} late is useless; humans prefer minor glitching over freezing audio. VoIP (SIP/RTP), Zoom, Live Gaming, Video Streaming
Simple Request-Response Completes in a single round-trip without connection setup/teardown overhead. DNS (Port 53), DHCP (Port 67), NTP (Port 123)
Network Management Works even on unstable, highly congested links. SNMP (Port 161), TFTP (Port 69)
Multicast / Broadcast TCP cannot maintain synchronized connection states with multiple recipients. IPTV, mDNS, Routing updates (RIP)

Frequently Asked Questions

QWhy is the UDP header size fixed at 8 bytes?

Unlike IPv4 and TCP which support variable Options fields, UDP does not support options. It contains exactly four 2-byte fields (Source Port, Destination Port, Length, Checksum), making its header permanently fixed at 8 bytes.

QWhat happens if a UDP segment is corrupted in transit?

The receiver verifies the 16-bit checksum. If corruption is detected, the datagram is silently discarded. UDP generates no retransmission request.

QWhy is UDP considered "Message-Oriented" while TCP is "Stream-Oriented"?

UDP preserves application message boundaries: each write by an application results in one standalone datagram on the wire. TCP treats data as a continuous, boundaryless stream of bytes that can be fragmented into arbitrary segment sizes.

QName four fields of the UDP header.

Source Port, Destination Port, Length and Checksum, each 16 bits, which makes the header exactly 8 bytes.

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Computer Networks modules