5.3.2 cyclic redundancy check and error check plan
The parity check code (PCC) introduced in the previous section can only verify one error. The cyclic redundancy check code (CRC) described in this section has higher error checking capability and can detect multiple errors.
1. CRC Verification Principle
The CRC verification principle seems complicated and difficult to understand, because most books basically describe it in the form of binary polynomials. In fact, it is very simple. The fundamental idea is to first append a number to the frame to be sent (this is the verification code used for verification, but note that the number here is also a binary sequence,) to generate a new frame and send it to the receiver. Of course, this additional number is not random. It should enable the generated new frame to combine with a specific number selected by the sender and receiver (note, the binary division is not used directly, but is called"Modulo 2 Division"). After arriving at the receiving end, divide the received new frame byModulo 2 Division") The selected divisor. Because a number has been appended to the sender before sending the data frame, and the "de-remainder" is processed (this can be divisible), there should be no remainder in the result. If there is a remainder, it indicates that the frame has an error during transmission.
Specifically, the principle of CRC verification is as follows:
(1) Select (either randomly selected or selected according to the standard, as described later) One for verification at the receiving end, divide the received frame (it is a binary comparison special string, usually expressed in multiple ways, so CRC is also called a polynomial encoding method, which is also called a "generate polynomial ").
(2) Look at the selected divisor binary digits (assuming K bit), and then add the K-1 bit "0" after the data frame to be sent (assuming M bit ", then the new frame with the K-1 "0" (a total of M + k-1 bits) is divided by the divisor above by the "mod 2 Division, the obtained remainder (also a binary Bit String) is the CRC verification code of the frame, also known as the FCS (frame verification sequence ). However, note that,The number of digits of the remainder must be only one bit less than the number of divisor, even if the first digit is 0 or even all is 0 (with a better integer division), it cannot be omitted..
(3) then append the verification code to the original data frame (m-bit frame, note that it is not in the form of M + k-1 frame), build a new frame to send to the receiving end, at last, the new frame is divided by the divisor in the form of "modulo 2 Division". If there is no remainder, it indicates that the frame has no error during transmission, otherwise, an error occurs.
After the above introduction, you can understand the principle of CRC verification, and do not think it is very complicated.
We can see from the above that there are two key points in CRC verification: first, we need to determine in advance that both the sending end and the receiving end are used as the divisor binary bits (or polynomials ); the second is to divide the original frame with the binary division operation selected above and calculate the FC. The former can be selected randomly or internationally,The maximum and maximum bits must be "1", For example, the CRC-16 used in IBM's SDLC (synchronous Data Link Control) procedure (that is, this divisor is a total of 17 bits) to generate polynomial g (x) =X16 +X15 +X2 + 1 (corresponding to binary bits: 11000000000000101), while in iso hdlc (Advanced Data Link Control) procedure, itu sdlc, X.25, V.34, V.41, v.42, etc. using CCITT-16 to generate polynomial g (x) =X16 +X15 +X5 + 1 (corresponding binary bits: 11000000000100001 ).
2. Example of CRC verification code calculation
The above analysis shows that since the divisor is random or selected according to the standard, the key to CRC verification is how to obtain the remainder, that is, the CRC verification code.
The following is an example to illustrate the entire process. Assume that the selected CRC generation polynomial is g (x) = X4 + X3 + 1, and the CRC verification code of 10110011 of the binary sequence is required. The specific calculation process is as follows:
(1) first, convert the generated polynomial to the binary number, which can be known from g (x) = X4 + X3 + 1 (, it has a total of five digits (the total number of digits equals the power of the highest digit plus 1, that is, 4 + 1 = 5 ), then, based on the meanings of the polynomials (polynomials only list the bits whose binary value is 1, that is, the binary values of the binary value 4th, 3rd, and 0th are 1, and the other bits are 0) soon, we can see that its binary bit string is11001.
(2) because the number of digits of the generated polynomial is 5, according to the previous introduction, we know that the number of digits of the CRC verification code is 4 (the number of digits of the verification code is 1 less than the number of digits of the generated polynomial ). Because the original data frame is 10110011, add four zeros to it to get 101100110000Divide the number by the division of the modulo 2 to generate a polynomial, and the remainder is obtained, that is, the CRC verification code is0100, 5-10. NOTE: Refer to the "modulo 2 Division" algorithm described above.
(3) Replace the CRC verification code 0100 calculated in the previous step with the original frame 10110011.0000The four following "0" get the new frame 101100110100. Then, the new frame is sent to the receiver.
(4) When the new frame arrives at the receiving end, the receiving end will use the new frame with the divisor selected above.11001This parameter is removed in the form of "mod 2 Division" to verify whether the remainder is 0. If it is 0, it indicates that no error occurs during the transmission of the frame data; otherwise, an error occurs.
Through the analysis of the above CRC verification principle and the introduction of the CRC verification code calculation example, we should be clear about this seemingly complex CRC Verification Principle and calculation method.
Cyclic Redundancy Verification Code