The UDP datagram is the smallest unit of data in the UDP protocol. It consists of a header and a payload. The header contains information about the source and destination of the datagram, as well as other control information. The payload is the data that is being carried by the datagram.
Checkout this video:
User Datagram Protocol (UDP) is one of the core protocols of the Internet Protocol Suite. UDP is a minimal message-oriented transport layer protocol that is documented in [RFC 768](https://www.ietf.org/rfc/rfc768.txt).
UDP datagrams are typically smaller than TCP segments because UDP has no inherent congestion control mechanisms and therefore does not require the extra overhead of sequence numbers, flow control, and acknowledgments that TCP does. The minimum size of a UDP datagram is 8 bytes, which includes the 4-byte UDP header and the 4-byte IP header. The headers for UDP and IP are both fixed in length, so the minimum size of a UDP datagram is 8 bytes (64 bits).
UDP is often used for time-sensitive applications such as audio or video streaming where small delays can cause noticeable degradation in quality. The small overhead of UDP makes it well suited for applications where reliability is not critical and latency is more important than throughput.
The UDP Header
Every UDP datagram has a header composed of 8 octets. The header fields are:
-Source port: 16 bits
-Destination port: 16 bits
-Length: 16 bits
-Checksum: 16 bits
The checksum field is used for error-checking of the header and data.
The UDP Datagram
UDP is a very simple protocol. It has no concept of a “connection.” It just sends packets from one host to another. Each packet is called a datagram. UDP datagrams have a minimum size of 8 bytes. This is the size of the UDP header, which contains 4 bytes for the source port, 4 bytes for the destination port, and 0 bytes for the CRC (checksum).
The UDP Checksum
The UDP checksum is a 16-bit checksum that is used to detect errors in the data portion of UDP datagrams. The checksum is calculated over the entire UDP datagram, including the data and the UDP headers. The checksum is optional, but when it is included, it can help to improve the reliability of UDP datagrams.
When the checksum is included in a UDP datagram, the minimum size of a UDP datagram increases by two bytes. This means that a UDP datagram with a checksum must be at least four bytes long (the size of the UDP header).
The checksum is not required for every UDP datagram. It is up to each application to decide whether or not to use the checksum.
In conclusion, the minimum size of a UDP datagram is 8 bytes. However, most applications will require at least 20-28 bytes in order to function properly.