en:pfw:crc32_ieee
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
en:pfw:crc32_ieee [2023-09-04 18:12] – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1 | en:pfw:crc32_ieee [2023-09-04 18:12] (current) – ↷ Seite von pfw:crc32_ieee nach en:pfw:crc32_ieee verschoben uho | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{pfw: | ||
+ | ==== CRC, 32bit IEEE CRC ==== | ||
+ | |||
+ | The IEEE 32bit CRC standard was introduced for the ethernet protocol. The essential difference with previous CRC-implementations was that the start-number is 0xFFFFFFFF instead of 0x0. The reason is that a network can easily start with a couple of spurious 0x0's. A CRC with a 0x0 as start-number cannot detect such a network-specific error. By having 0xFFFFFFFF as start number, the first 4 characters received are effectively inverted. And that enables the detection of spurious zero's at the start of a transmission. | ||
+ | |||
+ | This CRC version is probably the most widely used CRC-version there is. Examples where it is used: ethernet protocol, PKZIP, Gzip, MPEG-2, SATA, PNG, ZMODEM. | ||
+ | |||
+ | If you look at the implementation below you will see that the CRC is shifted to right and that the polynomial of the CRC-IEEE has been reversed. This avoids having to bit-reverse every received byte, another IEEE peculiarity. | ||
+ | |||
+ | < | ||
+ | EDB88320 constant crc-polynomial ( reversed IEEE ) | ||
+ | |||
+ | hex | ||
+ | : CRC32_IEEE ( addr len -- crc ) \ input is address and length | ||
+ | FFFFFFFF -rot \ FFFFFFFF = start-value CRC | ||
+ | bounds do | ||
+ | i c@ xor | ||
+ | 8 0 do | ||
+ | dup 1 and if \ if lsb = ' | ||
+ | 1 rshift | ||
+ | crc-polynomial xor | ||
+ | else \ otherwise only a rshift | ||
+ | 1 rshift | ||
+ | then | ||
+ | loop | ||
+ | loop | ||
+ | -1 xor \ invert output | ||
+ | ; | ||
+ | </ | ||
+ | |||
+ | ===== Contributions ===== | ||
+ | |||
+ | < | ||