public class Crc extends Object
| Constructor and Description |
|---|
Crc() |
| Modifier and Type | Method and Description |
|---|---|
static int |
computeCrc24(long bytes,
int len)
NOTE: the order of bytes must reach the wire in the same order the CRC is computed, with the
CRC immediately following in a trailer.
|
static <B> int |
computeCrc32(B buffer,
PrimitiveCodec<B> codec) |
public static <B> int computeCrc32(B buffer,
PrimitiveCodec<B> codec)
public static int computeCrc24(long bytes,
int len)
Make sure either to write byte-by-byte to the wire, or to use Integer/Long.reverseBytes if you write to a BIG_ENDIAN buffer.
See http://users.ece.cmu.edu/~koopman/pubs/ray06_crcalgorithms.pdf
Complain to the ethernet spec writers, for having inverse bit to byte significance order.
Note we use the most naive algorithm here. We support at most 8 bytes, and typically supply 5 or fewer, so any efficiency of a table approach is swallowed by the time to hit L3, even for a tiny (4bit) table.
bytes - an up to 8-byte register containing bytes to compute the CRC over the bytes AND
bits will be read least-significant to most significant.len - the number of bytes, greater than 0 and fewer than 9, to be read from bytesCopyright © 2017–2022. All rights reserved.