Homework 6

Homework 6: Studying TCP’s congestion control with ns-3

Brief Background on ns-3

ns-3 is a discrete event simulator that models all the layers of the TCP/IP stack (except physical layer, of course!). It is open-source and is used extensively by researchers. The TCP code base of ns-3 is structured similar to the actual kernel code. Therefore, it is a good platform to implement newer protocols before spending arduous effort with hacking the actual kernel. ns-3 is written entirely in C++ along some Python scripts. All our code must be written in C++. Although you might be able to get by with some Python, I won’t recommend it. Another nice thing about ns-3 is that it generates PCAP packet traces and is compatible with other tools like Tcpdump and Wireshark.

This homework is not an exhaustive ns-3 project. So, I suggest that you refer to ns-3 documentation on a need-to-know (on-demand) basis. However, I recommend spending some time reading the tutorial on the ns-3 website.

Goals of the assignment

Primarily, there are three goals of this homework:

  1. Learning to use ns-3 for evaluating simple protocol extensions.
  2. Understanding the difference between loss and congestion.
  3. Understanding TCP’s congestion control implementation by hacking it.

Getting the code base

To get started, check out the ns-3 code base from the repository. DO NOT download the code from the ns-3 web page. I have customized the ns-3 code for this homework.

public/hw6

Building the simulator

Prior to building the ns-3 simulator, your VM must be setup for development. If you have installed “build-essential” as part of homework #1, then you should be good to go.

cd hw6/ns-allinone-3.25/ns-3.25
./waf configure --enable-examples --enable-tests
./waf

Once the build succeeds, we are ready to simulate some TCP!

Task (1): Understanding loss (25% of grade)

In class, we learned that TCP Reno uses duplicate acks to deal with transient congestion i.e., congestion episodes that last for a short amount of time. However, random losses induced by the medium (i.e., wi-fi) can confuse TCP’s congestion control.

I have provided a simulator code in ns-allinone-3.25/ns-3.25/scratch/homework6a_lossy.cc. This code simulates FTP over TCP between a client and a server. It uses TCP NewReno protocol which is an advanced version of the TCP Reno protocol (TCP Tahoe + Fast re-transmit/recovery) that we studied in the class. In addition, it also simulates random packet losses such as a wireless medium. Assuming that you are in hw6/ns-allinone-3.25/ns-3.25/ directory, you can simulate this code using the command:

./waf --run "scratch/homework6a_lossy --duration=5"

This will simulate a FTP transfer for 5 seconds. At the end of simulation, you will find many homework6a_lossy-* files. Among them, the file homework6a_lossy-cwnd.data shows how TCP’s congestion window evolves over time (the first column is time in seconds and the second column is congestion window in bytes). You can plot this data using excel or gnuplot. If you are using gnuplot, then you can use the command gnuplot homework6a_lossy.plot. The gnuplot script homework6a_lossy.plot is given to you as well. Spend some time understanding how the simulator code works.

TO DO:

  1. Plot of congestion window vs. time
  2. Label and explain “interesting” datapoints (i.e., packet loss, slow-start, congestion avoidance).

Task (2): Understanding congestion (25% of grade)

Congestion happens when the aggregate sending rate exceeds the network capacity. In the next example, we have multiple senders sending data to one receiver causing congestion. The provided simulator code ns-allinone-3.25/ns-3.25/scratch/homework6b_incast.cc creates a scenario where 100 senders send to one common destination and the final link to the destination becomes congested. Assuming that you are in hw6/ns-allinone-3.25/ns-3.25/ directory, you can simulate this code using the command:

./waf --run "scratch/homework6b_incast --num_flows=100 --duration=300"

This will simulate 100 FTP transfers to the same destination for 300 seconds. At the end of simulation, you will find many homework6b_incast-* files. Among them, the file homework6b_incast-cwnd.data shows how TCP’s congestion window evolves over time (the first column is time in seconds and the second column is congestion window in bytes). You can plot this data using excel or gnuplot. If you are using gnuplot, then you can use the command gnuplot homework6b_incast.plot. The gnuplot script homework6b_incast.plot is given to you as well. Spend some time understanding how the simulator code works.

TO DO:

  1. Plot of congestion window vs. time
  2. Label and explain “interesting” datapoints (i.e., packet loss, slow-start, congestion avoidance).
  3. What is the qualitative difference between this plot and the previous one?

Task (3): Implementing TCP Tahoe from TCP Reno (50% of grade)

In simple terms, TCP Tahoe is TCP Reno without fast re-transmit and fast-recovery. Thus, implementing TCP Tahoe on top of TCP Reno code is easy, and, therefore, is going to be our last homework! In this last task, you will hack the TCP stack so that you don’t react to duplicate ACKs. If you recall, simply not reacting to duplicate ACKs will disable fast-retransmit and fast-recovery.

I understand ns-3 is a large codebase. But here is a little pointer to the core of the congestion control code ==> ns-allinone-3.25/ns-3.25/src/internet/model/tcp-socket-base.cc. The code change would be less than 50 lines. Once you have made the changes in tcp-socket-base.cc, run the simulation code from task(1) and task(2) with your modified code (TCP Tahoe). (Running the command line will automatically complile the code!).

TO DO:

  1. Two plots of congestion window vs. time from running the modified code.
  2. Explain how the new plots with your modified code (TCP Tahoe) differ from the previous plots (i.e.,TCP Reno)?

Turn-in

  • Add/commit your version of ns-3 directory to git. We will build your code to check if your plots are reproducible.
  • Make a PDF report with plots and explanations for tasks (1), (2), and (3): one plot + explanation for task(1), one plot + explanation for task(2), and two plots + explanation for task (3). Place the report in a directory called report in hw6/ns-allinone-3.25/ns-3.25/. Commit the report to git.

Deadline

This homework is due on November 21, Monday at 11 pm .

Grading

The grading for this homework, will be done manually.