Homework 5

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


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 <base port> > RECEIVED_FILE
# later on, this happens...
File received, exiting.

In a separate terminal, you run the sender:

cat ORIGINAL_FILE | ./hw5_sender <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).


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


  • 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 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. If the received file's content is correct then you will get 1 point for that test-case. If the content is correct then the throughput is also calculated, which will be used for bonus points. Sample output from the grading script is following:

[SUCCESS] latency=300 forwarding=1 [1]: 1 [throughput (kB/s)=0.76]
[SUCCESS] latency=200 forwarding=0.99 [1]: 1 [throughput (kB/s)=0.86]
[SUCCESS] latency=100 forwarding=0.9 [1]: 1 [throughput (kB/s)=0.92]
[SUCCESS] latency=50 forwarding=0.8 [1]: 1 [throughput (kB/s)=1.28]
[SUCCESS] latency=20 forwarding=0.7 [1]: 1 [throughput (kB/s)=0.45]
[SUCCESS] latency=10 forwarding=0.6 [1]: 1 [throughput (kB/s)=0.38]
Total score: 6
Edit | Attach | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r7 - 2011-09-29 - 16:05:49 - Main.jakob
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF