CSCI 342: Networks

Semester: Spring 2013
Room: Kng 227
Class Time: Mon/Wed/Fri 2:30pm-3:20pm
Office Hours: Monday,  3:30-4:30pm
Thursday, 4:30-5:30pm
or by appointment
Professor: Cynthia Taylor
email: ctaylor AT oberlin edu
Please include "cs342" in the subject.
Office: King 229
Phone: x58424

Homework 5 - Reliable Delivery over an Unreliable Link

Mininet Setup

We will use Mininet to simulate an unreliable link between sender and receiver.

We have 10 virtual machines already configured to use mininet. For this assignment, you can choose to work in a group of 2 or 3 and use our provided virtual machine, or you can configure mininet on your own computer, and work on your own.

The first choice will be easier - if you choose it, you must send me an email with who is in your group, and I will send you the information for the server you will be using.

For the second choice, you will need to follow the instructions at mininet.org/download. If you choose to install in a virtual machine, you can use the the virtual box virtual machine platform.

After setting up the environment, you need to create a vitual network with two hosts. Run

$ sudo mn --link tc,delay='10ms',loss=5,max_queue_size=2 -x

This will drop you into a mininet shell. To pull up a terminal on each of your new virtual network hosts, run this in the mininet shell:
mininet> xterm h1 h2

This creates a minimal network topology with two hosts connected to a switch with 10ms latency on each link, 5% packet loss on each link, and a buffer of size 2. Note that there is no space between parameters.

All the operations you perform within these windows are just like if you were sshed to two lab machines. They work independently like different machines but share the same files on the machine. Usually h1 has IP address 10.0.0.1 and h2 has 10.0.0.2. Try to ping each other. And here are some commands may be useful if you don't use GUI. For more tips, see http://mininet.github.com/walkthrough/.

help % display commands

exit % quit

pingall % all the machine ping each other to test connectivity 

xterm h1 % display h1 termial window

Note that you need to have an X Server running and X forwarding enabled for this to work. For windows users, here is a walkthrough for Xming + putty on windows: http://www.math.umn.edu/systems_guide/putty_xwin32.html
For Mac users, you need to install XQuartz. If you want to ssh to this virtual machine, add -X parameter, like "ssh -X @".

Homework Description

The sample code for this lab is available here.

At a high level, your job is to change the reliable transport protocol implementation in the template so that the following example execution always produces the correct result. In one terminal(say h2), you run the receiver in the following way, and it produces output as shown below.

./hw5_receiver PORTNUMBER > RECEIVED_FILE
# later on, this happens...
File received, exiting.

In a separate terminal of h1, you run the sender:
cat ORIGINAL_FILE | ./hw5_sender 10.0.0.2 PORTNUMBER
Sent 1020544 bytes in 25 seconds: 35 kB/s
Estimated RTT: 1029 ms
The link has a total buffer size of two packets (including packets in both directions). This is specified using the parameter max_queue_size=2. This leaves enough room for a single ack and a single packet in flight at the same time. So you only need to implement a simple TCP with ACK works, no pipelining. If you send a second packet before the first one arrives at the destination, chances are that either an ack or the second packet will be lost, so it is important that you get your timeouts and your acknowledgments right.

A few things to pay attention to:
hw5_sender.c, hw5_receiver.c - these are to be thought of as 'applications', using the 'library' you implement in hw5.c. You may change these files, but we will use the original files when grading.
hw5.c - this is where your code should go. You will need to make major changes to rel_socket(), rel_connect(), rel_send(), rel_receive() and rel_close(). The file transferred: your program should work for any file, and reproduce it exactly. You can check this with the md5sum utility, or diff. The RTT: you are to dynamically estimate the RTT using the EWMA technique, and use this to set your timeout period. With correctly tuned timeouts, lower RTT will result in higher throughput.
Keep your packets smaller than or equal to MAX_PACKET (1400 bytes).

Finally:
Pay attention to the end of the connection. Ensure that both sides of the connection finish without user assistance, even if packet losses occur, while guaranteeing that the entire file is transferred. Look at the FIN/FINACK/ACK sequence in TCP for ideas.

Hints

For trying out your code, you can tune the packet loss ratios and round-trip latencies by changing the parameters when creating the mininet.
In rel_close(), you may want to just wait for some time, to make sure the last ack didn't get lost (leaving one end hanging).

Grading

The grading script is availabe here. Note that these files must be in the same directory as your program to work.

Grading script usage is following: ./hw5_score username base_port score_file The grading script will run 6 testcases with different latency and forwarding probability. For each test case, there is a minimum throughput requirement and a timeout for your program to exit. The timeout is set as 50% more than the corresponding required throughput. If your program exits normally before the timeout but the content of the received file is invalid then there is 0 point. However, if the program exits normally before the timeout and the received file's content is valid but the throughput obtained is lower than the required minimum throughput then you will get 0.5 point. Finally, if your program doesn't exit before the timeout then it will be killed after timeout and hence the content of the file will be incorrect and you will get 0 point. Sample output from the grading script is following:

[SUCCESS] latency=1000ms packet loss=0% [1]: 1 [throughput (kB/s)=0.26] 
[SUCCESS] latency=100ms packet loss=0% [1]: 1 [throughput (kB/s)=3.11] 
[SUCCESS] latency=10ms packet loss=0% [1]: 1 [throughput (kB/s)=28.78] 
[SUCCESS] latency=100ms packet loss=5% [1]: 1 [throughput (kB/s)=1.36] 
[SUCCESS] latency=10ms packet loss=5% [1]: 1 [throughput (kB/s)=16.22] 
[SUCCESS] latency=10ms packet loss=10% [1]: 1 [throughput (kB/s)=4.86] 
Total score: 6

This script is NOT how I will be determining your final grades for this assignment. However, it should give you a good idea of how your program is performing.

Handin

We will be using Handin to turn in all assignments. Turn this in for class 342, assignment 5.