EmbeddedRelated.com
Forums

Checksum for a data packet of max 255 bytes?

Started by Mr December 20, 2007
What kind of checksum is appropriate for a data package with a maximum 
length of 255 byte?

Is an one byte XOR checksum sufficient or should i use some kind of 16-bit 
checksum or is that overkill for so litle data?

The data is to be transmitted on an RS232 line at 115200 kbit/s.


"Mr" <Mr@mr.com> a &#4294967295;crit dans le message de
news:476a88bc$0$90275$14726298@news.sunsite.dk...
> What kind of checksum is appropriate for a data package with a maximum > length of 255 byte? > > Is an one byte XOR checksum sufficient or should i use some kind of 16-bit > checksum or is that overkill for so litle data? > > The data is to be transmitted on an RS232 line at 115200 kbit/s. >
The rfc 1071 summarizes some algorithms : http://www.faqs.org/rfcs/rfc1071.html In one section there are example of Internet checksum implementation algorithms that have been found to be efficient on a variety of CPU's. It's very easy to implemente... -- -Stan
Mr wrote:
> What kind of checksum is appropriate for a data package with a maximum > length of 255 byte? > > Is an one byte XOR checksum sufficient or should i use some kind of 16-bit > checksum or is that overkill for so litle data? > > The data is to be transmitted on an RS232 line at 115200 kbit/s.
What are the consequences of a packet error? A misplaced dot on a graph that a user will eyeball-out or somebody dies? A CRC or checksum plus structured data plus sanity checking on the receiving end is often adequate but more robust error detection and correction techniques are certainly available and may be warranted. P(error) will never be exactly zero. How small does it need to be? -- Rich Webb Norfolk, VA
Mr wrote:
> What kind of checksum is appropriate for a data package with a maximum > length of 255 byte? > > Is an one byte XOR checksum sufficient or should i use some kind of 16-bit > checksum or is that overkill for so litle data? > > The data is to be transmitted on an RS232 line at 115200 kbit/s.
Depends on how frequently you are sending packets and how much a bad one will cost you. My personal, totally empirical, preference would be crc16. It only takes a few more instructions to implement than checksum.
Jim Stewart wrote:
> Mr wrote: > >> What kind of checksum is appropriate for a data package with a >> maximum length of 255 byte? >> >> Is an one byte XOR checksum sufficient or should i use some kind >> of 16-bit checksum or is that overkill for so litle data? >> >> The data is to be transmitted on an RS232 line at 115200 kbit/s. > > Depends on how frequently you are sending packets and how much a > bad one will cost you. > > My personal, totally empirical, preference would be crc16. It > only takes a few more instructions to implement than checksum.
I agree completely. Use the CCITCRC polynomial, and initialize the checksum to 0xffff. -- Merry Christmas, Happy Hanukah, Happy New Year Joyeux Noel, Bonne Annee. Chuck F (cbfalconer at maineline dot net) <http://cbfalconer.home.att.net> -- Posted via a free Usenet account from http://www.teranews.com