Customizable HTTP Server with Concurrency & Document Size (CSCE 515 Project 3) - Prof. W. , Study Guides, Projects, Research of Computer Science

A university computer science project where students are required to develop an http server that returns custom-sized html documents based on the requested uri. The server must provide concurrency using either a forking or pre-threaded method, and take no more than two command-line arguments. The server should return an http response with the appropriate headers and send error messages for invalid uris. Students are encouraged to use the apachebench program for testing and debugging. The project is worth 15 points towards the final grade.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 09/02/2009

koofers-user-jyi
koofers-user-jyi ๐Ÿ‡บ๐Ÿ‡ธ

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSCE 515 Computer Network Programming
Project 3, Due Date: November 24, 2:30pm, 2008
Undergraduate level
In this project, you are required to write an HTTP server that returns a document whose size is determined by the
requested URI. Your server will provide concurrency with TWO different methods.
More specifically, your server needs to achieve the following requirements:
1. (4 points) Your HTTP server must be capable of providing concurrency in 2 different ways, either a forking
server (new child per request), or a pre-threaded server. A command line option is used to select whether a forking
server or the threaded server should be used for this execution.
2. (1 point) Your program should take at most two arguments, the port number that your server should bind to,
or/and the number of threads that should be created when your server initially starts.
If there is only one augment, the port number is found, your server should be a forking server.
If a second command line argument is found, your server should treat this as the number of threads to be used for a
pre-threaded server.
Usage: pj3 portnum [num_threads]
./pj3 1234 starts forking server on port 1234
./pj3 3333 100 starts pre-threaded server on port 3333 with 100 threads
3. (4 points) Your server should return a HTML document. The size of the document is determined by the requested
URI (any size between 100 and 20,000bytes). Your server should remove the leading slash โ€˜/โ€™ from the URI and
extract the resulting string as an integer (in decimal) that specified the size of the document to be sent to the client.
For example, for the following request line
GET /2000 HTTP/1.0
Your server should send back a HTML document that contains exactly 2,000 bytes of text, e.g. when the client save
the document on the local disk, the file size should be 2,000 bytes. The returned HTML document should follow the
proper format, but the content of the document can be anything. The minimum size requested to create a valid
document (with HTML, HEAD and BODY tags) will be 100 bytes. So if the requested URI asks for a size less than
100 bytes, your server should return a document with 100 bytes. As an example, the following document is 100
bytes long:
<HTML>
<HEAD>
<TITLE>100 bytes of fun</TITLE>
</HEAD>
<BODY> a a a a a a a a a a a a </BODY>
</HTML>
4. (2 point) Your server must send back an HTTP response line, a Content-Type header and a Content-Length
header. None of these count towards the size of the document.
pf3

Partial preview of the text

Download Customizable HTTP Server with Concurrency & Document Size (CSCE 515 Project 3) - Prof. W. and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CSCE 515 Computer Network Programming

Project 3, Due Date: November 24, 2:30pm, 2008

Undergraduate level

In this project, you are required to write an HTTP server that returns a document whose size is determined by the

requested URI. Your server will provide concurrency with TWO different methods.

More specifically, your server needs to achieve the following requirements:

1. (4 points) Your HTTP server must be capable of providing concurrency in 2 different ways, either a forking

server (new child per request), or a pre-threaded server. A command line option is used to select whether a forking

server or the threaded server should be used for this execution.

2. (1 point) Your program should take at most two arguments, the port number that your server should bind to,

or/and the number of threads that should be created when your server initially starts.

If there is only one augment, the port number is found, your server should be a forking server.

If a second command line argument is found, your server should treat this as the number of threads to be used for a

pre-threaded server.

Usage: pj3 portnum [num_threads]

./pj3 1234 starts forking server on port 1234

./pj3 3333 100 starts pre-threaded server on port 3333 with 100 threads

3. (4 points) Your server should return a HTML document. The size of the document is determined by the requested

URI (any size between 100 and 20,000bytes). Your server should remove the leading slash โ€˜/โ€™ from the URI and

extract the resulting string as an integer (in decimal) that specified the size of the document to be sent to the client.

For example, for the following request line

GET /2000 HTTP/1.

Your server should send back a HTML document that contains exactly 2,000 bytes of text, e.g. when the client save

the document on the local disk, the file size should be 2,000 bytes. The returned HTML document should follow the

proper format, but the content of the document can be anything. The minimum size requested to create a valid

document (with HTML, HEAD and BODY tags) will be 100 bytes. So if the requested URI asks for a size less than

100 bytes, your server should return a document with 100 bytes. As an example, the following document is 100

bytes long:

100 bytes of fun

a a a a a a a a a a a a

4. (2 point) Your server must send back an HTTP response line, a Content-Type header and a Content-Length

header. None of these count towards the size of the document.

5. (1 points) Your server should send back an HTTP response line that indicates an error if the requested URI is not

a number, or is less than 100, or is greater than 20,000.

The ApacheBench program is available for debugging or testing your server. This program can generate multiple

HTTP requests to your server with any desired level of concurrency. The program executable is installed on the CS

(ashley.cse.sc.edu) as /usr/sbin/ab, you can get usage information by โ€˜/usr/sbin/ab โ€“hโ€™. Below is sample usage of the

ab program to give you an idea of what it does. The test run below sends 100 requests to www.cse.sc.edu for the

URI ~wyxu/foo.html, sending 10 requests at a time (10 clients at a time).

> /usr/sbin/ab -n 100 -c 10 www.cse.sc.edu/~wyxu/foo.html This is ab implemented using the ApacheBench Perl API, version 0. Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/ Copyright (c) 2000-2002 Ling Wu, Adi Fairbank, http://www.certsite.com/ Copyright (c) 2003-2004 Adi Fairbank, http://adiraj.org/

Server Software: Apache

Server Hostname: www.cse.sc.edu Server Port: 80

Document Path: /~wyxu/foo.html Document Length: 409 bytes

Concurrency Level: 10 Time taken for tests: 0.318 seconds Sent requests: 100 Completed requests: 100 Failed requests: 0 Total transferred: 66400 bytes HTML transferred: 40900 bytes Requests per second: 314. Transfer rate: 203.911163522013 kb/s received

Connnection Times (ms) min avg max Connect: 1 3.34 17 Response: 6 29.05 110

Warning messages from ab(): [Warn:] None.

HTTP request: GET /~wyxu/foo.html HTTP/1.

User-Agent: ApacheBench-Perl/0.

Host: www.cse.sc.edu

Accept: /

Response headers: HTTP/1.1 200 OK

Date: Wed, 07 Nov 2007 23:19:12 GMT

Server: Apache

Last-Modified: Wed, 07 Nov 2007 03:06:29 GMT