Lab: Reliable Transport

In this lab, you will write a reliable transport protocol that uses cumulative ACKs, sliding window, and a retransmission timer, similar to TCP. You will use the simulator to examine the efficiency achieved by different window sizes.


The Bene simulator includes stubs for TCP, including an implementation of TCP buffering.


Implement reliable transport using TCP as your model. The TCP code in the simulator is written so that no opening handshake is required; a host can immediately begin sending data. We will only simulate data traveling one way from the sender to the receiver, but the code is written so that you could send data in both directions.

You should implement the following for the sender:

You should implement the following for the receiver:

The source code includes an implementation of both a send buffer and a receiver buffer. You should not modify this code.

The send buffer implements a basic sliding window algorithm, which is a buffer with three values called base, next, and last. The buffer is a sequence of bytes that can be transmitetd. The base of the window is the sequence number of the first byte in the buffer. The next value is the sequence number of the next data that has not yet been sent. Everything between the base and next is data that has been sent and not yet ACKed. The last value is the sequence number for the last byte in the buffer. Use the put() method to add data to the buffer, and the get() method to remove data from the buffer. use the resend() method to get data that needs to be resent. Use the slide() method when ACKing data that has arrived in order.

The receive buffer holds all the data that have been received, indexed by starting sequence number. Data may come in out of order, and the buffer will order them. Data may also be duplicated, and the buffer will remove any duplicated bytes.

Dynamic Retransmission Timer

Once you have basic TCP reliability working, add a dynamic retransmission timer that uses an EWMA for the timer value and for the variance. See RFC 2988 for details on doubling the timer value when retransmitting a segment.


Use the simulator to set up a simple network consisting of two nodes and and one bidirectional link:


Using this network, test the following scenarios:

  1. Set the bandwidth of the links to 10 Mbps, with a propagation delay of 10 ms. Transfer the file test.txt from n1 to n2 using a window size of 3000 bytes. Repeat this test, with loss rates of 0%, 10%, 20%, and 50%.

  2. Set the bandwidth of the links to 10 Mbps, with a propagation delay of 10 ms. Transfer the file internet-architecture.pdf from n1 to n2 using a window size of 10000 bytes. Repeat this test, with loss rates of 0%, 10%, 20%, and 50%.

Write a Python script for each of these tests, where the loss rate is passed in on the command line. The script should output traces from your TCP implementation demonstrating that it works well, and it should run a diff to ensure the file is transferred correctly. Use the script as an example.


Using the same network configuration as above, set the bandwidth of the links to 10 Mbps, with a propagation delay of 10 ms, a queue size of 100 and a loss rate of 0%. Transfer the internet-architecture.pdf file using window sizes of 1000, 2000, 5000, 10000, 15000, and 20000 bytes. Compute the throughput of the transfer as the total bits sent divided by the total time to send the file, measured from the start of the simulation to when the last segment is received. Compute the average queueing delay of all segments sent. Plot the throughput and the average queueing delay as a function of the window size, on two separate graphs.


Write a report that includes the following:

Write using a formal, scientific report style. Your report should be written as if you are explaining your work to another CS student, and they need all of the details of what you did so that they can replicate your experiments.

Your report can be any length, as long as you thoroughly describe your project and results. The paper must use 11 point type, single spacing, and one column per page.

Your report must match the LaTex style shown in this template. If you choose to use LaTeX, I suggest using the WikiBooks LaTex reference.


Your code should be located in a directory called lab2 in the top level:

 bene/ src/ examples/ lab2/ 

You should copy to the lab2 directory and modify it there. You should be sure your scripts call this and not the one in the src directory. Turn in a tarball that includes all of your code (for the simulator, experiments, graphing, etc), and a PDF of your report:

 tar -czvf bene.tgz bene 

using Learning Suite.


This lab is worth 200 points, and will be graded using the following rubric:

To get full points, all tests must pass and the report must be complete and written with a scientific style.