0

I am trying to calculate CRC-32 for this 64-bit series of bits. Why is it not coming out right? I checked my CRC-32 against a number of online calculators, but mine doesn't match. Moreover, the online calculators don't match with each other either....

I am appending 32 zeros too. I am trying to calculate simple CRC32 here, not performing bit flipping on first 32 bits as required in IEEE 802.3 ethernet and flipping the CRC-32 bits before transmission.

Wait!! Or is that my problem? Am I supposed to flip the first 32 bits? It does not mention it on the websites I mentioned I think...

https://ghsi.de/CRC/index.php?Polynom=100000100110000010001110110110111&Message=1010101010101011111000001010101010100001010111101101000111011101

https://leventozturk.com/engineering/crc/?error=invalid_scope&error_description=Your+application+has+not+been+authorized+for+the+scope+"r_contactinfo"

How is a CRC32 checksum calculated?

                                                                              1010 1000 0 111 0100 1_011 0000 1_110 1100   0100 1111 1000 1000 0001 0100 0010 000
100000100110000010001110110110111   1010 1010 1010 1011 1110 0000 1010 1010 _ 1010 0001 0_101 1110 1_101 0001 1_101 1101 - 0000 0000 0000 0000 0000 0000 0000 0000                                                                                    
                                    1000 0010 0110 0000 1000 1110 1101 1011   1                                             
                                 ----------------------------------------------------------------------------------------------0
                                    x010 1000 1100 1011 0110 1110 0111 0001   00
                                     000 0000 0000 0000 0000 0000 0000 0000   00
                                 ----------------------------------------------------------------------------------------------1
                                     x10 1000 1100 1011 0110 1110 0111 0001   001
                                      10 0000 1001 1000 0010 0011 1011 0110   111  
                                 ----------------------------------------------------------------------------------------------2
                                      x0 1000 0101 0011 0100 1101 1100 0111   1100
                                       0 0000 0000 0000 0000 0000 0000 0000   0000  
                                 ----------------------------------------------------------------------------------------------3
                                       x 1000 0101 0011 0100 1101 1100 0111   1100 0
                                         1000 0010 0110 0000 1000 1110 1101   1011 1
                                 ----------------------------------------------------------------------------------------------4
                                         x000 0111 0101 0100 0101 0010 1010   0111 10
                                          000 0000 0000 0000 0000 0000 0000   0000 00
                                 ----------------------------------------------------------------------------------------------5
                                          x00 0111 0101 0100 0101 0010 1010   0111 100 
                                           00 0000 0000 0000 0000 0000 0000   0000 000                                                                                     
                                 ----------------------------------------------------------------------------------------------6
                                           x0 0111 0101 0100 0101 0010 1010   0111 1001                                         
                                            0 0000 0000 0000 0000 0000 0000   0000 0000   
                                 ----------------------------------------------------------------------------------------------7
                                            x 0111 0101 0100 0101 0010 1010   0111 1001 0

                                              0000 0000 0000 0000 0000 0000   0000 0000 0
                                 ----------------------------------------------------------------------------------------------0
                                              x111 0101 0100 0101 0010 1010   0111 1001 0_1
                                               100 0001 0011 0000 0100 0111   0110 1101 1_1
                                 ----------------------------------------------------------------------------------------------1
                                               x11 0100 0111 0101 0110 1101   0001 0100 1_00
                                                10 0000 1001 1000 0010 0011   1011 0110 1_11
                                 ----------------------------------------------------------------------------------------------2
                                                x1 0100 1110 1101 0100 1110   1010 0010 0_111
                                                 1 0000 0100 1100 0001 0001   1101 1011 0_111
                                 ----------------------------------------------------------------------------------------------3
                                                 x 0100 1010 0001 0101 1111   0111 1001 0_000 1
                                                   0000 0000 0000 0000 0000   0000 0000 0_000 0
                                 ----------------------------------------------------------------------------------------------4
                                                   x100 1010 0001 0101 1111   0111 1001 0_000 11
                                                    100 0001 0011 0000 0100   0111 0110 1_101 11
                                 ----------------------------------------------------------------------------------------------5
                                                    x00 1011 0010 0101 1011   0000 1111 1_101 001
                                                     00 0000 0000 0000 0000   0000 0000 0_000 000
                                 ----------------------------------------------------------------------------------------------6
                                                     x0 1011 0010 0101 1011   0000 1111 1_101 0010
                                                      0 0000 0000 0000 0000   0000 0000 0_000 0000
                                 ----------------------------------------------------------------------------------------------7
                                                      x 1011 0010 0101 1011   0000 1111 1_101 0010 1

                                                        1000 0010 0110 0000   1000 1110 1_101 1011 1
                                 ----------------------------------------------------------------------------------------------0
                                                        x011 0000 0011 1011   1000 0001 0_000 1001 0_1
                                                         000 0000 0000 0000   0000 0000 0_000 0000 0_0
                                 ----------------------------------------------------------------------------------------------1
                                                         x11 0000 0011 1011   1000 0001 0_000 1001 0_10
                                                          10 0000 1001 1000   0010 0011 1_011 0110 1_11
                                 ----------------------------------------------------------------------------------------------2
                                                          x1 0000 1010 0011   1010 0010 1_011 1111 1_011
                                                           1 0000 0100 1100   0001 0001 1_101 1011 0_111
                                 ----------------------------------------------------------------------------------------------3
                                                           x 0000 1110 1111   1011 0011 0_110 0100 1_100 0
                                                             0000 0000 0000   0000 0000 0_000 0000 0_000 0
                                 ----------------------------------------------------------------------------------------------4
                                                             x000 1110 1111   1011 0011 0_110 0100 1_100 00
                                                              000 0000 0000   0000 0000 0_000 0000 0_000 00
                                 ----------------------------------------------------------------------------------------------5
                                                              x00 1110 1111   1011 0011 0_110 0100 1_100 000
                                                               00 0000 0000   0000 0000 0_000 0000 0_000 000
                                 ----------------------------------------------------------------------------------------------6
                                                               x0 1110 1111   1011 0011 0_110 0100 1_100 0001
                                                                0 0000 0000   0000 0000 0_000 0000 0_000 0000
                                 ----------------------------------------------------------------------------------------------7
                                                                x 1110 1111   1011 0011 0_110 0100 1_100 0001 1

                                                                  1000 0010   0110 0000 1_000 1110 1_101 1011 1
                                 ----------------------------------------------------------------------------------------------0
                                                                  x110 1101   1101 0011 1_110 1010 0_001 1010 0_1
                                                                   100 0001   0011 0000 0_100 0111 0_110 1101 1_1
                                 ----------------------------------------------------------------------------------------------1
                                                                   x10 1100   1110 0011 1_010 1101 0_111 0111 1_00
                                                                    10 0000   1001 1000 0_010 0011 1_011 0110 1_11
                                 ----------------------------------------------------------------------------------------------2
                                                                    x0 1100   0111 1011 1_000 1110 1_100 0001 0_111
                                                                     0 0000   0000 0000 0_000 0000 0_000 0000 0_000
                                 ----------------------------------------------------------------------------------------------3
                                                                     x 1100   0111 1011 1_000 1110 1_100 0001 0_111 1
                                                                       1000   0010 0110 0_000 1000 1_110 1101 1_011 1
                                 ----------------------------------------------------------------------------------------------4
                                                                       x100   0101 1101 1_000 0110 0_010 1100 1_100 01
                                                                        100   0001 0011 0_000 0100 0_111 0110 1_101 11
                                 ----------------------------------------------------------------------------------------------5
                                                                        x00   0100 1110 1_000 0010 0_101 1010 0_001 100
                                                                         00   0000 0000 0_000 0000 0_000 0000 0_000 000
                                 ----------------------------------------------------------------------------------------------6
                                                                         x0   0100 1110 1_000 0010 0_101 1010 0_001 1001
                                                                          0   0000 0000 0_000 0000 0_000 0000 0_000 0000
                                 ----------------------------------------------------------------------------------------------7
                                                                          x   0100 1110 1_000 0010 0_101 1010 0_001 1001 - 0    <<<<<<<<<<<<<<<<

                                                                              0000 0000 0_000 0000 0_000 0000 0_000 0000 - 0
                                 ----------------------------------------------------------------------------------------------------------------------------------0
                                                                              x100 1110 1_000 0010 0_101 1010 0_001 1001 - 00
                                                                               100 0001 0_011 0000 0_100 0111 0_110 1101 - 11
                                 ----------------------------------------------------------------------------------------------------------------------------------1
                                                                               x00 1111 1_011 0010 0_001 1101 0_111 0100 - 110
                                                                                00 0000 0_000 0000 0_000 0000 0_000 0000 - 000
                                 ----------------------------------------------------------------------------------------------------------------------------------2
                                                                                x0 1111 1_011 0010 0_001 1101 0_111 0100 - 1100
                                                                                 0 0000 0_000 0000 0_000 0000 0_000 0000 - 0000
                                 ----------------------------------------------------------------------------------------------------------------------------------3
                                                                                 x 1111 1_011 0010 0_001 1101 0_111 0100 - 1100 0
                                                                                   1000 0_010 0110 0_000 1000 1_110 1101 - 1011 1
                                 ----------------------------------------------------------------------------------------------------------------------------------4
                                                                                   x111 1_001 0100 0_001 0101 1_001 1001 - 0111 10
                                                                                    100 0_001 0011 0_000 0100 0_111 0110 - 1101 11
                                 ----------------------------------------------------------------------------------------------------------------------------------5
                                                                                    x11 1_000 0111 0_001 0001 1_110 1111 - 1010 010
                                                                                     10 0_000 1001 1_000 0010 0_011 1011 - 0110 111     
                                 ----------------------------------------------------------------------------------------------------------------------------------6
                                                                                     x1 1_000 1110 1_001 0011 1_101 0100 - 1100 1010
                                                                                      1 0_000 0100 1_100 0001 0_001 1101 - 1011 0111
                                 ----------------------------------------------------------------------------------------------------------------------------------7
                                                                                      x 1_000 1010 0_101 0010 1_100 1001 - 0111 1101 0

                                                                                        1_000 0010 0_110 0000 1_000 1110 - 1101 1011 1
                                 ----------------------------------------------------------------------------------------------------------------------------------0
                                                                                        x_000 1000 0_011 0010 0_100 0111 - 1010 0110 10
                                                                                         _000 0000 0_000 0000 0_000 0000 - 0000 0000 00
                                 ----------------------------------------------------------------------------------------------------------------------------------1
                                                                                          x00 1000 0_011 0010 0_100 0111 - 1010 0110 100
                                                                                           00 0000 0_000 0000 0_000 0000 - 0000 0000 000
                                 ----------------------------------------------------------------------------------------------------------------------------------2
                                                                                           x0 1000 0_011 0010 0_100 0111 - 1010 0110 1000
                                                                                            0 0000 0_000 0000 0_000 0000 - 0000 0000 0000
                                 ----------------------------------------------------------------------------------------------------------------------------------3
                                                                                            x 1000 0_011 0010 0_100 0111 - 1010 0110 1000 0
                                                                                              1000 0_010 0110 0_000 1000 - 1110 1101 1011 1
                                 ----------------------------------------------------------------------------------------------------------------------------------4
                                                                                              x000 0_001 0100 0_100 1111 - 0100 1011 0011 10
                                                                                               000 0_000 0000 0_000 0000 - 0000 0000 0000 00
                                 ----------------------------------------------------------------------------------------------------------------------------------5
                                                                                               x00 0_001 0100 0_100 1111 - 0100 1011 0011 100
                                                                                                00 0_000 0000 0_000 0000 - 0000 0000 0000 000
                                 ----------------------------------------------------------------------------------------------------------------------------------6
                                                                                                x0 0_001 0100 0_100 1111 - 0100 1011 0011 1000
                                                                                                 0 0_000 0000 0_000 0000 - 0000 0000 0000 0000
                                 ----------------------------------------------------------------------------------------------------------------------------------7
                                                                                                 x 0_001 0100 0_100 1111 - 0100 1011 0011 1000 0

                                                                                                   0_000 0000 0_000 0000 - 0000 0000 0000 0000 0
                                 ----------------------------------------------------------------------------------------------------------------------------------0
                                                                                                   x_001 0100 0_100 1111 - 0100 1011 0011 1000 00
                                                                                                    _000 0000 0_000 0000 - 0000 0000 0000 0000 00
                                 ----------------------------------------------------------------------------------------------------------------------------------1
                                                                                                     x01 0100 0_100 1111 - 0100 1011 0011 1000 000
                                                                                                      00 0000 0_000 0000 - 0000 0000 0000 0000 000
                                 ----------------------------------------------------------------------------------------------------------------------------------2
                                                                                                      x1 0100 0_100 1111 - 0100 1011 0011 1000 0000
                                                                                                       1 0000 0_100 1100 - 0001 0001 1101 1011 0111 
                                 ----------------------------------------------------------------------------------------------------------------------------------3
                                                                                                       x 0100 0_000 0011 - 0101 1010 1110 0011 0111 0
                                                                                                         0000 0_000 0000 - 0000 0000 0000 0000 0000 0
                                 ----------------------------------------------------------------------------------------------------------------------------------4
                                                                                                         x100 0_000 0011 - 0101 1010 1110 0011 0111 00
                                                                                                          100 0_001 0011 - 0000 0100 0111 0110 1101 11
                                 ----------------------------------------------------------------------------------------------------------------------------------5
                                                                                                          x00 0_001 0000 - 0101 1110 1001 0101 1010 110
                                                                                                           00 0_000 0000 - 0000 0000 0000 0000 0000 000
                                 ----------------------------------------------------------------------------------------------------------------------------------6
                                                                                                           x0 0_001 0000 - 0101 1110 1001 0101 1010 1100
                                                                                                            0 0_000 0000 - 0000 0000 0000 0000 0000 0000
                                 ----------------------------------------------------------------------------------------------------------------------------------7
                                                                                                            x 0_001 0000 - 0101 1110 1001 0101 1010 1100 0

                                                                                                              0_000 0000 - 0000 0000 0000 0000 0000 0000 0
                                 ----------------------------------------------------------------------------------------------------------------------------------0
                                                                                                              x_001 0000 - 0101 1110 1001 0101 1010 1100 00

                                                                                                               _000 0000 - 0000 0000 0000 0000 0000 0000 00
                                 ----------------------------------------------------------------------------------------------------------------------------------1
                                                                                                                x01 0000 - 0101 1110 1001 0101 1010 1100 000
                                                                                                                 00 0000 - 0000 0000 0000 0000 0000 0000 000
                                 ----------------------------------------------------------------------------------------------------------------------------------2
                                                                                                                 x1 0000 - 0101 1110 1001 0101 1010 1100 0000
                                                                                                                  1 0000 - 0100 1100 0001 0001 1101 1011 0111
                                 ----------------------------------------------------------------------------------------------------------------------------------3
                                                                                                                  x 0000 - 0001 0010 1000 0100 0111 0111 0111 0
                                                                                                                    0000 - 0000 0000 0000 0000 0000 0000 0000 0
                                 ----------------------------------------------------------------------------------------------------------------------------------4
                                                                                                                    x000 - 0001 0010 1000 0100 0111 0111 0111 00
                                                                                                                     000 - 0000 0000 0000 0000 0000 0000 0000 00
                                 ----------------------------------------------------------------------------------------------------------------------------------5
                                                                                                                     x00 - 0001 0010 1000 0100 0111 0111 0111 000
                                                                                                                      00 - 0000 0000 0000 0000 0000 0000 0000 000
                                 ----------------------------------------------------------------------------------------------------------------------------------6
                                                                                                                      x0 - 0001 0010 1000 0100 0111 0111 0111 0000
                                                                                                                       0 - 0000 0000 0000 0000 0000 0000 0000 0000
                                 ----------------------------------------------------------------------------------------------------------------------------------7
                                                                                                                       x - 0001 0010 1000 0100 0111 0111 0111 0000 <<<<<<<<<<<<<<<
Community
  • 1
  • 1
  • Which "simple" CRC-32 are you trying to calculate? There are many. What answer are you expecting for those bits? – Mark Adler Oct 05 '15 at 18:51
  • By "simple", I mean... Am I not supposed to perform only a modulo 2 division and thats it? May be append W 0-bits to the dividend, but nothing more? – speedbooster Oct 06 '15 at 03:00
  • https://ghsi.de/CRC/index.php?Polynom=10011&Message=1101011011 This tool's calculations don't match the example given in: http://stackoverflow.com/questions/2587766/how-is-a-crc32-checksum-calculated By simple CRC-32 I mean, that we don't flip the first 32-bits (like in Ethernet packet) and we don't flip the remainder bits before transmitting (like in Ethernet packet). I think I stated it above. The algorithm on most online webpages or Tanenbaum's Networking book is to perform modulo 2 division by using XOR. The only complication is that some append W 0-bits (32 0-bits) and others don't. – speedbooster Oct 06 '15 at 03:03
  • I suggest that you read and work through the examples in [Ross William's A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS](http://www.ross.net/crc/download/crc_v3.txt). Also take a look at the [catalog of CRCs](http://reveng.sourceforge.net/crc-catalogue/17plus.htm#crc.cat-bits.32), where you can see the variety of CRC-32s. You have not, for example, specified whether you are doing the CRC in the forward or reverse direction. – Mark Adler Oct 06 '15 at 04:44
  • Thanks Mark, do you mean LSB first or MSB first, by referring to forward/ reverse direction? – speedbooster Oct 06 '15 at 05:04
  • By the way, I tried the painless guide and wikipedia examples. They modulo 2 divide the message without reversing the bit order. – speedbooster Oct 06 '15 at 05:18
  • You still haven't answered what you _want_. What CRC-32 are you trying to compute? How are you determining that you are not getting what you're looking for? – Mark Adler Oct 06 '15 at 05:54
  • Which CRC-32 variant is this, where you take the message and divide it by modulo 2. My ultimate objective is Ethernet CRC-32, HOWEVER, I am testing my hardware implementation of CRC-32, where I don't flip the bits as required in Ethernet CRC-32. – speedbooster Oct 06 '15 at 07:39
  • Why do all those websites like painless guide etc, not mention the type of CRC they calculate??? They simply perform "modulo 2 divisison" and call it CRC. Extend the bits to 16 or 32 and you have CRC-16 or CRC-32. The minor modifications which make different flavours of CRC-32 are not mentioned.... – speedbooster Oct 06 '15 at 07:41
  • And thanks for the sourceforge link, it has links to the reference documents where the standards are defined. – speedbooster Oct 06 '15 at 07:42
  • Though you make claims about it, you have apparently not read Ross William's guide. It goes into great detail on the "flavours" of CRCs: polynomials, reflection of the polynomial, initialization, final xor, reflection of the final output value, and ordering of the bits from the bytes. That guide in fact established the complete specification for CRCs that is now commonly used, including in the RevEng catalogue. – Mark Adler Oct 06 '15 at 15:07
  • Yes, I had not completely read the guide. The reason being, I was doing it with pen and paper then. And for that, the section 5 and 6 of Ross' guide provided enough information. The initial and final values you're talking about, got into effect from section 8 onwards, which discuss "implementation". I was not using a shift register or a lookup table. I thought my hardware implementation would be irrelevant here. Why is my pen and paper calculation not yielding the correct results? Well, I finally found out. Thanks Mark. I didn't notice the small font on one of calculators which says CRC-32 .. – speedbooster Oct 07 '15 at 15:42
  • ... which says CRC has many flavours. You were right. The Initial and final values make a difference. I was under the impression that since my implementation was not shift register based, I didn't need to worry about initial condition. But it so happens that initializing to 0xFFFF..F (XORing the input with this value) is equivalent to inverting the bits. Same with output XORing to 0xFFFF..F. So I just inverted the bits. I realized no matter what the implementation, one must consider the effect of shift register practices/ initial or final conditions to calculate the correct CRC. – speedbooster Oct 07 '15 at 15:45
  • How do I mark your last comment as the correct answer Mark? – speedbooster Oct 07 '15 at 15:47
  • @MarkAdler I am quite late to thank you for the help, but I'd like to mark your answer as correct. Thank you for pointing me to the CRC guide. – speedbooster Apr 21 '20 at 03:13

0 Answers0