inetSum
inetSum(
data):number
Defined in: checksum/inet-sum.ts:15
Computes the RFC 1071 Internet checksum of data — the one’s-complement sum
of 16-bit big-endian words, used by IPv4, TCP, UDP and ICMP headers.
An odd-length input is padded with an implicit zero byte, per RFC 1071 §1. Every carry out of bit 16 is folded back in (end-around carry), which is what makes the whole scheme independent of the order words are summed in — RFC 1071 §2 relies on this to update a running checksum incrementally.
Complexity: O(n) in the byte length of data.
Parameters
Section titled “Parameters”Uint8Array
The bytes to check.
Returns
Section titled “Returns”number
The one’s complement of the folded sum, as an unsigned 16-bit value.