April 18
How did the homework go? It was
In particular, there are several ways that the polynomial
is described, and there isn't much on the length of the
packet and how that motivates the a particular CRC length.
Let's look at one example more closely : CRC-8 bluetooth.
The wikipedia article says for example that
- CRC-8 means "8 check bits"
- the bluetooth CRC-8 polynomial is 0xA7.
You might therefore think that the polynomial is
>>> '{:b}'.format(0xA7)
'10100111'
i.e. x^7 + x^5 + x^2 + x + 1 ... but that is wrong.
Reading the fine print, if there are m check bits,
then the polynomial is always of order (m+1).
In polynomial division with this mod 2 system,
the remainder is always one degree smaller.
(Quick quiz: do an example to make sure this is clear.)
One common convention (the "normal" column in the wikipedia article)
is to omit the highest order 1 ... since it always must be there.
Seems rather confusing to me, but that's what it is.
So for bluetooth CRC-8 the polynomial is 9
x^8 + x^7 + x^5 + x^2 + x + 1 the correct bluetooth CRC-8
which is a bit string has an addition one on the the left :
110100111 the 9-bit denominator in the division
How long can the data packet be if the checksum is 8 bits?
Well, that's back to the packing theorem ... but we are now
using the following definitions.
k = data bits
m = check bits
n = codeword (i.e. data and checksum) bits = k + m
Packing theorem :
2**n > (n+1) * 2**k
or
2**(k+m) > (k+m+1) * 2**k
which means
2**m > k + m + 1
or
k < 2**m - m - 1 <=== TA DA !
For bluetooth 8, m = CRC check bits = 8,
which means the data can be of size k < 2**8 - 8 - 1 = 247 bits
For a CRC-16, k < 2**16 - 16 - 1 = 65519 bits, i.e. the packet can be up to about 8kb .
Let's do a long division with the CRC-8 polynomial and a longer (say 24 bits) data packet.
A few more sources on all this :
What does it look like to implement this with bit hacking?