PDA

View Full Version : Checksum curiosa


sjackman
September 19th, 2006, 11:29 AM
The spec states that...

The Checksum field is the unsigned, modulo 0x10000, 16-bit additive checksum of the entire packet’s slot data, including START Code.

However, the checksum covers a maximum of 255 bytes, each with a maximum value of 255, so the maximum possible checksum is 65025, or 0xfe01. So the checksum is in fact not modulo at all.

Cheers,
Shaun

sblair
September 19th, 2006, 12:42 PM
Shaun,

If I recall correctly the Message Length max is 255. That field points to the Slot # of Checksum High. So I believe the max packet is 257 bytes.

If each of those bytes was 255, then the Checksum would be 65535. So in that case it wouldn't roll over.

It would be best for everyone to implement it as a modulo anyway as there will be less problems when/if there is any expansion to it in the future.

sjackman
September 19th, 2006, 02:36 PM
The 257 byte maximum includes the two bytes of the checksum, which clearly aren't covered by the checksum. The checksum only covers 255 bytes.

Brian Sidebotham
October 3rd, 2006, 07:24 AM
Just because you can't get to the roll over point doesn't mean you can't say it's modulo. By it's very definition of being a 16-bit number it has to be modulo 0x10000