COSC 4377 - Introduction to Computer Networks

Spring 2012

MW 1:00-2:30pm at PGH347

InstructorOmprakash Gnawali

Homework 6 : Rate Limits

Due: midnight March 7, 2012

In this assignment, we will rate limit the HTTP client and server. We will write three separate set of programs in this assignment.

Part 1 - Rate limiting client and server

Change http_client (lets call it http_client1) and http_server (http_server1) that you wrote in previous assignments so that they can negotiate the rate at which they should transfer the files.

http_client1 accepts the rate on the command line. http_server1 accepts the rate on the command line. The file transfer should happen at the smaller of the two rates.

Here is how we will launch the server:

./http_server1 -p port -r rate

where rate is specified in bytes per second

Example:

./http_server1 -p 20001 -r 10000

(launch the server on port 20001 with a maximum rate of 10000 bytes
per second)

Here is how we will launch the client:

./http_client1 -u url -o outputfile -r rate

Example:

./http_client1 -u http://bayou.cs.uh.edu:20001/testfile.txt -o localtestfile.txt -r 8000

(connect to the http server running on port 20001 on bayou with a maximum
download rate of 8000 bytes per second, and write the output to localtestfile.txt)

To simplify url parsing, you can assume that we will always provide a numeric port number after the ":" after the hostname. In the example above, the file should download at the client at 8000 bytes per second (smaller of 10000 and 8000).

Because the client and the server need to negotiate the sending rate, they need to exchange information regarding transfer rate supported. They can do this exchange using a custom HTTP header: "Max-rate". The header sent to the server might now look like:

GET /file1.tif
Max-rate: 8000
Please make sure your client and server are still compatible with the standard http server and client respectively. That is, despite this new header field, you client should still work with a standard server that does not recognize this new field. If your server sends an HTTP response with a custom header, it should still be compatible with a standard http client even though it cannot parse the customer header field.

Part 2 - Fair rates for all clients

Change http_server (lets call it http_server2) you wrote in previous assignments so that it can serve all the clients at the same rate.

http_server2 accepts the maximum bandwidth as an argument. When a single client connects to the server, it serves the client at the maximum rate. When multiple clients send http request to the server, the server serves all those clients at the same rate. The sum of all the rates should be equal to the maximum rate.

Here is how we will launch this server:


./http_server2 -p port -r rate

where rate is specified in bytes per second

Example:

./http_server2 -p 20001 -r 10000

(launch the server on port 20001 with a maximum rate of 10000 bytes
per second)

In the example above, when the server is serving one client, the files are transferred at 10000 bytes per second. When there are two clients, they each receive files at 5000 bytes per second. When there are three clients, they each get files at 3333 bytes per second.

The challenging part of this assignment is adjusting the rates dynamically as clients connect and disconnect. For example, the rate for a specific client might go up or down as the number of connected clients changes. Lets imagine a client starts downloading a large file at 10000 bytes per second. After several seconds into the file transfer, if another client connects to the server, the rate for the first client should drop to 5000 bytes per second. If yet another client connects to the server in the middle of the file transfer, the rate should further drop to 3333 bytes per second. When the two clients complete their transfer, the rate for the first client (which is still downloading the long file) should go back up to 10000 bytes per second.

Part 3 - Throttling large downloads

Change http_server (lets call it http_server3) you wrote in previous assignments so that it throttles large downloads.

http_server3 accepts the maximum unthrottled transfer size, unthrottled rate, and throttled rate as command line arguments. When clients download files that are small (size less than the unthrottled transfer size), they get to download at the full unthrottled rate. When the transferred bytes exceed the unthrottled transfer size, the transfer rate goes down to throttled rate.

Here is how we will launch this server:


./http_server3 -p port -a rate1 -b rate2 -s size 

where rate1 and rate2 are specified in bytes per second and size is specified in bytes.

Example:

./http_server3 -p 20001 -a 10000 -b 1000 -s 100000 

(launch the server on port 20001 with an unthrottled rate of 10000
bytes per second, throttled rate of 1000 bytes per second, and
unthrottled transfer size of 100,000 byts per second)

In the example above, when a client requests a 70000-byte file, the transfer happens at 10,000 bytes per second. It will take approximately 7 seconds to download this file. When the client requests a 115,000-byte file, the first 100,000 bytes are transferred at 10,000 bytes per second. The remaining 15,000 bytes are transferred at the throttled rate of 1,000 bytes per second. It will take approximately 25 seconds to download this file.

Instrumentation

It is helpful for your program to internally measure the rate at which it is transferring the file and print it either to a file or stdout so you can verify that the rates at different times for a given transfer match what you expect to happen. You will also need such an instrumentation to draw graphs to be included in your submission.

Testing your program

We will copy several files to directory in which your web server is launched. Then, we will use the http client to test the scenarios covered in the assignment. For part 2 and 3, we will use wget to test the functionalities of your server.

Compiling and Running

It is perfectly fine for you to work on your own Linux machine. Regardless of where you do your assignment, your assignment must compile and execute on bayou.

Questions

Please provide answers to these questions in a single pdf file called answers.pdf, which is no longer than 2 pages including all the graphs and text no smaller than 11 points:
  1. What is your implementation strategy? Describe in no more than half a page
  2. Please provide three time-series graphs (time in x-axis and rate(s) in y-axis) from measurements using your client and servers to illustrate how the three parts of the assignment work. For the first graph, your graph should show the measured transfer rate. For the second graph, you can show how the rate goes up and down as the number of flow changes, with one line per flow on the same graph. On the third graph, you can show the rate achieved by a small transfer and a large transfer as a function of time. The resolution on x-axis should be 500ms, i.e., you should take rate measurements twice a second. On all graphs, you can manually draw the expected rate.
  3. Were measured rates identical to the expected rates in all cases? If not, why not? Please refer to the graph while answering this question.

Submission

Put your source code into a folder with the name: uhid_hw6, where uhid is the prefix of your .uh.edu email address. There should be a single Makefile in that directory. When we run make on that directory, it should produce four executables: http_client1, http_server1, http_server2, and http_server3. Put a README.txt in the directory describing anything unusual (e.g., limitations) of your implementation. Then, zip the directory and upload the zip file using Blackboard.