pub fn internet_checksum(data: &[u8]) -> u16Expand description
Calculate the Internet checksum (RFC 1071).
This is used for IP, ICMP, TCP, and UDP checksums.
§Algorithm
- Sum all 16-bit words in the data
- Add any odd byte as the high byte of a word
- Fold 32-bit sum to 16 bits by adding carry bits
- Take one’s complement of the result