Contiki Web Server - bugs, observations and questions...

Open forum for discussion on the Contiki Operating System for the Apple II series of computers.

Moderators: support, oliver

Contiki Web Server - bugs, observations and questions...

Postby luddite » Tue Feb 19, 2008 6:26 pm

This seems like the best place to bring these up:
    Server is looking for "404.html" which is clearly not viable in ProDOS. I think the 1.3 version used "A404.html"
    HTML tags and attributes have to be in uppercase, attribute values and URLs in lowercase (I'm not certain if that's a browser-specific issue)
    Absolute URL paths work better than relative ones.
The HTML case-sensitivity is probably not a big deal, but it would be nice to have 404 properly supported.

Overall the 2.0 version seems much more stable than 1.3... mines been running continuously for about 48 hours with some pretty heavy traffic in the last 24. With 1.3 the best run I got was about 3 hours.

A few questions:
    How does Contiki handle multiple simultaneous connections? Does it serve small chunks of files to all requests or does it cue the requests and serve complete files?
    Are there any adjustable parameters other than the config file?
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Postby support » Tue Feb 19, 2008 10:09 pm

I might not have this 100% but I hope Oliver will drop by to correct anything I have said in error.

How does Contiki handle multiple simultaneous connections?


It can be configured to support multiple simultaneous connections (subject to memory constraints of course). Current config values set at compile time are

//#define UIP_CONF_BUFFER_SIZE 1500
#define UIP_CONF_BUFFER_SIZE 500

This first one might explain the odd behavior of some browsers. Iam going to increase that back to 1500 and send you a new binary.

#define UIP_CONF_TCP_SPLIT 1
#define UIP_CONF_UDP_CHECKSUMS 1
#define UIP_CONF_LOGGING 1

Turning off logging saves some memory, although Oliver recommends that the logging be turned on - if that is turned off, I think the memory can be used for more connections.

#define WEBSERVER_CONF_CGI_CONNS UIP_CONNS
#define WEBSERVER_CONF_CFS_CONNS 3

Sets the number of web connections and the number of disk accesses ... I think - I haven't examined the code yet so thats a guess (I will edit this post if I am wrong).


Does it serve small chunks of files to all requests or does it cue the requests and serve complete files?


From Contiki readme - "Contiki processes use light-weight protothreads that provide a linear, thread-like programming style on top of the event-driven kernel."

Contiki will handle the requests as they come in .. I don't think there is any queuing .... Once a file is open for sending all the data is sent for that file
(under the covers there be more happening)

Are there any adjustable parameters other than the config file?


Not that I am aware of
support
Site Admin
 
Posts: 169
Joined: Tue Mar 08, 2005 10:49 pm
Location: Ajax, On, Canada

Postby luddite » Wed Feb 20, 2008 12:20 am

support wrote://#define UIP_CONF_BUFFER_SIZE 1500
#define UIP_CONF_BUFFER_SIZE 500

This first one might explain the odd behavior of some browsers. Iam going to increase that back to 1500 and send you a new binary.


That would be awesome... thanks!
And thanks for taking the time to explain things. I wonder if it's possible to have the log write to a file... I suspect it may be of more value to someone who knows how to interpret it. FWIW the most common error I'm seeing now is
"IP.IP.IP.IP: reset (no memory block)"
Though I'm not watching the screen 24/7, so it might not be that common in reality.
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Postby support » Wed Feb 20, 2008 12:45 am

I sent you the new disk image - let me know when you have it updated so I can test it out.
support
Site Admin
 
Posts: 169
Joined: Tue Mar 08, 2005 10:49 pm
Location: Ajax, On, Canada

Postby luddite » Wed Feb 20, 2008 1:30 am

support wrote:I sent you the new disk image - let me know when you have it updated so I can test it out.


Updated as of now... I've tested with all browsers I have available and performance is dramatically improved... Thanks!
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Postby oliver » Wed Feb 20, 2008 1:19 pm

Hi,

First of all let me express how happy I'm to see Contiki 2 in action :-)

Here are some information on the webserver you might be interested in:

- The '404.html' issue is a bug and therefore I'll change the name to something ProDOS 8 compatible.

- The webserver doesn't interpret the content of the files it serves at all. There's just no code to do so. Therefore I can't see how the case of html / css tags could influence its behaviour.

- The webserver isn't well optimized for ProDOS 8. It presumes file streams, not random access files. This presumption is always true for the C64 and unfortunately in fact currently true for the A2 as well. I just didn't implement lseek() in the cc65 C-library for ProDOS 8. As a result the webserver implements a doublebuffering of data to be sent in order to be able to resend it on errors (->TCP). These buffers limit the number of concurrent connections (currently to 3). The message "reset (no memory block)" just means that you hit that limit. Unfortunately beside that memory ProDOS 8 needs 1k memory for every open file. Basically ProDOS 8 is quite expensive on open files (with regards to memory) but feature-rich. But both the C-library and the webserver ignore that feature and the webserver workarounds it using even more memory.

- The webserver does a quite naive connection handling. If there's no free buffer available it just aborts the connection. A full grown TCP/IP stack internally supports a backlog of connections. This is a queue of connections acknowlegded but not yet served.

So you see there are PLENTY of opportunities to optimize the webserver:

- Implement lseek() and avoid doublebuffering
- Implement a custom allocator for the 1k ProDOS buffers
- Implement a builtin 404 page not using an open file
- Implement a connection queue
- Implement a builtin "busy" page sent on queue overflow and/or queue timeout instead of just aborting the connection

With these changes it should be easy to push the 3 concurrent open connections on the A2 to the ProDOS 8 limit of open files of 8. All within 64k, with maximum MTU, with logging, with splitting.

Best, Oliver
oliver
 
Posts: 30
Joined: Wed Mar 09, 2005 6:36 am
Location: Germany

Postby luddite » Wed Feb 20, 2008 4:54 pm

oliver wrote:- The webserver doesn't interpret the content of the files it serves at all. There's just no code to do so. Therefore I can't see how the case of html / css tags could influence its behaviour.


I'll have to try a few more test pages... I noticed that some browsers are more tolerant than others of dodgy html, so it very likely has nothing to do with the server.
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Postby luddite » Wed Feb 20, 2008 4:56 pm

oliver wrote:...
With these changes it should be easy to push the 3 concurrent open connections on the A2 to the ProDOS 8 limit of open files of 8. All within 64k, with maximum MTU, with logging, with splitting.

That would be quite impressive...
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Postby oliver » Thu Feb 21, 2008 4:33 am

Hi,

- '404.html' is now called 'notfound.html'.

- I've never tried but theoretically it should be possible to place files in a ProDOS subdirectory and use the "usual" /dir/file pathname syntax to request the files via http. However the whole pathname mustn't be longer than 19 characters.

Best, Oliver
oliver
 
Posts: 30
Joined: Wed Mar 09, 2005 6:36 am
Location: Germany

Postby luddite » Thu Feb 21, 2008 12:30 pm

oliver wrote:- I've never tried but theoretically it should be possible to place files in a ProDOS subdirectory and use the "usual" /dir/file pathname syntax to request the files via http. However the whole pathname mustn't be longer than 19 characters.

I did try that initially and it worked fine.
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Postby oliver » Fri Feb 22, 2008 4:37 am

luddite wrote:I did try that initially and it worked fine.

Thanks for the - positive - feedback :-)

Best, Oliver
oliver
 
Posts: 30
Joined: Wed Mar 09, 2005 6:36 am
Location: Germany

Postby oliver » Sat Feb 23, 2008 6:58 am

Hi,

Yet another thing probably worth trying:

In general ProDOS 8 allows to open every file only once. So if the same file gets requested twice simultaniously the second requester is expected to get a 404 because the webserver naively presumes that an open call only fails because the file doesn't exist.

However 'Beneath Apple ProDOS' states on page 6-41 that a single file may successfully opened several times if the file is a read-only file. The easiest way to assert that is to LOCK the file.

So it would be interesting to check if both expected behaviours can be in fact experienced. In that case it would obviously be advisable to LOCK all files to be served...

Best, Oliver
oliver
 
Posts: 30
Joined: Wed Mar 09, 2005 6:36 am
Location: Germany

Postby luddite » Thu Feb 28, 2008 1:22 pm

oliver wrote:So it would be interesting to check if both expected behaviours can be in fact experienced. In that case it would obviously be advisable to LOCK all files to be served...


I'll try that on the weekend... haven't had much free time this week.

I did have to reboot the server last night as every request was resulting in
"TCP: Bad Checksum" and "No Memory Block" errors... that's after about 7 or 8 days uptime. I had the same thing happen with the first version Glenn sent me, but it was much more frequent (about 3-4 hours uptime). Presumably if locking the files works as you expect, it might help in that regard.

8 days running flat out isn't too bad, I'd say!
luddite
 
Posts: 23
Joined: Wed Feb 13, 2008 10:44 pm
Location: Daysland AB Canada

Image for Contiki 2 : Web server?

Postby quag7 » Wed Apr 02, 2008 3:05 am

Is there a publicly accessible image of the web server being discussed here? Some months ago I inquired as to whether or not it was possible to serve pages, and with 1.3, it was not, but it sounds like it is possible now with 2, and this continues to interest me greatly.

Any pointers or further information would be appreciated. Thanks to those continuing to work on this! The server functionality of Contiki is by far what interests me the most.
quag7
 
Posts: 3
Joined: Tue Oct 16, 2007 2:53 pm

Contiki Web Server binary

Postby support » Fri Apr 04, 2008 2:52 pm

Hi there is not a publicly accessible image available yet but I can send you one privately. Just send me a private message or an email.

I am working with Oliver to get a binary distribution setup that will have the configuration info written to the image for each person that downloads it.

Glenn
support
Site Admin
 
Posts: 169
Joined: Tue Mar 08, 2005 10:49 pm
Location: Ajax, On, Canada


Return to Contiki

Who is online

Users browsing this forum: No registered users and 1 guest

cron