embedded webserver-1

234
EMBEDDED WEB SERVER ABSTRACT As we know the home pages or web pages are created by means of HTML code. But first time by using our RABBIT 3000 processor & coding on it, we are get the home pages. So by using our RABBIT 3000 processor we are designing a project called “Embedded Web Server”. Rabbit 3000 processor has a protocol converter that transmits the data sent by serial equipment as TCP/IP data to the network. It also supports UDP Protocol for Broadcast kind of application. As we are accessing the Internet in our daily life, so in that the main problem occurring is speed of accessing i.e., many peoples are accessing the same web site at same time so the heavy burden will occur for main server. So instead of this problem we are developing a kit, which shares the risk of main server by means of duping the home page code in to our Rabbit 3000 microprocessor & connecting it to our main server. Then, the accessing time for people will access well when compared to previous one. 1

Upload: kramsunil

Post on 15-Nov-2014

159 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Embedded Webserver-1

EMBEDDED WEB SERVER

ABSTRACT

As we know the home pages or web pages are created by means of

HTML code. But first time by using our RABBIT 3000 processor & coding on it, we are

get the home pages. So by using our RABBIT 3000 processor we are designing a project

called “Embedded Web Server”.

Rabbit 3000 processor has a protocol converter that transmits the data

sent by serial equipment as TCP/IP data to the network. It also supports UDP Protocol for

Broadcast kind of application. As we are accessing the Internet in our daily life, so in that

the main problem occurring is speed of accessing i.e., many peoples are accessing the

same web site at same time so the heavy burden will occur for main server. So instead of

this problem we are developing a kit, which shares the risk of main server by means of

duping the home page code in to our Rabbit 3000 microprocessor & connecting it to our

main server. Then, the accessing time for people will access well when compared to

previous one.

Web Server is a device, which hosts static or dynamic web pages. In

this project static web pages will be hosted on an embedded controller. We are going to

use an Ethernet controller that is interfaced to our main controller for communicating

over Internet. Our Server opens the http port and waits in the listening mode. Whenever a

request comes from any node in the network it serves the static html page stored in its

memory. First we will initialize the TCP/IP stack and then the http server at the

application layer.

1

Page 2: Embedded Webserver-1

EMBEDDED WEB SERVER

DESCRIPTION ABOUT PROJECT

With the wide spread availability of web browsers on virtually every

conceivable hardware platform, offering web based access to an application or device is

becoming a common requirement. Although there are several available web server

implementations, most standard web servers are just too large or inconvenient to use.

Embedding a web server into a device or a stand-alone application requires a light-weight

and low overhead Implementation. Embedded Web Server provides a solution to this

problem.

In this project static web pages will be hosted on an Rabbit Processor based

embedded module, this module will be having a Ethernet interface through which it can

be connected to internet. The software inside the module will have TCP / IP stack which

is used for establishing communication with other systems in the internet. This

Embedded module is designed with Rabbit 3000 processor to which memory chips and

Ethernet controllers are interfaced.

The Transmission Control Protocol / Internet Protocol (TCP / IP) protocol

suite is the engine for internet and networks world wide. Its simplicity and power has lead

to its becoming the single network protocol of choice in the world to day.

This project provides you with the tools to incorporate a low overhead web

server into your application or device. Using this framework offered you can provide

secure and efficient access to both static and dynamically generated content.

2

Page 3: Embedded Webserver-1

EMBEDDED WEB SERVER

The basic series of operations that our application must perform is:

I. Receive and interpret an HTTP request received from a browser client.

II. Process the request and return the required response via HTTP.

This Project explores the capabilities of the Rabbit Processor and its

features and specifications. It also gives the brief over view of the the TCP / IP protocol

and the networking concepts.

3

Page 4: Embedded Webserver-1

EMBEDDED WEB SERVER

Application layer

Network layer

Transport layer

Host to network layer

Host to network layer

Network layer

Transport layer

Application layer

NETWORK THEORY

TCP / IP PROTOCOL STACK:

The TCP/IP protocol suite was developed prior to OSI reference

model. The TCP/IP protocol suite consists of 4 layers: host to network, network, transport

and application layers. The first three layers provide physical standards, network

interface, internetworking and transport functions.

4

Page 5: Embedded Webserver-1

EMBEDDED WEB SERVER

HOST –A HOST-B

BLOCK DIAGRAM OF THE TCP /IP REFERENCE MODEL.

LAYERS IN THE TCP / IP REFERENCE PROTOCAL

Application Layer:

The application layer is the layer that most common network-aware

programs work in order to communicate across a network. Communication that occurs in

this layer are application specific and data is passed from the program, in the format used

internally by this application, and is encapsulated into a transport layer protocol.

Since the IP stack has no layers between the application and transport

layers, the application layer in the IP suite include any protocols that act like the OSI’s

presentation and session layer protocols. The actual data sent over the network is passed

into the application layer where it is encapsulated into the application layer protocol.

From there, the data is passed down into the lower layer protocol in the transport layer

5

Page 6: Embedded Webserver-1

EMBEDDED WEB SERVER

The two most common lower layer protocols are TCP and

UDP.Both of which require a port in order to use their service and most

well-used applications have specific ports assigned to them (HTTP has port 80; FTP has

port 21; etc.)for servers while clients use ephemeral ports. Routers do not utilize this

layer.

Transport layer:

The transport layer is the layer between the application and the network

protocol (i.e., IP) and primarily provides the service of connecting applications together

through the use of ports. Since IP provides only a best effort delivery; the transport layer

is the first layer to address reliability.

For example, TCP is a connection-oriented protocol that addresses numerous reliability

issues to provide a reliable byte stream:

Data arrives in-order

Data is has minimal error-correctness

Duplicate data is discarded

Lost / discarded packets are resent

Includes traffic congestion control

The second protocol used in the transport layer is the User Datagram Protocol.

UDP is a connectionless datagram protocol. Like IP, it is a best effort or “unreliable”

protocol.UDP is typically used for applications such as streaming media (audio and

video, etc) where on-time arrival is more important than reliability or the overhead of

setting up a reliable connection is disproportionately large. Both TCP and UDP are used

6

Page 7: Embedded Webserver-1

EMBEDDED WEB SERVER

to carry a number of higher-level applications. The applications at any

given network address are distinguished by their TCP or UDP c port.

Network layer:

The network layer solves the problem of getting packets across a single

network. With the advent of the concept of internetworking, additional functionally was

added to this layer, namely getting data from the source network to the destination

network. This generally involves routing the packet across a network of networks,

knowns an internet. In the internet protocol suite, IP performs the basic task of getting

packets of data from source to destination.IP can carry data for a number of different

upper layers protocols; these protocols are each identified by a unique protocol number:

ICMP and IGMP are protocols 1 and 2, respectively. Some of the protocols carried

by IP, such as ICMP (used to transmit diagnostic information about IP transmission) and

IGMP (used to manage multicast data) are layered on top of IP but perform internet work

layer functions.

Host to network layer:

The Host-to-Network layer interfaces the TCP / IP protocol stack to the

physical network. The TCP /IP reference model does not specify in any great detail the

operation of this layer, expect that the host has to connect to the network using some

protocol so it can send IP packets over it. It do the same work as the Data link layer and

the physical layer in the open systems inter-connection model.

ETHERNET:

7

Page 8: Embedded Webserver-1

EMBEDDED WEB SERVER

Ethernet is the most widely used LAN protocol. This

protocol was designed in 1973 by Xerox with a data rate of 10 Mbps and a

bus topology. Today it has a data rate of 100 Mbps and 1 Gbps. Ethernet is formally

defined by the IEEE 802.3 standard.

TRADITIONAL ETHERNET:

The original Ethernet, usually referred to as traditional Ethernet, had a

10-Mbps data rate. But there are other Ethernets with different data rates.

ACCESS METHOD (CSMA / CD):

The IEEE 802.3 standard defines carrier sense multiple access with

collision detection (CSMA / CD) as the access method for traditional Ethernet. Stations

on a traditional ethernet can be connected together using a physical bus or star topology,

but the logical topology is always a bus. By this, we mean that the medium is shared

between stations and only one station at a time can use it. It also implies that all stations

receive a frame sent by a station (broadcasting).The real destination keeps the frame

while the rest drop it. In this situation, how can we be sure that the stations are not using

the medium at the same times? If they do, their frames will collide with each other.

CSMA / CD is designed to solve the problem according to the following principles:

1. Every station has an equal right to the medium (multiple access).

2. Every station with a frame to send first listens to the medium. If there is no data

on the medium, the station can start sending (carrier sense).

3. It may happen that two stations sense the medium, find it idle and start sending. In

this case, a collision occurs. The protocol forces the station to continue to listen to

the line after sending has begun. If there is a collision, all station sense the

8

Page 9: Embedded Webserver-1

EMBEDDED WEB SERVER

collision; each sending station sends a jam signal to destroy the

data on the line and after each waits a deferent random time, try

gain. The random times prevent the simultaneous re-sending of data

In traditional ethernet, the minimum frame length is 520 bits, the transmission rate

is 10Mbps, propagation speed is almost the speed of light and the collision domain is

almost 2500 meters.

The traditional 10 Mbps Ethernet has 2 layers. The data link layer has two sub-

layers: the logical ink control (LLC) sub layer and the medium access control (MAC) sub

layer. The LLC layer is responsible for flow and error control and the data-link layer. The

MAC sub layer is responsible for the operation of the CSMA / CD access method. The

MAC sub layer also frames data received from the LLC layer and passes the frames to

the physical layer for encoding. The physical layer transfers data into electrical signals

and sends them to the next station via the transmission medium. This bottom layer also

detects and reports collisions to the data link layer.

ETHERNET FRAME:

IEEE 802.3 specifies one frame type containing seven fields: Preamble,

SFD, DA, SA, length /type of PDU, 802.2 frames, and the CRC. Ethernet does not

provide any mechanism for acknowledging received frames, making it what is known as

an unreliable medium. Acknowledgements must be implemented at the higher layers.

This format of the CSMA/CD MAC frame is shown below

9

Page 10: Embedded Webserver-1

EMBEDDED WEB SERVER

D E 7 bytes 1 bytes 6 bytes 6 bytes 2 bytes 4 bytes

Preamble:

The preamble of 802.3 contains 7 bytes (56 bits) of alternating 0s and 1s

and that alerts the receiving system to the coming frame and enables it to synchronize its

input timing. The preamble is actually added at the physical layer and is not (formally)

part of the frame.

Start frame delimiter (SFD):

The SFD field (1 byte 10101011) of the 802.3 frame signals the

beginning of the frame. The SFD gives the station a last chance for synchronization.

The last two bits are 11 and are signal that the next field is the destination address.

Destination address (DA):

The DA field is 6 bytes and contains the physical address of the

intermediate or destination station.

Source address (SA):

The SA field is also 6 bytes and contains the physical address of the

sending or intermediate station.

Length type:

The length type field has one of two meanings. If the value of the field is

less than 1518, it is a length field defines the length of the data field that follows. If the

10

PREAMBLE SFD DEST ADD

SOURCEADD

LENGTH DATA andPADDING

CRC

Page 11: Embedded Webserver-1

EMBEDDED WEB SERVER

value of the field is greater than 1536, if defines the upper layer protocol

that uses the service of the Internet.

Data:

The data field carries data encapsulated from the upper layer protocols.

It is a minimum of 46 and a maximum of 1500 bytes.

Crc:

The last field in the 802.3 frame contains the error detection information. It

tells whether the transmitted data is error free or not.

IMPLEMENTATIONS:

The IEEE standard defines several implementations for IEEE

standards. The following are the common

10BASE5 (thick ethernet) uses a bus topology with a thick coaxial cable as a

transmission medium.

10BASE2 (thin ethernet or cheaper net) uses a bus topology with a thin coaxial

cable as transmission medium.

10BASE-T (twisted pair Ethernet) uses a physical star topology with stations

connected by two pairs of twisted-pair cable to the hub.

10BASE-FL (fiber link Ethernet) uses a star topology with stations connected

by a pair of fiber-optic cables to the hub.

11

Page 12: Embedded Webserver-1

EMBEDDED WEB SERVER

NETWORK ELEMENTS:

While dealing with the networks we most often come across the terms called the

routers, repeaters, bridges and hubs. These are used as connecting devices when we are

connecting the LANs or WANs together.

Repeaters:

A repeater is a device that operates only in the physical layer. Signals that carry

information within a network can travel a fixed distance before attenuation endangers the

integrity of data. A repeater receives a signal, before it becomes too weak or corrupted,

regenerates the original bit pattern. It then sends the refreshed signal. A repeater can

extend the physical length of a network.

Bridges:

A bridge operates in both the physical and the data link layers. As a physical

layer device, it regenerates the signal it receives. As a data link layer device, the bridge

can check the physical address (source and destination) contained in the packet. A bridge

has no physical address.

Hub:

Hub refers to any connecting device; it does have a specific meaning. A hub is

actually a multiport repeater. It is normally used to create Connections between stations

in the physical star topology. The hubs are also used to create multiple levels of

hierarchy.

Routers:

12

Page 13: Embedded Webserver-1

EMBEDDED WEB SERVER

An internet is a combination of networks connected by

routers. When a datagram goes from a source and destination, it will

probably passes through many routers until it reaches the router attached to the

destination network. A router receives the packet from a network and passes it to another

network. A router usually attached to several networks.

DIFFERENCES:

There are three major differences between a router a repeater and a bridge.

1. A router has a physical and logical (IP) address for each of its interfaces.

2. A router acts only on those packets in which the destination address matches the

address of the interface at which the packet arrives. This is true for unicast,

multicast or broadcast addresses.

3. A router changes the physical address of the packet (both source and destination)

when its forwards the packet.

IP ADDRESSING:

At the network Layer we need to uniquely identify each device on the

Internet to allow global communication between all devices. The identifier used in the IP

layer of the TCP/IP protocol suite to identify each device connected to the Internet is

called the Internet address or IP address. An IP address is a 32-bit binary address that

uniquely and universally defines the connection of a host to a router to the Internet. IP

addresses are unique in the sense that each address defines one and only one connection

to the internet. Two devices in the internet can never have the same address. However, if

a device has two connections to the internet, via two networks, it has two IP addresses.

The IP addresses are universal in the sense that the addressing system must be accepted

by any host that wants to be connected to the Internet.

ADDRESS SPACE:

13

Page 14: Embedded Webserver-1

EMBEDDED WEB SERVER

A protocol like IP that defines address has an address

space. An address space is the total number of addresses used by the protocol. If a

protocol uses N bits to define an address, the address, space is 2N because each bit can

have tow different values (o and 1(and N bits can have 2N values. IPV4 (IP version 4)

uses 32-bit addresses, which means that the address space is 232 or 4,294,967,296.

DOTTED DECIMAL NOTATION OF IP ADDRESS:

To make an IP address more compatible and easier to read, internet

address are usually written in decimal form with a decimal point separating the bytes.

The below figure shows the IP address in dotted decimal notation. Note that because each

byte is only 8 bits, each number in the dotted decimal notation is between o and 255.

10000000 00001011 00000011 11101010

128.11.3.31

CLASSES IN IP ADDRESSING:

IP address used the concept of classes. This type of architecture if

called classful addressing .In classful addressing the IP address space is divided into five

classes A, B, C, D and E. Each class occupies some part of whole address space.

14

Page 15: Embedded Webserver-1

EMBEDDED WEB SERVER

Class A covers half of the address space, class B covers

1/4th of the

whole address space, class C covers 1/8th of the address space, and class D covers 1/16th

of the address space.

HOST ID AND NET ID:

An IP address in class A, B and C is divided in to Net id and Host id.

The net id defines the network in the internet while the hosted tells about the host in that

network. In class A 1 byte defines the net id and 3 bytes defines the host id. In class B

2 bytes defines the net id and 2 bytes defines the host id. In class C 3 bytes defines the net

id and 1 byte defines the host id. Classes D and E are not divided into net id and host id.

Class D addresses are used for multicasting. Classes E addresses are reserved for future

use.

Class A:

Net id Host id

Class A is divided into 128 blocks with each block having a different net

id. The first block covers addresses from 0.0.0.0 to 0.255.255.255(net id 0) The second

block covers the addresses from 1.0.0.0 to 1.255.255.255(net id 1). The last block covers

the addresses from 127.0.0.0 to 127.255.255.255(net id 127).For each block of addresses

the first byte (net id) is the same, but the other three bytes (host id) can take any value in

the given range. The first and the last blocks of this class are reserved for special purpose

15

0

Page 16: Embedded Webserver-1

EMBEDDED WEB SERVER

and one block (net id 10) is used for private addresses. The remaining

125 blocks can be assigned to organizations. However each block in the

class contains 16,777,216 addresses for hosts, which means that the organizations should

be a large one to use all the addresses. The first address in the block is used to identify the

organizations to the rest of the internet. This address is called the network address. It

defines the network of the organization, not individual hosts.

Class B:

Net id host id

Class B is divided into 16,384 blocks with each block having a different net

id. The first block covers the addresses from 128.0.0.0 to 128.0.255.255(net id 128.0).

The last block covers the addresses from 191.255.0.0 to 125.255.255.255 (net id

191.255).For each block of addresses the first 2 bytes (net id) are the same, but the other

2 bytes (hostid) can take any value in the given range.

There are 16,384 networks that are there in class B. Sixteen blocks are

reserved for private addresses .Therefore there are a total of 16,368 class B networks that

can be assigned to the organizations. Each block in the class contains 65,536 addresses to

be assigned to the hosts. Class B addresses are designed for mid size organizations.

Class C:

Net id Host id

16

10

110

Page 17: Embedded Webserver-1

EMBEDDED WEB SERVER

Class C is divided into 2,097,052 blocks with each block

having a different net id. 256 blocks are used for private addresses

leaving 2,096,896 blocks for assignment to organizations. The first block covers

addresses from 192.0.0.0 to 192.0.0.255 (net id 192.0.0). The last block covers addresses

from 223.255.255.0 to 223.255.255.255 (net id 223.255.255). For each block of address

the first three bytes (net id) are the same but the remaining byte (host id) can take any

value in the given range. There are 2,096,902 blocks that can be assigned this means that

the total number of organizations that can have class C address is 2,096,902.Howeever

each block in this class contain 256 address which means the organization should be

small enough to need less than 256 addresses. The first address is the network address

and the last address is reserved for special purpose. Class C addresses were designed for

small organizations with a small number of hosts attached to their networks.

Class D:

Multicast address

There is just one block of class D address. It is designed for

multicasting. Each address in this class is used to define one group of hosts on the

internet. When a group is assigned an address in this class, every host that is member of

this group will have a multicast address in addition to its normal address.

Class E:

Reserved for future use

17

1110

1111

Page 18: Embedded Webserver-1

EMBEDDED WEB SERVER

There is just one block of class E address. It was

designed for use as reserved addresses. The last addresses in this class

255.255.255.255 are used for special address.

INTERNET PROTOCOL:

The internet protocol is a transmission mechanism used by the TCP/IP

protocols. IP is an unreliable and connection less datagram protocol a best effort delivery

service. The term best effort means that IP provides no error checking or tracking. IP

assumes the unreliability of the underlying layers and does its best to get a transmission

through its destination but with no guarantees.

If reliability is important, IP must be paired with reliable protocol such

as TCP. IP is also a connection less protocol packaged for a packet switching network

that uses the datagram approach. This means that each datagram is handled independently

and each datagram can follow a different route to the destination. This implies that

datagram send by the same source to the same destination could arrive out of order. Also

some could be lost or corrupted during transmission. Again IP also relies on higher level

protocol to take care of all these protocols.

Datagram:

Packets in the IP layers are called datagrams. A datagram is a variable length

packet consisting of two parts: header and data. The header is 20 to 60 bytes in length and

contains information essential to routing and delivery. It is customary in TCP/IP to show

the header in 4 byte sections.

18

Page 19: Embedded Webserver-1

EMBEDDED WEB SERVER

IP DATAGRAM

32 bits

19

VER4 bits

HLEN4 bits

DS8 bits

Total length 16 bits

Identification16bits

Flags3 bits

Fragment offset13 bits

Time to live8 bits

Protocol8 bits

Header checksum16 bits

Page 20: Embedded Webserver-1

EMBEDDED WEB SERVER

Version (VER):

This four bit field defines the version of IP protocols. Currently the version is 4.

However version 6 may replace version 4 in few years. This field tells the IP software

running in the processing machine that the datagram has the format of the version 4. All

fields must be interpreted as specified in the fourth version of the protocol. If the machine

is using some other version of IP the data gram is discarded rather than interpreted

incorrectly.

Header Length (HLEN):

This four bit field defines the total length of the datagram header in four byte

words. This field is needed because the length of the header is variable (between 20 and

60 bytes). When there are no options the header length is 20 bytes and the value of this

field is 5(5*4 = 20). When the option field is at its maximum size the value of this field is

15(15*4 = 60).

Differentiated services:

In this interpretation the first six bits make up the code point subfield

and the last two bits are not used. The code point subfield can be used in two different

ways

20

Source IP address32 bits

Destination IP address32 bits

DATA

Page 21: Embedded Webserver-1

EMBEDDED WEB SERVER

1. When the three right most bits are zeros the three left most bits are

interpreted the same as the precedence bits in the service type

interpretation. In other words it is compatible with the old interpretation.

2. When the three right most bits are not all zeros, the six bits define 64 services based

on the priority assignment by the internet or the local authorities according to the

table given below.

The first category contains the 32 service types. The second any third

contains 16 bytes. The first category (numbers 2, 4, 6… 62) is assigned by the internet

authorities. The second category (3, 7, 11, 15 … 63) can be used by local authorities. The

third category (1, 5, 9 …61) is temporary and can be used for experimental purposes. The

numbers are not contiguous. If they were the first category would range from 0 to 31. The

second 32 to 47 and the third 48 to 63. This would be incompatible with the TOS

interpretation because xxx000 (which includes 0, 8, 16, 24,32,40,48 and 56) will fall into

all three categories.

Total length:

This is a 16 bit field that defines the total of the IP datagram in bytes. To

find the length of the data coming from the upper layer, subtract the header length from

the total length. The header length can be found by multiplying the value in the HLEN

field by four.

Length of data = total length - header length.

21

Category Code point Assigning authority

1 XXXXX0 Internet

2 XXXX11 Local

3 XXXX01 Temporary or experimental

Page 22: Embedded Webserver-1

EMBEDDED WEB SERVER

Since the field length is 16 bits the total length of the IP datagram is

limited to 65535 (2^16 – 1) of which 20 to 60 bytes of the header and the rest is data

from the upper layer. Though a size of 65535 bytes might seem large the size of IP

datagram may increase in the near future as the underlying technologies allow even more

throughput. Some physical networks are not able to encapsulate the datagram of 65535

bytes in their frames. The datagram must be fragmented to be able to pass through these

networks. When a machine receives a frame it drops the header and trailer leaving the

datagram.

Identification flags and fragmentation offset:

These fields are used in fragmentation.

Time to live:

A datagram has limited lifetime in its travel through its internet. This

field was originally designed to hold a timestamp which was decremented by each visited

router. The datagram was discarded when the value become zero. However for this

scheme all machines must have synchronized clocks and must know how long it takes for

datagram to go from one machine to another. Today this field is used mostly to control

the maximum number of hops visited by the datagram. When the source host sends the

datagram it stores a number in this field. This value is approximately 2 times the

maximum number of routes between any two hosts. Each router that processes the

datagram decrements this number by one. If this value after being decremented is zero

the router discards the datagram. This field is needed because routing tables in the

internet cab become corrupted. A datagram may travel between two or more routers for a

long time without getting delivered to the destination host. Resources may become tied

up. This field limits the life time for a datagram and prevents old data grams from

popping out of the networks and perhaps confusing higher level protocols (especially

22

Page 23: Embedded Webserver-1

EMBEDDED WEB SERVER

TCP). Another use of this field is to intentionally limit the journey of the

packet. For example if the source wants to confine the packet to the local

network it can store 1 in

this field. When the packet arrives at the first router this value is decremented to zero and

the datagram is discarded.

Protocol:

This eight bit field defines the higher level protocol that uses the services of

the IP layer. An IP datagram can encapsulate data from several higher level protocols

such as TCP, UDP, ICMP and the IGMP. This field specifies the final destination

protocol to which the IP datagram must be delivered. In other words since the IP protocol

multiplexes and demultiplexes data from different higher level protocols the value of this

field helps in demultiplexing process when the datagram arrives at its final destination

Check sum:

The check sum field tells the check sum of the datagram. It is used for the

error detection purpose. It is the redundant information added to the packet. The

checksum is calculated at the sender and the value obtained is sent with the packet. The

receiver repeats the same calculation on the whole packet including the checksum. If the

result is satisfactory the packet is accepted otherwise it is rejected.

Source address:

This 32 bit field defines the IP address of the source. This field must remain

unchanged during the time the IP datagram travels from the source host to the destination

host.

Destination address:

23

Page 24: Embedded Webserver-1

EMBEDDED WEB SERVER

This 32 bit defines the IP address of the destination this field

must remain unchanged during the time the IP datagram travels from the

source host to the destination host.

Fragmentation:

A datagram has to travel through different networks. Each router de-

encapsulates the IP datagram from the frame it receives, processes it, and then

encapsulates it in another frame. The format and size of the received frame depend on the

protocol used by physical network through which the frame just traveled. The format and

size of the sent frame depend on the protocol used by the physical network through which

the frame is going to travel. For example, if a router connects an Ethernet network t a

token ring network, it receives a frame in the Ethernet format and sends in the token ring

format.

Each datagram packet has its own format. One of the fields define in the

format is the maximum size of the data field. In other, words, when a datagram is

encapsulated in a frame, the total size of the datagram must be less than this maximum

size, which is defined by the restriction imposed by the hardware and the software used in

the network.

In order to make IP protocol independent of physical network, the packagers

decided to make maximum length of IP datagram equal to the largest maximum transfer

unit defined so far (65535 bytes). This makes transmission more efficient if we use a

protocol with an MTU of this size. However, for other physical networks we must divide

the datagram to make it possible to pass through these networks. This is called as

fragmentation. There are three fields used for the purpose of the fragmentation. The fields

that are related to fragmentation and reassembly of IP datagram are Identification, flags,

and fragmentation offset fields.

24

Page 25: Embedded Webserver-1

EMBEDDED WEB SERVER

Identification:

This 16 bit field identifies a datagram originating from the source host. The

combination of Identification and source IP address must uniquely define a datagram

as it leaves the source host. To guarantee the uniqueness the IP protocol uses a counter to

label the datagrams. The counter is initialized to a positive number. When IP protocol

sends a datagram it copies the current value of the counter to the identification field and

increments the count by one.As long as the counter is kept in the main memory

uniqueness is guaranteed. When a datagram is fragmented the value in this identification

field is copied into all fragments. In other words all fragments had same identification

number which is also the same as the original datagram. The identification number helps

the destination in reassembling the datagram. It knows that all fragments having the same

identification value should be assembled into one datagram.

Flags:

This is a three bit field. The first field is reserved. The second bit is called do not

fragment bit. If its value is ‘1’ the machine must not fragment the datagram. If it cannot

pass the datagram through any physical network it discards the datagram and sends an

ICMP error message to the source host. If its value is zero the datagram can be

fragmented if necessary. The third bit is called more fragment bit. If its value is ‘1’ it

means the datagram is not the last fragment, there are more fragments after this one. If its

value is ‘0’ this is last or only fragment.

Fragmentation offset:

This 13 bit field shows the relative position of this fragment with respect

to the whole datagram. It is the offset of the data in the original datagram measured in

units of 8 bytes. For example a datagram with a data size of 4000 bytes is fragmented

into 3 fragments the bytes in the original data are numbered from 0 to 3999. The first

25

Page 26: Embedded Webserver-1

EMBEDDED WEB SERVER

fragment carries the bytes from 0 to 1399. The offset for this datagram is

0/8 = 0. The second byte carries bytes from 1400 to 2799, the offset

value for this fragment is 1400/8 = 175. Finally the third fragment carries bytes 2800 to

3999. The offset value for this fragment is 2800/8 = 350.

TRANSMISSION CONTROL PROTOCOL:

TCP lies between the application layer and the network layer and serves

as the intermediary between the application programs and the network operations. A

transport layer protocol usually has several responsibilities one is to process to process

communication. TCP uses port numbers to accomplish this. Another responsibility of the

transport layer protocol is to create a flow and error control mechanism at the transport

layer. TCP uses a sliding window protocol to achieve flow control. It uses the

acknowledge packet, timeout and retransmission to achieve error control. The transport

layer is also responsible for providing connection mechanism for the application

program. The application program sends streams of data to the transport layer. It is the

responsibility of the transport layer at the sending station to make a connection with the

receiver, chop the stream into transportable units, number them and send them one by one

it is the responsibility of the transport layer at the receiving end to wait until all the

different units belonging to the same application program have arrived, check and pass

those that are error free, and deliver them to the receiving application program as a

stream. After the entire stream has been sent the transport layer closes the connection.

TCP performs all these tasks. TCP is called a connection oriented reliable transport

protocol. It adds connection oriented and reliability features to the services of IP.

TCP SERVICES:

The services offered by TCP to the processes at the application layer are

given below

Stream delivery service:

TCP is a stream oriented protocol. TCP allows the sending process to

deliver data as a stream of bytes and the receiving process to obtain data as a stream of

26

Page 27: Embedded Webserver-1

EMBEDDED WEB SERVER

bytes. TCP creates an environment in which two processes seem to be

connected by an imaginary tube that carries the data across the internet.

The sending process produces a stream of bytes and the receiving process consumes it.

Sending and receiving buffers:

Because a sending and receiving processes may not produce and

consume data at the same speed TCP needs to buffer for storage. There are two buffers,

the sending and receiving buffers for each direction used for storing the data in case of

flow control.

Segments:

Although buffering handles the disparity between speed of producing

and consuming processes we need one more step before we can send the data. The IP

layer as a service provider for TCP needs to send data in packets not as a stream of bytes.

At the transport layer TCP groups a number of bytes together into a packet called a

segment. TCP adds the header to each segment and delivers the segment to the IP layer

for transmission. The segments are encapsulated in the IP datagram and transmitted. This

entire operation is transparent to the receiving process.

Full duplex service:

TCP offers full duplex service where data can flow in both directions at

the same time. Each TCP has sending and receiving buffers and segments are send in

both directions

Connection oriented service:

TCP is connection oriented protocol. When a process at site A wants to

send and receive data from another process at site B following occurs.

1. A’s TCP informs B’s TCP and gets approval from B’s TCP

2. A’s TCP and B’s TCP exchange data in both directions.

3. After both processes have no data left to send and the buffers are empty the two

TCP’s destroy their buffers.

27

Page 28: Embedded Webserver-1

EMBEDDED WEB SERVER

This is a virtual connection but not a physical

connection .The TCP segment is encapsulated in an IP datagram and can be sent out of

order or lost or corrupted and then resent. Each may use a different path to reach the

destination. Theirs is no physical connection. However, because TCP creates a stream

oriented in which it accepts the responsibility of delivering the bytes in order to the other

site. The situation is similar to that of having a connection between the two sites.

PROJECT DESCRIPTION

BLOCK DIAGRAM:

28

ProcessorRABBIT

3000

Ethernet controller RTL

8019AS

Page 29: Embedded Webserver-1

EMBEDDED WEB SERVER

DESCRIPTION:

The term Web server can mean one of two things:

1. A computer that is responsible for accepting HTTP requests from clients, which

are known as Web browsers, and serving them Webpages, which are usually

HTML documents.

2. A computer program that provides the functionality described in the first sense of

the term.

29

RJ45 CONNECTOR

HUB 10/100 mbps

ComputerMain Server

PC PC

PC

PC

PC

PC

Page 30: Embedded Webserver-1

EMBEDDED WEB SERVER

This web server consists of Rabbit processor, Ethernet controller,

flash memory, RJ45 jack. The web pages are stored in the flash memory.

When ever a request comes from a client the Ethernet controller first receives the request

and attaches the source and destination address and forwards the frame to rabbit

processor. Then the processor serves the web pages to the pc that request the page.

There are two ways to connect our web server one way by using a direct

connection between pc and RCM board using Ethernet cross over cable or simple

arrangement using a hub. In order to set up this direct connection the user will have to use

a pc without networking or disconnecting a pc from the corporate network.

The figure below shows the two ways of connecting the RCM 3700 module to the Pc

OPERATION

The project we have designed is user friendly any individual with

basic knowledge of computer networks can apply to its full fledged application.

We got the following information for activating the equipment:

30

Page 31: Embedded Webserver-1

EMBEDDED WEB SERVER

1. We need TCP / IP properties of network neighbourhood that is IP

address of client or server we use 169. 254. 52. 47

2. Subnet mask =255. 255. 255. 0

3. Default Gateway = 169. 254. 52. 10

4. DNS Server = 169. 254. 52. 10

5. Alternate DNS Server = 218. 248. 240. 23

The IP address 169. 254. 52. 47 have been code dumped in the Rabbit

module. For this we used a special type of bus compatible with LAN and Rabbit.

The way to communicate with our device is:

Let us start using WINDOWS XP .All options are here by

activated by clicking it.

START INTERNET EXPLORER.

A Web page is opened. Now we can activate the device by typing the IP

address 169. 254. 52. 47.

To change IP Address:

At WINDOWS XP ‘START’.

START SETTINGS CONTROL PANEL NETWORK CONNECTION

LAN CONNECT.

Double click to connect. Right click for TCP / IP Properties.

If you want to change IP Address change to 169 . 254. 52. 56 (for example.).

31

Page 32: Embedded Webserver-1

EMBEDDED WEB SERVER

WEB SERVER

INTRODUCTION:

The term Web Server can mean one of two things.

32

Page 33: Embedded Webserver-1

EMBEDDED WEB SERVER

A computer that is responsible for accepting HTTP requests from

clients, which are known as Web browsers, and serving them

Web pages, which are usually HTML documents.

A computer program that provides the functionality described in the first sense of

the term.

Although Web server programs differ in detail, they all share some basic common

features.

Every Web server program operates by accepting HTTP requests from the

network, and providing an HTTP response to the requester.

The HTTP response typically consists of an HTML document, but can also be a

raw text file, an image, or some other type of document.

The origin of the content sent by server is called static if it comes from an

existing file or dynamic if it is dynamically generated by some other program or

script called by Web server. Serving static content is usually much faster than

serving dynamic content.

RABBIT CORE MODULE 3700

INTRODUCTION:

33

Page 34: Embedded Webserver-1

EMBEDDED WEB SERVER

Now-a-days the servers that are commonly used are

APACHE, TOMCAT etc. These servers are very huge in size and are to

be operated from a fixed location .In contrast EMBEDDED WEB SERVER is portable

web-server that can be moved to any remote location and can be accessed by connecting

it to the network where ever it is required. The web server is designed using RCM 3700

module.

The RCM3700 has a Rabbit 3000 microprocessor operating at 22.1 MHz,

static RAM, flash memory, two clocks (main oscillator and real-time clock), and the

circuitry necessary for reset and management of battery backup of the Rabbit 3000’s

internal real-time clock and the static RAM. One 40-pin header brings out the Rabbit

3000 I/O bus lines, parallel ports, and serial ports.

The RCM3700 receives its +5 V power from the customer-supplied

motherboard on which it is mounted. The RCM3700 can interface with all kinds of

CMOS-compatible digital devices through the motherboard.

RCM 3700 FEATURES, ADVANTAGES AND HARDWARE DIAGRAM:

Features of RCM 3700:

1. Small size: 1.20" x 2.95" x 0.89"

(30 mm x 75 mm x 23 mm)

2. Microprocessor: latest revision of Rabbit 3000 running at 22.1 MHz supports

Dynamic C. .

3. 33 parallel 5 V tolerant I/O lines: 31 configurable for I/O, 2 fixed outputs.

4. External reset I/O.

5. Alternate I/O bus can be configured for 8 data lines and 5 address lines (shared with

parallel I/O lines), I/O read/write.

34

Page 35: Embedded Webserver-1

EMBEDDED WEB SERVER

6. Ten 8-bit timers (six cascadable) and one 10-bit timer with two match

registers.

7. 512K flash memory and 512K SRAM (Options for 256K flash memory and 128K

SRAM).

8. 1Mbytes serial flash memory, which is required to run the optional Dynamic C FAT

file system.

9. Real-time clock.

10. Provision for customer-supplied backup battery via connections on header J1.

11.10-bit free-running PWM counter and four pulse-width registers.

12. Two-channel Input Capture can be used to time input signals from various port pins

13. Two-channel Quadrature Decoder accepts inputs from external incremental encoder

modules.

14. Four available 3.3 V CMOS-compatible serial ports: maximum asynchronous baud

rate of 2.76 Mbps. Three ports are configurable as a clocked serial port (SPI), and

one port is configurable as an HDLC serial port. Shared connections to the Rabbit

microprocessor make a second HDLC serial port available at the expense of two of

the SPI configurable ports, giving you two HDLC ports and one asynchronous/SPI

serial port.

15. Watchdog supervisor.

Advantages of the RCM 3700:

35

Page 36: Embedded Webserver-1

EMBEDDED WEB SERVER

1. Easy C-language program development and debugging.

2. Integrated Ethernet port for network connectivity, with royalty-free

TCP/IP software

3. Ideal for network-enabling security and access systems, home automation, HVAC

systems and industrial controls.

4. Generous memory size allows large programs with tens of thousands of lines of code,

and Substantial data storage.

5. Program download utility (Rabbit Field Utility) and cloning board options for rapid

production loading of programs.

6. Fast to market using a fully engineered ”ready- to- run/ready- to- program”

microprocessor core.

7. Competitive pricing when compared with the alternatives of purchasing and

assembling individual components.

8. Integrated Ethernet port for network connectivity, with royalty-free TCP/IP software.

Hardware diagram of RCM 3700:

36

Page 37: Embedded Webserver-1

EMBEDDED WEB SERVER

RCM3700 Digital Inputs and Outputs:

The RCM3700 has 52 parallel I/O lines grouped in seven 8-bit ports

available on headers J1 and J2. The 44 bidirectional I/O lines are located on pins

PA0–PA7, PB0, PB2–B7, PD2–PD7, PE0–PE1, PE3–PE7, PF0–PF7, and PG0–PG7.

Figure shows the RCM3000 Rabbit Core series pin outs for headers J1 and J2.

37

Page 38: Embedded Webserver-1

EMBEDDED WEB SERVER

Figure: RCM3700 Pinouts

Headers J1 and J2 are standard 2 × 34 headers with a nominal 2 mm

pitch. An RJ-45 Ethernet jack is also included with the RCM3000 series.

The signals labeled PD2, PD3, PD6, and PD7 on header J1 (pins 29–

32) and the pins that are not connected (pins 33–34 on header J1 and pin 33 on header J2)

are reserved for future use on other models in the RCM3000 series.

38

Page 39: Embedded Webserver-1

EMBEDDED WEB SERVER

Figure: The Use of the Rabbit 3000 Ports in the RCM3700 Series Rabbit Core

modules:

The ports on the Rabbit 3000 microprocessor used in the RCM3000 Series are

configurable, and so the factory defaults can be reconfigured.

MEMORY I/O INTERFACE:

The Rabbit 3000 address lines (A0–A18) and all the data lines (D0–D7) are

routed internally to the onboard flash memory and SRAM chips. I/0 write (/IOWR) and

I/0 read (/IORD) are available for interfacing to external devices.

Parallel Port A can also be used as an external I/O data bus to isolate

external I/O from the main data bus. Parallel Port B pins PB2–PB5 and PB7 can also be

used as an auxiliary address bus.

39

Page 40: Embedded Webserver-1

EMBEDDED WEB SERVER

When using the auxiliary I/O bus for either Ethernet or the

LCD/keypad module on the Prototyping Board, you must define the usage of port A as

the auxiliary I/O bus.

SERIAL COMMUNICATION: The RCM3700 board does not have any serial

transceivers directly on the board. However, a serial interface may be

incorporated on the board the RCM3700 is mounted on.

For Example, the Prototyping Board has RS-232, RS-485 and IrDA

transceiver chips.

Serial ports:

There are five serial ports designated as Serial Ports A,

C, D, E, and F. All five serial ports can operate in an asynchronous

mode up to the baud rate of the system clock divided by 8.An

asynchronous port can handle 7 or 8 data bits. A 9th bit address

scheme, where an additional bit is sent to mark the first byte of a

message, is also supported.

Serial Port A is normally used as a programming port, but

may be used either as an asynchronous or as a clocked serial port

once the RCM3700 has been programmed and is operating in the Run

Mode.

Serial Ports C and D can also be operated in the clocked

serial mode. In this mode, a clock line synchronously clocks the data in

or out. Either of the two communicating devices can supply the clock.

Serial Ports E and F can also be configured as HDLC serial

ports. The IrDA protocol is also supported in SDLC format by these two

ports.

40

Page 41: Embedded Webserver-1

EMBEDDED WEB SERVER

Either Serial Ports C and D or Serial Port F

can be used at one time because these ports share some

common pins on header J1, as shown in below Figure. The selection of

port(s) depends on your need for two clocked serial ports (Serial Ports

C and D) vs. a second HDLC serial port (Serial Port F).

Figure: RCM 3700 Serial Ports C, D and F.

The serial ports used are selected with the serXOpen function call, where X

is the serial port (C, D, or F). Remember that Serial Ports C and D cannot be used if

Serial Port F is being used.

Ethernet port:

The figure below shows the pinout for the RJ-45 Ethernet port (J3).

41

Page 42: Embedded Webserver-1

EMBEDDED WEB SERVER

Two LEDs are placed next to the RJ-45 Ethernet jack, one to indicate an

Ethernet link (LINK) and one to indicate Ethernet activity (ACT).The RJ-45 connector is

shielded to minimize EMI effects to/from the Ethernet signals.

Programming Port:

Serial Port A has special features that allow it to cold-boot the system after

reset. Serial Port A is also the port that is used for software development under Dynamic

C. The RCM3700 is accessed using a 10-pin program header labeled J2. The

programming port uses the Rabbit 3000’s Serial Port A for communication, and is used

for the following operations.

• Programming/debugging

• Cloning

• Remote program download/debug over an Ethernet connection via the Rabbit

Link

EG2100.

42

Page 43: Embedded Webserver-1

EMBEDDED WEB SERVER

The Rabbit 3000 startup-mode pins (SMODE0, SMODE1)

are presented to the programming port so that an externally connected

device can force the RCM3700 to start up in an external bootstrap mode. The Rabbit

3000 status pin is also presented to the programming port. The status pin is an output that

can be used to send a general digital signal. The clock line for Serial Port A is presented

to the programming port, which makes synchronous serial communication possible.

The programming port is used to start the RCM3700 in a mode where the

RCM3700 will download a program from the port and then execute the program. The

programming port transmits information to and from a PC while a program is being

debugged.

MEMORY:

SRAM:

RCM3700 series boards have 256K–512K of SRAM

packaged in 32-pins Package.

Flash ROM:

A Flash Memory Bank Select jumper configuration option

based on 0 surface-mounted resistors exists at header JP1 on the RCM3700 modules.

This option, used in conjunction with some configuration macros, allows Dynamic C to

compile two different co-resident programs for the upper and lower halves of the 512K

flash in such a way that both programs start at logical address 0000. This is useful for

applications that require a resident download manager and a separate downloaded

program.

43

Page 44: Embedded Webserver-1

EMBEDDED WEB SERVER

Serial Flash:

A 1Mbyte serial flash is available to store data and Web

pages.

SCHEMATIC DIAGRAM:

The diagram below shows the schematic diagram of RCM3700

module showing interfacing of FLASH memory SRAM memory chips with the

Rabbit 3000 Processor.

44

Page 45: Embedded Webserver-1

EMBEDDED WEB SERVER

RABBIT 3000 MICRO PROCESSOR

INTORDUCTION:

45

Page 46: Embedded Webserver-1

EMBEDDED WEB SERVER

Rabbit Semiconductor was formed expressly to design a

better microprocessor for use in small and medium-scale controllers. The

first microprocessor was the Rabbit 2000. The second microprocessor, now available, is

the Rabbit 3000. Rabbit microprocessor designers have had years of experience using

Z80, Z180, and HD64180 microprocessors in small controllers. The Rabbit shares a

similar architecture and a high degree of compatibility with these microprocessors, but it

is a vast improvement. The Rabbit 3000 has been designed in close cooperation with Z-

World, Inc., a long-time manufacturer of low-cost single-board computers. Z-World’s

products are supported by an innovative C-language development system (Dynamic C).

Z-World is providing the soft-ware development tools for the Rabbit 3000.

The Rabbit 3000 is easy to use. Hardware and software interfaces are as

uncluttered and are as foolproof as possible. The Rabbit has outstanding computation

speed for a micro-processor with an 8-bit bus. This is because the Z80-derived instruction

set is very compact, and the timing of the memory interface allows higher clock speeds

for a given memory speed.

Microprocessor hardware and software development is easy for Rabbit

users. In-circuit emulators are not needed. Software development is accomplished by

connecting a simple interface cable from a PC serial port to the Rabbit-based target

system or by performing software development and debugging over a network or the

Internet using interfaces and tools provided by Rabbit Semiconductor.

Features and Specifications of Rabbit 3000 Processor:

• 128-pin LQFP package. Operating voltage 1.8 V to 3.6 V. Clock speed to 54+

MHz. All specifications are given for both industrial and commercial temperature

and voltage ranges. Rabbit microprocessors are low-cost.

46

Page 47: Embedded Webserver-1

EMBEDDED WEB SERVER

• Industrial specifications are for 3.3 V ±10% and a temperature

range from -40°C to +85°C. Modified commercial specifications

are for a voltage variation of 5% and a temperature range from -40°C to 70°C.

• 1-megabyte code-data space allows C programs with 50,000+ lines of code. The

extended Z80-style instruction set is C-friendly, with short and fast opcodes for

the most important C operations.

• Four levels of interrupt priority make a fast interrupt response practical for critical

applications. The maximum time to the first instruction of an interrupt routine is

about 0.5 µs at a clock speed of 50 MHz.

• Access to I/O devices is accomplished by using memory access instructions with

an I/O prefix. Access to I/O devices is thus faster and easier compared to

processors with a distinct and narrow I/O instruction set. As an option the

auxiliary I/O bus can be enabled to use separate pins for address and data,

allowing the I/O bus to have a greater physical extent with less EMI and less

conflict with the requirements of the fast memory bus.

• Hardware design is simple. Up to six static memory chips (such as RAM and

flash memory) connect directly to the microprocessor with no glue logic. Also

most I/O devices may be connected without glue logic.

• The memory read cycle is two clocks long. The write cycle is 3 clocks long. A

clean memory and I/O cycle completely avoid the possibility of bus fights.

Peripheral I/O devices can usually be interfaced in glue less fashion using the common

IORD and IOWR strobes.

• EMI reduction features reduce EMI levels by as much as 25 dB compared to other similar microprocessors. Separate power pins for the on-chip I/O buffers prevent high-frequency noise generated in the processor core from propagating to the signal output pins. A built-in clock spectrum spreader reduces electromagnetic interference and facilitates passing EMI tests to prove compliance with government regulatory requirements. As a consequence, the designer of a Rabbit-

47

Page 48: Embedded Webserver-1

EMBEDDED WEB SERVER

3000 based system can be assured of passing FCC or CE EMI tests as long as minimal design precautions are followed.

• The Rabbit may be cold-booted via a serial port or the parallel access slave port. This means that flash program memory may be soldered in unprogrammed, and can be reprogrammed at any time without any assumption of an existing program or BIOS.

• There are 56 parallel I/O lines. Some I/O lines are timer synchronized, which permits precisely timed edges and pulses to be generated under combined hardware and software control.

• Four pulse width modulated (PWM) outputs are implemented by special hardware. The repetition frequency and the duty cycle can be varied over a wide range. The resolution of the duty cycle is 1 part in 1024.

• There are six serial ports. All six serial ports can operate asynchronously in a variety of commonly used operating modes. Four of the six ports (designated A, B, C, D) support clocked serial communications suitable for interfacing with “SPI” devices and various similar devices such as A/D converters and memories that use a clocked serial protocol. Two of the ports E and F, support HDLC / SDLC synchronous communication. High data rates are supported by all six serial ports.

• A slave port allows the Rabbit to be used as an intelligent peripheral device slaved to a master processor.

• The built-in battery back able time/date clock uses an external 32.768 kHz crystal

oscillator. The suggested model circuit for the external oscillator. The time/date

clock can be used to provide periodic interrupts every 488 µs.

• Numerous timers and counters can be used to generate interrupts, baud rate

clocks, and timing for pulse generation.

• Two input-capture channels can be used to measure the width of pulses or to record the times at which a series of events take place. Each capture channel has a 16-bit counter and can take input from one or two pins selected from any of 16 pins.

48

Page 49: Embedded Webserver-1

EMBEDDED WEB SERVER

• Two quadrature decoder units accept input from incremental optical shaft encoders. These units can be used to track the motion of a rotating shaft or similar device.

• A built-in clock doubler allows ½-frequency crystals to be used.

• The built-in main clock oscillator uses an external crystal or a ceramic resonator. Typical crystal or resonator frequencies are in the range of 1.8Mhz to 30Mhz.The current is proportional to voltage and clock speed at 1.8 V and 3.84 MHz the current could be about 5 mA, and at 1 MHz the current is reduced to about 1 mA.. This greatly reduces the power used by flash memory when operating at low clock speeds.

• There is a built-in watch dog timer.

. The built- in battery- backable time / date clock uses an external 32.768 kHz crystal oscillator. The time / date clock can be used to provide interrupts every 488 µs.Typical battery current consumption is about 3µA.

BLOCKDIAGRAM OF RABBIT 3000 MICRO-PROCESSOR

49

Page 50: Embedded Webserver-1

EMBEDDED WEB SERVER

RABBIT 3000 ADVANTANAGES:

• The glue less architecture makes it is easy to design the hardware system.

• There are a lot of serial ports and they can communicate very fast.

50

Page 51: Embedded Webserver-1

EMBEDDED WEB SERVER

• Precision pulse and edge generation is a standard feature.

• EMI is at extremely low levels.

• Interrupts can have multiple priorities.

• Processor speed and power consumption are under program control.

• The ultra low power mode can perform computations and execute logical tests

since the processor continues to execute, albeit at 32 kHz or even as slow as 2

kHz.

• The Rabbit may be used to create an intelligent peripheral or a slave processor.

• The Rabbit can be cold-booted so unprogrammed flash memory can be soldered

in place.

• One can write serious software, be it 1,000 or 50,000 lines of C code. The tools

are there and they are low in cost.

• The battery-backable time/date clock is included.

• The standard Rabbit chip is made to industrial temperature and voltage

specifications.

• The Rabbit 3000 is backed by extensive software development tools and libraries,

especially in the area of networking and embedded Internet.

• The standard rabbit chip is made to industrial temperature and voltage

specifications.

FEATURES and SPECIFICATIONS:

On-Chip Peripherals and Features:

51

Page 52: Embedded Webserver-1

EMBEDDED WEB SERVER

The major on-chip peripherals are the serial ports, system

clock, time/date oscillator, parallel I/O, slave port, motion encoders, pulse width

modulators, pulse measurement, and timers. These and other features are described

below.

5 V Tolerant Inputs:

The Rabbit 3000 operates on a voltage in the range of 1.8 V to 3.6 V, but most

Rabbit 3000 input pins are 5 V tolerant. The exceptions are the power supply pins, and

oscillator buffer pins. The 5 V tolerant features allow 5 V devices that have a suitable

switching threshold to be directly connected to the Rabbit.

Serial Ports:

There are six serial ports designated ports A, B, C, D, E, and F. All six serial

ports can operate in an asynchronous mode up to a baud rate equal to the system clock

divided by 8. The asynchronous ports use 7-bit or 8-bit data formats, with or without

parity. A 9th bit address scheme, where an additional bit is set or cleared to mark the first

byte of a message, is also supported.

Serial ports A, B, C and D can be operated in the clocked serial mode. In this

mode, a clock line synchronously clocks the data in or out. Either the Rabbit serial port or

the remote device can supply the clock. Serial Port A has special features. It can be used

to cold-boot the system after reset. Serial Port A is the normal port that is used for

software development under Dynamic C.

All the serial ports have a special timing mode that supports infrared data

communications standards.

52

Page 53: Embedded Webserver-1

EMBEDDED WEB SERVER

System Clock:

The main oscillator uses an external crystal with a frequency typically in

the range from 1.8 MHz to 26 MHz. The processor clock is derived from the oscillator

output by either doubling the frequency, using the frequency directly, or dividing the

frequency by 2, 4, 6 or by 8. The processor clock can also be driven by the 32.768 kHz

real-time clock oscillator for very low power operation, in which case the main oscillator

can be shut down under software control.

32.768 kHz Oscillator Input:

The 32.768 kHz oscillator input is designed to accept a 32.768 kHz

clock. The 32.768 kHz clock is used to drive a battery-backable (there is a separate power

pin) internal 48-bit counter that serves as a real-time clock (RTC). The counter can be set

and read by software and is intended for keeping the date and time. There are enough bits

to keep the date for more than 100 years.

Parallel I/O:

There are 56 parallel input/output lines divided among seven 8-bit ports

designated A through G. Most of the port lines have alternate functions, such as serial

data or chip select strobes. Parallel Ports D, E, F, and G have the capability of timer-

synchronized outputs.

Slave Port:

The slave port is designed to allow the Rabbit to be a slave to another

processor, which could be another Rabbit. The port is shared with Parallel Port A and is a

53

Page 54: Embedded Webserver-1

EMBEDDED WEB SERVER

bidirectional data port. The slave port can be used to signal the master to

perform tasks using a variety of communication protocols over the slave

port.

Auxiliary I/O Bus:

The Rabbit 3000 instruction set supports memory access and I/O access.

Memory access takes place in a 1 megabyte memory space. I/O access takes place in a

64K I/O space. In a traditional microprocessor design the same address and data lines are

used for both memory and I/O spaces. Sharing address and data lines in this manner often

forces compromises or makes With the Rabbit 3000, the designer has the option of

enabling completely separate buses for I/O and memory. Parallel Port A is used to

provide 8 bidirectional data lines.

Input Capture Channels:

The input capture channels are used to determine the time at which an event

takes place. An event is signaled by a rising or falling edge (or optionally by either edge)

on one of 16 input pins. A 16 bit counter is used to record the time at which the event

takes place. The input capture channels can be used to measure the width of fast pulses.

This is done by starting the counter on the first edge of the pulse and capturing the

counter value on the second edge of the pulse.

Quadrature Encoder Inputs:

A quadrature encoder is a common electromechanical device used to track

the rotation of a shaft, or in some cases to track the motion of a linear follower. The

output signals are square waves 90 degrees out of phase also called being in quadrature

with each other. By having quadrature signals, the direction of rotation can be detected by

noting which signal leads the other signal. The Rabbit 3000 has 2 quadrature encoder

54

Page 55: Embedded Webserver-1

EMBEDDED WEB SERVER

units. Each unit has 2 inputs, one being the normal input and the other

the 90 degree or quadrature input.

Spread Spectrum Clock:

The main system clock, which is generated by the crystal oscillator or input

from an external oscillator, can be modified by a clock spectrum spreader internal to the

Rabbit 3000 chip. When the spectrum spreader is engaged, the clock is alternately

speeded up and slowed down, thus spreading the spectrum of the clock harmonics in the

frequency domain. This reduces EMI and improves the results of official radiated-

emissions tests typically by 15–20 dB at critical frequencies.

Timers:

The Rabbit has several timer systems The periodic interrupt is driven by

the 32.768 KHz oscillator divided 16, giving an interrupt every 488 micro-seconds if

enabled. This is intended to be used as a general-purpose clock interrupt. Timer A

consists of ten 8-bit countdown and reload registers. Each countdown register can be set

to divide by any number between 1 and 256.The output of six of the timers is used to

provide baud clocks for the serial ports. Timer B consists of a 10 bit counter that can be

read but not written.

PIN DIAGRAM OF RABBIT 3000 PROCESSOR:

55

Page 56: Embedded Webserver-1

EMBEDDED WEB SERVER

56

Page 57: Embedded Webserver-1

EMBEDDED WEB SERVER

PIN CONFIGURATIONS:

57

Page 58: Embedded Webserver-1

EMBEDDED WEB SERVER

58

Page 59: Embedded Webserver-1

EMBEDDED WEB SERVER

DETAILS ON RABBIT MICROPROCESSOR

FEATURES:

Error: Reference source not found Error: Reference source not found

The Slave Port:

The slave port allows a Rabbit to act as a slave to another processor, which

can also be a Rabbit. The slave has to have only a processor chip, a RAM chip, and clock

and reset signals that can be supplied by the master. The master can cold boot and

download a program to the slave. The master does not have to be a Rabbit processor, but

can be any type of processor. The slave processor’s slave port is connected to the master

processor’s data bus.

Code Compilation to Memory:

The compiler actually generates code for root code and constants and

extended code and extended constants. It allocates space for data variables, but does not

generate data bits to be stored in memory. In any but the smallest programs, most of the

code is compiled to extended memory. This code executes in the 8K window from E000

to FFFF. This 8K window uses paged access.

Parallel Ports:

The Rabbit has seven 8-bit parallel ports designated A, B, C, D, E, F and G.

The pins used for the parallel ports are also shared with numerous other functions.

59

Page 60: Embedded Webserver-1

EMBEDDED WEB SERVER

The important properties of the ports are summarized below:

• Port A — Shared with the slave port data interface and auxiliary I/O data bus.

• Port B — Shared with control lines for slave port, auxiliary I/O address bus, and

clock I/O for clocked serial mode option for Serial Ports A and B.

• Port C — Shared with serial port data I/O.

• Port D — 4 bits shared with alternate I/O pins for Serial Ports A and B. 4 bits are

not shared.

• Port E — All bits of Port E can be configured as I/O strobes. 4 bits of port E can

be used as external interrupt inputs. One bit of port E is shared with the slave port

chip select.

• Port F — Parallel Port F outputs can carry the four Pulse-Width Modulator

outputs. As inputs, Parallel Port F inputs can carry the inputs to the two channels

of the quadrature decoders. Port F pins can also be configured to be used as clock

pins for clocked Serial Ports C and D.

• Port G — Port G inputs and outputs are also used for access to other serial

peripherals on the chip such as those used for asynchronous or synchronous

communication.

• Parallel Ports D–G behave in the same manner when used as digital I/O.

TIMERS:

There are two timers Timer A and Timer B. Timer A is intended mainly for

generating the clock for various peripherals, baud clock for the serial ports, a periodic

clock for clocking Parallel Ports D and E, or for generating periodic interrupts. Timers

60

Page 61: Embedded Webserver-1

EMBEDDED WEB SERVER

A1–A7 are general-purpose timers, and Timers A8–A10 are dedicated to specific

peripherals. Timer B can be used for the same functions, but it cannot generate the baud

clock. Timer B is more flexible when it can be used because the program can read the

time from a continuously running counter and events can be programmed to occur at a

specified future time.

EMI CONTROL:

Electromagnetic Interference (EMI) from unintentional radiation is

of concern to the microprocessor system designer. One concern is passing the tests

sometimes it requires that computing devices intended for use in the home or in office

environments not have unintentional electromagnetic radiation above certain limits of

field strength that depend on frequency and whether the device is intended for home or

office use. This is verified by measuring radiation from the device at a test site.

The Rabbit 3000 has important features that aid in the control of EMI.

• The power supply for the processor core is on separate pins from the power

supply for the I/O buffers associated with the processor and various peripheral

devices.

• A spectrum spreader in the clock circuit can be enabled to spread the spectrum of

the clock by varying the clock frequency in a regular pattern.

61

Page 62: Embedded Webserver-1

EMBEDDED WEB SERVER

Watchdog Timer Support:

A microprocessor system can crash for a variety of reasons. A

software bug or an electrical upset are common reasons. When the system crashes the

program will typically settle into an endless loop because parameters that govern looping

behavior have been corrupted.

Typically, the stack becomes corrupted and returns are made to

random addresses. The usual corrective action taken in response to a crash is to reset the

microprocessor and reboot the system. The crash can be detected either because an

anomaly is detected by program consistency checking or because a part of the program

that should be executing periodically is not executing and the watchdog times out.

Watchdog Timer:

The watchdog timer is a 17-bit counter. In normal operation it is

driven by the 32.768 kHz clock. When the watchdog timer reaches any of several values

corresponding to a delay of from 0.25 to 2 seconds, it “times out.” When it times out, it

emits a 1-clock pulse from the watchdog output pin and it resets the processor via an

internal circuit. To prevent this timeout, the program must “hit” the watchdog timer

before it times out. The watchdog timer may be disabled. The purpose of the watchdog is

to unhang the processor from an endless loop caused by a software crash or a hardware

upset.

62

Page 63: Embedded Webserver-1

EMBEDDED WEB SERVER

The Schematic Diagram below shows the Interfacing of Rabbbit3000

Processor with Ethernet Controller Chip.

63

Page 64: Embedded Webserver-1

EMBEDDED WEB SERVER

The Rabbit 8-bit Processor vs. Other Processors:

The Rabbit 3000 processor has been designed with the objective of creating

practical systems to solve real world problems in an economical fashion.

• The Rabbit is a processor that can be used to build a system in which EMI is

nearly absent, even at clock frequencies in excess of 40 MHz. This is due to the

split power supply, the clock doubler, the clock spectrum spreader.

• Execution speed with the Rabbit is usually a pleasant surprise compared to other

processors. This is due to the well-chosen and compact instruction set partnered

with and excellent compiler and library.

• The Rabbit memory bus is an exceptionally efficient and very clean design. No

external logic is required to support static memory chips. Battery-backed external

memory is supported by built-in functionality.

• The Rabbit 3000 operates at 3.6 V or less, but it has 5 V tolerant inputs and has a

second complete bus for I/O operations that is separate from the memory bus.

This second auxiliary bus can be enabled by the application as a designer option.

These features make it easy to design systems that mix 3 V and 5 V components,

and avoid the loading problems and the EMI problems that result if the memory

bus is extended to connect with many I/O devices.

• The Rabbit may be remotely programmed, including complete cold-boot, via a

serial link, Ethernet, or even via a network or the Internet using built in

capabilities. These capabilities are inexpensive to implement.

64

Page 65: Embedded Webserver-1

EMBEDDED WEB SERVER

• The Rabbit is an 8-bit processor with an 8-bit external data bus and an 8-bit internal data bus. Because the Rabbit makes the most of its external 8-bit bus and because it has a compact instruction set, its performance is as good as many 16-bit

processors. Many Rabbit instructions are 1 byte long. In contrast, the minimum instruction length on most 32-bit RISC processors is 32 bits.

65

Page 66: Embedded Webserver-1

EMBEDDED WEB SERVER

ETHERNET CONTROLLER

GENERAL DESCRIPTION:

The RTL8019AS is a highly integrated Ethernet Controller which

offers a simple solution to implement a Plug and Play NE2000 compatible adapter with

full-duplex and power down features. With the three level power down control features,

the RTL8019AS is made to be an ideal choice of the network device for a GREEN PC

system. The full-duplex function enables simultaneously transmission and reception on

the twisted-pair link to a full-duplex Ethernet switching hub. This feature not only

increases the channel bandwidth from 10 to 20 Mbps but also avoids the performance

degrading problem due to the channel contention characteristics of the Ethernet

CSMA/CD protocol. The Microsoft's Plug and Play function can relieve the users from

pains of taking care the adapter's resource configurations such as IRQ, I/O, and memory

address, etc. However, for special applications not to be used as a Plug and Play

compatible device, the RTL8019AS also supports the jumper and proprietary jumper less

options.

To offer a fully plug and play solution, the RTL8019AS provides

the auto-detect capability between the integrated 10BaseT transceiver, BNC and AUI

interface. Besides, the 10BaseT transceiver can automatically correct the polarity error on

its receiving pair. Furthermore, 8 IRQ lines and 16 I/O base address options are provided

for grand resource configuration flexibility. The RTL8019AS supports 16k, 32k & 64k

byte BROM and flash memory interface. It also offers the page mode function which can

support up to 4M-byte BROM within only 16k-byte system memory space. Besides, the

66

Page 67: Embedded Webserver-1

EMBEDDED WEB SERVER

BROM disable command is provided to release the BROM memory

space for other system usage (e.g. EMM386, etc.) after the BROM

program is loaded. The RTL8019AS

is built in with 16K-byte SRAM in a single chip. It is designed not to provide more

friendly functions but also to save the effort of SRAM sourcing and inventory.

FEATURES:

100-pin PQFP

RTL8019 software compatible

Supports PnP auto detect mode (RTL8019AS only)

Compliant to Ethernet II and IEEE802.3 10Base5, 10Base2, 10BaseT

Software compatible with NE2000 on both 8 and 16-bit slots

Supports both jumper and jumper less modes

Supports Microsoft‘s Plug and Play configuration for jumper less mode

Supports Full-Duplex Ethernet function to double channel bandwidth

Supports three level power down modes:

Sleep

Power down with internal clock running

Power down with internal clock halted

Built-in data prefetch function to improve performance

Supports UTP, AUI & BNC auto-detect (RTL8019AS only)

Supports auto polarity correction for 10BaseT

Support 8 IRQ lines

Supports 16 I/O base address options

_ and extra I/O address fully decode mode (RTL8019AS only)

Supports 16K, 32K, 64K and 16K-page mode access to BROM (up to 256 pages

with 16K bytes/page)

Supports BROM disable command to release memory after remote boot

67

Page 68: Embedded Webserver-1

EMBEDDED WEB SERVER

Supports flash memory read/write (RTL8019AS only)

16k byte SRAM built in (RTL8019AS only)

Use 9346 (64*16-bit EEPROM) to store resource configurations and ID parameters

Capable of programming blank 9346 on board for manufacturing convenience

Support 4 diagnostic LED pins with programmable outputs

PIN DIAGRAM OF RTL8019AS :

The below figure shows the pinout for the RJ-45 Ethernet port (J3).

68

Page 69: Embedded Webserver-1

EMBEDDED WEB SERVER

PIN CONFIGURATIONS OF RTL 8019AS:

69

Page 70: Embedded Webserver-1

EMBEDDED WEB SERVER

DYNAMIC C SUPPORT FOR THE RABBIT:

Dynamic C is z-World’s interactive C language development

system. Dynamic C runs on a PC under Windows 32-bit operating systems. Dynamic C

provides a combined compiler, editor and debugger. The usual method for debugging a

target system based on the Rabbit is to implement the 10-pin programming connector that

connects to the PC serial port via a standard converter cable. Dynamic C libraries contain

highly perfected software to control the Rabbit. These include drivers, utility and math

routines and the debugging BIOS for Dynamic C.

70

Page 71: Embedded Webserver-1

EMBEDDED WEB SERVER

POWER SUPPLY

DESCRIPTION: AC Supply (230V, 50Hz) is given to a rectifier circuit through the step-

down transformer (230V/18V, 50Hz).The rectifier used is bridge rectifier. The bridge

rectifier converts AC signal to pulsating DC.The output of rectifier is given to filter

circuit, which removes ripples. Here the capacitance filter is used which open for DC and

conducts for the AC voltage.AC supply is given to the rectifier circuit through the step

down transformer. The output is free from ripples and is given to the regulator unit. This

unit maintains the output voltage irrespective of the fluctuations in the input AC voltage.

Here LM 7805 is used which gives regulated voltage. The output of bridge rectifier is

12V AC and it is stepped down to +5V DC by the LM 7805.The whole circuit powers up

with this voltage.

AC VOLTAGE

BLOCK DIAGRAM OF R P S

The supply given is the +5V DC. The incoming power is 230V AC.So there

is need to convert it into +5V DC

The input AC supply is stepped down from 230V to 12-0-12V.The rectifier

consists of diodes D1, D2, D3 and D4 that makes the supply DC i.e. unidirectional

waveform. The output from rectifier is a URDC, whose value is +12V peak to peak.

The voltage regulator makes this URDC to RDC of +5V.The capacitor C1

and C2 is used to maintain constant voltage between two consecutive positive cycles

71

ORDINARY POWER SUPPLY

VOLTAGE REGULATOR

Page 72: Embedded Webserver-1

EMBEDDED WEB SERVER

where as C3 and C4 is used to remove the fluctuations caused by regulator. Here we are

selecting +12V as a peak value. Because of fluctuations, the peak voltage may decrease,

and then regulator cannot step up to +5V.If we select peak value, a higher one, then the

problem can be overcome.

A regulated power supply, which maintains the output voltage constant

irrespective of AC mains fluctuations or load variations, is known as regulated power

supply. A regulated power supply consists of an ordinary power supply and voltage-

regulating device. The output of ordinary power supply is fed to the voltage regulator,

which produces the final output. The output voltage remains constant whether the load

current changes or there are fluctuations in the input AC voltage.

The rectifier converts the transformer secondary AC voltage into pulsating

voltage.The pulsating DC voltage is applied to the capacitor filter. This filter reduces the

pulsations in the rectifier DC output voltage.Finally; it reduces the variations in the

filtered output voltage.

Need of RPS:

In an ordinary power supply, the voltage regulation is poor i.e. DC output

voltage changes with load current. Output voltage also changes due to variations in the

input AC voltage. This is due to the following reasons:

1. There are considerable variations in AC line voltage caused by outside factors

beyond our control. This change the DC output voltage. Most of the electronic

circuits will refuse to work satisfactorily on such output voltage fluctuations.

These necessities to use regulated DC power supply.

2. The internal resistance of ordinary power supply in relatively

large.Therefore,output voltage is markedly affected by the amount of load current

drawn from the supply . These variations in DC voltage may cause erratic

operation of electronic circuits. Therefore, regulated DC power supply is the only

solution in such situations

72

Page 73: Embedded Webserver-1

EMBEDDED WEB SERVER

LM7805

C1 C2 C3 C4

GROUND

2

D1

_

D1

+

_

D2+

_

+D4

_

D3

+

CIRCUIT DIAGRAM:

1 3

73

output+5V230vAC

INPUT

+VCC

OUTPUT

Page 74: Embedded Webserver-1

EMBEDDED WEB SERVER

C1=1000 µf. C2=100 µf

C3=10 µf

C4=1 µf

WAVE FORMS:

74

Page 75: Embedded Webserver-1

EMBEDDED WEB SERVER

DYNAMIC-C

Description:

Dynamic C is an integrated development system for writing embedded

software. It is designed for use with Z-World controllers and other controllers based on

the Rabbit microprocessor. The Rabbit family of processors are high-performance 8-bit

microprocessors that can handle C language applications of approximately 50,000 C+

statements or 1 MB.

The Nature of Dynamic C:

Dynamic C integrates the following development functions into one program.

• Editing

75

Page 76: Embedded Webserver-1

EMBEDDED WEB SERVER

• Compiling

• Linking

• Loading

• Debugging

In fact, compiling, linking and loading are one function. Dynamic C has an

easy-to-use, built-in, full-featured, text editor. Dynamic C programs can be executed and

debugged interactively at the source-code or machine-code level. Pull-down menus and

keyboard shortcuts for most commands make Dynamic C easy to use.

Dynamic C also supports assembly language programming. It is not necessary to

leave C or the development system to write assembly language code. C and assembly

language may be mixed together.

Debugging under Dynamic C includes the ability to use printf commands, watch

expressions and breakpoints. Watch expressions can be used to compute C expressions

involving the target’s program variables or functions. Watch expressions can be

evaluated while stopped at a breakpoint.

Dynamic C 9 introduces advanced debugging features such as execution

and stack tracing. Execution tracing can be used to follow the execution of debuggable

statements, including such information as function/file name, source code line and

column numbers, action performed, time stamp of action performed and register contents.

Stack tracing shows function call sequences and parameter values. Dynamic C provides

extensions to the C language (such as shared and protected variables, co statements and

co functions) that support real-world embedded system development. Dynamic C

supports cooperative and preemptive multitasking.

76

Page 77: Embedded Webserver-1

EMBEDDED WEB SERVER

Dynamic C comes with many function libraries, all in

source code. These libraries support realtime programming, machine

level I/O, and provide standard string and math functions.

The Dynamic C file system, known as the Flash filesystem or mk II or

simply as FS2, was designed to be used with a second flash memory or in SRAM.

It allows:

• The ability to overwrite parts of a file.

• The simultaneous use of multiple device types.

• The ability to partition devices.

• Efficient support for byte-writable devices.

• Better performance tuning.

• A high degree of backwards compatibility with its predecessor.

Speed:

Dynamic C compiles directly to memory. Functions and libraries are compiled

and linked and downloaded on-the-fly. On a fast PC, Dynamic C might load 30,000

bytes of code in 5 seconds at a baud rate of 115,200 bps.

Dynamic C Enhancements and Differences:

Dynamic C differs from a traditional C programming system running on a PC or

under UNIX. The reason? To be better help customers write the most reliable embedded

control software possible. It is not possible to use standard C in an embedded

environment without making adaptations. Standard C makes many assumptions that do

not apply to embedded systems.

77

Page 78: Embedded Webserver-1

EMBEDDED WEB SERVER

Many enhancements have been added to Dynamic C. Some of these are

listed below:

• Function chaining, a concept unique to Dynamic C, allows special segments of

code to be embedded within one or more functions. When a named function chain

executes, all the segments belonging to that chain execute. Function chains allow

software to perform initialization, data recovery, or other kinds of tasks on request.

• Co statements allow concurrent parallel processes to be simulated in a single

program.

• Co functions allow cooperative processes to be simulated in a single program.

• Slice statements allow preemptive processes in a single program.

• Dynamic C supports embedded assembly code and stand-alone assembly code.

• Dynamic C has shared and protected keywords that help protect data shared

between different Contexts or stored in battery-backed memory.

• Dynamic C has a set of features that allow the programmer to make fullest use of

extended memory. Dynamic C supports the 1 MB address space of the microprocessor.

The address space is segmented by a memory management unit (MMU). Normally,

Dynamic C takes care of memory management, but there are instances where the

programmer will want to take control of it. Dynamic C has keywords and directives to

help put code and data in the proper place.

The keyword root selects root memory. The keyword xmem selects

extended memory, which means anywhere in the 1024 KB or 1 MB code space. root

and xmem are semantically meaningful in function prototypes and more efficient code is

generated when they are used. Their use must match between the prototype and the

function definition.

78

Page 79: Embedded Webserver-1

EMBEDDED WEB SERVER

Graphical User Interface:

Dynamic C can be used to edit source files, compile and run programs, and

choose options for these activities using pull-down menus or keyboard shortcuts. There

are two modes: edit mode and run mode. To debug a program, a controller must be

connected to the PC, either directly via a programming cable or indirectly via an Ethernet

connection and a Rabbit Link board. Multiple instances of Dynamic C can run

simultaneously.

FLOW CHART:

79

START

INITIALIZE THEPORT

PARAMETERS

CONFIGURE RABBIT IPADDRESS

INITIALIZE TCP/IP

PARAMETERS

Page 80: Embedded Webserver-1

EMBEDDED WEB SERVER

NO

YES

NO

YES

NO

80

RESOLVE IP ADDRESS AND LOAD TO ETHERNET DEVICE

CHECK VALIDITY?

LOAD HTML PAGES FROM FLASH

IF ANY REQUEST?

A

GET HTML PAGES ANDFORM INTO PACKETS

SERVE FIRSTLINK PAGE

DISCONNECT THELINK SERVING

SERVE REMAINING LINK PAGESA

IS DISCONNE

C--TED

ANY LINK REQUESTED

Page 81: Embedded Webserver-1

EMBEDDED WEB SERVER

YES YES

NO

YES

YES

ALGORITHM

Step-1 Initializing the port parameters like baurd rate=96 MHz, enable serial

Communication.

Step-2 Initializing the TCP/IP parameters like IP address, subnet mask, default gateway and DNS server.

Step-3 Particular PC IP address is loaded into Rabbit processor.

Step-4 Load HTML pages from the flash memory.

81

Page 82: Embedded Webserver-1

EMBEDDED WEB SERVER

Step-5 Convert the IP address into 64-bit string and load it into the Ethernet device.

Step-6 If any request from the client arrives go to step-7, otherwise repeat step-6.

Step-7 Check for validity of IP address? If yes, go to step-8, otherwise repeat step-6.

Step-8 Get the HTML Pages from the computer main server and form data into packets.

Step-9 Then serves the first link page to the requested PC.

Step-10 Check for further link request? If yes to go step-11, otherwise repeat

step10.

Step-11 Serve the remaining link pages requested from the corresponding PC.

Step-12 Check whether the link is disconnected or not; If yes, goto step-13.otherwise

repeat step-12.

Step-13 Disconnect the serving link and goto step-6.

APPLICATION CODE USING DYNAMIC C SOFTWARE

browseled.c

Z-World, 2003

This program is used with RCM3700 series controllers

with prototyping boards.

Description

82

Page 83: Embedded Webserver-1

EMBEDDED WEB SERVER

===========

This program demonstrates a basic controller running a

WEB page. Two "device LED's" are created with two

buttons to toggle them. Users can browse to the device

and change thestatus of the lights. The LED's on the

prototyping board will match the ones on the web page.

This program is adapted from \Samples\TCPIP\ssi.c.

Instructions

============

1. Make changes below in the configuration section to

match your application.

2. Compile and run this program.

3. With your WEB browser access the WEB page running on

the controller.

4. View LEDS on Web page and the prototyping board to

see that they match-up when changing them via the

WEB pagecontrol button.

**********************************************************/

#class auto

#define DS1 0x40 //led, port F bit 6 bitmask

#define DS2 0x80 //led, port F bit 7 bitmask

/***********************************

* Configuration Section *

* --------------------- *

* All fields in this section must *

83

Page 84: Embedded Webserver-1

EMBEDDED WEB SERVER

* be altered to match your local *

* network settings. *

***********************************/

/*

* Pick the predefined TCP/IP configuration for this sample. See

* LIB\TCPIP\TCP_CONFIG.LIB for instructions on how to set the

* configuration.

*/

#define TCPCONFIG 1

/*

* TCP/IP modification - reduce TCP socket buffer

* size, to allow more connections. This can be increased,

* with increased performance, if the number of sockets

* are reduced. Note that this buffer size is split in

* two for TCP sockets--1024 bytes for send and 1024 bytes

* for receive.

*/

#define TCP_BUF_SIZE 2048

/*

* Web server configuration

*/

/*

* Define the number of HTTP servers and socket buffers.

* With tcp_reserveport(), fewer HTTP servers are needed.

*/

84

Page 85: Embedded Webserver-1

EMBEDDED WEB SERVER

#define HTTP_MAXSERVERS 2

#define MAX_TCP_SOCKET_BUFFERS 2

/*

* Our web server as seen from the clients.

* This should be the address that the clients (netscape/IE)

* use to access your server. Usually, this is your IP address.

* If you are behind a firewall, though, it might be a port on

* the proxy, that will be forwarded to the Rabbit board. The

* commented out line is an example of such a situation.

*/

#define REDIRECTHOST _PRIMARY_STATIC_IP

// #define REDIRECTHOST "my.host.com:8080"

/********************************

* End of configuration section *

********************************/

/*

* REDIRECTTO is used by each ledxtoggle cgi's to tell the

* browser which page to hit next. The default REDIRECTTO

* assumes that you are serving a page that does not have

* any address translation applied to it.

*/

#define REDIRECTTO "http://" REDIRECTHOST "/index.shtml"

#memmap xmem

#use "dcrtcp.lib"

85

Page 86: Embedded Webserver-1

EMBEDDED WEB SERVER

#use "http.lib"

/*

* Notice that we have ximported in the source code for

* this program. This allows us to <!--#include file="ssi.c"-->

* in the pages/showsrc.shtml.

*

*/

#ximport "samples/rcm3700/tcpip/pages/browseled.shtml" index_html

#ximport "samples/rcm3700/tcpip/pages/rabbit1.gif" rabbit1_gif

#ximport "samples/rcm3700/tcpip/pages/ledon.gif" ledon_gif

#ximport "samples/rcm3700/tcpip/pages/ledoff.gif" ledoff_gif

#ximport "samples/rcm3700/tcpip/pages/button.gif" button_gif

#ximport "samples/rcm3700/tcpip/pages/showsrc.shtml" showsrc_shtml

#ximport "samples/rcm3700/tcpip/browseled.c" browseled_c

/*

* In this case the .html is not the first type in the

* type table. This causes the default (no extension)

* to assume the shtml_handler.

*

*/

/* the default for / must be first */

SSPEC_MIMETABLE_START

SSPEC_MIME_FUNC(".shtml", "text/html", shtml_handler),

SSPEC_MIME(".html", "text/html"),

86

Page 87: Embedded Webserver-1

EMBEDDED WEB SERVER

SSPEC_MIME(".gif", "image/gif"),

SSPEC_MIME(".cgi", "")

SSPEC_MIMETABLE_END

/*

* Each ledx contains a text string that is either

* "ledon.gif" or "ledoff.gif" This string is toggled

* each time the ledxtoggle.cgi is requested from the

* browser.

*

*/

char led1[15];

char led2[15];

/*

* Instead of sending other text back from the cgi's

* we have decided to redirect them to the original page.

* the cgi_redirectto forms a header which will redirect

* the browser back to the main page.

*

*/

int led1toggle(HttpState* state)

{

if (strcmp(led1,"ledon.gif")==0)

strcpy(led1,"ledoff.gif");

else

87

Page 88: Embedded Webserver-1

EMBEDDED WEB SERVER

strcpy(led1,"ledon.gif");

cgi_redirectto(state,REDIRECTTO);

return 0;

}

int led2toggle(HttpState* state)

{

if (strcmp(led2,"ledon.gif")==0)

strcpy(led2,"ledoff.gif");

else

strcpy(led2,"ledon.gif");

cgi_redirectto(state,REDIRECTTO);

return 0;

}

SSPEC_RESOURCETABLE_START

SSPEC_RESOURCE_XMEMFILE("/", index_html),

SSPEC_RESOURCE_XMEMFILE("/index.shtml", index_html),

SSPEC_RESOURCE_XMEMFILE("/showsrc.shtml", showsrc_shtml),

SSPEC_RESOURCE_XMEMFILE("/rabbit1.gif", rabbit1_gif),

SSPEC_RESOURCE_XMEMFILE("/ledon.gif", ledon_gif),

SSPEC_RESOURCE_XMEMFILE("/ledoff.gif", ledoff_gif),

SSPEC_RESOURCE_XMEMFILE("/button.gif", button_gif),

SSPEC_RESOURCE_XMEMFILE("browseled.c", browseled_c),

SSPEC_RESOURCE_ROOTVAR("led1", led1, PTR16, "%s"),

SSPEC_RESOURCE_ROOTVAR("led2", led2, PTR16, "%s"),

SSPEC_RESOURCE_FUNCTION("/led1tog.cgi", led1toggle),

SSPEC_RESOURCE_FUNCTION("/led2tog.cgi", led2toggle),

88

Page 89: Embedded Webserver-1

EMBEDDED WEB SERVER

SSPEC_RESOURCETABLE_END

void update_outputs()

{

auto int value;

value=PFDRShadow&0x3F; //on state for leds

/* update O0 */

if (strcmp(led1,"ledon.gif"))

value|=DS1;

/* update O1 */

if (strcmp(led2,"ledon.gif"))

value|=DS2;

WrPortI(PFDR, &PFDRShadow, value);

}

main()

{

brdInit(); //initialize board for this demo

strcpy(led1,"ledon.gif");

strcpy(led2,"ledoff.gif");

sock_init();

http_init();

tcp_reserveport(80);

89

Page 90: Embedded Webserver-1

EMBEDDED WEB SERVER

while (1)

{

update_outputs();

http_handler();

}

}

#nodebug

HTML Description

INTRODUCTION:

HyperText Markup Language (HTML) is a markup language

designed for the creation of web pages with hypertext and other information to be

displayed in a web browser. HTML is used to structure information denoting certain text

as headings, paragraphs, lists and so on and can be used to describe, to some degree, the

appearance and semantics of a document.

90

Page 91: Embedded Webserver-1

EMBEDDED WEB SERVER

The most common extension for files containing

HTML is .html, however, older operating systems, such as DOS, limit

file extensions to three letters, so a .htm extension is also used. Although perhaps less

common now, the shorter form is still widely supported by current software.

Markup element types: Below are the kinds of markup element types in HTML.

Structural markup. Describes the purpose of text. For example,

<h2>Golf</h2>

directs the browser to render "Golf" as a second-level heading, similar to "Markup

element types" at the start of this section. Structural markup does not denote any

specific rendering, but most web browsers have standardised on how elements

should be formatted. For example, by default, headings like these will appear in

large, bold text. Further styling should be done with Cascading Style Sheets

(CSS).

91

Page 92: Embedded Webserver-1

EMBEDDED WEB SERVER

Presentational markup. Describes the appearance of the text, regardless of its

function. For example,

<b>boldface</b>

will render "boldface" in bold text. In the majority of cases, using presentational markup

is inappropriate, and presentation should be controlled by using CSS. In the case of both

<b>bold</b> and <i>italic</i> there are elements which usually have an equivalent

visual rendering but are more semantic in nature, namely <strong>strong

emphasis</strong> and <em>emphasis</em> respectively .Hypertext markup Links

parts of the document to other documents.

The Document Type Definition:

In order to specify which version of the HTML standard they

conform to, all HTML documents should start with a Document Type Declaration

(informally, a "DOCTYPE"), which makes reference to a Document Type Definition

(DTD). For example:

<!DOCTYPE html ----">

Publishing HTML with HTTP:

The World Wide Web is primarily composed of HTML documents

transmitted from a web server to a web browser using the HyperText Transfer Protocol

(HTTP). However, HTTP can be used to serve images, sound and other content in

addition to HTML. To allow the web browser to know how to handle the document it

received, an indication of the file format of the document must be transmitted along with

the document.

92

Page 93: Embedded Webserver-1

EMBEDDED WEB SERVER

HYPERTEXT TRANSFER PROTOCOL

HyperText Transfer Protocol (HTTP) is the method used to transfer or

convey information on the World Wide Web. The original purpose was to provide a way

to publish and receive HTML pages.

Development of HTTP was coordinated by the World Wide Web

Consortium and working groups of the Internet Engineering Task Force. HTTP is a

request/response protocol between clients and servers. The originating client, such as a

web browser, spider, or other end-user tool, is referred to as the user agent. The

destination server, which stores or creates resources such as HTML files and images, is

called the origin server. In between the user agent and origin server may be several

intermediaries, such as proxies, gateways, and tunnels.

A HTTP client initiates a request by establishing a Transmission Control

Protocol (TCP) connection to a particular port on a remote host (port 80 by default; see

List of well-known ports (computing)). A HTTP server listening on that port waits for the

client to send a Request Message.

Upon receiving the request, the server sends back a status line, such as

"HTTP/1.1 200 OK", and a message of its own, the body of which is perhaps the

requested file, an error message, or some other information.

Resources to be accessed by HTTP are identified using Uniform Resource Identifiers

(URIs) (or, more specifically, URLs) using the http: or https: URI schemes.

Request Message:The request message consists of the following:

Request line, such as GET /images/logo.gif HTTP/1.1, which requests the file

logo.gif from the /images directory .

Headers, such as Accept-Language: en.

93

Page 94: Embedded Webserver-1

EMBEDDED WEB SERVER

An empty line .

An optional message body.

The request line and headers must all end with CRLF (i.e. a carriage return

followed by a line feed). The empty line must consist of only CRLF and no other

whitespace.Some headers are optional, while others (such as Host) are required by the

HTTP/1.1 protocol.

Request methods:

HTTP defines eight methods indicating the desired action to be performed

on the identified resource.

GET – Requests a representation of the specified resource. By far the most

common method used on the Web today.

HEAD – Asks for the response identical to the one that would correspond to a

GET request, but without the response body.

POST – Submits user data (e.g. from a HTML form) to the identified resource.

The data is included in the body of the request.

PUT – Uploads a representation of the specified resource.

DELETE – Deletes the specified resource (rarely implemented).

TRACE – Echoes back the received request, so that a client can see what

intermediate servers are adding or changing in the request.

OPTIONS – Returns the HTTP methods that the server supports. This can be

used to check the functionality of a web server.

CONNECT – For use with a proxy that can change to being an SSL tunnel.

94

Page 95: Embedded Webserver-1

EMBEDDED WEB SERVER

HTTP versions:

HTTP differs from other TCP-based protocols such as FTP, because

HTTP has different protocol versions:

0.9 Deprecated. Was never widely used. Only supports one command, GET. Does

not support headers. Since this version does not support POST the client can't

pass much information to the server.

HTTP/1.0 Still in wide use, especially by proxy servers. Allows persistent

connections (alias keep-alive connections, more than one request-response per

TCP/IP connection) when explicitly negotiated; however, this only works well

when not using proxy servers.

HTTP/1.1 Current version, persistent connections enabled by default and works

well with proxies. Also supports request pipelining, allowing multiple requests to

be sent at the same time, allowing the server to prepare for the workload and

potentially transfer the requested resources more quickly to the client.

In HTTP/0.9 and HTTP/1.0, a client sends a request to the server, the server

sends a response back to the client. After this, the connection is closed. HTTP/1.1,

however, supports persistent connections. This enables the client to send a request and

get a response, and then send additional requests and get additional responses. The TCP

connection is not released for the multiple additional requests, so the relative overhead

due to TCP is much less per request. The use of persistent connection is often called keep

alive. It is also possible to send more than one (usually between two and five) request

before getting responses from previous requests. This is called pipelining.

95

Page 96: Embedded Webserver-1

EMBEDDED WEB SERVER

APPLICATIONS

Perfectly suited for applications like:

Bar Code Readers

Printers Point of Purchase Terminals

Attendance Recording

Access Control Systems Card Verification and Kiosks Medical.

Equipments Factory Floor Automation Scanning Devices

Security Systems etc.

ADVANTAGES

Easy C language program development and debugging.

Integrated Ethernet port for network connectivity.

Ideal for network enabling security ,and access system ,home automation and

industrial control

96

Page 97: Embedded Webserver-1

EMBEDDED WEB SERVER

CONCLUTION:

Embedded Web Server is developed to serve the static pages, to eliminate

the heavy traffic on main servrers.Usually the homepage of a site is maintained in the

ews. Ews can also serve the dynamic pages. Here rabbit 3000 module is used to develop

this project. It consists of rabbit 3000 and TCP/IP controller.

Embedded Web Server is designed by using light weight components. It

is a simple design and efficient, protable, high performance. In our project we are able to

design a server with the help of embedded concepts.

Next, by providing the IP address to that module, we are able to access

the web pages from any computer in the LAN. In this project static web pages will be

hosted by an Rabbit processor based embedded module, this module will be having a

ethernet interface through which it can be connected to internet.

97

Page 98: Embedded Webserver-1

EMBEDDED WEB SERVER

]FUTURE ENHANCEMENTS

Embedded devices

Mobile browsers

Today/Tomorrow

98

Page 99: Embedded Webserver-1

EMBEDDED WEB SERVER

BIBILOGRAPHY

BOOKS

1. TCP / IP PROTOCOL SUITE By BEHROUZ A FOROUZAN

2. COMPUTER NETWORKS By A.S. TANENBAUM

3. EMBEDDED SYSTEMS DESIGN USING THE RABBIT 3000 PROCESSOR

By KAMAL HYDER, BOB PERRIN

WEB SITES

1. WWW.RABBITSEMICONDUCTOR.COM

2. WWW.WIKEPEDIA.COM

3. WWW.ZWORLD.COM

99

Page 100: Embedded Webserver-1

EMBEDDED WEB SERVER

RCM 3700 MODULE

100

Page 101: Embedded Webserver-1

EMBEDDED WEB SERVER

Today/Tomorrow

101

Page 102: Embedded Webserver-1

EMBEDDED WEB SERVER

102

Page 103: Embedded Webserver-1

EMBEDDED WEB SERVER

103

Page 104: Embedded Webserver-1

EMBEDDED WEB SERVER

104

Page 105: Embedded Webserver-1

EMBEDDED WEB SERVER

105

Page 106: Embedded Webserver-1

EMBEDDED WEB SERVER

106

Page 107: Embedded Webserver-1

EMBEDDED WEB SERVER

107

Page 108: Embedded Webserver-1

EMBEDDED WEB SERVER

108

Page 109: Embedded Webserver-1

EMBEDDED WEB SERVER

109

Page 110: Embedded Webserver-1

EMBEDDED WEB SERVER

110

Page 111: Embedded Webserver-1

EMBEDDED WEB SERVER

111

Page 112: Embedded Webserver-1

EMBEDDED WEB SERVER

112

Page 113: Embedded Webserver-1

EMBEDDED WEB SERVER

113

Page 114: Embedded Webserver-1

EMBEDDED WEB SERVER

114

Page 115: Embedded Webserver-1

EMBEDDED WEB SERVER

115

Page 116: Embedded Webserver-1

EMBEDDED WEB SERVER

116

Page 117: Embedded Webserver-1

EMBEDDED WEB SERVER

117

Page 118: Embedded Webserver-1

EMBEDDED WEB SERVER

118

Page 119: Embedded Webserver-1

EMBEDDED WEB SERVER

119

Page 120: Embedded Webserver-1

EMBEDDED WEB SERVER

120

Page 121: Embedded Webserver-1

EMBEDDED WEB SERVER

121

Page 122: Embedded Webserver-1

EMBEDDED WEB SERVER

122

Page 123: Embedded Webserver-1

EMBEDDED WEB SERVER

123

Page 124: Embedded Webserver-1

EMBEDDED WEB SERVER

124

Page 125: Embedded Webserver-1

EMBEDDED WEB SERVER

125

Page 126: Embedded Webserver-1

EMBEDDED WEB SERVER

126

Page 127: Embedded Webserver-1

EMBEDDED WEB SERVER

127

Page 128: Embedded Webserver-1

EMBEDDED WEB SERVER

128

Page 129: Embedded Webserver-1

EMBEDDED WEB SERVER

129

Page 130: Embedded Webserver-1

EMBEDDED WEB SERVER

130

Page 131: Embedded Webserver-1

EMBEDDED WEB SERVER

131

Page 132: Embedded Webserver-1

EMBEDDED WEB SERVER

132

Page 133: Embedded Webserver-1

EMBEDDED WEB SERVER

133

Page 134: Embedded Webserver-1

EMBEDDED WEB SERVER

134

Page 135: Embedded Webserver-1

EMBEDDED WEB SERVER

135

Page 136: Embedded Webserver-1

EMBEDDED WEB SERVER

136

Page 137: Embedded Webserver-1

EMBEDDED WEB SERVER

137

Page 138: Embedded Webserver-1

EMBEDDED WEB SERVER

138

Page 139: Embedded Webserver-1

EMBEDDED WEB SERVER

139

Page 140: Embedded Webserver-1

EMBEDDED WEB SERVER

140

Page 141: Embedded Webserver-1

EMBEDDED WEB SERVER

141

Page 142: Embedded Webserver-1

EMBEDDED WEB SERVER

142

Page 143: Embedded Webserver-1

EMBEDDED WEB SERVER

143

Page 144: Embedded Webserver-1

EMBEDDED WEB SERVER

144

Page 145: Embedded Webserver-1

EMBEDDED WEB SERVER

145

Page 146: Embedded Webserver-1

EMBEDDED WEB SERVER

146

Page 147: Embedded Webserver-1

EMBEDDED WEB SERVER

147

Page 148: Embedded Webserver-1

EMBEDDED WEB SERVER

148

Page 149: Embedded Webserver-1

EMBEDDED WEB SERVER

149

Page 150: Embedded Webserver-1

EMBEDDED WEB SERVER

150

Page 151: Embedded Webserver-1

EMBEDDED WEB SERVER

151

Page 152: Embedded Webserver-1

EMBEDDED WEB SERVER

152

Page 153: Embedded Webserver-1

EMBEDDED WEB SERVER

153

Page 154: Embedded Webserver-1

EMBEDDED WEB SERVER

154

Page 155: Embedded Webserver-1

EMBEDDED WEB SERVER

155

Page 156: Embedded Webserver-1

EMBEDDED WEB SERVER

156

Page 157: Embedded Webserver-1

EMBEDDED WEB SERVER

157

Page 158: Embedded Webserver-1

EMBEDDED WEB SERVER

158

Page 159: Embedded Webserver-1

EMBEDDED WEB SERVER

159

Page 160: Embedded Webserver-1

EMBEDDED WEB SERVER

160

Page 161: Embedded Webserver-1

EMBEDDED WEB SERVER

161

Page 162: Embedded Webserver-1

EMBEDDED WEB SERVER

162

Page 163: Embedded Webserver-1

EMBEDDED WEB SERVER

163

Page 164: Embedded Webserver-1

EMBEDDED WEB SERVER

164

Page 165: Embedded Webserver-1

EMBEDDED WEB SERVER

165

Page 166: Embedded Webserver-1

EMBEDDED WEB SERVER

166

Page 167: Embedded Webserver-1

EMBEDDED WEB SERVER

167

Page 168: Embedded Webserver-1

EMBEDDED WEB SERVER

168

Page 169: Embedded Webserver-1

EMBEDDED WEB SERVER

169

Page 170: Embedded Webserver-1

EMBEDDED WEB SERVER

170

Page 171: Embedded Webserver-1

EMBEDDED WEB SERVER

171

Page 172: Embedded Webserver-1

EMBEDDED WEB SERVER

172

Page 173: Embedded Webserver-1

EMBEDDED WEB SERVER

173

Page 174: Embedded Webserver-1

EMBEDDED WEB SERVER

174

Page 175: Embedded Webserver-1

EMBEDDED WEB SERVER

175

Page 176: Embedded Webserver-1

EMBEDDED WEB SERVER

176

Page 177: Embedded Webserver-1

EMBEDDED WEB SERVER

177

Page 178: Embedded Webserver-1

EMBEDDED WEB SERVER

178

Page 179: Embedded Webserver-1

EMBEDDED WEB SERVER

179