๐ŸŽ“ BookMCQ
โ† Back to 24. Transport Layer Protocols

๐Ÿ“ 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.
3
Easy
4
Medium
3
Hard

๐Ÿ“ All UDP datagram header format MCQs

Q1. What is the range of wellโ€‘known port numbers defined for Internet services?

A.0โ€“1023 โœ…
B.1024โ€“49151
C.49152โ€“65535
D.1024โ€“65535
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– 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?

A.Domain Name Service (DNS)
B.Simple Mail Transfer Protocol (SMTP)
C.Simple Network Management Protocol (SNMP) โœ…
D.Hypertext Transfer Protocol (HTTP)
๐Ÿ’ก Difficulty: easy | โœ… Correct: C

๐Ÿ“– 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?

A.UDP guarantees delivery, while TCP does not
B.TCP includes retransmission mechanisms, whereas UDP does not โœ…
C.Both protocols use checksums, but only TCP uses acknowledgments
D.UDP uses flow control, TCP does not
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– 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?

A.2482^{48} โœ…
B.\ (2^{64})
C.2322^{32}
D.2162^{16}
๐Ÿ’ก Difficulty: medium | โœ… Correct: A

๐Ÿ“– Explanation: An IPv4 address consists of 2322^{32} possible values, and each port number adds 2162^{16} possibilities. The combination yields 232ร—216=2482^{32}\times2^{16}=2^{48} 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?

A.Yes, because the destination IP distinguishes the servers โœ…
B.No, because ports must be unique across the Internet
C.Only if the servers use different transport protocols
D.Only when NAT is disabled
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– 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?

A.Source IP address
B.Destination port number
C.Destination IP address
D.Source port number โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– 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?

A.Checksum
B.Window Size
C.Acknowledgment Number
D.Sequence Number โœ…
๐Ÿ’ก Difficulty: hard | โœ… Correct: D

๐Ÿ“– 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?

A.1.05 โœ…
B.1.1
C.1.2
D.1.25
๐Ÿ’ก Difficulty: hard | โœ… Correct: A

๐Ÿ“– Explanation: The expected number of transmissions for a success probability of 1โˆ’p1-p is 1/(1โˆ’p)1/(1-p). With a loss probability p=0.05p=0.05, the expectation is 1/0.95โ‰ˆ1.05261/0.95\approx1.0526, 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?

A.Dynamic ports are less likely to be blocked by firewalls, reducing exposure
B.Wellโ€‘known ports are more vulnerable because they are targeted by attackers โœ…
C.Using wellโ€‘known ports for clients simplifies auditing and improves security
D.Dynamic ports hide the application identity, making intrusion detection harder
๐Ÿ’ก Difficulty: hard | โœ… Correct: B

๐Ÿ“– 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?

A.The IP address selects the network interface, while the port selects the transport protocol
B.The IP address identifies the host, and the port identifies the specific process on that host โœ…
C.Both values are combined into a single identifier that the OS uses to route the packet
D.The port number overrides the IP address when multiple processes listen on the same host
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– 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.

๐Ÿ”— Related Topics (MCQs)