3 ms·
CRCs (and other error checking codes) are routinely misused and misunderstood by the engineers that implement systems with them. For instance, how do you know
by Isamu 12y ago
CRCs (and other error checking codes) are routinely misused and misunderstood by the engineers that implement systems with them.
For instance, how do you know a CRC will detect the errors you care about? For that matter, do you have any idea of the most common errors your system will have to deal with?
Error-detecting codes have an implicit model for the kinds of errors they will effectively detect. They are valid for systems that fit this model, and less effective (possibly staggeringly ineffective) for systems that don't fit that model.
CRCs date from the days of serial communications, and they were well suited to the kinds of errors you would see: bit errors that were independent and randomly distributed, and short burst errors. If you conducted experiments to measure the probability distribution of errors on your communication medium, you could calculate the probability of an undetected error with a given code. Without that you have no model of the reliability of your communication system.
For instance, with CD's (or DVD's) they didn't just slap a CRC on there - they made a model of the kinds of errors they expected, in this case they expected big scratches on a CD to create very long burst errors, and they need to be able to not just detect but also correct them. Based on the density of recording, they made a reasonable estimation of the length of errors they had to deal with.
To do this they used a powerful Reed-Solomon code, and interleaved the blocks in order to handle the extremely long burst error requirement, and meet their reliability goals.
Look at it another way.
So you slap a CRC on a file. Great, now it can detect one- or two-bit errors, and burst errors as big as the CRC. Are those the most common errors in your file system? That is, what is the likelihood that the first file corruption you see will be of a kind that your CRC will detect with only a low probability? File corruptions are poorly characterized.
Still, a CRC is cheap and better than nothing, so we slap them on.
Anyway if you like math at all, I recommend delving into codes, it really is fun and fascinating.