kolej universiti teknologi tun hussein...

24

Upload: trinhtram

Post on 13-Mar-2019

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information
Page 2: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information
Page 3: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONN

BORANG PENGESAHAN STATUS TESIS·

JUDUL: EMBEDDED WEB SERVER

SESI PENGAJIAN: 200412005

Saya MUHAMMAD SHUKRI BIN AHMAD ( 801208-14-5007) (HURUF BESAR)

mcngaku mcmbcnarkan tcsis (Sarjana MudaiSarjana !Doktor Falsafah)* ini disimpan di Perpustakaan dcngan syarat-syarat kcgunaan scperti berikut:

I. Tcsis adalah hakmilik Kolej Universiti Teknologi Tun Hussein Onn. 2. Perpustakaan dibenarkan mcmbuat salinan untuk tujuan pcngajian sahaja. 3. Perpustakaan dibenarkan membuat salinan tcsis ini sebagai bahan pcrtukaran antara institusi

pcngajian tinggi.

4. **Sila tandakan (" )

SULIT

TERHAD

(Mcngandungi maklumat yang berdarjah keselamatan atau kepentingan Malaysia scpcrti yang termaktub di dalam AKTA RAHSIA RASMI 1972)

(Mcngandungi maklumat TERHAD yang telah ditcntukan olch organisasilbadan di mana pcnyclidikan dijalankan)

" TIDAK TERHAD

Disahkan oleh:

(T

Alamat Tctap:

NO. 21 JALAN 6/5C, 40000 SHAH ALAM,

SELANGOR

PROF. MADYA. AWTARSINGH ( Nama Pcnyelia )

Tarikh: 9 OCTOBER 2004 Tarikh:: 9 OCTOBER 2004

CATATAN: * **

Potong yang tidak bcrkcnaan. Jika tesis ini SULlT atau TERHAD, sila lampirkan surat daripada pihak bcrkuasalorganisasi bcrkcnaan dengan menyatakan sckali tempoh tcsis ini pcrlu dikelaskan scbagai atau TERHAD. Tcsis dimaksudkan sebagai tcsis bagi Ijazah doktor FaIsafah dan Sarjana secara Pcnyclidikan, atall disertasi bagi pengajian secara kcrja kurslls dan penyelidikan, atau Laporan Projek Sarjana Mllda (PSM).

Page 4: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

"I hereby acknowledge that the scope and quality of this thesis is qualified for the

award of the Master Degree of Electrical Engineering"

Signature :~. =--

Name : PROF. MADYA AWTAR SINGH

Date : 9 OCTOBER 2004

Page 5: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

EMBEDDED WEB SERVER

MUHAMMAD SHUKRI BIN AHMAD

This thesis is submitted as partial fulfillment of the requirements for the award of the

Master Degree of Electrical Engineering

Faculty of Electrical & Electronic Engineering

Kolej Universiti Teknologi TW1 Hussein Onn

OCTOBER, 2004

Page 6: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

"All the trademark and copyrights use herein are property of their respective owner.

References of information from other sources are quoted accordingly; otherwise the

information presented in this report is solely work of the author."

Signature

Author : MUHAMMAD SHUKRI BIN AHMAD

Date : 9 OCTOBER 2004

11

Page 7: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

III

Por my 6efin;ea famify

Page 8: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

ACKNOWLEDGEMENT

I am deeply grateful for the help that I received from my supervisor, Associate

Professor Awtar Singh, during the development of this project. His willingness to help

and ideas has kept me on my toes from the beginning stage of this project until the

completion of this thesis.

I would also like to extend my gratitude to all lecturers that has given me all the

basic needed for completing this project, and also to my classmates and friend for their

encouragement and help.

IV

I could not have done this project without the unconditional support, active

encouragement, complete cooperation, and honest sacrifice by my family. To appreciate

their immense contribution, this thesis is lovingly dedicated to them.

Page 9: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

v

ABSTRAK

Dilihat dari sudut teknologi, internet berkemungkinan besar merupakan perkara

yang terhebat berIaku terhadap kita selepas revolusi perindustrian. Ia membawa kita

kepada era letusan maklumat. Internet telah menjadi sebahagian daripada hidup kita

seharian melalui pelbagai alatan di pejabat dan rumah yang disambungkan ke internet.

Faedah yang diperolehi adalah tidak terbatas. Bayangkan situasi di mana kita boleh

meggunakan alatan eletrik secara kawalanjauh atau menggunakan pengantaramuka

interaktifuntuk mengawal perkakasan rumah. Ini membolehkan kita menjalankan

pelbagai penyenggaraan perkakasan dan diagnostic daripada sebarang temp at di dunia

yang mempunyai akses ke internet. Pengantaramuka web ini memberikan faedah kepada

pengguna dan juga kepada pembuat perkakasan. laporan ini membincangkan tentang

perkara-perkara yang perIu diambil kira ketika mereka bentuk sebuah system kawalan

berasaskan pelayan web embedded. Sebuah sistem akan dibangunkan menggunakan

PICDEM.net Development Board, yang membolehkan pengguna mengawal dan

perkakasan secarajarak memantaujauh.

Page 10: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

VI

ABSTRACT

In term of technology, internet must be the greatest thing to happen to mankind

after industrial revolution. It has led us into the age of information explosion. Internet is

becoming part of our everyday life through the various devices which are connected to

internet at our home and work. The benefits are endless. Consider the situation where

we can 'use' equipment from a remote location or work using an interactive user

interface on our household device. This enables us to perform device management and

even appliance diagnostics from any where in the world where you have the internet

access. Thus web interfaces bring benefits to end-users as well as to manufacturers. This

report discussed the design consideration of a web server based control system. Using

PICDEM.net Development Board as a project, a system will be developed, allowing a

user to control and monitor device remotely.

Page 11: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

Vll

TABLE OF CONTENTS

CHAPTER TITLE PAGE

DECLARATION ii

DEDICATION iii

ACKNOWLEDGEMENT iv

ABSTRACT v

ABSTRAK vi

TABLE OF CONTENTS vii

LIST OF TABLES x

LIST OF FIGURES xi

GLOSSARY OF ABBREVIATIONS xiii

LIST OF APPENDIX xiv

CHAPTER I: INTRODUCTION

1.1 Project Background 1

1.2 Problem Statement 3

1.3 Objective 4

1.4 Scope of Work 4

1.5 Project Motivation 5

Page 12: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

VIII

CHAPTER II: LITERATURE REVIEW

2.1 The Internet 6

2.1.1 Protocols 7

2.1.1.1 Tranmission Control Protocol (TCP) 7

2.1.1.2 Internet Protocol (IF) 11

2.1.1.3 Address Resolution Protocol 14

2.1.1.4 Internet Control Message Protocol (ICMP) 15

2.1.1.5 Dynamic Host Configuration Protocol (DHCP) 18

2.1.1.6 Hyper Text Transfer Protocol (HTTP) 19

2.1.2 Markup Language 20

2.1.2.1 Hyper Text Markup Language (HTML) 20

2.1.2.2 eXtensible Markup Language (XML) 22

2.1.3 Script 24

2.1.3.1 Common Gateway Interface (CGI) 24

2.1.3.2 JavaScript 27

2.2 Local Area Network (LAN) 29

2.2.1 Token Ring 29

2.2.2 Radio Modem 30

2.2.3 Ethernet 31

2.2.4 Fiber Optic Network Technologies 34

2.2.5 Wireless 36

2.3 Embedded Web Server 37

2.3.1 WebZerver from Microtest 39

2.3.2 The Dawning Secure Network Interface (SNI) 40

2.3.3 Stallion Technology Easy Server II 43

2.3.4 Pro WeblHTTP Server 45

Page 13: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

CHAPTER III: METHODOLOGY

3.1 Introduction

3.2 The PICDEM.net Board

3.3 PIC Programming

3.2.1 The Main Program

3.2.2 Ethernet Module

3.2.3 Reduced TCP/IP Stack Module

3.4 User Interface

3.4.1 Main Frame

3.4.2 Bottom Frame

CHAPTER IV: EXAMPLE APPLICATION

4.1 The Goal

4.2 Hooking up the Board

4.3 Establishing Connection

4.4 Using the User Interface

CHAPTER V: CONCLUSION AND RECOMMENDATION

5.1 Achievement

5.2 Recommendation

48

49

51

52

54

56

59

60

63

64

65

66

67

69

70

IX

Page 14: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

LIST 0 F TABLE

Table number Title Page

2.1 TCP flags 9

2.2 TCP port and services 10

2.3 ICMP type 17

2.4 ICMP code 18

Page 15: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

Xl

LIST OF FIGURE

Figure number Title Page

1.1 Basic Concept of a Web Server 2

1.2 The Project Block Diagram 4

2.1 TCP segment format 9

2.2 TCP connection process 11

2.3 IP datagram 12

2.4 ARP header 14

2.5 ICMP header 16

2.6 Various ICMP type 16

2.7 HTMLcode 21

2.8 HTMLbeing displayed in a browser 22

2.9 Difference between HTML and XML 23

2.10 Operation of CGI 26

2.11 Operation of J avaScript 28

2.12 MAC frame header 33

2.13 Fiber optic network 34

2.14 Using SNI as a real-time weather station monitoring 41

device

2.15 Easy Server II 43

2.16 Example access of embedded web server found in 44

easy server II

Page 16: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

Xll

Figure number Title Page

2.17 Example use of API to display dynamic content 46

2.18 Example use of Pro Web HTTP server 47

3.1 PICDEM.net feature 51

3.2 PICDEM.net Boards 51

3.3 The PIC program structure 53

3.4 The ISA bus cycle 55

3.5 The index page 60

3.6 The motor control interface 61

3.7 The analog output interface 62

3.8 The switch output interface 62

3.9 Input display 63

4.1 Hooking the embedded web server to LAN 65

4.2 Pinging the embedded web server 66

4.3 User interface using a web browser 67

Page 17: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

API

ARP

COl

CPU

CSMAJCD

DHCP

FDDI

FIN

FTP

HTML

HTTP

ICD

ICMP

IP

LAN

MAC

RAM

ROM

SMTP

TCP

WWW

GLOSSARY OF ABBREVIATIONS

Application programming interface

Address resolution protocol

Common gateway interface

Central processing unit

Carrier sense multiple access with collision detection

Dynamic host configuration protocol

Fiber distributed data interface

Finish

File transfer protocol

Hypertext markup language

Hypertext transfer protocol

In-circuit debugger

Internet control message protocol

Internet protocol

Local area network

Medium access control

Random access memory

Read only memory

Simple mail transfer protocol

Transmission control protocol

World wide web

X III

Page 18: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

LIST OF APPENDIX

Title

A. TCP/IP Networking Protocols

B. MPLAB lCD & 16F877 tutorial

XIV

Page

73

78

Page 19: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

CHAPTER I

INTRODUCTION

1.1 Project Background

A web server is basically a program that can respond to requests from web

browsers. The server listens to a port. A web browser then sends a request to the server

(1) see Figure l.1. The request contains the name and location of the wanted file

(Uniform Resource Location, URL). The server receives the request and tries to interpret

the request (2). If the web server can find the requested file it will return it to the web

browser (3). Otherwise, an error message will be returned.

Page 20: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

2

-.:

Figure 1.1: Basic Concept of a Web Server

An embedded web server is a web server that has been designed to be included in

different kinds of small devices. It is an easy and well-defined way for infonnation

access. When designing an embedded web server there are some requirements to take

notice of. First of all it has to have a small memory footprint (> 1 00 kb is quite much).

Often the devices do not have a file system (hard drive), so it must be possible to store

the web content on ROM or to have the web pages created dynamically (created when

requested).

Embedded systems are integrated hardware and software systems implementing

dedicated functions, such as, electronic gadgets, communication devices, household

appliances and medical instruments. We are fast approaching a point where there are

more microprocessor based systems than people on the planet. They are generally not

programmed by the users. In the Last few years there has been a significant demand for

remote monitoring and control of embedded systems. The most convenient way to do

this is to connect the embedded system to the internet, replacing traditional serial user

interfaces, and allowing the use of familiar Web browsers from any desktop.

Page 21: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

Web browsers have become the default standard user interface to a variety of

applications. They have become omnipresent and they can run on various platforms

right from gigantic work stations to even almost hand phones. It allows end-users to

access Web-enabled applications from any location. Hence applied to embedded

systems, Web tec1mologies offer graphical user interfaces that are user friendly,

inexpensive, cross-platform, and network-ready. It also provides a means of remote

system monitoring and management.

By using an embedded Web server, developers can format and display the same

data with HTML and any standard browser. The user's response to the data can include

input to modify the embedded device's configuration. Moreover, communication with

the embedded application can use Ethernet or fast serial connections.

1.2 Problem Statement

3

The enormous growth of the internet has established itself in every comer of our

life, thus making it an indispensable tool to work with. As embedded systems become

more prevalent, the need for connectivity of these devices to the World Wide Web

becomes inevitable. The integration of the ubiquitous internet with embedded devices

brings an almost limitless possibility of application. Affordable monitoring and control

of real-time environments over the Internet is of importance to the general public, as

well as professionals.

Page 22: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

4

1.3 Objective

The project objectives are as follows:

• To determine the design consideration of an embedded web server system

• To make it possible to control and monitoring device remotely using this system

via LAN.

• To design sample application for this system

1.4 Scope of Work

The scope of the project is to design, implement and illustrate mechanisms

providing connectivity between an embedded system and the .internet.

.Dl~l · ~. ..)

Client Computer

. " LocOJ' .l\ro '; l NHI ..... 'uk

, , .

Embedded Web Server

> t6~7":~~;:(I)f1 . I _

I Cantroila"

:.- J _

Figure 1.2: The Project Block Diagram

Page 23: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

5

1.5 Project Motivation

The motivation of this project is the increasing importance of home networking.

More and more intelligent devices are being used. By connecting these devices to

internet there are so many advantages. Also this project is the continuation of my degree

project but replacing the server computer with an embedded web server.

Page 24: KOLEJ UNIVERSITI TEKNOLOGI TUN HUSSEIN ONNeprints.uthm.edu.my/1111/1/24_Pages_from_EMBEDDED_WEB_SERVER.pdf · laporan ini membincangkan tentang ... It has led us into the age of information

CHAPTER II

LITERATURE REVIEW

2.1 The Internet

Internet is an astonishing technology because the internet created a new space in

our physical world. This is due to the success of the World Wide Web (WWW) ancl its

common application. In this section of literature review, we will look at the common

protocol, markup language and script used by the internet.