I graduated from UNC Chapel Hill in May 2012 and am no longer actively involved with Rapid, Tmix, or ns-2. These pages are here to serve as a resource but they will not be updated. For more information, please see rapid.web.unc.edu.

Tutorials |||| Installing and Using ns-2 | Installing Rapid in ns-2 | Using Tmix in ns-2

A Short Tutorial for Installing Rapid in ns-2

Rebecca Lovewell

Rapid Research Group @ CS @ UNC-CH

Initial draft: February 2011
Last updated: 17 March 2013

This guide is dedicated (but not limited in its utility) to UNC-CH people who are interested in using ns-2 to simulate and test Rapid packet-scale congestion control. For general information about how to install ns-2, see the ns-2 website.

Update: Bryan Ward has created a patch which will automagically do all of this installation stuff for you! The patch was created with ns-2.34 in mind. I have not tested it out using any other version of ns.

  1. Install ns-2
  2. Add Rapid Code
  3. Modify Existing Files
  4. Remove Gen Directory
  5. Configure and Install
  6. Run Your Experiments!

Step 1: Install ns-2

While you can use your current installation of ns, we recommend starting with a fresh copy. To do this, download the all-in-one build of the latest update of ns from the ns website. As of this writing, the current version is 2.34. Untar this file into a directory called ns-allinone-2.34/.

Step 2: Add Rapid Code

Copy the files rapid-sink.cc, rapid-sink.h, tcp-rapid.cc, and tcp-rapid.h into the folder ns-allinone-2.34/ns-2.34/tcp/. Internally, you can find copies of these files on the rapid.cs.unc.edu machine in the /playpen/lovewell/ns/rapid/ directory.

Step 3: Modify Existing Files

  1. ns-allinone-2.34/ns-2.34/tcl/lib/ns-default.tcl

    Add the following lines of code to this file:

    Agent/TCPSink/RapidSink set sport_ 0
    Agent/TCPSink/RapidSink set dport_ 0
    Agent/TCPSink/RapidSink set packetSize_ 40
    Agent/TCPSink/RapidSink set maxSackBlocks_ 3
    Agent/TCPSink/RapidSink set ts_echo_bugfix_ true ; # default changed, 2003/8/13
    Agent/TCPSink/RapidSink set ts_echo_rfc1323_ false ; # default added, 2003/8/13
    Agent/TCPSink/RapidSink set generateDSacks_ false
    Agent/TCPSink/RapidSink set qs_enabled_ false
    Agent/TCPSink/RapidSink set RFC2581_immediate_ack_ true
    Agent/TCPSink/RapidSink set bytes_ 0
    Agent/TCPSink/RapidSink set ecn_syn_ false ; # Added 2005/11/21 for SYN/ACK pkts.

    #Agent/TCP/RapidSink/DelAck set interval_ 100ms
    #catch {
    # Agent/TCP/RapidSink/Asym set interval_ 100ms
    # Agent/TCP/RapidSink/Asym set maxdelack_ 5
    #}

    Agent/TCP/Rapid set rapid_timestamp_resolution 1000
    Agent/TCP/Rapid set tcp_timestamp_resolution 1000
    Agent/TCP/Rapid set send_queue_size 200000
    Agent/TCP/Rapid set initial_p_stream_size 5
    Agent/TCP/Rapid set ss_spread_factor 2
    Agent/TCP/Rapid set init_min_rate 500000
    Agent/TCP/Rapid set spread_factor 1.04
    Agent/TCP/Rapid set max_p_stream_size 90
    Agent/TCP/Rapid set index_till_p_stream_end 2
    Agent/TCP/Rapid set dup_ack_threshold 3
    Agent/TCP/Rapid set computation_method 0
    Agent/TCP/Rapid set pkt_size 1000
    Agent/TCP/Rapid set sender_processing_overhead 0
    Agent/TCP/Rapid set tao 0.25
    #Agent/TCP/Rapid set eta 0.1
    Agent/TCP/Rapid set eta 1.5
    Agent/TCP/Rapid set decrease_factor 6.0
    Agent/TCP/Rapid set excursion_threshold 2
    Agent/TCP/Rapid set tcp_computationmethod 1
  2. ns-allinone-2.34/ns-2.34/Makefile.in

    Add the following lines to OBJ_CC:

    tcp/tcp-rapid.o \
    tcp/rapid-sink.o \
  3. ns-allinone-2.34/ns-2.34/common/packet.h

    Add the following to the list after the comment "Used by wireless routing code to attach routing agent":

    #define HDR_RAPID(p) (hdr_rapid::access(p))
  4. ns-allinone-2.34/ns-2.34/common/agent.cc

    Change the line "oldValueList_(NULL), app_(0), et_(0)" to "oldValueList_(NULL), app_(0), et_(0), closed(false)".

    Add the line "closed = true;" to the method Agent::close().

  5. ns-allinone-2.34/ns-2.34/common/agent.h

    Declare "bool closed;" after the declaration of "Application *app_;".

  6. ns-allinone-2.34/ns-2.34/tcp/tcp-session.cc

    Add "#include "tcp-rapid.h"" to the includes section after initial comment.

    Add the following two functions after the function "void SessionBurstSndTimer: ...":

    void SessionGapSndTimer::expire(Event*)
    {
    a_->timeout(RAPID_TIMER_GAPSND);
    }
    void SessionOverheadSndTimer::expire(Event*)
    {
    a_->timeout(RAPID_TIMER_OVERHEAD);
    }

    Add the following lines to the end of TcpSessionAgent::cancel_timers()":

    gapsnd_timer_.force_cancel();
    overheadsnd_timer_.force_cancel();

    Change the line:

    TcpSessionAgent::TcpSessionAgent() : CorresHost(), rtx_timer_(this), burstsnd_timer_(this), sessionSeqno_(0), last_send_time_(-1), curConn_(0), numConsecSegs_(0), scheduDisp_(FINE_ROUND_ROBIN), wtSum_(0), dynWtSum_(0)

    to:

    TcpSessionAgent::TcpSessionAgent() : CorresHost(), rtx_timer_(this), burstsnd_timer_(this), gapsnd_timer_(this), overheadsnd_timer_(this), sessionSeqno_(0), last_send_time_(-1), curConn_(0), numConsecSegs_(0), schedDisp_(FINE_ROUND_ROBIN), wtSum_(0), dynWtSum_(0)
  7. ns-allinone-2.34/ns-2.34/tcp/tcp-session.h

    Add the following declarations after the declaration of "class SessionBurstSndTimer...":

    class SessionGapSndTimer : public TimerHandler {
    public:
         SessionGapSndTimer(TcpSessionAgent *a) : TimerHandler() { a_ = a; }
    protected:
         virtual void expire(Event *e);
         TcpSessionAgent *a_;
    };
    class SessionOverheadSndTimer : public TimerHandler {
    public:
         SessionOverheadSndTimer(TcpSessionAgent *a) : TimerHandler() { a_ = a; }
    protected:
         virtual void expire(Event *e);
         TcpSessionAgent *a_;
    };

    Then, add the following declarations under "protected" just below "SessionBurstSndTimer burstsnd_timer_;":

    SessionGapSndTimer gapsnd_timer_;
    SessionOverheadSndTimer overheadsnd_timer_;

Step 4: Remove Gen Directory

Remove the ns-allinone-2.34/ns-2.34/gen/ directory and all of its contents, if it exists.

Step 5: Configure and Install

Run ./configure in the ns-allinone-2.34/ns-2.34/ directory, and run ./install from the ns-allinone-2.34/ directory.

Step 6: Run Your Experiments!

You should now have a working copy of Rapid!