Re: simple transport protocol



On May 24, 7:34 pm, "Roman Mashak" <m...@xxxxxxxx> wrote:
Hello,

I'm designing simple protocol for a bootloader, which is supposed to
transfer data from host computer to target (ARM7-based embedded system) over
USB. It should not be very reliable, so a simple checksum algorithm can be
used by now. I plan to transmit data in blocks, prepended with a header and
ended with a control check sum.

I think this is quite relevant conference to post such a questioin, as it's
not a deeply hardware-related one :) So here is how I assume it may be:

| command 1 byte | data's length 2 bytes | ... data ...| checksum 4 bytes |

Command is to issue commans to target system such as start, stop,
acknowledge, error. Next is the size of raw data transmitted (i.e. not
containing header and checksum), followed by the checksum.

Please critisize such solution. Any advices and comments will be welcomed!

And the second half of question. Being not an expert in algorithms, I found
this straighforward solution: adding up the bytes and dropping the most
significant byte. I think it should suffice to my needs by now. Therefore I
reserve 4 bytes for future more reliable implementation (CRC32 or similar):

unsigned int checksum(unsigned char *data, size_t length)
{
size_t i;
unsigned int sum = 0U;

for (i = 0; i < length; i++) {
sum += (unsigned int)data[i];
sum &= 0x0000ffff;
}

return sum;

}

I realize this is not perfect at all and vulnerable to various errors, but
apart from this is that OK in terms style, coding etc.?

Thanks in advance!

With best regards, Roman Mashak. E-mail: m...@xxxxxxxx

What standard protocols have you eliminated and why?
e.g.
SFTP
BOOTP

ed
.



Relevant Pages

  • simple transport protocol
    ... transfer data from host computer to target (ARM7-based embedded system) over ... It should not be very reliable, so a simple checksum algorithm can be ... ended with a control check sum. ... Command is to issue commans to target system such as start, stop, ...
    (comp.programming)
  • Re: simple transport protocol
    ... I'm designing simple protocol for a bootloader, ... transfer data from host computer to target (ARM7-based embedded system) ... It should not be very reliable, so a simple checksum algorithm ... Command is to issue commans to target system such as start, stop, ...
    (comp.programming)
  • Re: simple transport protocol
    ... I'm designing simple protocol for a bootloader, ... transfer data from host computer to target (ARM7-based embedded system) ... Command is to issue commans to target system such as start, stop, ... failure (extra data provides detail). ...
    (comp.programming)
  • Re: Help! Raw Socket CheckSum
    ... > unsigned long sum; ... generate the check value required by that protocol. ... If you want to watch it work, put it in a single source code file with ... It is neither a C language nor a C coding ...
    (comp.lang.c)
  • Re: find combination of cells that equals a sum
    ... On Feb 1, 4:27 pm, Billy Rogers ... of cells with an amount in each cell and see if any combination of those ... Sum Xi - Target Value ...
    (microsoft.public.excel.programming)