Network Simulator 2: a Simulation Tool for Linux

Using Network Simulator 2 to simulate case scenarios using SCTP and TCP protocols with FTP and HTTP traffic.

The ARIES (Advanced Research on Internet E-Servers) Project started in 2000 as part of the Open Systems Lab research activities at the Ericsson Corporate Unit of Research. Initially, the project aimed to find and prototype the necessary technology to prove the feasibility of an internet server that had the guaranteed availability, response time and scalability using Linux and open-source software. The project was successful, and it continued in 2001 to focus on enhancing the clustering capabilities of Linux to be the operating system of choice for the Mobile Internet servers. Many enhancements were added in the areas of load balancing, traffic distribution and security, in addition to IPv6 support.

One interesting question that came up was what is the impact of supporting IPv6 on other protocols used by different applications on our Linux clusters? To answer this question, we started a study investigating the effects of IPv6 support on other protocols, such as SCTP. Part of the study is to test applications in SCTP over IPv6. However, we did not have the time and resources to set up a lab with multiple nodes and applications that use SCTP over IPv6. Instead, we chose the next best solution, network simulation.

There is a growing recognition within different internet communities of the importance of simulation tools that help design and test new internet protocols. New services and protocols present challenges for testing. For instance, quality of service and multicast delivery require large and complex environments. Protocol designers recognize the advantages of simulation when computing resources are not available or are too expensive to duplicate a real lab setup. With simulation, you can do large-scale tests that are controlled and reproducible. This was exactly what we needed to build our case scenarios; the search started primarily for an open-source tool because most of our work targets the deployment of open-source software based on Linux.

Our target application is a real-time network simulation tool that we can use to define the different scenarios. A very interesting open-source tool we came across was Network Simulator 2 (NS2), which was developed by the Information Sciences Institute at the University of Southern California.

In this article, we summarize how to install and configure NS2 and look at two different simulation scenarios. The first scenario involves monitoring SCTP traffic between two nodes, and the second scenario looks at the behavior of web traffic and web applications over TCP over a six-node network.

The Tool: Network Simulator 2

NS2 is an open-source simulation tool that runs on Linux. It is a discreet event simulator targeted at networking research and provides substantial support for simulation of routing, multicast protocols and IP protocols, such as UDP, TCP, RTP and SRM over wired and wireless (local and satellite) networks. It has many advantages that make it a useful tool, such as support for multiple protocols and the capability of graphically detailing network traffic. Additionally, NS2 supports several algorithms in routing and queuing. LAN routing and broadcasts are part of routing algorithms. Queuing algorithms include fair queuing, deficit round-robin and FIFO.

NS2 started as a variant of the REAL network simulator in 1989 (see Resources). REAL is a network simulator originally intended for studying the dynamic behavior of flow and congestion control schemes in packet-switched data networks.

Currently NS2 development by VINT group is supported through Defense Advanced Research Projects Agency (DARPA) with SAMAN and through NSF with CONSER, both in collaboration with other researchers including ACIRI (see Resources). NS2 is available on several platforms such as FreeBSD, Linux, SunOS and Solaris. NS2 also builds and runs under Windows.

Simple scenarios should run on any reasonable machine; however, very large scenarios benefit from large amounts of memory. Additionally, NS2 requires the following packages to run: Tcl release 8.3.2, Tk release 8.3.2, OTcl release 1.0a7 and TclCL release 1.0b11.

Installation and Configuration

The process of installing NS2 is straightforward yet lengthy. At the time of writing, the most recent version was 2.1b8. We are interested in the "all-in-one" package because it includes the source code that we want to patch in SCTP support.

You can download the all-in-one package from the NS2 home page (see Resources) into /usr/src and extract it as follows:

cd /usr/src
tar xzvf ns-allinone-2.1b8.tar.gz
cd ns-allinone-2.1b8

Because we want to examine a case scenario involving SCTP, we need to apply the SCTP patch to NS2 from the University of Delaware. The patch is available for the NS2 all-in-one 2.1b8 version and can be downloaded from the Protocol Engineering Lab home page (see Resources). With the Linux patch utility, you can update the NS2 source code to include support for SCTP by applying the patch:

patch -p0 < ns-allinone-2.1b8.sctp-rel2.2_patch_orig

In the same directory, there is a script named install that will configure, compile and install the required and optional NS2 components. There is no interaction with the user while installing; the script is completely automated. You must execute the script as superuser so that installation of binaries will be completed:


When the installation process is complete, the following message will appear on your shell

Please put
tk$TKVER/unix into your PATH environment; so that
you'll be able to run itm/tclsh/wish/xgraph.

Carefully follow all instructions given in the notices. The above-mentioned variables can be updated either by editing /etc/profile or changing environment variables directly. In case you updated /etc/profile, you need to source your new environment for the changes to take effect (i.e., source /etc/profile).

The NS2 validation suite will verify that all protocols are functional. This will fail if the install process was not completed; however, running validation is optional, and it consumes twice as much time as the compilation and installation process.

To run the validation suite:

cd ./ns-2.1b8


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Simulation for a High speed mass data transfer protocol

echonyne's picture

Hello everybody,

I'll be doing a project simulation for a high speed mass data transfer protocol.
Will be needing your help..

If anybody interested or want to contribute they are humbly invited.. :)
Just drop me a mail at:

is there any specific kernel support required for installing ns2

sujo's picture

is there any specific kernel support required for installing ns-2.1b8-mcast

Change queue parameters dynamically during the simulation r

raeisy's picture

Dear friend,
I want to change parameters of a RED queue during the simulation but it seems that some parameters can be modified only before starting the simulation, not dynamically, while the simulation is in progress. For example the following subroutines works before $ns run command but it do not affect the behavior of the queue during the simulation( I want to change maxthresh_ and thresh_ after $ns run command):
proc setREDParameters { redQueue MINth MAXth PER_MaxP Wq } {
$redQueue set thresh_ $MINth
$redQueue set maxthresh_ $MAXth
$redQueue set q_weight_ $Wq
$redQueue set linterm_ $PER_MaxP
return $redQueue

Who knows what I should do ?


sharath's picture

pls send me the ns2 code for any topology scheme preferably span in wireless sensor networking

voice security in ns-2

Jay Jay's picture

please, can i implement voice security in ns-2
all contributions would be appreciated.

cellular envirnoment in NS-2

Anonymous's picture

i m doing the project in channel allocation in mobile communication, i wants to implement it in NS-2. i wants to create the wireless envirnoment. can anybody helps me in doing that?

Hi, Iam also doing project

Anonymous's picture


Iam also doing project in cellular networks. if you know how to simulate it in ns2 please tell me. My email:

About SCTP and NS-2.32

Nhan's picture

Now, I want to simulate SCTP on NS-2. And I use NS-2 2.32. I want to know does NS-2 2.32 support SCTP???
Thank for your help.