WEB Server


Internet Protocol Suite

The implementation for TCP/IP uses uIP*1 as a TCP/IP Stack.


uIP is an open source TCP/IP Stack developed by Adam Dunkels of the Networked Embedded Systems group at the Swedish Institute of Computer Science . The IP is free for both commercial and non-commercial use. uIP is written in C language and very small code size, very low RAM usage TCP/IP Stack. It also Includes a set of example applications: web server, web client, Telnet server,etc.

uIP contains in the following directories.

TCP/IP Stack source code is in uip directory, and WEB Server example application is in app/webserver directory respectively. These two directories are used to implement TCP/IP Stack and WEB Server.

uIP Configuration

To fit uIP to the target system, configuration setting and timer implementation is required.

Configuration File Setting

Most configuration parameters to be modified is in the file “uip-conf.h”. The main modification points are data types and array size. The array size decides the packet’s buffer size and it also affects MSS (Maximum Segment Size).

Timer Implementation

The timer is used to change the TCP/IP connection state from TIME_WAIT to CLOSED, and for re-transmit timing of the packet to be sending. In this implementation, 32bits timer unit in SH-4A (TMU2) is used for the timer function. In the following configuration, TMU2 generates an under-flow timer interrupt every 1 second.



uIP Porting to the Target System

An Ethernet Frame is received, uIP starts data processing. The first step is to check the type field in the Frame, then the process is branched depending on the type value.If the Frame is ARP packet, uip_arp_arpin() is called to prepare ARP response packet. The ARP response packet is set the target embedded system’s MAC address as a source address. The ARP packet is transmitted by calling ether_write_frame().

If the Frame is IP packet, the data is processed in the following way.

  1. uip_arp_ipin() is called to update internal ARP table. This update confirms that a pair of source IP address and MAC address in current table has same value in the IP packet.
  2. uip_input() is called to start TCP packet processing. Depending on current TCP state, event flag is checked and then UIP_APP_CALL() is called. WEB Server application is handled in UIP_APP_CALL().
  3. After calling UIP_APP_CALL(), if there is an IP packet for transmission, uip_arp_out() is called to generate Ethernet Header data.
  4. ether_write_frame() is called to transmit Ethernet Frame.

uIP Processing Flow Chart

Actual coding is below. In the source code, uip_len and uip_buf are global variables defined in uIP. The variables are used for sharing data between uIP(TCP/IP) and Ethernet. uip_buf stores transmission/reception packet and uip_len stores effective data length in uip_buf.
(SH4 interrupt handler INTR IRQ2)