CS030 -- Introduction to Computer Science II
Fall, 2005
Project 2
(updated 11/18/2005)

Updates:
[11/18]  To record the things we discussed in class: 
1. Let the output log file be "tab-delimited".  That means separate fields with tab characters. 
2. In the output file, we added a time-stamp.  Let the output format be: time of day the recording was made, bandwidth for this download, latency for this download, average bandwidth over last 20 minutes, average latency over last 20 minuts, bandwidth over last hour, latency over last hour.
3. The average bandwidth and latency is undefined until enough data points have been collected to compute the given average.
4. Sample the download speed every four (4) minutes instead of 3.
5. You do not need to use the jds Queue.  A java LinkedList implements the general notion of a queue and will serve our purposes adequately.

[11/18]  I'm converting the 'q' for exiting the program into extra credit.  The KeyReader/KeyAdapter does not appear to be readily applicable to our program.  For extra credit, you may extend your program to read a 'q' from the keyboard in the standard input (System.in) and then quit the program (closing all open files, etc.).  To do this, you will need to create a separate thread in which the program reads from System.in.  Naturally, you would start this thread after the initial interactions of getting the URL and the output file.



Programming Project:
This week, you will write a program that creates a running log of bandwidth measurements.  The result of the program (over a period of time), will be a log file that can be loaded into a spreadsheet application.  The log will inform the user of the bandwidth speed and latency (a) at the moment, (b) averaged over the last 20 minutes, and (c) averaged over the last hour.  I would like you to use a Queue to do this.

This is an individual project, but you are encouraged to discuss design issues together.  Submit your projects via Eureka by 1:15pm on Tuesday Nov. 22.

Requirements:
On start up, the application prompts the user for a URL that will be used to measure download speed.  If the URL cannot be accessed, the program should print an appropriate error message and prompt again.  Once an acceptable URL has been entered, it will also prompt the user for an output file to which it will write the collected information.  At this point the application will run until interrupted by the user.  As extra credit, start a separate thread that reads standard input (System.in) and terminates the program when the user presses the 'q' key.

The application should make a request to get the URL.  We assume that the entered URL points to a file that is sufficiently large to provide a meaningful test.  For our purposes, sufficiently large probably means 10-15 megabytes (although smaller files should work and would be appropriate for testing). 

Measure latency as the time from initiating the request until data is available to be read.  Measure download speed as the time from data is available until the end of the downloaded file is read.  You should repeatedly download the specified file every four minutes.  (Note, you might want to ensure that the file can be downloaded in less than four minutes.  You can make this part of the initialization if you like.)

I'm suggesting you place these timings in a queue of some sort and then periodically compute and record in the log the last timings, the timings averaged over the last 20 minutes, and over the last hour.