Open In App

How Checksum Computed in UDP?

Last Updated : 27 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Answer: The UDP checksum is a 16-bit one’s complement sum of the UDP header, payload, and a pseudo-header with IP addresses, protocol, and UDP length.

Inclusion of Components

It starts with the aggregation of the UDP header, payload, and a pseudo-header, which is a construct that includes the source and destination IP addresses, the protocol indicating UDP, and the UDP length.

Summation

The checksum calculation proceeds by summing the one’s complement where all binary 0s become 1s, of all 16-bit words in these components. If the total length of the data is odd, padding with zero is applied to form a complete 16-bit word.

Complementing

The total sum then undergoes a one’s complement operation itself, effectively inverting its bits.

Finalizing the Checksum

This final value is the checksum, inserted into the checksum field of the UDP header. A special case arises if the computed checksum is zero; it’s transmitted as 0xFFFF to differentiate from a non-calculated checksum.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads