[英]How to decide when to reflect or XOR CRC data?
I found multiple optimal CRC-32 polynomials on the CRC Polynomal Zoo site of Philip Koopman.我在 Philip Koopman 的CRC Polynomal Zoo 网站上找到了多个最佳 CRC-32 多项式。 Now I want to generate a CRC lookup table for one of the polynomials, by using the software pycrc .
现在我想通过使用软件pycrc为多项式之一生成一个 CRC 查找表。
To generate a CRC lookup table you have to provide the following information for the choosen polynomial:要生成 CRC 查找表,您必须为所选多项式提供以下信息:
For some polynomials I found the above parameters in a specification (for instance a AUTOSAR specification for the polynomial "F4ACFB13"), but what parameters should I choose if there is no specification for a certain polynomial?对于某些多项式,我在规范中找到了上述参数(例如多项式“F4ACFB13”的AUTOSAR 规范),但是如果某个多项式没有规范,我应该选择哪些参数? The Koopman site doesn't seem to provide the recommended parameters to use.
Koopman 网站似乎没有提供建议使用的参数。
I already tried to find an explanation how to choose these parameters, but I could only find explanations how to implement these parameters and not how to choose them.我已经尝试找到如何选择这些参数的解释,但我只能找到如何实现这些参数而不是如何选择它们的解释。 Most websites recommend searching for specifications describing "common CRC polynomials", because they provide the optimal parameters.
大多数网站建议搜索描述“通用 CRC 多项式”的规范,因为它们提供了最佳参数。
Generally you are trying to match the CRC used in some existing protocol.通常,您正在尝试匹配某些现有协议中使用的 CRC。 In that case you need to do the same thing you did for the AUTOSAR CRC: find the specification for the CRC.
在这种情况下,您需要执行与 AUTOSAR CRC 相同的操作:找到 CRC 的规范。 Or you need to get several examples of messages and correct CRCs and try to reverse-engineer the CRC parameters.
或者您需要获取多个消息示例并更正 CRC,然后尝试对 CRC 参数进行逆向工程。
You can find over a hundred CRC definitions here .您可以在此处找到一百多个 CRC 定义。
If you are creating your own protocol from scratch, then you can select any polynomial, reflection, initial value, and final exclusive-or you like, as well as any byte order of the CRC in the message.如果您从头开始创建自己的协议,那么您可以 select 任何多项式、反射、初始值和最终异或您喜欢的,以及消息中 CRC 的任何字节顺序。 I would recommend that the polynomial be chosen with good properties for your message length from Phil's data, and that the initial value of the CRC register,
init
, not be zero.我建议从 Phil 的数据中为您的消息长度选择具有良好属性的多项式,并且 CRC 寄存器的初始值
init
不为零。 (If it is zero, then the CRC of any string of zeros will be the same value, that final exclusive-or, regardless of the length.) Also there is no detriment, and it is more aesthetic to pick the initial value and the final exclusive-or to be equal, so that the CRC of an empty sequence is zero. (如果它是零,那么任何零串的 CRC 都将是相同的值,即最终的异或,无论长度如何。)也没有损害,选择初始值和最终异或相等,因此空序列的 CRC 为零。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.