circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

January 2006, Issue 186

Portable Web Server
Renesas M16C Design Contest 2005 Entry


PROTOCOL STACKS

The web site module’s protocol stacks consist of the usual industry-standard TCP/IP sockets, PPP, FTP, and HTTP servers. The stacks are based heavily on the TinyTCP package’s software framework.

At the application level, the framework consists of a minimalist callback structure, where the TCP/IP stack runs as a single foreground thread. This thread continuously calls a user-nominated polling callback function when it is idling and waiting for incoming data.

The server ports listening for HTTP and FTP requests are also initialized with callback functions. Any data packets received on these ports are passed up to the handler for further processing. 

The user-nominated polling callback function runs the background activities such as client-based TCP/IP socket processes, file transmission, and modem connection status monitoring. If the modem drops out, as indicated by the loss of the carrier detect signal, the web site module resets itself and attempts to reconnect to the ISP.

Currently, the HTTP and FTP servers are able to send only a single page or file at a time, because only a single active file descriptor is used. This can be extended in the future to a higher-capacity server by maintaining a larger list of active file descriptors.

At the link layer interface level, the TinyTCP distribution consists of an example serial line IP-based (SLIP) serial interface driver as well as an Ethernet card driver. The PPP interface was adapted into a PPP client because PPP is well supported by ISPs on their dial-up as well as ADSL links.

The PPP protocol is somewhat similar to SLIP in that it inserts escape code sequences into the serial stream to indicate packet boundaries. But it also checksums the packet data for errors and has flexible link control features. The flexibility of the link control negotiation works in favor of the lightweight embedded implementations of PPP. It’s possible to get the PPP client to reject most of the more advanced PPP features that the ISP attempts to negotiate during link initialization. This simplifies the PPP client implementation by requiring only the minimum number of link features required for establishing a PPP link.

The PPP client also intercepts Internet control message protocol (ICMP) echo requests (pings) and sends a response back to the originating party. The PPP client also generates a periodic keep-alive ping request to a nominated IP address, which is used to keep overzealous ISPs from dropping the call during periods of inactivity. The ping/pong sequence is shown in Photo 1.

(Click here to enlarge)

Photo 1—The M32C/84 evaluation board sits on top of the web site motherboard. The ICMP keep-alive ping response displays a “PONG” message. In no way does this refer to the quality of the modifications required to fix the RS-232 wiring.