I am trying to setup communications between a pair of Xbee radios with micro controllers. These radios have their own built in acknowledge and checksum functions but they are too simplistic and I still end up with incorrect messages out the other end anyways.
I want to implement a more robust acknowledgment scheme in which the receiver sends a message containing a hash/checksum of the message and the sender looks up that value in a table of sent messages and clears the matching sent message (if a message has not been cleared for a set period of time, the message is resent until a match is found).
My problem is I’m not familiar with checksums and hashing functions, both of which are similar but designed for different purposes.
Is there a simple algorithm that would work well as both a hashing function (collision avoidance so that we don’t clear the wrong sent message) and a checksum function (highly sensitive to transmission errors) at the same time that could be simply implemented on an 8-bit micro controller (programmed in C).
It sounds like you are looking for CRC. Depending on the length you choose, you should be able to calculate it quickly enough on your microcontroller.
If I were you, I wouldn’t use the checksum to identify your data packets. I would use an incrementing packet ID for this purpose. This will give you better control and should make it simpler to implement a sliding window protocol.