Re: Suggestions for custom application-layer protocol?

From: Glyn Davies (gryn_at_riffraff.plig.net)
Date: 05/26/05


Date: Thu, 26 May 2005 08:09:15 +0000 (UTC)

In comp.os.linux.embedded Mark <mark_2811nospam@excite.com> wrote:
> I need to implement a simple application layer protocol that will be used to
> communicate between an embedded device (single-board computer running Linux)
> and a monitoring terminal (running Windows). There isn't alot of data being
> passed around, mostly status information collected by the embedded device,
> and control messages from the monitoring terminal. Messages will consist of
> between 1 and 10 fields of data.

> I want the protocol to be text based rather than binary since the data
> throughput is low. I also want the protocol to be based on TCP/IP. Does
> anyone here have any suggestions on the design of a simple protocol? Are
> there simple, standard ways of formatting text messages to be sent over a
> TCP socket (such as comma-separated)? I would prefer to avoid the
> complexities of XML. Since either the embedded device or the monitoring
> terminal can initiate a message, is it preferable to have TCP servers
> running on both sides? Or is it better to simply leave a TCP connection
> open between client and server? Any suggestions on ultra-simple standard
> protocols that do something similar to this?

> Any suggestions or pointers to further reading are much appreciated.

> Thanks,
> Mark

Hi Mark,

You seem to be implying that you have a network connection to your SBC,
but don't confirm it!

For simplicity of implementation, I'd recommend implementing a message
layer over the TCP socket - something as simple as a two byte binary header
to indicate the length of the message to follow.

This means you can then read a whole message - text based or otherwise,
and the process it accordingly. You don't need to mess about with parsing
lines and stuff like that. It drops out to:

 1. Read Header:
 2. Read Data:
 3 Process Request
Repeat (ad infinitum)

I'd suggest just running the server on the SBC. Its always possible you
might need to run multiple monitoring terminals in other places, and there
is no need for the SBC to connect to the monitoring terminal if the software
for the monitoring is not running (by the sound of it)

After that, the format of your payload could be a simple text header indicating the
message type with the specific format of data to follow. CSV for the data for example

Hope this helps,

Glyn

-- 
------------------------------------------------------------------------
Glyn Davies / gryn@plig.net / www.technobobbins.com / Insert quote here?
------------------------------------------------------------------------


Relevant Pages