2

Following are the things that I already know about these:

  • Hamming codes can be used both to detect and correct errors, while in crc errors can only be detected.

  • CRC is used in communication while Hamming code is used to detect errors in memory disks

My main question is what is the advantage of using one code over another?

user5951764
  • 33
  • 1
  • 7

2 Answers2

1

Hamming is used in case where fixed length of data is to be detected and corrected while CRC works for any length of data.

0

It will depend on your application, but as you have pointed out, the two are quite different. The main difference I would consider is the amount of overhead needed for each.

For a simple (7,4) hamming code, you are adding 75% overhead to your data in order to get the ability to correct one error for every 4-bits. So if you were sending or storing a 1000 byte message, you would have to really send/store 1750 bytes. That's a lot of overhead!

For a CRC, you are accumulating a single result over a large amount of data in order to detect if there is an error somewhere in the data. You do not need to tell exactly where it is, just that something is wrong. For that, you could accumulate a 32-bit CRC over your message and do pretty well. So for our 1000 byte message, you would really be sending/storing 1004 bytes. That is very efficient if all you need is detection of a problem.

  • (7,4) hamming code is an unfair example for sending large data chuncks. using a (72, 64) code would only have 12% overhead, and longer codes with lower overhead are possible. The main advantage of CRC is that it can detect a very large number of bit errors. Even with number of errors being greater than the CRC length there is still a very good statistical chance the CRC will detect the error. For example with 32-bits CRC there is something close to a 1 in 4 billion chance that it will fail to detect any number of bit errors. – EmbeddedSoftwareEngineer Aug 10 '23 at 12:05