TWiki> CS450 Web>Homework1 (2013-01-16, Main.ckanich)EditAttach

Homework 1: VMWare, subversion and a web client

Install VMWare and Ubuntu

For this class, you will need a virtual machine running Ubuntu 12.04 Linux. You can get a free license of VMWare here, and download Ubuntu for free here. If you have trouble getting your VMWare license key, let know.

If your computer is windows or linux, VMWare Player will work just as well and is free: vmware player. You only need vmware fusion if your computer is a mac. If you were signed up for the class as of the afternoon of January 15, you should be able to access the uic vmware download site by Thursday.

Once installed, you will need to add some packages and prepare your VM for connecting to our IPv6 VPN. To prepare your new ubuntu install for class, run these commands:

cd /tmp/
tar xzf bitsvpn.tgz
cd bitsvpn
sudo ./

The install script will ask you for the password that you selected for your user account when you created the virtual machine.

If all goes well, your virtual machine is now on the IPv6 Internet. You can verify this by trying the command:


If that ping command works, you're in business! Now you're ready for the fun part.

Refer to our Piazza site if you have further questions.


The main objective of this homework is to get you familiarized with the versioning system we will be using for homework turn-in, called subversion (svn). You will also get a quick introduction to network programming in C, which will be our main language in the course.

Use the credentials you were given during lecture to check out your class directory:

svn checkout svn:// --username mynamehere

a directory with the same name as your username will appear. In this directory, create a directory for homework one. Call it hw1. Add this directory to the repository through the command:

svn add hw1

and then

svn commit -m "Added my first homework directory!"

to store it permanently in the central repository. Make sure you got it right by deleting the checked out directory (named as your username), and then running

svn checkout svn:// --username mynamehere

again. This time, the checked out directory should already contain your hw1 directory. Any file you want to turn in as your homework submission needs to be added to the correct directory using "svn add". Before the submission deadline, make sure that you have committed the most recent version of your submission directory, by running "svn commit" inside the directory. You can always double-check the status of all your files by running "svn status". You are encouraged to add files and commit new revisions as often as you like, before the submission deadline: only the most recent revision, committed to the repository before the submission deadline, will be used.

The Programming Part!

For this week's programming exercise, we will create a truly barebones ipv6 web client. Based on the example tcp client code in svn://, and the http example sessions shown in class, write a command-line program called hw1 that takes a URL as its only parameter, retrieves the indicated file, and stores it in the local directory with the appropriate filename. If the URL does not end in a filename, use 'index.html'. Make sure it works for both text and images by opening the stored file in a web browser. You may assume that the URL is on the form http://host/path, where path may or may not be an empty string, may or may not contain multiple slashes (for subdirectories), and may or may not contain a file name. You may assume files to be no larger than one megabyte, and you are not expected to handle HTTP redirect (3xx) return codes other than report them.

The hostname may be a name like, but the example code requires an ip address (like 64:ff9b::83c1:201d). To look up the IP address of a given host name, use getaddrinfo(). "man 3 getaddrinfo" on the command line will give you the details, or use this link, and see the getaddrinfo.c example.


For this homework, there is a prepared skeleton directory that you may use. To import a copy of this skeleton into your directory, first delete any old hw1 directory you may have with

svn rm hw1
svn commit -m "deleted old hw1 directory"

and then copy the skeleton directory from the svn like this

svn export svn://
svn add hw1

this will automatically copy all the contents of the skeleton directory to your local directory, and add these new files to your own repository.

A few hints

Use http version 1.0. Version 1.1 can get a lot more complicated. Good functions to use for handling filenames and text include:

sprintf, sscanf, strstr, strchr

Read more about these using the "man pages". For example, try "man sprintf" on the command line.

NOTE: Newlines in http are represented as "\r\n", not just "\n".

Your program will be tested (at least) on these urls:

make sure you handle all these cases gracefully. The first should produce a file index.html. The second should produce a logo.gif (containing the picture). The third and fourth should exit with error i.e. exit(1). Beej's Guide to Network Programming is a great resource you may want to make use of. For the engadget URLs, you need to supply an extra "host:" parameter in the request.

If you're curious, try firing up Wireshark, and then fetching the URL with "wget" or "curl". You'll find the request they sent (which may have a lot of addl. parameters in it) in one of the packets with destination port 80.

Spend some time thinking about how to do the string manipulation. It does not have to be complicated. The complete program, including comments, error handling etc. can be written in about 100 leisurely lines.

Turn-in instructions

For your turn-in, prepare a Makefile that compiles the hw1 target. To make sure your submission is complete, try the following in a temporary directory

svn checkout svn:// --username mynamehere 
cd hw1 

this should produce a file called index.html, containing the source for the google front page.

should produce a file called logo.gif, containing the google logo.


Grading will be done automatically using a script. You can check your grade even before final submission using the script. You can get the grading script using:

svn co svn://

The grading script is in /pub/grading-scripts/hw1/hw1_score. You will need to give your svn username, a file to have all output from your program run and another file for your score same as following

./hw1_score username output_file score_file

This script will create a directory with your username, download hw1 from svn and create output_file and score_file inside hw1. The score file will look something like the following, with minor changes:

[SUCCESS] files submitted using svn? [2]: 2
[SUCCESS] index.html created for [0.50]: 0.50
[SUCCESS] skype_logo.png created for [0.25]: 0.25
[SUCCESS] images_logo_lg.gif created for [0.25]: 0.25
[SUCCESS] chord_sigcomm.pdf created for [0.25]: 0.25
[SUCCESS] cs450.html created for ipv6 only host [0.25]: 0.25
[SUCCESS] ipv4.html created for ipv4 host [0.25]: 0.25
[SUCCESS] exit with error for [0.25]: 0.25
[SUCCESS] exit with error for [0.25]: 0.25
[SUCCESS] exit with error for [0.25]: 0.25
[SUCCESS] skype_logo.png size correct? [0.25]: 0.25
[SUCCESS] images_logo_lg.gif size correct? [0.25]: 0.25
[SUCCESS] chord_sigcomm.pdf size correct? [0.25]: 0.25
[SUCCESS] skype_logo.png content correct? [0.25]: 0.25
[SUCCESS] images_logo_lg.gif content correct? [0.25]: 0.25
[SUCCESS] chord_sigcomm.pdf content correct? [0.25]: 0.25
[SUCCESS] cs450.html content correct? [0.25]: 0.25
[SUCCESS] ipv4.html content correct? [0.25]: 0.25
[SUCCESS] index.html created for [0.25]: 0.25
[SUCCESS] Lenses-Product-Reviews-AdoramaTV created for [0.25]: 0.25
Total score: 7
Topic revision: r10 - 2013-01-16 - 05:55:49 - Main.ckanich
Copyright 2016 The Board of Trustees
of the University of
Helping Women Faculty Advance
Funded by NSF