CRC Test Principle

Source: Internet
Author: User

Introduction 1:

I. Basic Principles

The CRC Check principle is to add an r-bit binary check code (sequence) after a p-bit binary data sequence to form a binary sequence with a total length of n = p + r; there is a specific relationship between the verification code appended to the data sequence and the content of the data sequence. If one or some bits in the data sequence are wrong due to interference or other reasons, this specific relationship will be damaged. Therefore, you can check the data correctness by checking the relationship.

Ii. Several Basic Concepts

1. Frame Check Sequence: The Sequence code added for the error Check.

2. Run polynomial mod 2: It is actually an Exclusive OR (Exclusive OR) operation, that is, the same is 0, the difference is 1, that is, the binary addition and subtraction operations of carry and borrow bits are not considered. For example, 10011011 + 11001010 = 01010001.

3. generator polynomial ). The highest and lowest bits of the generated polynomials must be 1. Commonly used CRC code generation polynomials include:

CRC8 = X8 + X5 + X4 + 1

CRC-CCITT = X16 + X12 + X5 + 1

CRC16 = X16 + X15 + X5 + 1

CRC12 = X12 + X11 + X3 + X2 + 1

CRC32 = X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 + X8 + X7 + X5 + X4 + X2 + X1 + 1

Each generated polynomial can correspond to a code, for example, CRC8 code: 100110001.

Iii. CRC verification code calculation

If the information field is set to K-bit and the verification field is R-bit, the codeword length is N (N = K + R ). If both parties agree on an R polynomial g (x) in advance, the CRC code is:

V (x) = A (x) g (x) = xRm (x) + r (x)

M (X) is K times information polynomial, R (X) is R-1 times verification polynomial.

Here, the code corresponding to R (x) is the verification code, and the CRC code is formed after the original information field.

The R (x) calculation method is to add r 0 after the K-bit information field, and then divide it by the code sequence corresponding to G (x, the resulting remainder is the code corresponding to R (x) (it should be a R-1 bit; if not, it must be 0 in a high position ).

Computing example

Set the message to be sent to M = 1010001101, and the code corresponding to the generated polynomial is P = 110101, r = 5. Add 5 zeros after M, and then perform the modulo 2 division operation on P to obtain the code corresponding to the remainder R (x): 01110. Therefore, the actual data to be sent is 101000110101110.

 

Iv. Error Detection

When the receiver receives the data, it uses the received data to divide P (as agreed in advance) by Model 2. If the remainder is 0, it is considered that there is no error in data transmission. If the remainder is not 0, in this case, an error occurs during data transmission. because you do not know where the error occurred, you cannot perform automatic correction. The general practice is to discard the received data.

V. Notes:

1. CRC is a common error code and cannot be used for automatic error correction.

2. As long as the selection is strict and the Division P with enough digits is used, the probability of an error that cannot be detected is very small.

3. CRC error detection technology can only be used to test CRC errors with cyclic redundancy, which is considered to be error-free only in a very similar way. reliable transmission is not guaranteed.

Introduction 2:

1. Cyclic checksum (CRC ):It is the most common error verification code in the field of data communication. It is characterized by the length of information fields and verification fields that can be selected at will.

2. Basic principles for generating CRC codes:Any code composed of binary strings can correspond to a polynomial with a coefficient of only '0' and a value of '1. For example, code 1010111 corresponds to a polynomial of X6 + X4 + X2 + x + 1, while a polynomial of code 101111 corresponds to X5 + X3 + X2 + x + 1.

3. Principles of CRC code set selection: If the length of a codeword is set to N, the information field is K-bit, and the verification field is R-bit (N = K + R), for any codeword in the CRC code set, only one R polynomial g (x) exists

V (x) = A (x) g (x) = xRm (x) + r (x );

Where:  M (x) is K times of information polynomial, r (x) is the R-1 times of verification polynomial,

        G (x) is called the generative polynomial:

G (x) = g0 + g1x + g2x2 +... + g (R-1) x (R-1) + gRxR

The sender generates a CRC code word through the specified g (x), and the receiver verifies the received CRC code word through the g (x.

4. CRC verification code Software Generation Method:

   By means of Polynomial division, the remainder are verified fields.

For example:Code of the Information Field: 1011001; corresponding to m (x) = x6 + x4 + x3 + 1

     
Assume that the generated polynomial is: g (x) = x4 + x3 + 1; then the code corresponding to g (x) is: 11001

     X4m (x) = x10 + x8 + x7 + x4
The corresponding code is recorded as: 10110010000;

Polynomial Division:The remainder is: 1010.   (Check field: 1010)

Sender: The sent transmission field is:1 0 1 1 0 0 1 0 10

                         
Information Field     
Verification Field

Receiver: Use the same generation code for verification: The received field/Generation Code (Binary Division) is correct if it can be exhausted,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.