![]() ![]() For example, the Cyclic Redundancy Check algorithms, CRC-8, CRC-16, and CRC-32, do fairly complex things to make the checksum sensitive to such problems. People who care deeply about this have developed a number of much more reliable algorithms. Certain kinds of noise injection on the line can also introduce undetectable errors because the noise that mangles one byte is cancelled by the noise that mangles another byte. For example, if you were to transpose two of the characters of the transmission, the result would be the same, so although the wrong packet is received, a correct checksum is believed. Nonetheless, for all its simplicity, the checksum technique just described is remarkably weak. This means that the 0-lossage problem goes away. A solution to this is to do something like negate the checksum value computed, subtract 1 from it, and expect that the result of the receiver's checksum of the n bytes is 0xFF (-1, as a signed 8-bit value). Of course, if there is a hardware failure that simply fails to transmit the data bytes (particularly easy on synchronous transmission, where no "start bit" is involved), then the fact that you receive a packet of 64 0 bytes with a checksum result of 0 is misleading you think you've received a valid packet and you've received nothing at all. These techniques are not terribly reliable for example, if the packet is known to be 64 bits in length, and you receive 64 '\0' bytes, the sum is 0, so the result must be correct. This means that the sum of all n bytes should be 0. Since this is a bit awkward, a variant on this theme is to, on transmission, sum up all the bytes, the (treating the byte as a signed, 8-bit value) negate the checksum byte before transmitting it. ![]() ![]() The idea is that upon receipt of n bytes, you sum up the first n-1 bytes, and see if the answer is the same as the last byte. This value is appended as the last byte of the transmission. For example, the simplest checksum is to sum up all the bytes of a transmission, computing the sum in an 8-bit counter. Typically, checksums are used in data transmission contexts to detect if the data has been transmitted successfully.Ĭhecksums take on various forms, depending upon the nature of the transmission and the needed reliability. A checksum is a value which is computed which allows you to check the validity of something. ![]()
0 Comments
Leave a Reply. |