Due date: 3pm on Friday, November 22

This homework is continuation of hw6 with addition of pipelining. You can either use your solution of hw6 or start over with the hw6 skeleton code. A correct solution to homework 6 will still get roughly 50% credit on this assignment; if you didn’t successfully complete homework 6, this is a chance to regain some of those points. You should copy the code over to a hw7 directory so that it will be saved and graded properly.

To simulate an unreliable link in a single computer, you still need to run mininet. Like homework 6, run the following command and change the delay, loss and buffer size parameter.

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

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, you run the receiver in the following way, and it produces output as shown below.

./hw7_receiver base port > RECEIVED_FILE
# later on, this happens...
File received, exiting.

In a separate terminal, you run the sender:

cat ORIGINAL_FILE | ./hw7_sender 10.0.0.1 base port
Sent 1020544 bytes in 25 seconds: 35 kB/s
Estimated RTT: 1029 ms

A few things to pay attention to:

  1. hw7_sender.c, hw7_receiver.c - these are to be thought of as ‘applications’, using the ‘library’ you implement in hw7.c. You may change these files, but we will use the original files when grading.

  2. hw7.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().

  3. The file transferred: your program should work for any file, and reproduce it exactly. You can check this with the md5sum utility, or diff.

  4. 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.

  5. Keep your packets smaller than or equal to MAX_PACKET (1400 bytes).

  6. In case you buffer the packets and close the connection before you send all the packets, throughput is also calculated in hw7_receiver. Make sure there is no significant difference between the throughputs of both sender and receiver.

Finally:

  1. 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

  1. For trying out your code, you can tune the packet loss ratios and round-trip latencies by changing the parameters to MININET

  2. 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

Grading script usage is following:

./hw7_score username base_port score_file

Same story as previous homeworks, the grading script for this assignment is available in public repository, which you can use it to check whether your code meet the requirement.

The grading script will pull your code from git server, run 10 times for each case. For each case, it will be regarded as success if more than 7 throughput are faster than the threshold, and will be regarded as partial success if less than 8 but more than 5 throughput are faster than the threshold.

Sample output from the grading script is following:

[SUCCESS] buf=2 loss=0% threshold=14 [1]: 1 [throughput(kB/s)= 37.0 32.5 28.3 27.8 42.3 28.2 28.5 27.6 28.8 28.4] mean=30.94 kB/s
[SUCCESS] buf=2 loss=5% threshold=2.1 [1]: 1 [throughput(kB/s)= 14.8 13.8 16.7 21.5 9.8 15.2 14.0 7.4 9.4 13.3] mean=13.59 kB/s
[SUCCESS] buf=10 loss=0% threshold=80 [1]: 1 [throughput(kB/s)= 151.2 151.1 151.5 151.3 151.1 151.3 151.9 151.1 151.5 151.5] mean=151.35 kB/s
[SUCCESS] buf=10 loss=5% threshold=10 [1]: 1 [throughput(kB/s)= 19.0 28.4 38.1 21.7 20.5 17.4 11.3 15.6 27.0 14.8] mean=21.38 kB/s
[SUCCESS] buf=100 loss=0% threshold=85 [1]: 1 [throughput(kB/s)= 162.4 162.3 162.3 162.3 162.2 161.3 162.3 162.4 162.3 162.3] mean=162.21 kB/s
[SUCCESS] buf=100 loss=5% threshold=10 [1]: 1 [throughput(kB/s)= 31.5 48.8 33.8 19.9 28.4 37.5 32.7 40.0 28.5 46.6] mean=34.77 kB/s

Total score: 6