[NTLUG:Discuss] What is the best method to communicate between a device and a server?

Steve Baker steve at sjbaker.org
Fri Apr 4 16:56:26 CDT 2008


With little embedded devices, one good option is to lay as much of the 
work onto the server as possible.  I would be nervous about FTP because 
it's not very secure - but SCP would be a viable alternative.

You could have your gizmo's upload their data as simple files containing 
(along with whatever data they need to send), the time on their local 
clock when they sent the data - then download from the server a file 
containing a shell script to execute.  That's all you need.   Even clock 
correction can be easily handled.  The server can (at it's leisure) 
compare the time contained in the message the gizmo sent with the 
locally-generated time-stamp when the file arrived and determine by how 
much that gizmo's clock is off.  In next day's message it can send a 
command to adjust the gizmo's clock.  If it drifts by a second a month, 
that'll be enough to stop the clock from drifting by much.

For software updates - the server simply sends the gizmo a shell script 
that tells it to grab the new software release - verify some kind of 
checksum - and then execute it.

I wouldn't bother with load balancing the server - the amount of traffic 
from (say) 10,000 devices reporting in once a day isn't much for even a 
sinple PC server with a low-speed connection to the net.  Over 24 hours 
(86,400 seconds), 10,000 gizmo's would have 8.6 seconds of server time 
each - but the trivially simple transaction shouldn't consume even close 
to one second.  I honestly would keep it simple - until you're looking 
at (say) 100,000 client machines.


Kipton Moravec wrote:
> I am designing a device or appliance (it does not matter what) that
> needs to report results to a server, over the Internet and get new
> instructions once a day or whenever it powers up. (Or had a power
> failure). There could be thousands of these devices.
>
> I have to assume the device will be behind a firewall so the device will
> have to contact the Linux server and the server will not be able to
> initiate the communications to the device.
>
> The device will send a progress report each day, reporting a few
> statistics (probably 100 - 200 bytes). The only other time it will
> report is when things go wrong.
>
> When it checks in, it will look for any new commands for itself,
> including software updates. A command may be to provide additional data,
> or a recommendation to check in at a specific time (for load balancing
> on the server). It may be required to download a new program revision,
> and reprogram itself.
>
> I do need to keep track of time, so I am thinking of implementing NTP
> also. It will have its own clock that is good to a couple of seconds per
> month.
>
> What application protocols are best for something like this?
>
> I can see using FTP to upload and download files with the data.
>
> I can see using SMTP and a POP server (email) for sending and receiving
> messages.
>
> Some have suggested SNMP which I am not familiar with.
>
> Another way is to open a socket to socket custom connection.
>
> Someone suggested opening up a secure telnet connection.
>
> I am sure there are more ways to do this. But what I do not know is what
> is the best way to do this. I want something that is robust, and easy.
> (KISS) And preferably small. 
>
> It is hard to predict what will be required in the future so flexibility
> is good for both sides, the device and the server.
>
> Any suggestions? And more importantly why one way would be better than
> another?
>
> Kip
>   




More information about the Discuss mailing list