Modulo 2 division (CRC redundancy code calculation) and binary/decimal division

tags: The internet


After reviewing the network, I accidentally encountered the calculation of the CRC redundant code for error control. I randomly calculated it and found that I did not calculate it correctly, so I found a string of knowledge, which is summarized as follows. The main reason is that the modulo 2 operation used in the CRC is different from the binary/decimal division. The former is a special division, or even a division or an exclusive OR.

CRC Cyclic Redundancy Check: There is no error when the remainder is 0; you cannot determine which bits are wrong


It seems that it is necessary to increase the cost, there is no free lunch, no wonder the name is "redundant"



is that the sender first puts n zeros in the position of the redundant code, and then takes the entire data (k+n) bits as a number and divides it by (Modulo 2 division is used, which is very important! ! Not conventional division) A pre-prepared divisor p (n+1 digits), the divided remainder R is n bits, and this n-bit remainder is used as the sender's CRC cyclic redundancy code.

When it arrives at the recipient, divide the received number by the same divisor P (probably the P specified in the agreement), and the remainder of 0 means no error

Check every frame

It is not 100% that the detection is correct, and there is a probability that the result of the detection is incorrect. The larger the number of redundant codes, the more accurate the result will be and the lower the probability of detecting errors.

Binary division (same as decimal division!)

Modulo 2 division (unlike binary division! The essence is XOR only)

This blog wakes me up
I have never understood the calculation process of the CRC redundancy code. It took more than an hour to study. I thought that the above description was about decimal division. My own examples and ppt examples are not feasible. , I read a lot of webpages, thought it was binary division, and found that the essence of binary division is the same as decimal division, and the result is the same. . .

I finally understood that the division mentioned in the CRC calculation is not a decimal or binary division at all, but a modulo 2 division. This is a special division. It is basically only used in the calculation of CRC redundant codes. Not used.

The key point of modulo 2 division is (as long as you have mastered these points, you can get through the meridians of modulo 2 division, and you are no longer in doubt):

  • Do not consider carry
  • It is equivalent to bitwise XOR. Although the name is division, it is actually not the same as conventional division. The essence is XOR. For example, the quotient is not based on the size of the remainder and divisor, but on the basis of whether the first digit of the remainder is 0 or 1. If the first digit of the remainder is 0, then quotient 1, and if the first digit of the remainder is 1, then quotient 0.

Why is the first digit of the remainder 1 and the quotient is 0?
because in fact the quotient isXOR of the first digit of the remainder and the first digit of the divisor, But the divisor is always the same and its first digit must be 1, so naturally the first digit of the remainder is 1, and the quotient is 0.

  • The first digit of the quotient is determined by the dividend: if the first digit of the dividend is 1, the highest digit of the quotient is 1, otherwise it is 0.
  • During the calculation, if the first digit of the remainder is not 0, you cannot move to the right, that is, you cannot take one more bit from the dividend, and the quotient of this bit is 0; only the first digit of the remainder can be 0. The position is down, and the quotient of this position is 1. So it can also be said that whether the quotient is 0 or 1 is determined based on whether it can be shifted to the right, or 1 if it can be shifted to the right.

You can see how important XOR is in the IT field

can be seen:

  • The calculation of each bit of the modulo 2 division is completely independent, that is, XOR, there is nothing to borrow at all
  • If the first digit of the remainder is 1, the quotient is 0, and XOR with the divisor again, the second digit of the remainder must be 0, but this time only the right shift, and no quotient is obtained. So the above example did 8 XOR operations, but only 6 quotients, because the remainder of two of them is 1.
  • The divisor and remainder in modulo 2 operations areXOR; Divisor and remainder in binary and decimal division areSubtraction

After the recipient receives the data:

The remainder is 0, so no error, receive.

Intelligent Recommendation

CRC verification calculation and principle (including instructions for molding 2 division)

  First, CRC definition CRC (CYCLIC Redundancy Check), that is, cyclic redundancy check code, can also be called loop code, with error-in error and error correction.Unlike the Hallup checksum par...

CRC cyclic redundancy code and its detailed calculation

This article is actually the handling of the teaching video of station B:Link click Article Directory Definition of cyclic redundancy check code Features of cyclic redundancy check code What is modulo...

How to calculate modulo 2 division, the simplest understanding of modulo 2 division

In order to make a topic, I searched a bunch of information about modulo 2 division on the Internet, but I don’t think it is practical. Let me talk about my personal understanding. The relevant ...

Some summary of CRC binary division

Programming with matlab for the first time. After looking up the crc cyclic redundancy data, I followed the idea of ​​crc to find the remainder. Crc method: Use the 12-bit polynomial as the divisor, a...

More Recommendation

Network calculation: CRC, IP subnet division

CRC: Cyclic Redundancy Code Check Detailed calculation of station B IP subnetting Binary calculation, decimal means the result The subnet mask is a placeholder. The subnet mask always appears in pairs...

Modulo 2 operation of addition, subtraction, multiplication and division

In the basic algorithms, what we learn is basically the modulus two arithmetic. What is a modulus two arithmetic, here is a brief introduction. Modulo 2 operation It is a binary algorithm, the core pa...

Computer Network: Binary Division and CRC Verification

Here we record the after-class questions of two computer network textbooks: 1. The data to be sent is 1101011011. The generated polynomial using CRC is P(X)=X^4+X+1. Try to find the remainder that sho...

Moduling 2 division and binary division

Moduling 2 division and binary division The binary addition and subtraction and division and decoration and the decimal, "Mod 2 and", "Mod 2 Decrease", name, algorithm, although th...

CRC redundancy code

CRC check Fundamental The principle of CRC check is actually to add a 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 bits;...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top