CN103297196A - Cyclic redundancy check algorithm of non-integral byte data - Google Patents
Cyclic redundancy check algorithm of non-integral byte data Download PDFInfo
- Publication number
- CN103297196A CN103297196A CN2013102469495A CN201310246949A CN103297196A CN 103297196 A CN103297196 A CN 103297196A CN 2013102469495 A CN2013102469495 A CN 2013102469495A CN 201310246949 A CN201310246949 A CN 201310246949A CN 103297196 A CN103297196 A CN 103297196A
- Authority
- CN
- China
- Prior art keywords
- formula
- crc16
- byte
- crc
- reg
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Abstract
The invention discloses a cyclic redundancy check algorithm of non-integral byte data. The cyclic redundancy check algorithm of the non-integral byte data comprises obtaining a CRC16 value of a fist byte S0 through directly looking up a table of Crcl6-Table [S0]; performing exclusive or on Bn and a n bits higher CH of the CRC16 value a last byte and performing the exclusive or result as a subscript to be looked up the table to obtain Crcl6-Table [(CH+Bn)]; and performing exclusive or on a n bits left shifted (16-n) bits and the table looked up value Crcl6-Table [(CH+Bn)]. The value relationship of n is that n is equal to 8 when an integral byte CRC 16 is calculated and the n is the actual bite when the CRC 16 which not satisfies a bite. The cyclic redundancy check algorithm of the non-integral byte data has the advantages of being applicable to a situation that input information which is a non-integral byte cannot be calculated according to the bites, greatly improving the calculation efficiency, reducing the calculation time, releasing a large number of CPU (Central Processing Unit) resources and reducing power consumption of the CPU.
Description
Technical field
The present invention relates to a kind of cyclic redundancy check (CRC) algorithm of non-whole byte data.
Background technology
In various data communication, generally all will transmit after the packet, additional data Frame Check Sequence after grouped data (Frame Check Sequence, be called for short FCS) carries out error control, with the correctness of the transmission that guarantees data.In the realization of Frame Check Sequence, cyclic redundancy check (CRC) code (Cyclic Redundancy Code, be called for short CRC) obtained to use widely with its high efficiency, high-performance, be a kind of method that improves data communication reliability that generally adopts in the present data transmission procedure.
Data are in process of transmitting, and the data that transmitting terminal will need to transmit are carried out the CRC check yardage and calculated, and check code is attached to sends together after transmitting data.Receiving terminal need carry out check code to the data that receive with same computational methods and calculate, and then the CRC sign indicating number that calculates and the CRC sign indicating number that receives is compared, if the consistent transfer of data that illustrates is errorless, if inconsistent explanation transfer of data is wrong.
The computational efficiency of CRC and time of delay all are the keys of CRC coding techniques all the time, determine directly whether it can use in the reality.At present, the computational methods of CRC, there is step-by-step calculating and calculates two kinds of distinct modes by byte, calculate the computational efficiency height by byte mode, in the computational process cycle-index for the position mode calculate 1/8, and calculate weak point consuming time and controlled, byte mode is by tabling look-up to finish calculating, weak point consuming time and fixing, calculate by the condition judgment executive mode more than the position mode and to be more suitable for the real-time embedded system, although the byte mode superiority is obvious, but its practical application has the stringent condition requirement: transmission information is necessary for the integer byte, transmission information is that just the having only of service condition that the non-integer byte does not satisfy byte mode uses the position mode to calculate the CRC that transmits information sequence, and efficient is extremely low, seriously restricts the real-time response performance of product.
Summary of the invention
The objective of the invention is to overcome the deficiencies in the prior art, providing a kind of can be to use under the satisfied service condition of calculating by byte mode of non-integer byte in transmission information, improved computational efficiency greatly, shortened computing time, discharged a large amount of cpu resources, reduce the requirement to cpu performance and operation clock, reduced the cyclic redundancy check (CRC) algorithm of a kind of non-whole byte data of CPU power consumption.
The objective of the invention is to be achieved through the following technical solutions: a kind of cyclic redundancy check (CRC) algorithm of non-whole byte data, CRC mathematics essence be to the transmission message polynomial to the complementation of CRC generator polynomial, the generator polynomial of CRC16 is:
G (x)=x
16+ x
12+ x
5+ 1, its computational methods are: with 16 0 back of adding S (x) to, just
S (x)=r
16* S (x), wherein r=2 is the base of binary system multinomial operation, S (x) does division arithmetic to generator polynomial G (x) then, namely carries out the logic xor operation, obtains the remainder part of division at last, is CRC16, abbreviates C as
Reg, and merchant's part is called for short M (x), it may further comprise the steps:
S1: suppose S
mCorresponding CRC16 value is C
Reg, by definition, then:
R
2* S
m=M (x) * G (x)+C
Reg(formula 2)
S2: at S
mThe back increases byte information position of less than, n position, forms a new binary system multinomial S'
m, calculate S'
mCRC16, it may further comprise the steps:
S201: at S
mThe back increases byte information position of less than, n position, forms a new binary system multinomial S'
m,
S'
m=r
n* S
m+ B
n(formula 3)
B
nExpression n position binary system multinomial, wherein high-order preceding, low level after.
S202: to S'
mIncrease by 16 0 operations and guarantee that remainder directly is exactly the CRC16 result of data flow:
R
2* S'
m=R
2* (r
n* S
m+ B
n)=r
n* (R
2* S
m)+R
2* B
n(formula 4)
Substituting formula 2 into, formula 4 gets:
R
2*S'
m=rn*(M(x)*G(x)+C
reg)+R
2*B
n
=(r
n* M (x) * G (x))+r
n* C
Reg+ R
2* B
n(formula 5)
Make C
HExpression C
RegHigh n position, C
LExpression C
RegLow (16-n) position,
C
Reg=r
(16-n)* C
H+ C
L(formula 6)
Formula 6 substitution formulas 5 are got:
R
2* S'
m=(r
n* M (x) * G (x))+R
2* C
H+ r
n* C
L+ R
2* B
n(formula 7)
=(r
n*M(x)*G(x))+R
2*(C
H+B
n)+r
n*C
L
Known by the CRC definition: (r
n* Mod (G (x)) ≡ 0 (formula 8) M (x) * G (x))
By logic or the associativity of operation, formula 7 and formula 8:
(R
2* S'
m) Mod (G (x))=Crc16_Table[C
H+ B
n]+r
n* C
L(formula 9)
That is:
S3: by formula 10 as can be known, the CRC16 that calculates current data finishes in two steps, and concrete steps are as follows;
S301: the high n position C that will go up the CRC16 value of a byte
HAnd B
nThe phase XOR, the XOR result tables look-up as subscript and obtains Crc16_Table[(C
H+ B
n)];
S302: will go up behind low (16-n) lt n position of CRC16 of a byte and the value of tabling look-up Crc16_Table[(C
H+ B
n)] the phase XOR.
S4: calculate the CRC16 of random length byte, it may further comprise the steps:
S401: the first byte S of the stream that fetches data
0As the subscript Crc16_Table[S that tables look-up
0] obtain S
0Current C RC16 value;
S402: in order all can be finished CRC16 according to byte by the part that byte is handled and calculate;
S403: the actual bit of getting n and be remaining data is counted substitution formula 10, finishes the calculating of the not enough byte portion C RC16 of residue;
S404: the CRC16 result that the current C RC16 value that obtains in conjunction with S401, S402 and S403, the CRC result who calculates according to byte and not enough byte portion C RC result obtain whole data.
The invention has the beneficial effects as follows:
The present invention can be to use under the satisfied service condition of calculating by byte mode of non-integer byte in transmission information, not only CRC result is correct, and improved computational efficiency greatly, shortened computing time, actual test shows: bring up to 9us from 70us computing time, promoted the real-time response performance, discharged a large amount of cpu resources, reduce the requirement to cpu performance and operation clock, reduced the CPU power consumption.
Embodiment
Technical scheme of the present invention is described in further detail below: a kind of cyclic redundancy check (CRC) algorithm of non-whole byte data, CRC mathematics essence be to the transmission message polynomial to the complementation of CRC generator polynomial, the generator polynomial of CRC16 is:
G (x)=x
16+ x
12+ x
5+ 1, its computational methods are: with 16 0 back of adding S (x) to, just
S (x)=r
16* S (x), wherein r=2 is the base of binary system multinomial operation, S (x) does division arithmetic to generator polynomial G (x) then, namely carries out the logic xor operation, obtains the remainder part of division at last, is CRC16, abbreviates C as
Reg, and merchant's part is called for short M (x), it may further comprise the steps:
S1: suppose S
mCorresponding CRC16 value is C
Reg, by definition, then:
R
2* S
m=M (x) * G (x)+C
Reg(formula 2)
S2: at S
mThe back increases byte information position of less than, n position, forms a new binary system multinomial S'
m, calculate S'
mCRC16, it may further comprise the steps:
S201: at S
mThe back increases byte information position of less than, n position, forms a new binary system multinomial S'
m,
S'
m=r
n* S
m+ B
n(formula 3)
B
nExpression n position binary system multinomial, wherein high-order preceding, low level after.
S202: to S'
mIncrease by 16 0 operations and guarantee that remainder directly is exactly the CRC16 result of data flow:
R
2* S'
m=R
2* (r
n* S
m+ B
n)=r
n* (R
2* S
m)+R
2* B
n(formula 4)
Substituting formula 2 into, formula 4 gets:
R
2*S'
m=rn*(M(x)*G(x)+C
reg)+R
2*B
n
=(r
n* M (x) * G (x))+r
n* C
Reg+ R
2* B
n(formula 5)
Make C
HExpression C
RegHigh n position, C
LExpression C
RegLow (16-n) position,
C
Reg=r
(16-n)* C
H+ C
L(formula 6)
Formula 6 substitution formulas 5 are got:
R
2* S'
m=(r
n* M (x) * G (x))+R
2* C
H+ r
n* C
L+ R
2* B
n(formula 7)
=(r
n*M(x)*G(x))+R
2*(C
H+B
n)+r
n*C
L
Known by the CRC definition: (r
n* Mod (G (x)) ≡ 0 (formula 8) M (x) * G (x))
By logic or the associativity of operation, formula 7 and formula 8:
(R
2* S'
m) Mod (G (x))=Crc16_Table[C
H+ B
n]+r
n* C
L(formula 9)
That is:
S3: by formula 10 as can be known, the CRC16 that calculates current data finishes in two steps, and concrete steps are;
S301: the high n position C that will go up the CRC16 value of a byte
HAnd B
nThe phase XOR, the XOR result tables look-up as subscript and obtains Crc16_Table[(C
H+ B
n)];
S302: will go up behind low (16-n) lt n position of CRC16 of a byte and the value of tabling look-up Crc16_Table[(C
H+ B
n)] the phase XOR.
S4: calculate the CRC16 of random length byte, it may further comprise the steps:
S401: the first byte S of the stream that fetches data
0As the subscript Crc16_Table[S that tables look-up
0] obtain S
0Current C RC16 value;
S402: in order all can be finished CRC16 according to byte by the part that byte is handled and calculate;
S403: the actual bit of getting n and be remaining data is counted substitution formula 10, finishes the calculating of the not enough byte portion C RC16 of residue;
S404: the CRC16 result that the current C RC16 value that obtains in conjunction with S401, S402 and S403, the CRC result who calculates according to byte and not enough byte portion C RC result obtain whole data.
Claims (1)
1. the cyclic redundancy check (CRC) algorithm of a non-whole byte data, CRC mathematics essence be to the transmission message polynomial to the complementation of CRC generator polynomial, the generator polynomial of CRC16 is: G (x)=x
16+ x
12+ x
5+ 1, its computational methods are: with 16 0 back of adding S (x) to, and S (x)=r just
16* S (x), wherein r=2 is the base of binary system multinomial operation, S (x) does division arithmetic to generator polynomial G (x) then, namely carries out the logic xor operation, obtains the remainder part of division at last, is CRC16, abbreviates C as
Reg, and merchant's part is called for short M (x), it is characterized in that: it may further comprise the steps:
S1: suppose S
mCorresponding CRC16 value is C
Reg, by definition, then:
R
2* S
m=M (x) * G (x)+C
Reg(formula 2)
S2: at S
mThe back increases byte information position of less than, n position, forms a new binary system multinomial S'
m, calculate S'
mCRC16, it may further comprise the steps:
S201: at S
mThe back increases byte information position of less than, n position, forms a new binary system multinomial S'
m,
S'
m=r
n* S
m+ B
n(formula 3)
B
nExpression n position binary system multinomial, wherein high-order preceding, low level after.
S202: to S'
mIncrease by 16 0 operations and guarantee that remainder directly is exactly the CRC16 result of data flow:
R
2* S'
m=R
2* (r
n* S
m+ B
n)=r
n* (R
2* S
m)+R
2* B
n(formula 4)
Substituting formula 2 into, formula 4 gets:
R
2*S'
m=rn*(M(x)*G(x)+C
reg)+R
2*B
n
=(r
n* M (x) * G (x))+r
n* C
Reg+ R
2* B
n(formula 5)
Make C
HExpression C
RegHigh n position, C
LExpression C
RegLow (16-n) position,
C
Reg=r
(16-n)* C
H+ C
L(formula 6)
Formula 6 substitution formulas 5 are got:
R
2* S'
m=(r
n* M (x) * G (x))+R
2* C
H+ r
n* C
L+ R
2* B
n(formula 7)
=(r
n*M(x)*G(x))+R
2*(C
H+B
n)+r
n*C
L
Known by the CRC definition: (r
n* Mod (G (x)) ≡ 0 (formula 8) M (x) * G (x))
By logic or the associativity of operation, formula 7 and formula 8:
(R
2* S'
m) Mod (G (x))=Crc16_Table[C
H+ B
n]+r
n* C
L(formula 9)
That is:
S3: by formula 10 as can be known, the CRC16 that calculates current data finishes in two steps, and concrete steps are as follows;
S301: the high n position C that will go up the CRC16 value of a byte
HAnd B
nThe phase XOR, the XOR result tables look-up as subscript and obtains Crc16_Table[(C
H+ B
n)];
S302: will go up behind low (16-n) lt n position of CRC16 of a byte and the value of tabling look-up Crc16_Table[(C
H+ B
n)] the phase XOR.
S4: calculate the CRC16 of random length byte, it may further comprise the steps:
S401: the first byte S of the stream that fetches data
0As the subscript Crc16_Table[S that tables look-up
0] obtain S
0Current C RC16 value;
S402: in order all can be finished CRC16 according to byte by the part that byte is handled and calculate;
S403: the actual bit of getting n and be remaining data is counted substitution formula 10, finishes the calculating of the not enough byte portion C RC16 of residue;
S404: the CRC16 result that the current C RC16 value that obtains in conjunction with S401, S402 and S403, the CRC result who calculates according to byte and not enough byte portion C RC result obtain whole data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310246949.5A CN103297196B (en) | 2013-06-20 | 2013-06-20 | A kind of cyclic redundancy check method of non-whole byte data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310246949.5A CN103297196B (en) | 2013-06-20 | 2013-06-20 | A kind of cyclic redundancy check method of non-whole byte data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103297196A true CN103297196A (en) | 2013-09-11 |
CN103297196B CN103297196B (en) | 2016-09-28 |
Family
ID=49097563
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310246949.5A Active CN103297196B (en) | 2013-06-20 | 2013-06-20 | A kind of cyclic redundancy check method of non-whole byte data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103297196B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106788878A (en) * | 2015-11-24 | 2017-05-31 | 中国航空工业第六八研究所 | A kind of Parallel CRC error correction method with monobit errro correction function |
CN106788909A (en) * | 2017-03-31 | 2017-05-31 | 重庆邮电大学 | CRC computational methods and device based on GMR satellite communication protocols |
CN110445583A (en) * | 2019-08-12 | 2019-11-12 | 珠海市伟高变频科技有限公司 | Method of calibration, check system and the computer readable storage medium of data transmission |
CN111181628A (en) * | 2020-01-09 | 2020-05-19 | 成都国星通信有限公司 | Method, terminal and storage medium for transmitting voice data through Beidou short message |
CN116107800A (en) * | 2023-04-12 | 2023-05-12 | 浙江恒业电子股份有限公司 | Verification code generation method, data recovery method, medium and electronic equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101527615A (en) * | 2009-04-07 | 2009-09-09 | 华为技术有限公司 | Implementation method of cyclic redundancy check (CRC) codes and device |
CN102546089A (en) * | 2011-01-04 | 2012-07-04 | 中兴通讯股份有限公司 | Method and device for implementing cycle redundancy check (CRC) code |
-
2013
- 2013-06-20 CN CN201310246949.5A patent/CN103297196B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101527615A (en) * | 2009-04-07 | 2009-09-09 | 华为技术有限公司 | Implementation method of cyclic redundancy check (CRC) codes and device |
CN102546089A (en) * | 2011-01-04 | 2012-07-04 | 中兴通讯股份有限公司 | Method and device for implementing cycle redundancy check (CRC) code |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106788878A (en) * | 2015-11-24 | 2017-05-31 | 中国航空工业第六八研究所 | A kind of Parallel CRC error correction method with monobit errro correction function |
CN106788878B (en) * | 2015-11-24 | 2019-11-15 | 中国航空工业第六一八研究所 | A kind of Parallel CRC error correction method with monobit errro correction function |
CN106788909A (en) * | 2017-03-31 | 2017-05-31 | 重庆邮电大学 | CRC computational methods and device based on GMR satellite communication protocols |
CN106788909B (en) * | 2017-03-31 | 2019-11-01 | 重庆邮电大学 | CRC calculation method and device based on GMR satellite communication protocols |
CN110445583A (en) * | 2019-08-12 | 2019-11-12 | 珠海市伟高变频科技有限公司 | Method of calibration, check system and the computer readable storage medium of data transmission |
CN111181628A (en) * | 2020-01-09 | 2020-05-19 | 成都国星通信有限公司 | Method, terminal and storage medium for transmitting voice data through Beidou short message |
CN116107800A (en) * | 2023-04-12 | 2023-05-12 | 浙江恒业电子股份有限公司 | Verification code generation method, data recovery method, medium and electronic equipment |
CN116107800B (en) * | 2023-04-12 | 2023-08-15 | 浙江恒业电子股份有限公司 | Verification code generation method, data recovery method, medium and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN103297196B (en) | 2016-09-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103297196A (en) | Cyclic redundancy check algorithm of non-integral byte data | |
CN105119694B (en) | The method and system of crc value in a kind of calculating express network | |
CN102546089B (en) | Method and device for implementing cycle redundancy check (CRC) code | |
CN106788878B (en) | A kind of Parallel CRC error correction method with monobit errro correction function | |
US20120102382A1 (en) | Method and Device for Fast Cyclic Redundancy Check Coding | |
CN103312458B (en) | Hybrid coding method | |
CN102970049B (en) | Based on parallel circuit and the RS decoding circuit of money searching algorithm and Fu Ni algorithm | |
CN105634506A (en) | Soft decision decoding method of quadratic residue (QR) code based on shifting search algorithm | |
CN101296053A (en) | Method and system for calculating cyclic redundancy check code | |
CN102820892B (en) | A kind of circuit for encoding parallel BCH, encoder and method | |
CN101325706B (en) | Reed-Solomon decoder with low hardware spending | |
CN104639294A (en) | Improved CRC (Cyclic Redundancy Check) realization method | |
CN107231213A (en) | Implementation method of the algorithms of CRC 32 in USB3.0 packets | |
CN100384116C (en) | High-speed coding chip | |
CN103763064A (en) | CRC code generating method and circuit applicable to ultra-high-speed communication system | |
CN105721107B (en) | A kind of piecemeal calculates device and method of the CRC to improve clock frequency | |
CN102130744B (en) | Method and device for computing Cyclic Redundancy Check (CRC) code | |
WO2017128731A1 (en) | Coding method and codec with dynamic power consumption control | |
CN103260154B (en) | A kind of integrity protection Enhancement Method based on 128-EIA3 | |
CN103944589A (en) | BCH (Bose, Ray-Chaudhuri and Hocquenghem) encoding and decoding method and device | |
CN105099466A (en) | CRC (Cyclic Redundancy Check) matrix generating method for 128bit parallel data | |
CN103138881A (en) | Encoding and decoding method and encoding and decoding equipment | |
CN101741397A (en) | RS (reed-solomon) decoding device and key polynomial solving device used by same | |
CN103117752A (en) | High-speed parallel RS encoder and encoding method for consultative committee for space data system (CCSDS) system | |
CN104579368B (en) | A kind of channel error correction encoding RS codes solving key equation circuit |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |