SoFunction
Updated on 2025-03-10

Binary inverse code summing algorithm in TCP/IP

Verify with 4bit (computing is easier, and the same as 16bit).

The original data of construction is 1100, 1010, 0000 (check bit)

Then add them in bitwise inverted according to a 4bit group. 1100 invert 0011, 1010 invert is 0101, 0011 plus 0101 is 1000, after filling in the check bit

1100 , 1010 , 1000

Then this is the data to be sent. After receiving the data, the bitwise inverted addition is also performed. 0011+0101+0111 =1111; all 1 means correct


Also note that when calculating the checksum locally, it is possible that the highest bit will carry after addition, so it cannot be discarded. It must be added to the low bit to make the result correct.