๐ UDP datagram header format (10 MCQs)
Fixed Eight-Byte UDP Header
The UDP header is an eight-byte transport-layer header defined by four 16-bit fields: Source Port, Destination Port, Length, and Checksum. It precedes the application payload and is carried inside an IP packet. Source and destination ports support endpoint delivery, Length describes the complete UDP datagram, and Checksum provides error detection over the pseudo-header, UDP header, and data. It defines the boundary between application processes and packet delivery.
Compact Header Design and Field Purposes
UDP is designed for low processing overhead, so its header omits sequence numbers, acknowledgment numbers, flags, and window fields found in TCP. The two port fields identify endpoints, Length allows the receiver to determine the datagram extent, and Checksum helps detect corruption. Reliability and ordering are not supplied by the header or protocol.
Reading the Four Header Fields
Source Port and Destination Port each occupy 16 bits. Length is also 16 bits and includes the eight-byte header plus payload; its minimum valid value is 8. Checksum occupies the final 16 bits. In IPv4, a zero transmitted checksum means checksum generation was omitted; in IPv6, UDP checksum use is normally mandatory, subject to defined exceptions.
Calculating a UDP Length Field
Suppose an application sends 120 bytes of payload. The UDP Length field is 128 bytes because it includes the eight-byte header plus 120 data bytes. The field is not the full IP packet length: IP header bytes are excluded. This distinction is important when interpreting packet captures or calculating protocol overhead.
Checksum Coverage and Header Limitations
The checksum detects accidental corruption but does not correct errors or authenticate the sender. It is calculated using the UDP pseudo-header, UDP header, and payload, linking the check to IP source and destination information. Because UDP has no sequence or acknowledgment fields, applications needing ordered recovery must implement it themselves or use another transport.
Misreading UDP Length and Checksum Fields
'UDP length counts only application data' is false: it includes the eight-byte UDP header. 'The checksum is a 32-bit field' is false: it is 16 bits. 'A valid checksum guarantees delivery' is false: it detects certain corruption but cannot detect a packet that never arrives or request retransmission. These distinctions separate similar mechanisms that are often confused.
Exam Focus: Field Widths and Length Calculations
Draw the four-field UDP header and label each field as 16 bits, producing an eight-byte total. Calculate UDP Length by adding eight bytes to the application payload, excluding the IP header. Explain the IPv4 zero-checksum convention and the normal IPv6 requirement, and distinguish corruption detection from reliable delivery. Use the assumptions stated in each question when calculating.
Key Terms for UDP Datagram Header Format
- Source Port - Sixteen-bit sending endpoint identifier.
- Destination Port - Sixteen-bit receiving endpoint identifier.
- Length - Total UDP header and payload bytes.
- Checksum - Sixteen-bit corruption-detection value.
- Pseudo-header - IP fields included in checksum calculation.
- Payload - Application data carried by UDP.
๐ All UDP datagram header format MCQs
Q1. What is the range of wellโknown port numbers defined for Internet services?
๐ Explanation: Wellโknown ports are reserved for standardized services and occupy the lowest range of port numbers, specifically from 0 up to 1023. This ensures that common protocols such as HTTP (portโฏ80) and DNS (portโฏ53) have predictable identifiers, while higher ranges are used for registered or dynamic ports.
Q2. A client sends a UDP datagram from source port 5000 to destination port 161. Which service is most likely being accessed?
๐ Explanation: Portโฏ161 is the wellโknown port assigned to the Simple Network Management Protocol (SNMP). When a client directs a UDP packet to this port, it is typically interacting with an SNMP agent on the server, making SNMP the most probable service in this scenario.
Q3. Which statement best differentiates UDP from TCP regarding error handling?
๐ Explanation: TCP provides reliability through mechanisms such as acknowledgments, retransmissions, and flow control, ensuring lost or corrupted segments are resent. UDP, in contrast, offers only a checksum for basic error detection and does not attempt to recover from errors, leaving reliability to the application layer.
Q4. How many distinct socket addresses can be formed using the full IPv4 address space and all possible port numbers?
๐ Explanation: An IPv4 address consists of possible values, and each port number adds possibilities. The combination yields unique socket addresses, representing every possible pairing of host address and port.
Q5. If two different hosts each run a UDP server bound to port 8080, can a client on a third host communicate with both simultaneously without ambiguity?
๐ Explanation: Each UDP datagram is addressed by both a destination IP address and a destination port number. Even though the port number is identical, the differing IP addresses uniquely identify the two server processes, allowing the client to target either one unambiguously.
Q6. When a UDP packet traverses a NAT device, which component of the socket address is most likely to be altered?
๐ Explanation: Network Address Translation rewrites the source information of outbound packets so that multiple internal hosts can share a single external address. Typically, the source IP address and source port number are replaced with the NATโs public IP and a newly allocated external port, preserving the destination unchanged.
Q7. To add ordered delivery to a UDPโbased protocol, which additional header field is essential?
๐ Explanation: Ordered delivery requires the receiver to know the intended position of each datagram. Introducing a sequence number field enables the application to detect outโofโorder arrivals and reorder them appropriately, a capability absent from standard UDP which lacks any sequencing mechanism.
Q8. If a UDP application implements stopโandโwait with a 5โฏ% packet loss probability, what is the expected total number of transmissions required to successfully deliver a single datagram?
๐ Explanation: The expected number of transmissions for a success probability of is . With a loss probability , the expectation is , which rounds to about 1.05 transmissions on average for each datagram.
Q9. Which statement best reflects the security impact of using dynamic (private) ports versus wellโknown ports for a client application?
๐ Explanation: Wellโknown ports are publicly documented and frequently scanned by attackers looking for vulnerable services. By using dynamic, privately allocated ports for clientโside communication, the application reduces its visibility to opportunistic scans, thereby lowering the likelihood of targeted attacks.
Q10. In UDP communication, how do the destination IP address and destination port number together determine the server process that receives the datagram?
๐ Explanation: The destination IP address pinpoints the target host on the network, while the destination port number pinpoints the particular application or process listening on that host. Together they form the unique socket address that the operating system uses to deliver the incoming UDP datagram to the correct server process.