CRC principle summary

CRC is often used to determine whether the file content has been changed during transmission and some other encryption algorithms. In Java, the CRC32 tool class is provided for us to use.

1. The specific principle of CRC check is as follows:

  Append a number to the data frame to be sent (this is the verification code used for verification, all of which are binary sequences) to generate a new frame and send it to the receiver. Of course, this additional number cannot be arbitrary, it must make the new frame generated with

The sender and the receiver jointly select a number for division (note: this is not the binary division used, but a method called: modulo 2 division). After the generated new frame arrives at the receiver, divide the new frame by (as above) the selected number.

Because a number has been attached before sending, "removing the remainder" is done. It can also be eliminated. So the result should have no remainder. If there is a remainder, it means that an error occurred during transmission.

illustrate:

  "modulo 2 division" is similar to arithmetic division, but it neither borrows upwards nor compares the same number of digits of the divisor and dividend, as long as the division is performed with the same number of digits. Modulo 2 addition operation is: 1+1=0; 1+0=1; 0+1=1; 0+0=0

2. Modulo 2 subtraction is: 1-1=0; 1-0=1; 0-1=1; 0-0=0. Equivalent to the logical XOR operation in binary (the same is 1, the difference is 0). For example, if 100101 is divided by 1110, the quotient is 11 and the remainder is 1. For example, 11*11=101

 

 3. CRC specific execution steps:

  1. First select a divisor for dividing the received frame when checking at the receiving end

  2. Look at the selected divisor binary number (assume k bits), then add k-1 bits of "0" to the data frame to be sent (assume m bits), and then add k-1 "0" to this The new frame (m+k-1 bits in total) is divided by the above divisor in the "modulo 2 division" method, and the remainder (that is, the binary string) is the CRC check code of the frame, also known as: FCS (Frame Check Sequence). But we must pay attention: the number of digits in the remainder must be only one less than the number of digits in the divisor, even if the first digit is 0, or even all 0, it cannot be omitted.

  3. Then attach the check code to the original data frame (that is, the m-bit frame, note that it is not the frame with m+k-1 formed later), and construct a new frame to send to the receiver. Finally, the receiving end is divided by the previously selected divisor in the "modulo 2 division" method. If there is no remainder, it means that there is no error in the transmission process of the frame.

 

4. Summary
  As can be seen from the above: CRC has two key points. One is to choose a binary bit string (or polynomial) that both the sender and receiver use as divisors. The second is to use the original frame and the above selected binary division operation to calculate the FCS. The former can be selected randomly or according to international standards, but both the highest and lowest must be 1, CRC16=X^16+X^15+X^2+X (corresponding to binary: 11000000000000101)

 

5. Cases

  The CRC generator polynomial G(X)=X^4+X^3+1 is selected, and the CRC check code of the binary sequence 10110011 is required to be obtained.

 

Reference: https://wenku.baidu.com/view/34ba49149b89680202d82513.htmlram=1

http://www.repairfaq.org/filipg/LINK/F_crc_v31.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325902041&siteId=291194637