3.3 Connectionless Transport: UDP
UDP Overview
Protocol: User Datagram Protocol (UDP) defined in RFC .
Characteristics:
Connectionless: No handshaking between sender and receiver before sending data. Each segment is handled independently of those that preceded or followed it.
Best-Effort Service: There is no guarantee that the segment will reach its destination, nor is there a guarantee on the order of delivery.
Minimalist Design: No congestion control or flow control. This allows the application to send data at any rate, restricted only by the link bandwidth and the underlying IP layer.
No Connection State: Servers do not need to track sequence numbers, acknowledgement numbers, or congestion window sizes, allowing a single server to handle significantly more active clients compared to TCP.
Sender and Receiver Actions
Sender Process:
The application layer passes a message to UDP.
UDP wraps the message with a header containing multiplexing and error-detection fields.
The resulting segment (header + payload) is then passed to the IP layer for encapsulation.
Receiver Process:
The transport layer receives the UDP segment from the IP datagram.
Checksum Verification: The receiver calculates its own checksum for the received segment. If it does not match the value in the header, the segment is usually discarded.
Demultiplexing: The segment is directed to the appropriate application-layer socket based on the destination port number.
UDP Segment Structure
Total Header Size: Fixed at bytes ( bits).
Header Fields (each bits):
Source Port: Identifies the port on the sender's side to which replies should be sent.
Destination Port: Identifies the specific receiving process on the destination host.
Length: Specifies the total number of bytes in the segment (Header + Data). The minimum length is bytes.
Checksum: Used to provide error detection for the segment.
Internet Checksum Details
Objective: Detect errors (e.g., bit flips) incurred during transmission.
Computation at Sender:
The segment is treated as a series of -bit integers.
These integers are summed. If a carry bit is produced from the most significant bit, it is added to the least significant bit (end-around carry).
The final sum is inverted (one’s complement).
Verification at Receiver: The receiver sums all -bit words including the checksum itself. If no errors occurred, the resulting sum should be all ones ().
UDP Applications and Advantages
Why choose UDP?:
No Connection Establishment: No three-way handshake means no RTT (Round Trip Time) delay before data transfer begins.
Low Overhead: The small -byte header minimizes bandwidth waste compared to TCP's -byte header.
Application-Level Control: Fine-grained control over when data is sent; ideal for real-time applications where timeliness is preferred over reliability.
Common Use Cases:
Streaming Multimedia: Can tolerate some data loss while requiring steady delivery rates (VoIP, Video Conferencing).
Network Services: DNS (for speed) and SNMP (to operate even when the network is congested).
Reliable UDP: Reliability can be implemented at the application layer. HTTP/3 uses the QUIC protocol, which runs on top of UDP to provide congestion control and error recovery without the setup delays of traditional TCP.