Re: CCITT-CRC16 in kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Aug 11, 2005, at 11:19:59, linux-os (Dick Johnson) wrote:
On Thu, 11 Aug 2005 [email protected] wrote:
You're wrong in two ways:
1) You've got CRC-16 and CRC-CCITT mixed up, and
2) You've got the bit ordering backwards. Remember, I said very clearly,
  the lsbit is the first bit, and the first bit is the highest power
of x. You can reverse the convention and still have a CRC, but that's
  not the way it's usually done and it's more awkward in software.

CRC-CCITT = X^16 + X^12 + X^5 + X^0 = 0x8408, and NOT 0x1021
CRC-16 =  X^16 + X^15 + X^2 + X^0 = 0xa001, and NOT 0x8005

Thank you very much for your time, but what you say is completely
different than anything else I have found on the net.

Do the math:

     2^ 16 = 65536
     2^ 12 =  4096
     2^  5 =    32
     2^  0 =     1
----------------------
                 69655 = 0x11021

No, it's like this: first, the 16 term is ignored, then:

    2^ ( 15 - 12 ) = 2^  3 =     8 = 0x0008
    2^ ( 15 -  5 ) = 2^ 10 =  1024 = 0x0400
    2^ ( 15 -  0 ) = 2^ 15 = 32768 = 0x8000
-----------------------------------------------
                                   = 0x8408

This has 2 things:
    1) The least-significant bit is the first bit
    2) The first bit is the _highest_ power of X.

Cheers,
Kyle Moffett

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCM/CS/IT/U d- s++: a18 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$ L++++(+ ++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+ PGP+++ t+(+++) 5 X R?
tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r  !y?(-)
------END GEEK CODE BLOCK------


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux