Homework 5

In this homework, we implement reliable communication over a highly unreliable link. The homework template is available at:

svn://cs450.cs.uic.edu/pub/homeworks/hw5

To simulate an unreliable link in a single computer, sender and receiver communicate through a third "proxy" process. This proxy listens on two ports to get data from sender and receiver. And forwards the received data at those two listening ports after some delay and with some forwarding probability to another two ports at which the receiver and sender are listening. However, to make things easier, you can only supply a base port to all programs and it will configure all the ports automatically using the base port. To start the proxy, run

./proxy -p <base port> -l <latency> -f <forwarding probability> -b <buffer size>

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.

./hw5_receiver 127.0.0.1 <base port> > RECEIVED_FILE
# later on, this happens...
File received, exiting.

In a separate terminal, you run the sender:

cat ORIGINAL_FILE | ./hw5_sender 127.0.0.1 <base port>
Sent 1020544 bytes in 25 seconds: 35 kB/s
Estimated RTT: 1029 ms

In the grading script, the proxy has a total buffer size of two packets (including packets in both directions). This is specified using the flag -b 2. This leaves enough room for a single ack and a single packet in flight at the same time. 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 to the proxy process.
  • Note that we'll use our own proxy process when grading, changing proxy.c is only going to hurt your chances.
  • 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).

Turn-in instructions

Same story as previous homeworks, except that your makefile should generate two binaries called hw5_ receiver and hw5_sender.

Grading

Grading script usage is following:

./hw4_score username base_port score_file

The grading script will checkout you code from svn, copy a image file supplied in the grading script directory to your directory and 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=1000 forwarding=1 [1]: 1 [throughput (kB/s)=0.60]
[SUCCESS] latency=100 forwarding=1 [1]: 1 [throughput (kB/s)=12.46]
[SUCCESS] latency=10 forwarding=1 [1]: 1 [throughput (kB/s)=88.27]
[SUCCESS] latency=100 forwarding=0.95 [1]: 1 [throughput (kB/s)=8.55]
[SUCCESS] latency=10 forwarding=0.95 [1]: 1 [throughput (kB/s)=52.22]
[SUCCESS] latency=10 forwarding=0.9 [1]: 1 [throughput (kB/s)=53.93]
Total score: 6
Topic revision: r8 - 2011-09-29 - 16:12:35 - Main.amusa2
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF