Expand description

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.

Benchmarks

Checksum::add_bytes

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. Average values were calculated over 3 trials.

BytesTimeRate
202,649 ns7.55 MB/s
313,826 ns8.10 MB/s
323,871 ns8.27 MB/s
641,433 ns44.7 MB/s
1282,225 ns57.5 MB/s
2563,829 ns66.9 MB/s
102313,802 ns74.1 MB/s
102413,535 ns75.7 MB/s

Checksum::add_bytes_small

The following microbenchmarks were performed on a 2018 Google Pixelbook. Each benchmark constructs a Checksum object, calls Checksum::add_bytes_small with an input of the given number of bytes, and then calls Checksum::checksum to finalize. Average values were calculated over 3 trials.

BytesTimeRate
202,639 ns7.57 MB/s
313,806 ns8.15 MB/s

update

The following microbenchmarks were performed on a 2018 Google Pixelbook. Each benchmark calls update with an original 2 byte checksum, and byteslices of specified lengths to be updated. Average values were calculated over 3 trials.

BytesTimeRate
21,550 ns1.29 MB/s
41,972 ns2.03 MB/s
82,892 ns2.77 MB/s

Structs

RFC 1071 “internet checksum” computation.

Functions

Compute the checksum of “bytes”.
Updates bytes in an existing checksum.