Simulation of TCP connections

December 5, 2001

Homework solutions with sample tcl script for task 3.

This page was modified on December 9th, following bug reports from some students. While the tasks have not been modified, the scripts have been updated to correct the bugs. Some additional comments have also been included in this page, to further clarify critical issues. The deadline to email the answers has been moved to Monday Dec. 17.

These tests are aimed at practicing with the basics of the 'ns' simulator. A basic description of the ns simulator and of the nam network animator is available in the form of slide handouts (full page and 6 slides per page).
You can find tutorials, examples and manuals at the ns official site.

  1. One TCP connection is routed over three links. The link bandwidths and delays can be inspected using a sample nam file. The middle link is the bottleneck. Referring to the revised (the old one had some bugs) 'ns' input file tcp1.tcl:
    • run a simulation using the connection set-ups provided in the input file you were given: measure the connection throughput, including the transient (i.e., from time 0);
    • find the smallest maximum congestion window to assign to the TCP connection such that the bottleneck link is fully utilized; running 'ns' and then 'nam', verify that, eventually, there's a sustained, seamless flow of packets on the bottleneck link;
    • compute the time it takes for the TCP source to reach the full window computed in the previous subtask; this period of time is called the transient; run a simulation measuring the connection throughput without the transient (i.e., after the connection has reached the full window). Is the measured throughput higher than before? Why?
  2. Two TCP connections are routed over a common link (see the sample nam file for further details). Referring to the revised 'ns' input file tcp2.tcl;
    • run a simulation using the setups provided: measure the overall throughput, as well as the throughput of single connections;
    • find the smallest maximum congestion window for both connections such that the bottleneck link reaches full utilization (check using 'nam').
    • identify the transient and repeat the measure without the transient
    • repeat the simulation with a slower bottleneck link (0.05 Mb/s). You should observe losses (use nam). Why? Dimension the buffer at the intermediate node so that losses disappear, without changing the TCP window size (i.e, find the smallest possible buffer size so that no TCP packet is lost). Notice that the throughput will be increased.
  3. The third task does not provide a sample input file, but requires that you write one, following the guideline of the two scripts provided above.
    Build a scenario where there are 4 TCP connections, following the scenario depicted in the figure on the right. TCP connection 0 is attached to node n0 and has its 'sink' (receiver) at node n6. Similarly, TCP 1 goes from n1 to n7, TCP 2 goes from n2 to n8 and TCP 3 goes from n3 to n9. Dimension each connections' congestion window as well as the bottleneck buffer so that you observe no losses (again, find the smallest possible window as well as the smallest possible buffer that do not lead to losses).
    • measure the throughput of single connections; are the throughputs different? Provide an explanation;
    • attach the Tcl script with your answer.


Answers should be emailed to casetti@polito.it by December 17, 2001 to be graded.