Programming Assignment 2 - Bufferbloat
In this assignment we will study the dynamics of TCP in home networks. The figure below shows a “typical” home network with a home router connected to an end host. The Home Router is connected via cable or DSL to a headend router at the Internet access provider's office. We are going to study what happens when we download data from a remote server to the End Host in this home network.

In a real network, it's hard to measure the sender's CWND and the buffer occupancy (since they are private to the server and the router, respectively). We are, therefore, going to use Mininet emulations to measure those metrics in an operating network.
Goals
- Learn the TCP sawtooth behavior and router buffer occupancy dynamics in a network.
- Learn why large router buffers may lead to poor performance (which is often called “bufferbloat.”)
- Learn how to use Mininet to run traffic generators, collect statistics, and plot graphs.
- Learn how to organize your experiments in a reproducible manner.
Tasks
Using Mininet, create the following topology. Here, h1 is your home computer that has a fast connection (1 Gbps) to your home router with a slow uplink connection (10 Mbps). The round-trip propagation delay or the minimum RTT between h1 and h2 is 4ms. The router buffer can hold up to 100 full-sized ethernet frames (about 150kB buffer size with a 1500-byte MTU).

Having set up the topology,
- Start a long-lived TCP flow, sending data from h1 to h2, using iperf.
- Send pings from h1 to h2 10 times a second and record the RTTs.
- Plot the following time series:
- CWND for The long-lived TCP flow
- RTT reported by ping
- Queue size at the bottleneck
- Spawn a webserver on h1. Periodically download the index.html web page (three times every five seconds) from h1 and measure how long it takes to be fetched (on average). The starter code has hints on how this can be done. Make sure the webpage downloading data is flowing in the same direction as that of the long-lived flow.
- The long-lived flow, ping train, and webserver downloads should all be happening simultaneously.
- Reduce the router buffer size to 20 packets, repeat the above experiment, and replot the three graphs .
Starting the Assignment
To do the assignment you will need the VM loaded with Mininet and the required dependencies of the assignment. Check the VM Setup page for information on how to access this VM. Note that the username/password for this VM is csc458/csc458.
To help you get started, we have provided a skeleton code, In your prepared VM, clone the starter code for this project:
mininet@mininet-vm:~$ git clone https://github.com/csc458-uoft/pa2
mininet@mininet-vm:~$ cd pa2
Look for TODOs in the starter code. The files you need to know about are:
- bufferbloat.py: Creates the topology; measures CWND, queue sizes, and RTTs; and spawns a webserver.
- plot_queue.py: Plots the queue occupancy at the bottleneck router.
- plot_ping.py: Parses and plots the RTT reported by ping.
- plot_tcpprobe.py: Plots the cwnd time-series for a flow specified by its destination port
- run.sh: Runs the experiment and generates all graphs in one go.
Questions
Include your answers to the following questions in your README file. Remember to keep answers brief.
- Why do you see a difference in webpage fetch times with small and large router buffers?
- Bufferbloat can occur in other places such as your network interface card (NIC). Check the output of ifconfig eth0 on your VirtualBox VM. What is the (maximum) transmit queue length on the network interface reported by ifconfig? For this queue size and a draining rate of 100 Mbps, what is the maximum time a packet might wait in the queue before it leaves the NIC?
- How does the RTT reported by ping vary with the queue size? Write a symbolic equation to describe the relation between the two (ignore computation overheads in ping that might affect the final result).
- Identify and describe two ways to mitigate the bufferbloat problem.
Submission/Deliverables
Please compress and submit all of the following files in a single file (named "pa2.tar.gz")
- Final Code: One goal of this assignment is for you to build a system that is easy to rerun and reproduce the results. Therefore, your final code MUST be runnable as a single shell command (
sudo ./run.sh
). We will test your code in the same setup. - README: A file named README file with instructions to reproduce the results as well as the answers to the below questions. Please identify your answers with the question number, and please keep your answers brief. Please list installation instructions for any dependencies required to run your code.
- Plots: There should be 6 plots in total, 3 each for router buffer sizes 100 and 20 packets. They MUST have the following names and be present in your submission folder
- bb-q20/cwnd-iperf.png
- bb-q20/q.png
- bb-q20/rtt.png.
- bb-q100/cwnd-iperf.png
- bb-q100/q.png
- bb-q100/rtt.png.
Notes
When running the curl command to fetch a web page, please fetch webserver_ip_address/http/index.html
.
Grading
Total: 18 pts
- 8 points: Producing working code that generates the graphs
- 8 points: Answering the questions
- 2 points: Producing correct graphs
Useful Hints
- If you have been running your code using ssh connection to the VM, you might find it difficult to view your plots with the VM's GUI. You can, instead, start a simple HTTP server inside your assignment directory using
which will expose the directory where you started the server on the 8000 port. You just need to use the same port forwarding technique you used when you were setting up the VM, to forward port 8000 of the VM to port 8000 on your host OS. Then you can point a web browser to http://localhost:8000 and browse your results.python -m SimpleHTTPServer
- If your Mininet script does not exit cleanly due to an error (or if you pressed Control-C), you may want to issue a clean command
sudo mn -c
before you start Mininet again.
Useful Links
- On the bufferbloat problem"
- More about Mininet and how it can be used:
- Monitoring and Tuning the Linux Networking Stack: