- First data bit is: 1 Remainder: 1010 101 The CRC code generated is: Enter the data to be sent: Enter bit number 10: 1 Enter bit number 9: 0 Enter bit number 8: 0 Enter bit number 7: 1 Enter bit number 6: 1 Enter bit number 5: 0 Enter bit number 4: 1 Enter bit number 3: 1 Enter bit number 2: 0 Enter bit number 1: 1 1.).
- CRC Cyclic Redundancy Check Java Program. Computer Networks CRC Cyclic Redundancy Check Java Program import java.util.Scanner.
- Java does not make it compulsory for programmers to always implement the graphs in the program. Java provides a lot of ready libraries that can be directly used to make use of graphs in the program. These libraries have all the graph API functionality required to make full use of the graph and its various features.
Java Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability.
OUTPUT:
- parameter model
- Algorithm implementation
- CRC-32
- CRC-32/MPEG-2
- Table generation algorithm
- reference material
- Source code of this article
CRC (cyclic redundancy check): is the most commonly used error checking code in the field of data communication. Its characteristic is that the length of information field and check field can be arbitrarily selected. Cyclic redundancy check (CRC) is a kind of data transmission error detection function. It calculates the polynomial of data and attaches the result to the frame. The receiving equipment also implements similar algorithm to ensure the correctness and integrity of data transmission.
CRC algorithm parameter model explanation:
- NAME: parameter model name.
- WIDTH: width, that is, the number of CRC bits.
- POLY: abbreviation of the generated item, expressed in hexadecimal. For example, CRC-32 is 0x04c11db7, ignoring the highest “1”, that is, the complete generated item is 0x104c11db7.
- INIT: This is the initialization preset value of the register (CRC) at the beginning of the algorithm, expressed in hexadecimal.
- REFIN: of the data to be measuredEach byteWhether to reverse bitwise, true or false.
- REFOUT: after calculation, before XOR output,The whole dataWhether to reverse bitwise, true or false.
- XOROUT: the final CRC value is obtained after the calculated result is XOR with this parameter.
The common CRC parameter models are as follows:
CRC algorithm name | Polynomial formula | width | polynomial | Initial value | Result XOR value | Input reversal | Output reversal |
---|---|---|---|---|---|---|---|
CRC-4/ITU | x4 + x + 1 | 4 | 03 | 00 | 00 | true | true |
CRC-5/EPC | x5 + x3 + 1 | 5 | 09 | 09 | 00 | false | false |
CRC-5/ITU | x5 + x4 + x2 + 1 | 5 | 15 | 00 | 00 | true | true |
CRC-5/USB | x5 + x2 + 1 | 5 | 05 | 1F | 1F | true | true |
CRC-6/ITU | x6 + x + 1 | 6 | 03 | 00 | 00 | true | true |
CRC-7/MMC | x7 + x3 + 1 | 7 | 09 | 00 | 00 | false | false |
CRC-8 | x8 + x2 + x + 1 | 8 | 07 | 00 | 00 | false | false |
CRC-8/ITU | x8 + x2 + x + 1 | 8 | 07 | 00 | 55 | false | false |
CRC-8/ROHC | x8 + x2 + x + 1 | 8 | 07 | FF | 00 | true | true |
CRC-8/MAXIM | x8 + x5 + x4 + 1 | 8 | 31 | 00 | 00 | true | true |
CRC-16/IBM | x16 + x15 + x2 + 1 | 16 | 8005 | 0000 | 0000 | true | true |
CRC-16/MAXIM | x16 + x15 + x2 + 1 | 16 | 8005 | 0000 | FFFF | true | true |
CRC-16/USB | x16 + x15 + x2 + 1 | 16 | 8005 | FFFF | FFFF | true | true |
CRC-16/MODBUS | x16 + x15 + x2 + 1 | 16 | 8005 | FFFF | 0000 | true | true |
CRC-16/CCITT | x16 + x12 + x5 + 1 | 16 | 1021 | 0000 | 0000 | true | true |
CRC-16/CCITT-FALSE | x16 + x12 + x5 + 1 | 16 | 1021 | FFFF | 0000 | false | false |
CRC-16/X25 | x16 + x12 + x5 + 1 | 16 | 1021 | FFFF | FFFF | true | true |
CRC-16/XMODEM | x16 + x12 + x5 + 1 | 16 | 1021 | 0000 | 0000 | false | false |
CRC-16/DNP | x16 + x13 + x12 + x11 + x10 + x8 + x6 + x5 + x2 + 1 | 16 | 3D65 | 0000 | FFFF | true | true |
CRC-32 | x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 | 32 | 04C11DB7 | FFFFFFFF | FFFFFFFF | true | true |
CRC-32/MPEG-2 | x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 | 32 | 04C11DB7 | FFFFFFFF | 00000000 | false | false |
Note:The polynomial selected by CRC algorithm will affect the ability of CRC algorithm to check errorsIt is not allowed to define polynomials at will, but to choose a general CRC polynomial.
It is only given hereCRC-32、CRC-32/MPEG-2The two algorithms have the same polynomial, but the parameter model is very different.
By comparing the implementation code of the two algorithms, it is easy to write other parameter model CRC algorithm with look-up table method, and then use itTable generation algorithmGenerate the corresponding table.
CRC-32
The code is as follows:
The tests are as follows:
Test results:
CRC-32/MPEG-2
The code is as follows:
The tests are as follows:
Test results:
Table generation algorithm
The tests are as follows:
Program To Implement Crc In Java
CRC online computing — ip33.com
Crc32helper -. Net source code
crc——github
Program To Implement Crc In Java Runtime
Crcdemo (Baidu disk extract code: 4xt3)