CS 3733 Operating Systems, Fall 2002 Assignment 5


Due Tuesday, December 3.
You may work on this assignment until Tuesday, December 3, 2002, at 12:30 PM.
The assignment must be finished at this time with no 12-hour grace period.
All assignments must be completed by 12:30 PM on December 3.
On December 3 we will meet in the lab and the assignments will be check at that time.


In this assignment you will be writing a proxy server with limited monitoring capability using the monitoring programs you wrote for Assignment 1 and finished in Assignment 4.

You will each need to use port numbers that will not conflict with others using the system. Students have been assigned 10 consecutive port numbers for this assignment, but you will need to use only 1 of them. You can find your port numbers here.

This assignment is based on the material from Chapter 16 of the second edition of PUP (not yet published). This new chapter is available on the web here. You will need a password to access the page. You may print a copy, but please do not distribute it. References in this chapter refer to the second edition of PUP, mainly chapter 15. All of the programs referenced from Chapter 15 were discussed in class. Here is the correspondence:
ReferenceProgram
Program 15.1read_and_write.c
Program 15.4server.c
Program 15.5serverp.c
Program 15.6client.c
Program 15.8copy2files.c
Program 15.9client2.c
These programs, as well as server2, a bidirectional server, can be found here.

Make an assign5 directory for this assignment and subdirectories for each part. When starting a new part, copy all of the files from the previous part into the new directory.

Part 0
Put all of the code from the above directory in an assign5/part0 directory on your account. Use the included makefile to compile and lint the code. Understand how to use server2 and client2 for bidirectional communication and make sure they work properly.

Also, make sure you have Assignment 1 working correctly.

Part 1
Implement the pass_monitor of Section 16.6.

Run your program with client2 as in Example 16.8 in the lab with your machine in place of os1.cs.utsa.edu and one of your port numbers in place of 15000. Save the output generated and print it out to be handed in.

Part 2
Implement the tunnel_server of Section 16.7.

Part 3
Implement the server_tester of Section 16.8. The simplest way to do the timing is with the gethrtime function. The man page has an example showing how to use it for timing. If necessary, comment out any lines that do output to the screen while the timing is taking place.

Run your programs as in Exercise 16.10 substituting your machine and port number but using port 80 for the pup web server. Make 20 requests from each of 10 children. Save the output generated and print it out to be handed in.

Part 4
Implement the proxy_server of Section 16.10. Section 16.9 describes the parse_initial function that you wrote in Assignment 1. As described in the book, you may assume a maximum line length of 4096 for this part, but a longer line should not overflow the buffer you use.

You will need to read in the first line, parse it, and make a request to send to the remote machine. After this you can just call the tunnel function that you used previously.

Test your proxy_server by setting your browser to use it as a proxy. Your browser should continue to work. Try accessing some UTSA web pages and some web pages off campus such as www.google.com. See if you can do a google search through your proxy. Make a list of at least 5 web sites on campus and 5 off campus that you successfully visited. Visit the site /classes/cs3733f2002/index.html. Save the output generated by your program when you do a SHIFT-RELOAD on this site. You will have to hand this it. Can you find a browser request that does not work through your proxy (but works directly)? If so, make a note of the URL and try to explain why this one does not work. Be prepared to demonstrate your proxy_server on the last day of class.

Here a possibly useful function for reading in the initial line:

 
/* Return 0 on success and -1 on failure */
/* read characters into buf until a line feed character is read. */
/* The line feed is put in the buffer */
/* Return -1 if no line feed is found in the first bufsize characters */
/* Return -1 if an end-of-file is found before the line feed */
static int readline(int fd, char *buf, int bufsize) {
   int i;
 
   for (i=0;i<bufsize;i++) {
      if (u_read(fd,buf+i,1) != 1) return -1;
      if (buf[i] == '\n') return 0;
   }
   return -1;
}

Part 5
Implement a simple version of the proxy monitor of Section 16.11. You are not being asked to implement all of the logging features of this section. Instead, you will use your command_logger from Assignment 1 to log only the initial line of each connection request. Your proxy_monitor_simple will now call a version of process_proxy that takes the name of the log file as an additional parameter. It opens this file using the O_APPEND flag and calls command_logger to log the information from the initial line. Remember that both command_logger and parse_initial modify the line given to it, so that you may need to pass copies of the initial line to these functions.

Note that you are passing the name of the log file rather than an open file descriptor. While this may be less efficient than having proxy_server open the log file when it starts up, this method simulates having different processes open the log file.

Test your program as in Part 4. Be prepared to demonstrate it on the last day of class.


Use this cover page for turning in your assignment. Do not fill in the top line of the cover sheet until you hand in your assignment. Be prepared to demonstrate it on the last day of class.