Re: simple transport protocol
- From: Ed Prochak <edprochak@xxxxxxxxx>
- Date: Tue, 27 May 2008 04:34:36 -0700 (PDT)
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
.
- Follow-Ups:
- Re: simple transport protocol
- From: Roman Mashak
- Re: simple transport protocol
- References:
- simple transport protocol
- From: Roman Mashak
- simple transport protocol
- Prev by Date: Re: The spinoza papers: design of the extra-precision number object 2
- Next by Date: Re: The spinoza papers: design of the extra-precision number object 2
- Previous by thread: Re: simple transport protocol
- Next by thread: Re: simple transport protocol
- Index(es):
Relevant Pages
|