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>

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

For this homework, you can only have a single outstanding packet at any time. If you send a second packet before the first one arrives at the destination, the first packet will get 'clobbered', 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.

Edit | Attach | Print version | History: r8 | r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2011-09-20 - 18:36:17 - Main.jakob
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF