Search code examples
tcpns-3

How to use Tcp Variants Comparison in NS3?


I need to compare different type of TCP using ns-3 for a class project. I am new with ns-3. I don't want to implement a new code. Briefly, I have 2 questions:

  1. Which example of ns-3 is the best for my purpose? Tcp-Variants-Comparison.cc?
  2. How can I see the output. I ran the code, but there was no output.

Solution

  • You can run your example using .waf. Navigate to your ns-3 directory (the place where .waf executable is located) and run:

    ./waf --run tcp-variants-comparison
    

    This will compile (if needed) and run the example with default arguments. You can change arguments using --command-template="%s <args>". If you look inside the tcp-variants-comparison.cc you can see all available arguments, e.g.:

    ...
    cmd.AddValue ("delay", "Access link delay", access_delay);
    cmd.AddValue ("tracing", "Flag to enable/disable tracing", tracing);
    cmd.AddValue ("tr_name", "Name of output trace file", tr_file_name);
    cmd.AddValue ("cwnd_tr_name", "Name of output trace file", cwnd_tr_file_name);
    ...
    

    So here is an example how you can store congestion window of default TcpWestwood protocol to cwndTrace file:

    ./waf --run tcp-variants-comparison --command-template="%s --tracing=1 --cwnd_tr_name=cwndTrace"
    

    You can then use any tool you like to display the data. Here is how to plot it with gnuplot:

    $ gnuplot
    gnuplot> set terminal png size 640,480
    gnuplot> set output "cwnd.png"
    gnuplot> plot "cwndTrace" using 1:2 title 'Congestion Window' with linespoints
    gnuplot> exit
    

    You should also take a look at this NS-3 tutorial. This gives you a pretty good introduction to NS-3, so read it carefully.

    cwnd

    So to answer your question completely, you can use this example for comparison of:

    cmd.AddValue ("transport_prot", "Transport protocol to use: TcpTahoe, TcpReno, TcpNewReno, TcpWestwood, TcpWestwoodPlus ", transport_prot);
    

    So run this example with different transport_prot arguments and compare your traces.