The PicoWeb servers demonstration firmware supports a simple
kernel, a tiny debug monitor, a p-code interpreter, a network adapter
driver, a TCP/IP stack, and an HTTP server (i.e., web server). Lets
look at what kinds of network messages the PicoWeb server responds
to and what the responses are.
At the lowest level, the PicoWeb server responds to network ARP requests
identifying it as an active device on the network with an assigned
IP Address. Every PicoWeb server is assigned a unique Ethernet address
that is sent as part of the ARP reply packet.
Next, well look at the BOOTP request. An IP address can be
assigned to the device statically by storing the devices IP
address in the microcontrollers flash memory or dynamically
by using the BOOTP protocol. When configured for dynamic IP address
assignment, the PicoWeb server will begin sending periodic BOOTP requests
after powerup until an appropriate reply is received.
The PicoWeb servers unique Ethernet address is broadcast as
part of the BOOTP request packet. If a valid BOOTP response is received,
the PicoWeb server uses the contents of the response to set its IP
address. A Windows 95/98/NT version of a BOOTP server program is also
available. This program uses a text file that maps PicoWeb server
Ethernet addresses into assigned IP addresses.
The PicoWeb server also responds to ICMP echo, or ping, requests.
The server responds to ICMP echo requests by responding with an echo
reply. ICMP echo requests are typically generated by using a program
called ping on a remote host. The ping program enables users to quickly
test network connectivity with the PicoWeb server and evaluate the
round trip time (RTT) of the echo request/replies.
The PicoWeb server can send and receive UDP packets. However, the
breadboard prototypes demonstration firmware does not make use
of this capability.
At the TCP/IP level, the PicoWeb server responds to HTTP GET requests
that are addressed to its IP address. HTTP GET requests are sent by
web browsers such as Netscape Communicator or Microsofts Internet
Explorer. Our web server responds to these requests by sending back
HTML documents, text, images, and so on, just like a "real"
web server. The only difference is that we dont need a giant
OS with its attendant large memories, fancy TCP/IP stacks, expensive
microprocessors, and high power consumption to get the same results!
The demonstration firmware purposely restricts the maximum size of
an HTTP GET response to a single Ethernet packet (i.e., no more than
1400 bytes of TCP/IP payload) to conserve memory resources. In the
context of an embedded web server using this class of low-cost microcontroller,
this restriction is not an unreasonable tradeoff. A number of HTML
coding techniques can be used to work within these limits, including
the use of HTML frames and the "gluing together" of multiple
GIF and JPEG images using things like HTML tables.
The demonstration firmwares basic response to an HTTP GET request
is shown in Photo 2. The basic response is to return a web page that
shows a title, two radio buttons, an update button, and a few JPEG
images. The two radio buttons show the state of the LED on the demonstration
board.
The user can click the radio buttons to change the state of the LEDs
(i.e., to on or off) and then click the Set LED button to send the
new state information to the PicoWeb server. The server responds by
setting the LEDs according to the request and then updates the returned
web page to reflect the current state of the LEDs. Those of you familiar
with server-side web programming will recognize this as the typical
behavior of a cgi-bin script. The images shown on the sample web page
are also supplied by the PicoWeb server.
The PicoWeb server demonstration firmware contains a simple, extensible
debugger that provides for things like memory dumps, EEPROM alteration,
p-code and network tracing control, and more. Debugger commands such
as those in Table 2 can be entered via the serial port, or via the
network using a web browser and a URL that references a special TCP
port (i.e., port 911).
The format of a debugger command URL is http://IPaddress:911/command[[+parameter1]+parameter2]
Any results from executing a debug command will be returned as a
web page. For example, http://IPaddress:911/dm+60+80 will list
the contents of the first 128 bytes of the microcontrollers
SRAM. New debugger commands can easily be added (or deleted to save
program code space).
The PicoWeb servers prime function is to return web pages and
images in response to HTTP GET requests directed to URLs targeting
its HTTP server. The PicoWeb servers firmware responds to URL
queries directed to TCP port 80 in a conventional manner. Because
the PicoWeb server doesnt have a true file system, URLs trigger
dedicated routines in the firmware as opposed to simply returning
the contents of a disk file.
A summary of the standard URLs implemented in the PicoWeb servers
demonstration firmware are shown in Table 3 (note that the http://IPaddress
part of the URL does not appear in the table). Either http://IPaddress
or http://IPaddress/ii00.html will retrieve the default web
page (home page) from the PicoWeb server.