0

As far as I understand to check if the data with it's CRC appended to the end of it has errors, one needs to run it through the same CRC algorithm and see if the newly calculated CRC is zero.

I've tried going though this using an online CRC calculator in the following way:

  1. Calculate CRC for 0xAABBDD (without the 0x part) - CRC16 outputs 0x8992
  2. Calculate CRC for 0xAABBDD8992 - CRC16 outputs 0xFB4A, not 0x0000

What am I doing wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
andrey
  • 1,515
  • 5
  • 23
  • 39
  • 2
    Wrong - You need to calculate CRC for the same data and compare with the previously computed result. This way You can detect if data was changed in tnasit. You can XOR original and new checkums - it will be zero, if data was transmitted correctly. – kestasx Dec 25 '14 at 11:03

1 Answers1

1

The appending the CRC thing only works for "pure" CRCs without pre and post-conditioning. Most real world CRCs however have pre and post-conditioning, mainly so that the CRC of strings of zeros are not zero.

The way to check a CRC is the same as any other check value. You get a message m c where m are the message bytes and c is the check value. You are told through some other channel (most likely a standards document) that c=f(m), with some description of the function f. To check the integrity of m c, you compute f(m) and see if that is equal to c. If not, then the message and/or check value were corrupted in transit. If they are equal, then you have some degree of assurance that the message has arrived unscathed. The assurance depends on the nature of f, the number of bits in c, and the characteristics of the possible errors on the transmission channel.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158