[−][src]Crate internet_checksum
RFC 1071 "internet checksum" computation.
This crate implements the "internet checksum" defined in RFC 1071 and updated in RFC 1141 and RFC 1624, which is used by many different protocols' packet formats. The checksum operates by computing the 1s complement of the 1s complement sum of successive 16-bit words of the input.
SIMD acceleration is used on some platforms (currently, x86_64 with the avx2 extensions).
Benchmarks
The following microbenchmarks were performed on a 2018 Google Pixelbook.
Each benchmark constructs a Checksum
object, calls
Checksum::add_bytes
with an input of the given number of bytes, and then
calls Checksum::checksum
to finalize. Benchmarks were performed with
SIMD both enabled and disabled. Average values were calculated over 3
trials.
Bytes | Time w/o SIMD | Rate w/o SIMD | Time w/ SIMD | Rate w/ SIMD | Ratio (time w / time w/o) |
---|---|---|---|---|---|
31 | 3,657 ns | 8.48 MB/s | 3,692 ns | 8.40 MB/s | 1.01 |
32 | 3,735 ns | 8.57 MB/s | 3,767 ns | 8.50 MB/s | 1.01 |
64 | 7,092 ns | 9.02 MB/s | 6,580 ns | 9.73 MB/s | 0.93 |
128 | 13,790 ns | 9.28 MB/s | 7,428 ns | 17.2 MB/s | 0.54 |
256 | 27,169 ns | 9.42 MB/s | 9,224 ns | 27.8 MB/s | 0.34 |
1024 | 107,609 ns | 9.52 MB/s | 20,071 ns | 51.0 MB/s | 0.19 |
Structs
Checksum | RFC 1071 "internet checksum" computation. |
Functions
checksum | Compute the checksum of "bytes". |
update | Updates bytes in an existing checksum. |