Wireshark-dev: [Wireshark-dev] Question about the CCITT/ITU/CRC-16 routine (crc16.c)
From: Stig Bjørlykke <stig.bjorlykke@xxxxxxxxx>
Date: Mon, 11 Dec 2006 17:21:33 +0100
Hi.

I am developing a dissector for a new protocol (an extension found in STANAG 4406 Ed. 2 Annex E) which specifies usage of the CCITT-16 mechanism described in ITU-T X.25. As I want this dissector to be included in Wireshark I want to implement the checksum checking the correct way, by using the functions found in epan/crc16.c.

My problem is that this checksum routine does not match the routine we have used in our prototype implementation of the protocol.

The question is which routine is the "correct" to use (I do not know anything about CRC routines), and if they both are correct should I add another table to use with the crc16_ccitt* functions?


From epan/crc16.c i find this table:

static const guint crc16_ccitt_table[256] =
{
   0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
   0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
   [...]
};

From our code I find this table:

static const unsigned short crc16_table[256] =
{
   0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
   0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
   [...]
};

From my point of view it seems like the one we have used has the correct poly (which is 1021 in both cases). When I read the article found in [1] I find several implementations which is not equivalent, so I am a bit confused here :)


--
Stig Bjørlykke

[1] http://www.joegeluso.com/software/articles/ccitt.htm