COSC 6377 : Computer Networks

Fall 2018

TR 1-230pm at F 154

Homework 1: Proxy and Web Servers

Due: 9/28/2018

In this homework, we will write a proxy server that intelligently works with a web server to deliver the content customized for the data rate to the HTTP client.

We will use a standard web client, a browser. The homework should work with any browser. You need to learn how to configure your browser to connect a proxy server installed on your computer.

Write a proxy server "proxy.py". The proxy server receives a request from the browser. It then performs network measurement by downloading a file from the measurement server "measure.py" which is hosted on the same machine as the web server. The proxy server can calculate the data rate based on how long it took to download a file "largeimage.jpg". The proxy server must use a standard HTTP request to download the file from the measurement server, which is an HTTP server. Thus, for the purposes of the measurement, your proxy server is an HTTP client. Your proxy server should download a file that is at least a few MB in size. Bonus question: Perform measurements with your proxy with different file sizes and see observe the data rate measures you obtained and try to understand why you see those results.

We are providing the code for the measurement server measure.py. For testing, you can change the code to introduce different fixed or random delays to make sure proxy is calculating the data rate correctly, i.e., you can increase or decrease the delays and see that the data rates observed by the proxy server changes.

Write an HTTP server "server.py" that accepts a web request from the proxy (on behalf of the browser) and sends an appropriate version of the content depending on the data rate. If the data rate is low, you need to send a smaller version of the image. If the data rate is high, you need to send the larger version of the image. Keep at least three different version of the image in your server. It is ok to use if statements to decide which version of the file to send. If the request is for an html file, the server should simply insert a funny text immediately after the < body > tag.

In the class, we standardized the filename convention: if the request is for myimage.jpg, the server will decide to send the content of one of myimage_small.jpg, myimage_medium.jpg, or myimage_large.jpg. The thresholds for switching among the three image sizes is read from the command line argument: datarate_low and datarate_high. If the measured data rate is less than datarate_low, send the content of myimage_small.jpg in the above example. If the measured data rate is between datarate_low and datarate_high, send the content of myimage_medium.jpg. If the measured data rate is larger than datarate_high, send the content of myimage_large.jpg

You will need to add a header field on the HTTP request from the proxy to the HTTP server. The proxy should send the result of the measurement to the HTTP server so the HTTP server can decide which version of the content to return to the proxy. We will standardize the header extension in the class.

How to run the program?


python3 server.py port datarate_low datarate_high

python3 measure.py port

python3 proxy.py serverip serverport measureip meaureport proxyport measurefile

Your program should be written in Python3 and must run on program.cs.uh.edu.

Submission

Please upload your code using git invitation for hw1. Please include a README that describes the author, contact information, a short description of the software, and finally limitations of your implementation. Include any interesting observations, measurement results, etc. in your README.