Date: Thu, 23 Jan 1997 19:26:49 +0200 From: sja@tekla.fi (Sakari Jalovaara) To: hackers@freebsd.org Cc: msmith@atrad.adelaide.edu.au Subject: Re: CRC-16 algorithms? Message-ID: <9701231726.AA15141@poveri.tekla.fi>
next in thread | raw e-mail | index | archive | help
> 00000000 00 39 3c 3e 01 02 03 00 80 00 00 00 00 00 00 00 |.9<>............| > 00000010 08 00 0e 20 3d 4b 00 00 00 00 00 00 00 02 01 00 |... =K..........| > 00000020 01 03 00 de ad 01 00 00 00 00 00 00 00 00 00 01 |....-...........| > 00000030 00 00 00 00 00 00 00 00 00 00 00 00 01 26 3c aa |.............&<.| > > The bytes at 0x3d and 0x3e are the CRC-16 of the bytes from 0-0x3c Just checking: without the _three_ last bytes of that data, the CRC-16 checksum is 0x3d3e? I don't seem to find such a CRC-16 algorithm (unless we assume an arbitrary "XorOut" parameter.) For trying CRC-16 with different parameters, get "crcmodel.c" from http://kbs.cs.tu-berlin.de/isis/crc and use the following little main program. I didn't try all different "cm_init" values, just -1 and 0. Write your own for loop for that. You'll need another set of test data if you try that. Or if you try different final xor parameters. int main (void) { cm_t cm; int x, crc; static unsigned char data[] = { 0x00, 0x39, 0x3c, 0x3e, 0x01, 0x02, 0x03, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x0e, 0x20, 0x3d, 0x4b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x03, 0x00, 0xde, 0xad, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }; int n; for (x = 1; x <= 0xffff; x += 2) { cm.cm_width = 16; cm.cm_poly = x; cm.cm_init = 0L; cm.cm_refin = FALSE; cm.cm_refot = FALSE; cm.cm_xorot = 0L; cm_ini(&cm); for (n = 0; n < sizeof (data); n++) cm_nxt(&cm, data[n]); crc = cm_crc(&cm); if (crc == 0x3d3e) printf("%x %x\n", crc, x); } return 0; } ++sja
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9701231726.AA15141>