CRC and Hamming Code
CRC and Hamming Code
CODE
Presented by :- Raunak Kumar Upadhyay (20BCA1507)
Overview
◦Cyclic redundancy check (CRC)
◦Hamming code
Cyclic redundancy check (CRC)
◦ A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital
networks and storage devices to detect accidental changes to digital data.
◦ It is an error-detecting code used to determine if a block of data has been corrupted. CRCs
are ubiquitous.
◦ CRC uses Generator Polynomial which is available on both sender and receiver side. An
example generator polynomial is of the form like x3 + x + 1. This generator polynomial
represents key 1011. They are present in many of the link layers that TCP/IP is used over. For
instance, Ethernet and Wi-Fi packets both contain CRCs.
◦ The mathematics behind CRCs initially appears daunting, but it doesn’t have to be. The idea is
given a block of N bits, let’s compute a checksum of a sort to see if the N bits were damaged in
some way, for instance by transit over a network
How does CRC Work?
◦ Error correction goes way back in computing. One of the first things I ran into while understanding the
ASCII character set was parity. The seven-bit ASCII character set in some computers used the 8th bit as
a check bit to see if the character had been transmitted correctly. If the character had an odd number of
ones in the lower 7 bits, the 8th bit was set to a 1, otherwise 0.
◦ So if the receiving device (modem, computer terminal, etc.) got an 8-bit quantity where the number of
ones in it was not even, it knew that character had been corrupted. This is a simplistic scheme, but some
important concepts shared with the CRC are here:
1.We added the check data to the transmitted data (a redundancy), and
2.It isn’t perfect — it only detects certain errors that it was designed to check. (Specifically, the parity bit
successfully detects all one-bit errors in each 7-bit block of data, but potentially can fail if worse data
corruption occurs.)
Examples
For example, let’s say we want to add 0101b + 1110b. With carries we see:
11
0101b
+1110b
------
10011b
Let’s just do the binary math without carries and see the difference:
0101b
+1110b
------
1011b
Hamming Code
◦ Hamming code is a set of error-correction codes that can be used to detect and correct
the errors that can occur when the data is moved or stored from the sender to the
receiver. It is technique developed by R.W. Hamming for error correction.
◦ In this coding method, the source encodes the message by inserting redundant bits within the
message. These redundant bits are extra bits that are generated and inserted at specific
positions in the message itself to enable error detection and correction. When the destination
receives this message, it performs recalculations to detect errors and find the bit position that
has error.
◦ Due to the limited redundancy that Hamming codes add to the data, they can only detect and correct errors
when the error rate is low. This is the case in computer memory (usually RAM), where bit errors are
extremely rare and Hamming codes are widely used, and a RAM with this correction system is a ECC RAM
(ECC memory). In this context, an extended Hamming code having one extra parity bit is often used.
Extended Hamming codes achieve a Hamming distance of four, which allows the decoder to distinguish
between when at most one one-bit error occurs and when any two-bit errors occur.
Hamming code
Encoding a message by Hamming Code
The procedure used by the sender to encode the message
encompasses the following steps −
• Step 1 − Calculation of the number of redundant bits.
• Step 2 − Positioning the redundant bits.
• Step 3 − Calculating the values of each redundant bit.
Hamming Code
Decoding a message in Hamming Code
Once the receiver gets an incoming message, it performs recalculations to detect errors and
correct them. The steps for recalculation are −
• Step 1 − Calculation of the number of redundant bits.
• Step 2 − Positioning the redundant bits.
• Step 3 − Parity checking.
• Step 4 − Error detection and correction
Examples
References
◦ https://cuchd.blackboard.com/ultra/courses/_57973_1/outline/edit/document/_22073047_1?courseId=_57
973_1
◦ Computer Networks, ANDREW S. TANENBAUM(PHI)
THANK YOU