Easy-to-understand CRC cycle check

CRC cycle check

CRC encoding, also known as polynomial encoding. It is an error checking code commonly used in data communication. It consists of an information field and a verification field. The length of the information field and the check field can be selected arbitrarily.

Let's first look at the principle of CRC check:


The sender wants to send d bits of data D to the receiver, so

1. Make an agreement in advance, that is, the two parties first negotiate an r+1 bit pattern, called a generator polynomial , represented by G, and the highest bit of G must be 1.

 
2. At the sending end, first add (G-1) 0s to the data bits (eg D: 110101) to get a frame, where G is negotiated in advance (eg x^4+x^3+1, converted to binary is 11001, and then add 4 0s after D, the frame becomes 1101010000), and then let the new data bits perform "modular division" operation on the generator polynomial, and the final remainder is CRC Check code (note that the CRC check code here must be G-1 digits, and if the high-order digit is 0, it must also be written), and then replace the G-1 0s just added with the obtained CRC check code. This results in a new frame. 


3. Then encapsulate the new frame and the generator polynomial and send it to the receiving end. The receiving end takes out the new frame and generator polynomial after receiving the packet. Then perform the same operation as the sending end, and perform modulo double division on the binary corresponding to the generator polynomial. If the final remainder is 0, it means that there is no error in the transmission process. Otherwise it is an error. And you can check exactly which one is wrong.

Let’s analyze the example above 
. First, the data bit is 110101, and the generating polynomial is x^4+x^3+1. Then the converted binary is 11001, and the generated frame is 1101010000 (the reason why this is the case is explained above), and then the modular double division is performed first, and the remainder is the CRC check code. Let’s first look at what is the modular double division operation. It is like a high-bit borrow, and the modulo two division is just the XOR of the current bit, and does not involve a 
borrow 

As long as the binary bits are the same, the quotient is 1, and if not enough, the quotient is 0. 
Now divide the above formula by modulo two


The former teacher of basic communication theory once said: "CRC check is the pride of our communicators". So why is the CRC check code so good? It is because he can detect an error in the transmission process at the receiving end, and can detect it, so he is very powerful, so now let’s analyze why it can specifically detect a certain bit error (in fact, it can detect multiple bit errors at a time). The remainder must be 0. If one of the bits is wrong, then there must be an error during transmission, resulting in an exception  
. How does the CRC check detect the wrong bit? Now assume that the frame received by the receiving end is 1101111101, that is, the fifth digit from left to right has changed from 0 to 1, and now calculate it by modulo two division.


Therefore, the receiving side pushes back according to the obtained remainder to get where the wrong bit is.

To sum up: the CRC check code is to use the sender and the receiver to negotiate a generator polynomial in advance, and then divide the binary sequence corresponding to the generator polynomial by the obtained data frame modulo two. If the remainder is 0 at the receiver, it means that there is no error in the transmission, otherwise an error will occur.

Guess you like

Origin blog.csdn.net/prokgtfy9n18/article/details/74855834