CS 3733 Operating Systems, Fall 1999 Assignment 5


Warning: This is not for the current semester.


Due Tuesday, November 30 and Tuesday, December 7, 1999 by the start of class

This assignment consists of several parts.
Put each part of the assignment in a new directory so that you keep the old parts around.
These can then be graded separately. Be prepared to demonstrate your programs on the due date. You will generate lint output for each part. Use only the -x option of lint and make sure you understand all of the warnings generated.

For this assignment you will need to use a port number which nobody else will be using. Each student is assigned a set a 10 port numbers for this assignment. The list can be found here. You may need more than one port number while testing because a port used by a server may not be available again for a few minutes after the server exits.

Part 1: Get the sample code
Obtain the client, server, and UICI code from /usr/local/courses/cs3733/fall1999/assign05, compile and link the client and server and make sure they work. Also print out a copy of the cover sheet from /usr/local/courses/cs3733/fall1999/cover5.ps,

Part 2: Web redirection
You are going to write a program which will allow browsers to point to the machine you are running on and redirect requests to another web server.

Here is how it will work.

You will be assigned a port number, p. You will write a concurrent UICI server which will listen on port p. When a connection request is made to port p, you will make a connection request to port 80 (the web server port) on ringer (our web server machine) and fork a child to handle the communication. The child will then monitor input on two communication channels, the one corresponding to port p on the local machine and the one corresponding to port 80 on ringer. Any input coming in on one port will be sent to the other. If either connection is closed, or an error occurs, both communication channels should be closed and the child should exit, but the parent should continue listening for additional connections.

Every time a connection is made, a message should be sent to standard error indicating the name of the machine the connection came in on. When the connection is closed, another message should print out the number of bytes that was transferred in each direction.

Test your program by having a browser point to your machine and try to access your course web page. If your web page is on ringer (www.cs.utsa.edu) in ~yourname/yourdir, and you are running on machine host, using port p, use the following URL: http://host:p/~yourname/yourdir

Your web page should come up on your browser.

Part 3: Gathering statistics

Modify your server from part 2 so that it keeps statistics on the number of connections made (easy), the total number of bytes transferred to it from client requests, and the total number of bytes transferred back to the client (harder).

You must devise a method for keeping track of the total number of bytes transmitted in each direction. This must be communicated by the child to a single process for tabulation.

Print the statistics to standard error each time the values change.

Write a short paragraph describing the method you will use to gather the statistics. Since there are variables that are being updated in response to concurrent processes, state clearly any issues of synchronization which are important to consider and how your methods handles these issues. Send me an email containging this paragraph before class on Tuesday, November 30. Also, hand in a hard copy of this paragraph in class on that day. Also include the paragraph, modified if necessary, with what you hand in on December 7.

Part 4: Control of statistics printing.

Modify your server from Part 3 so that it displays a PID when it starts. Modify the statistics printing so that it does not automatically display when the data changes. Instead, it will display the information when the server receives a SIGUSR1 signal. Make sure that the receipt of the signal does not affect the operation of the server.

Test your program by using kill to send a SIGUSR1 signal to your program from another window.


Part 5: Web redirection with monitoring. This part is optional.

Rewrite the myparser function from assignment 1 so that it is reentrant. The new parser will be called myparser_r and have the following prototype:
void myparser_r(char x, char *prefix, char *buf);
where prefix is a string which is printed at the start of each line of output, and buf is a buffer of size at least 512 to hold what was the static data needed by the original myparser. You can restrict the lines of printing characters in myparser_r to size 256. Make sure that this program sends all output to standard output and nothing to standard error. You should also modify it so the the test for the Content-Length string is not case sensitive.

Start with Part 2 of this assignment, and modify it so that all data also passes through the reentrant version of the parser from assignment 1.

Have your child process which monitors the two network connections create two buffers, one for the upstream data and one for the downstream data. The upstream data flows from the web browser to your program and the downstream data flows from the web browser to your program. When calling the parser, use a short prefix string containing the process ID of the process and either the word upstream or downstream. This will allow you to tell where the data is coming from.