How does CRC work?
Chapter 6 CRC size and the ability to detect transmission errors
In the previous chapter, the CRC register had 4 bits and the sent message was located in the 8-bits A register. You will probably agree, that the system would equally well calculate CRC for any multiple of 8 bits, i.e. for any number of bytes. But what is its ability to detect transmission errors with 4 bit CRC? We remember that the calculated CRC is a kind of “remainder of dividing” the message from A by a “divisor”. For real i.e. decimal division, e.g. 3784:25, the remainder is 3 and the same remainder can also be for many dividends, e.g. 3759, 3734, 3709,…,28. Similarly, for a 4-bit CRC with a given “divisor” there are also many different messages that have the same “remainder”. There may be 16 of them. An error in transmission will change the original message and most likely also change the CRC. But why most likely and not definitely? Because an error can also change the original message to one of these 16 but with the same remainder! We may be so unlucky! The receiver will then treat the message as error-free.
What’s the conclusion? The more of the same “remaiders” for a given message, the greater the power of error detection! So we want a large CRC register. In practice, and we will limit ourselves to this, CRC is 1, 2 or 4 bytes. One byte, i.e. 8 bits, gives us 256 different messages for the same remainder, but 4 bytes means as many as 4,294,967,296 of them. Finding the same message is now thousands of times more difficult than winning the lottery! Therefore, in this case, the same CRC in the transmitter and receiver almost guarantees error-free transmission! Unfortunately, you always have to add almost.
One more thing
1 byte CRC does not mean that, for example, every 256_th byte will pass with an undetected error! If so, just shoot yourself. Every manufacturer of data transmission equipment tries to make it as reliable as possible, so that there are no errors. Then even without CRC, as in Chapter 1 we can be almost sure that there were no errors. But the manufacturer, based on his experience, states that despite all its efforts, e.g. every million-th byte transferred may contain an error. And this is where CRC comes into play, which will “pass” an error every 256 million times, not every million! So, thanks to CRC, the operational reliability has increased 256 times and without any additional costs, e.g. in shielding or more careful technology. In the case of a 4-byte CRC, this operational reliability will increase by as much as 4,294,967,296 times!
And one more thing
The ability to detect errors depends on the size of the CRC. This is probably obvious. But it also depends on its value. It turns out, for example, that different 4-byte CRCs have different error detection powers. And among them there are those that detect them best!
Why is it like that? I will answer as simply as possible. I don’t know.
That’s what mathematicians are for and they found that, for example, CRC=100000100110000010001100110110111
detects errors well and that is why this CRC-32 is very popular in data transmission.