embedded web server (EWS) & persistent HTTP 1.1 connection
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
embedded web server (EWS) & persistent HTTP 1.1 connection

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Mischa Oliver Altmann
Guest





Posted: Mon Dec 06, 2004 7:18 am    Post subject: embedded web server (EWS) & persistent HTTP 1.1 connection Reply with quote

Hello,

I'm trying to build a minimal embedded web server, EWS (possibly using PIC
and later slow ARMs) as a proof of concept allowing the remote monitoring
of various automated measurements. There seems to be a wide variety of
available (open source, commercial and hobby) systems on various platforms.
One thing I haven't found too often is the use of HTTP 1.1's "persistent
connections"[1] which could cut down the amount of admin work needed for
TCP/IP connections. While I realise that it might not be significant for
"big" cores, it is for minimal configurations such as micro-controllers
(eg. PICs).
Any ideas as to why that is? (maybe i should post this in TCP/IP news
groups instead?)

thanks,
Mischa

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html

P.S.: Sorry, JB, I only thought of using newsgroups after I wrote you the
email.

--
Mischa Oliver Altmann

http://www.altmann.at/~mischa (in terrible state)
Back to top
Richard H.
Guest





Posted: Mon Dec 06, 2004 9:43 am    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

Mischa Oliver Altmann wrote:
Quote:
One thing I haven't found too often is the use
of HTTP 1.1's "persistent connections"...
[...]
Any ideas as to why that is?

A few reasons you might not find it widely implemented:

1) It's optional, requires lots more resources, and benefit isn't
obvious to the user. Embedded systems operate on tight resources, and
optional features (and many non-essential "required" features) are
omitted to conserve resources.

2) A common application is an admin page, which is often a dynamic HTML
page with static (cache-able) graphics, so only the single HTML object
is being fetched in many cases. (i.e., a persistent connection would
not be of benefit.)

3) TCBs = RAM, which is usually precious with embedded systems,
especially when each TCB easily requires 512+ bytes. Many have
resources for only 1-2 connections at once, so making them last for
seconds instead of milliseconds can have a huge impact on memory
requirements. (IIRC, persistent connections are often 10+ seconds,
though I exect this is tunable.)


Practically, it would seem straightforward to implement: jump back to
the TCB input handler instead of closing the session; timeout idle
connections after X msecs. (Probably can't be <1000ms, and may need to
be 2000ms for compatibility with slow connections.)

However, with the same amount of RAM you could possibly handle 50x more
requests in this same 1000ms window if each connection were terminated
and re-established instead of persistent. (Local connections could
easily service in <20msecs.)

So, persistent connections may save some CPU, and may reduce Internet
traffic with embedded applications, but at the expense of much more RAM
in the device, which translates to cost.


I expect you've got an application where persistent connections could be
beneficial - might I ask what that is? Perhaps an application where
many dynamic objects would be downloading in each page (i.e., seldom
cached in the browser)?

Cheers,
Richard
Back to top
Wolfgang Mües
Guest





Posted: Tue Dec 07, 2004 12:41 am    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

Hello Mischa,

you wrote:
Quote:
I'm trying to build a minimal embedded web server, EWS (possibly using PIC
and later slow ARMs) as a proof of concept allowing the remote monitoring
of various automated measurements.

Have you checked
http://www.sics.se/~adam/uip/

best regards
Wolfgang Muees
Back to top
Mischa Oliver Altmann
Guest





Posted: Tue Dec 07, 2004 5:55 am    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

On Sun, 05 Dec 2004 21:43:47 -0700, Richard H. <rh86@no.spam> wrote:

Quote:
Mischa Oliver Altmann wrote:
One thing I haven't found too often is the use
of HTTP 1.1's "persistent connections"...
[...]
Any ideas as to why that is?

A few reasons you might not find it widely implemented:

1) It's optional, requires lots more resources, and benefit isn't
obvious to the user. Embedded systems operate on tight resources, and
optional features (and many non-essential "required" features) are
omitted to conserve resources.
hm, interesting thought. I assumed that using persistent connections would

make TCP/IP stack coding easier as less connections have to be built up
and closed down.

Quote:
2) A common application is an admin page, which is often a dynamic HTML
page with static (cache-able) graphics, so only the single HTML object
is being fetched in many cases. (i.e., a persistent connection would
not be of benefit.)
you definately have a point here. For my purposes it would not be needed

(I am only doing a proof of concept EWS) but i thought it would be a
useful "exercise".

Quote:

3) TCBs = RAM, which is usually precious with embedded systems,
especially when each TCB easily requires 512+ bytes. Many have
resources for only 1-2 connections at once, so making them last for
seconds instead of milliseconds can have a huge impact on memory
requirements. (IIRC, persistent connections are often 10+ seconds,
though I exect this is tunable.)
agreed -- see 2)


[snip]
Quote:
So, persistent connections may save some CPU, and may reduce Internet
traffic with embedded applications, but at the expense of much more RAM
in the device, which translates to cost.

I expect you've got an application where persistent connections could be
beneficial - might I ask what that is? Perhaps an application where
many dynamic objects would be downloading in each page (i.e., seldom
cached in the browser)?
see 2)


thanks for your indepth explanation - it's very much appreciated.

Quote:
Cheers,
I'm in Leeds, are you nearby ;-) or on the other side of the globe?


thanks,
Mischa

--
Mischa Oliver Altmann

http://www.altmann.at/~mischa (in terrible state)
Back to top
Richard H.
Guest





Posted: Tue Dec 07, 2004 7:46 am    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

Mischa Oliver Altmann wrote:
Quote:
I assumed that using persistent connections would
make TCP/IP stack coding easier as less connections
have to be built up and closed down.

The quantity might be lower, but the TCP behavior would necessarily work
identically. Probably a touch more code to detect / activate / timeout
persistence for HTTP.


Quote:
(I am only doing a proof of concept EWS) but i
thought it would be a useful "exercise".

Exercises are always good if you have the time - practicality need not
apply. :-)


Quote:
thanks for your indepth explanation - it's very
much appreciated.

Happy to!


Quote:
I'm in Leeds, are you nearby ;-) or on the other
side of the globe?

In the Arizona desert, USA (which this week is cold and rainy).

Though I remember visiting Leeds many years back - enjoyed the castle
enough that we missed the last train back to London. :-)

Have fun!
Richard
Back to top
Richard H.
Guest





Posted: Tue Dec 07, 2004 8:40 am    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

Also...

I highly recommend Jeremy Bentham's book, TCP/IP Lean. It's the best
text so far about implementing TCP on a microcontroller. And the
example is based on a PIC.

http://www.amazon.com/exec/obidos/ASIN/157820108X/860710993-20

Even if you aren't interested in the included code, he's got some clever
techniques for dynamic HTML objects like slide bar graphics, and another
for handling the TCP checksum with HTML. Well worth the money as a
backgrounder to the issues and some ideas for handling them.

Enjoy!
Back to top
Mischa Oliver Altmann
Guest





Posted: Tue Dec 07, 2004 11:34 pm    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

Quote:
I highly recommend Jeremy Bentham's book, TCP/IP Lean. It's the best
text so far about implementing TCP on a microcontroller. And the
example is based on a PIC.

http://www.amazon.com/exec/obidos/ASIN/157820108X/860710993-20

hehe -- that's exactly where I was coming from! It doesn't even mention

persistent connections and I was wondering why. It's pretty clear to me
now, but I might just write the code to show it's possible.

thanks again,
Mischa

P.S.: I am not aware of a castle in Leeds (though there are some ruins of
monasteries/churches). You might mean Richmond which isn't "that" far form
Leeds and also in the "north".

--
Mischa Oliver Altmann

http://www.altmann.at/~mischa (in terrible state)
Back to top
Richard H.
Guest





Posted: Wed Dec 08, 2004 7:42 am    Post subject: Re: embedded web server (EWS) & persistent HTTP 1.1 connect Reply with quote

Mischa Oliver Altmann wrote:
Quote:
hehe -- that's exactly where I was coming from! It
doesn't even mention persistent connections and I
was wondering why. It's pretty clear to me now, but
I might just write the code to show it's possible.

Aha!

I've been thinking about a different technique than his for the checksum
handling. It makes more sense to write a null checksum, then go back
and update the NIC buffer with the right checksum value. And it works
for protocols other than HTTP.

I suspect the technique of guessing a checksum value & stuffing bytes at
the end to make it right was all due to the original implementation that
was SLIP-based, not Ethernet-based, and there was no buffer to go back
and update - it'd already been serialized out the port. Very clever,
considering the resources, but unnecessary using Ethernet NIC buffers, I
think.


Quote:
P.S.: I am not aware of a castle in Leeds (though
there are some ruins of monasteries/churches). You
might mean Richmond which isn't "that" far form
Leeds and also in the "north".

What? They moved it?! ;-)

Probably a bad assumption on my part that Leeds Castle was in Leeds. :-)

Cheers,
Richard
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB