Hamming code in computer composition principles (detailed explanation)

Table of contents

1. The principle of Hamming code

2. Composition of Hamming code

3. Examples of Hamming code

The first one: Calculate the corresponding Hamming code based on the transmitted data

1. Use even parity to calculate the Hamming code of 0011

Step 1: Calculate how many check digits there are

Step 2: Write the binary codes corresponding to the seven information flows, and mark the positions corresponding to the check digits.

Step 3: Group

Step 4: Write the transmitted information from left to right

Step 5: Use even parity to find out what the check digit is

Step 6: Obtain the Hamming code of the transmitted message

The second type: error correction based on the received Hamming code

2. The received data is 0100111, using even parity. Ask how much information is requested and whether there is any error.

Step 1: Determine how many information flows there are

Step 2: Write the binary codes corresponding to the seven information flows, and fill in the received information from left to right.

Step 3: Group (the same as the above grouping method)

Step 4: Use even parity to check which group has the problem and get the number on the corresponding check digit.

Step 5: Find out where the error occurred

Step 6: Get the transmitted data


1. The principle of Hamming code

Hamming code is a code that detects one bit error and corrects one bit error, so its minimum code distance is 3. It is a coding that uses parity code for verification and error correction.

2. Composition of Hamming code

Hamming code is a code composed of transmitted data bits and check bits

3. Examples of Hamming code

The first one: Calculate the corresponding Hamming code based on the transmitted data

1. Use even parity to calculate the Hamming code of 0011

Step 1: Calculate how many check digits there are

k: check digit n: data bit

First use the formulaeq?2%5E%7Bk%7D%3E%3Dn+k+1 to calculate how many check digits the transmitted data has. The check digit is placed at the position of eq?2%5E%7Bi%7D, that is, 1 , 2, 4, 8...eq?2%5E%7Bi%7D.

Solution: It can be seen from the question that there are four data bits. When put into the formula, there are three check digits. The positions of the check digits are 1, 2, and 4 respectively. So there are seven information flows

Step 2: Write the binary codes corresponding to the seven information flows, and mark the positions corresponding to the check digits.

Because the table will be messed up, pictures will be used instead.

 

Step 3: Group

Grouping method: Group according to the method of xx1. Counting from right to left, the first digit with 1 is one group, the second digit with 1 is the second group, and so on.

So we divide 1, 3, 5, and 7 into the first group

                  2, 3, 6, and 7 are divided into the second group

                  4, 5, 6 and 7 are divided into the third group

Step 4: Write the transmitted information from left to right

 

Step 5: Use even parity to find out what the check digit is

The first group: Because the first group is 1, 3, 5, and 7, the number of 1s counted on the table is 1, and the number of 1s is an odd number, and because even parity is used for verification, the first The number written on the check digit is 1.

The second group: Because the first group is 2, 3, 6, and 7, the number of 1s counted on the table is 2, and the number of 1s is an even number, and because even parity is used for verification, the second group The number written on the check digit is 0.

The third group: Because the first group is 4, 5, 6, and 7, the number of 1s counted on the table is 2, and the number of 1s is an even number, and because even parity is used for verification, the third group The number written on the check digit is 0.

So it can be concluded that the check digit of 0011 is 100

Step 6: Obtain the Hamming code of the transmitted message

Fill in the resulting check digits in the table to obtain the Hamming code of the transmitted information.

Therefore, the Hamming code obtained by using even parity for 0011 is 1000011.

The second type: error correction based on the received Hamming code

2. The received data is 0100111, using even parity. Ask how much information is requested and whether there is any error.

Step 1: Determine how many information flows there are

There are several information flows according to the number of data received. According to the meaning of the question, there are a total of 7 information flows.

Step 2: Write the binary codes corresponding to the seven information flows, and fill in the received information from left to right.

 

Step 3: Group (the same as the above grouping method)

Grouping method: Group according to the method of xx1. Counting from right to left, the first digit with 1 is one group, the second digit with 1 is the second group, and so on.

So we divide 1, 3, 5, and 7 into the first group

                  2, 3, 6, and 7 are divided into the second group

                  4, 5, 6 and 7 are divided into the third group

Step 4: Use even parity to check which group has the problem and get the number on the corresponding check digit.

The first group: Because the first group is 1, 3, 5, and 7, the number of 1s counted on the table is 2, and the number of 1s is an even number, and because even parity is used for verification, the first The number written on the check digit is 0. So there is no problem with the first group.

The second group: Because the first group is 2, 3, 6, and 7, the number of 1s counted on the table is 3, and the number of 1s is an odd number, and because even parity is used for verification, the second group The number written on the check digit is 1. So there is a problem with the second group.

 The third group: Because the first group is 4, 5, 6, and 7, the number of 1s counted on the table is 3, and the number of 1s is an odd number, and because even parity is used for verification, the third group The number written on the check digit is 1. So the third group is at fault.

So the data on the resulting check digit is 110 (check digit)

Step 5: Find out where the error occurred

Hamming code has a characteristic, that is, the decimal number of the check digit is, then the error position of the Hamming code is the decimal number of the check digit.

The above check digit is 110, so the error occurs in the 6th bit.

Step 6: Get the transmitted data

After removing the check digit and correcting the wrong position, the transmitted data is 0101.

Guess you like

Origin blog.csdn.net/yh1009/article/details/131893419