User Datagram Protocol (UDP) and its header

Posted onCategoriesComputer Networks

User Datagram Protocol (UDP) provides connectionless services for application-level procedures. UDP is an unreliable service; delivery and duplicate protection are not guaranteed. This does reduce the overhead of the protocol and may be adequate in many cases. Connectionless service is more robust.

UDP sits on top of IP. UDP header includes a source port (16 bits) and destination port (16 bits). The length (16 bits) field contains the length of the entire UDP segment, including header and data. The checksum (16 bits) field contains the result of a cyclic redundancy check (CRC) computation performed by the transmitting system, and is used by the receiving system to detect errors in the UDP header, data and the part of IP header. The checksum applies to the entire UDP segment plus a pseudo header prefixed to the UDP header at the time of calculation.

Source Port – The source port is the virtual port number assigned by the local computer when it transmits data to a remote machine. This is typically a number above 1023 and is the next highest number not already in use. This field is not always used, but when it is, it should indicate the port number the remote machine should use when sending any replies back to the source.

Destination Port – The Destination port is usually a “well known port number” such as 69 for trivial file transfer protocol, or 53 for DNS. These port numbers allow the remote machine to recognize a request for a particular type of service. When used with a source port, this allows a remote machine to recognize a data connection.

Length – Length is specified as a number of octets, and since it is a 16-bit value, it provides for a datagram of up to 65,535 bytes, including the header and data.

Checksum – A checksum is calculated using the 16-bit one’s complement of the one’s complement sum of data pulled from the IP header, the UDP header, and some of the data. This data is padded with zeroes so that it is a multiple of two octets before the checksum algorithm is run.