I generated a CRC integer over a byte array and converted it also to 4 bytes array. I used this class for CRC16 which uses generator polynomial = 0x1021; which means 1 + x + x^5 + x^12 + x^16 I send my byte array and the CRC over UDP to the server. On server side I like to check if the byte array was properly transmitted. As I understand it I can just divide the data-array concatenated with crc-array by the generator polynomial. Did I understood that right? And how to perform the data+crc division by generator polynomial in Java?

I've seen solutions that just generate the crc code again over the data and compare whether resulted crc codes are the same, but this is'n maybe the thing crc-codes are made for.

有帮助吗?

解决方案

CRC is designed that you simply repeat the CRC computation, but with the CRC bytes appended to the data bytes. From Wikipedia:

The validity of a received message can easily be verified by performing the above calculation again, this time with the check value added instead of zeroes. The remainder should equal zero if there are no detectable errors.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top