Last active
August 1, 2017 05:42
-
-
Save chenqingspring/b2b2f8748b37e65eead16dcadfec9460 to your computer and use it in GitHub Desktop.
crc32发送端和接收端算法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
要发送的数据:10101010 | |
crc32校验码:100000100110000010001110110110111 | |
发送端 | |
1010101000000000000000000000000000000000 ---> 发送数据添加32个0 | |
100000100110000010001110110110111 ---> 反复对校验码进行模2运算 | |
------------------------------------ | |
0010100001100000100011101101101110000000 | |
100000100110000010001110110110111 | |
----------------------------------------- | |
00100011111000101011010110110101100000 | |
100000100110000010001110110110111 | |
000011011110101001011000000011011 | |
----------------------------------------- | |
000011011110101001011000000011011 ---> 对校验码取余数 | |
接收端 | |
1010101011011110101001011000000011011 ---> 要发送的数据 + 余数 | |
100000100110000010001110110110111 ---> 反复对校验码进行模2运算 | |
----------------------------------------- | |
0010100010111110001010110101101101011000 | |
100000100110000010001110110110111 | |
----------------------------------------- | |
00100000100110000010001110110110111000 | |
100000100110000010001110110110111 | |
----------------------------------------- | |
000000000000000000000000000000000 --->接收端检验余数为0 | |
参考:https://en.wikipedia.org/wiki/Cyclic_redundancy_check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment