Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Network & Security Expert

IMPORTANT: The web server should be able to serve HTTP files only. You will not need to implement the directory listing and CGI-bin.

Purpose

The objective is to implement a HTTP server that will allow a HTTP client (a web browser like FireFox or Internet Explorer ) to connect to it and download files.

HTTP Protocol Overview

A HTTP client issues a 'GET' request to a server in order to retrieve a file. The general syntax of such a request is given below :

GET HTTP/1.0

{ }*

where :

  • stands for a whitespace character and,
  • stands for a carraige return-linefeed pair. i.e. a carriage return (ascii character 13) followed by a linefeed (ascii character 10).
  • is also represented as "\n\n".
  • gives us the name of the file requested by the client. This could be just a backslash ( / ) if the client is requesting the default file on the server.
  • { }* contains useful ( but not critical ) information sent by a client. These can be ignored for this project. Note that this part can be composed of several lines each seperated by a .
  • * - kleene star // regular expressions

Finally, observe that the client ends the request with two carriage return linefeed character pair:

The function of a HTTP server is to parse the above request from a client, identify the file being requested and send the file across to the client. However, before sending the actual document, the HTTP server must send a response header to the client. The following shows a typical response from a HTTP server when the requested file is found on the server:

HTTP/1.0 200 Document follows

Server:

Content-type:

{ }*

where :

  • identifies the manufacturer/version of the server. For this project, I will tell this in an email very soon but it should not affect the rest of the coding.
  • indicates to the client, the type of document being sent. This should be "text/html" for an html document, "image/gif" for a gif file, "text/plain" for plain text, etc.
  • {}* as before, contains some additional useful header information for the client to use. These may be ignored for this project.
  • is the actual document requested. Observe that this is separated from the response headers be two carraige return - linefeed pairs.

If the requested file cannot be found on the server, the server must send a response header indicating the error. The following shows a typical response:

HTTP/1.0 404 File Not Found

Server:

Content-type:

where :

  • indicates the type of document (i.e. error message in this case) being sent. Since you are going to send a plain text message, this should be set to text/plain.
  • is a human readable description of the error in plain text/html format indicating the error (e.g. Could not find the specified URL. The server returned an error).

Procedure and Algorithm Details

Stage 0:

The source of an example time server program called daytime-server are provided:

gunzip lab5-src.tar.gz

tar -xvf lab5-src.tar

Then build the server by typing make. Run the server by typing daytime-server without arguments to get information about how to use the server. Run the server and read the sources to see how it is implemented. Some of the functionality of the HTTP server that you will implement is already available in this server.

Stage 1:

Basic Server

You will implement an iterative HTTP server that implements the following basic algorithm:

  • Open Passive Socket.
  • Do Forever
  • Accept new TCP connection
  • Read request from TCP connection and parse it.
  • Frame the appropriate response header depending on whether the URL requested is found on the server or not.
  • Write the response header to TCP connection.
  • Write requested document (if found) to TCP connection.
  • Close TCP connection

The server that you will implement at this stage will not be concurrent, i.e., it will not serve more than one client at a time (it queues the remaining requests while processing each request). You can base your implementation on the example server given in [1] . The server should work as specified in the overview above. Make a copy of the daytime server and name it "myhttpd.cpp". Add the rules to the Makefile to build it.

Adding Concurrency

You will also add concurrency to the server. You will implement three concurrency modes. The concurrency mode will be passed as argument. The concurrency modes you will implement are the following:

-f :  Create a new process for each request

In this mode your HTTP server will fork a child process when a request arrives. The child process will process this request while the parent process will wait for another incoming request. You will also have to prevent the accumulation of inactive zombie processes. You can base your implementation on the server given in [3]

-t : Create a new thread for each request

In this mode your HTTP server will create a new thread to process each request that arrives. The thread will go away when the request is completed.

-p:  Pool of threads

In this mode your server will put first the master socket in listen mode and then it will create a pool of 5 threads where each thread will execute a procedure that has a while loop running forever which calls accept() and dispatches the request. The idea is to have an iterative server running in each thread. Having multiple threads calling accept() at the same time will work but it creates some overhead under Solaris (See [4]). To avoid having multiple threads calling accept() at the same time, use a MUTEX lock around the accept() call.

The format of the command should be:  

myhttpd [-f|-t|-p] []

 

If no flags are passed the server will be an iterative server like in the Basic Server section. If is not passed, you will choose your own default port number. Make sure it is larger than 1024 and less than 65536.

URL to File Mapping

In Apache and other web  servers, the mapping from URL documents to directories in the file system is done through a configuration file. In your project you will do this mapping programatically in the following way:

If document is icons/document in the URL, then it will serve the document from http-root-dir/icons/document.

If the document is cgi-bin/script, then your server will execute the scrip in http-root-dir/cgi-bin.

Otherwise, the document requested will be served from http-root-dir/htdocs. The document could be a subdirectory or a file in a subdirectory in htdocs.

IMPORTANT: A URL for your server should not contain http-root-dir or htdocs in it.

IMPORTANT: Make sure that a user should not be able to request/browse files above the htdocs/ cgi-bin/ or icons/ directories. You can use the "realpath" function to translate paths with ".." and other relative paths to absolute paths.

IMPORTANT: The default page when requesting http://host:port should be the index.html in htdocs.

Make sure that your server uses the http-root-dir and it loads by default the index.html from this directory. Test the simple, complex test.

Write a short README file that includes:

        a) Features in the handout that you have implemented av

        b) Features in the handout that you have not implemented

        c) Extra features

Write your program in a directory called lab5-src. Make sure that your server can be built by typing "make".

IMPORTANT: Do not include the http-root-dir in your submitted files.

Computer Network & Security, Computer Science

  • Category:- Computer Network & Security
  • Reference No.:- M9523532

Have any Question?


Related Questions in Computer Network & Security

It networking assignment - networking project areamajor lab

IT Networking Assignment - Networking Project Area Major Lab Scenario - Instructions This lab has a time limit of one term The lab must be completed by individual students, and the completed assessment returned to the as ...

If a router is attached to a network with a base ip address

If a router is attached to a network with a base IP address of 198.10.0.0/20 and receives a packet addressed to 198.10.10.144, answer the following questions: a. What is the network mask used by the router? (in dotted de ...

What comparison of means test was used to answer the

What comparison of means test was used to answer the question I need it now is there a relationship between parents highest level of education and socioeconomic status\need the entire script

You need to prepare packet tracer fileattached pdf contains

You need to prepare packet tracer file attached pdf contains topology and required configurations and assigned ip address. In packet tacer file you need to include banner, router and switches. 1. VLSM Design a) As first ...

Final project incident response exercise amp reportyour

Final Project: Incident Response Exercise & Report Your Task You have been assigned to work incident clean-up as part of the Sifers-Grayson Blue Team. Your task is to assist in analyzing and documenting the incident desc ...

Security challenges in emerging networksassignment

Security Challenges in Emerging Networks Assignment Description The purpose of this assignment is to develop skills to independently think of innovation. In this assignment students will first learn how to develop knowle ...

Below are the supply and demand schedules for fresh coffee

Below are the supply and demand schedules for fresh coffee in Vancouver: Price ($/cup) Quantity Demanded  (cups/day) Quantity Supplied (cups/day) 1 440 330 2 415 360 3 390 390 4 365 420 5 340 450 6 315 480 7 290 510 a. W ...

Question a signal travels through an amplifier and its

Question : A signal travels through an amplifier, and its power increased and becomes doubled. Then calculate amplification for this condition 2 Discuss about the TCP/IP PROTOCOL SUITE and Principles of Protocol Layering ...

Two countries australia and france have their interest

Two Countries Australia and France have their interest rates to be 8% and 2 %, respectively. If their currencies trade according to 2 Australian $s buy one euro in the spot market, what will their future spot rate be in ...

Consider the following series of paymentsyear 0 20year 1

Consider the following series of payments: Year 0: 20 Year 1: 30 Year 2: 40 Year 3: 10 Year 4: 5 Using an interest rate of 10%: a. What is the present value of this series of payments? b. What is the future value of this ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As