What is Hamming Code : History, Working and Its Applications

In digital systems, the transmitted data for communication can be corrupted due to external noise and any other physical failures. If the transmitted data is not matched with the given input data, then it is called an ‘error’. The data errors can delete vital data in digital systems. The transfer of data will be in the form of bits ( 0 and 1) in digital systems. If anyone of the bit is changed, then the entire system’s performance can be affected. If the bit ‘1’ is changed to the bit ‘0’ or vice versa, then it is called bit error. There are different types of errors like single bit errors, multiple errors and burst errors. In this article, we discuss error correction and detection, and hamming code.

What is Error Detection and Correction?

In digital communication, the data will be lost if there is an error in the transfer of information from one system/network to another system/network. So, it is important to find and correct errors. Some error detection and correction methods are used to detect and correct the errors for effective communication. If these methods are used, then the data can be transferred with higher accuracy.


Error detection is defined as, the method used to detect the errors transmitted from transmitter/sender to receiver in digital systems. Redundancy codes are added to the data during the transmission to find the errors. These are called error-detecting codes.

Error correction is the correction of data transmitted from transmitter to receiver. Error correction can be done in two types.

Backward Error Correction

In this type of error correction, the receiver requests back the sender to retransmit the data if the receiver detects the error.

Forward Error Correction

if the data received by the receiver finds the error, then it executes the error-correcting codes, to correct and recover the data automatically.

PCBWay

If there is ‘m’ no.of data bits and ‘r’ no.of redundant bits, then the combinations of information will be 2r.

2r > = m+r+1

Types of Error Detection Codes

The errors in the received data can be detected by using 3 types of error detection codes. They are, parity check, cyclic redundancy check (CRC) and longitudinal redundancy check.

Parity Check

The redundant bit called parity bit is added to make the no.of bits even or odd in case of even parity or odd parity. The receiver counts the no.of bits ( 1’s) in a frame to add the parity bit. This is called parity checking. If the no.of 1’s in a frame is even, then even parity is used by adding the bit ‘1’with zero value. Similarly, of the no.of 1’s is odd, then the odd parity is used by adding the bit with value ‘1’.

Error-Detection
error-detection

Hence, it is used to ensure that the frame/date received by the receiver from the source is not corrupted. In this type of error detection, the no.of 1’s should be even in the received frame. It is very less expensive among all types of error detection.

Longitudinal Redundancy Check(LRC)

hen the set/block of bits are organized, then the LRC method can be used to check the parity bit in every frame. It helps to send the set of parity bits along with the original data and checks the redundancy.

Cyclic Redundancy Check

his type is used to detect the data/frame received from the source is valid or not. It involves in the binary division of the data that should be sent and uses polynomials (to generate divisor). Before the transmission, a division operation is performed by the sender on the data/bits/frame to calculate the remainder.

Cyclic-Redundancy-Check
cyclic-redundancy-check

During the transmission of actual data from the sender, it adds the remainder at the end of the actual data. The combination of actual data and the remainder is called a codeword. The data is transmitted in the form of codewords. In this process, if the data is corrupted, then the data will be rejected by the receiver otherwise it will be accepted.

What is the Hamming Code?

Hamming code is defined as, a linear code that is used in the error detection process up to 2-intermediate errors. It is also capable of detecting single-bit errors. In this method, the redundant bits are added to the data/message by the sender to encode the data. In order to do error detection and correction, these redundant bits are added in certain positions for the error correction process.

Hamming-Code
hamming-code

History of Hamming Codes

In 1950, Richard W. hamming invented Hamming codes to detect and correct the errors in data. After the evolution of computers with higher reliability, he introduced hamming codes for 1-error correcting codes and later on he extended up to 2-error detecting codes. Hamming codes are created because parity check cannot detect and correct errors in the data. The Hamming codes are inserted to any blocklength of data between actual data and redundancy bits. He developed an array of algorithms to work on the problems of error correction methods and these codes are widely used in ECC memory.

Process of Encoding a Message using Hamming Code

The process of encoding a message using a hamming code by the sender includes 3 steps.

Step1: The first step is to calculate the no.of redundant bits in a message

  • For example, if a message contains ‘n’ no.of bits and ‘p’ no.of redundant bits are added to the message, then ‘np’ indicates (n+p+1) different states.
  • Where (n+p) represents the location of an error in every bit position
  • 1 (extra state) represents no error.
  • Since ‘p’ indicates 2^p (2p ) states, which are equal to (n+p+1) states.

Step2: Place the redundant bits in exact/correct position

‘p’ bits are inserted in the bit positions which are the power of 2 like 1, 2, 4, 8, 16, etc. These bit positions are indicated as p1 (position 1), p2 (position 2), p3 (position 4), etc.

Step 3: Calculate the values of redundant bits

  • Here parity bits are used to calculate the values of redundant bits.
  • Parity bits can make the no.of 1’s in a message either even or odd.
  • If total no.of 1’s in a message is even, then even parity is used
  • If total no.of 1’s in a message is odd, then odd parity is used.

Process of Decrypting a Message in Hamming Code

The process of decrypting a message received from the sender by the receiver using the hamming code includes the following steps. This process is nothing but recalculation to detect and correct the errors in a message.

Step1: Count the no.of redundant bits

The formula to encode the message using redundant bits is,

2p≥ n + p + 1

Step 2: correct the positions of all redundant bits

‘p’ no.of redundant bits are placed in a bit positions of power of 2 like 1,2,4,8,16,32 etc

Step3: parity checking (odd parity and even parity)

Parity bits are calculated based on the no.of 1’s in data bits and redundant bits.

For Example

Parity of p1 would be 1, 3, 5, 7, 9, 11,…

Parity of p2 would be 2, 3, 6, 7, 10, 11,…

Parity of p3 would be 4-7, 12-15, 20-23,…

Advantages of Hamming Code

The main advantage of using a hamming code is cost-effective if a data stream contains single-bit errors.

  • It can provide error detection and also indicates the bit which contains an error for correction.
  • Hamming codes are very easy and best to use in computer memory and single-bit error correction and detection.

Disadvantages of Hamming Code

  • It is best only for single-bit error correction and detection. If multiple bits errors, then the entire can be corrupted.
  • The Hamming code algorithm can resolve only single-bit errors.

Applications of Hamming Codes

Hamming codes are used in,

  • Computing
  • Telecommunications
  • Data compression
  • Solving puzzles and turbo codes
  • Satellites
  • Plasma CAM
  • Shielded wires
  • Modems
  • Computer memory
  • Open connectors
  • Embedded systems and processor

FAQs

1). Can the Hamming code detect 2-bit errors?

Hamming codes can detect and correct up to 2-bit errors in a data stream

2). How do you fix the Hamming code?

Hamming codes are placed in any length of data between the actual data and redundant bits. These codes are places with a minimum distance of 3 bits

3). What is the parity code?

Parity code or parity bit is adding a bit to the received frame ( data contains 1’s and 0’s) to make total no.of bits (1’s) even or odd.

4). What is the Hamming distance between the data?

The hamming distance between the two different data streams of equal length is no.of 1’s.

The hamming distance between two data strings of equal length can be calculated by using the XOR operation.

For example, a=11011001

b=10011101

Hamming distance can be calculated as,

11011001 ⊕ 10011101 = 01000100 (no.of 1-bits are 2)

The hamming distance indicates the no.of 1’s in the resultant data stream

So, d(11011001, 10011101) = 2

Similarly, 010 ⊕ 011 = 001, d(010, 011) = 1.

5). Is Hamming code cyclic?

Yes, hamming codes are equivalent to cyclic codes that can be used as error-detecting codes.

Thus this is all about error correction and detection, types of error detection, hamming codes, the process of encrypting and decrypting the message using hamming codes, applications of hamming codes, advantages, and disadvantages of Hamming codes. Here is a question for you, ‘What are the applications of error detection and correction?”

Add Comment