Skip to main content

internet_checksum

Function internet_checksum 

Source
pub fn internet_checksum(data: &[u8]) -> u16
Expand description

Compute the 16-bit ones’ complement of the ones’ complement sum of data.

The result is in network byte order and is the value that should be written into a checksum field so that verifying the entire header (including the checksum field) yields zero.

For odd-length data, a virtual zero byte is appended for the final 16-bit word.