Installing ns-2 and ns-3 on Fedora Linux

ns is a discrete-event network simulator targeted primarily for research and educational use. There are two version of ns, ns-2 and ns-3, which are quite different with each other in the implementation and method to use them. In this post, we introduce how to install ns-2 and ns-3 on Fedora Linux 15.

Install ns-2.34 on Fedora

Download the allinone package

$ wget

Uncompress the pacakge

$ tar xf ns-allinone-2.34.tar.gz

Install needed pacakges

# yum install gcc make libX11-devel libXt-devel libXmu-devel

Ns-2 requires older version of gcc. So we install gcc-34 and gcc-34-c++ for it

# yum install compat-gcc-34 compat-gcc-34-c++

Install the allinon package of ns-2. During the install process, specify the CXX compiler we use

$ cd ns-allinone-2.34
$ CXX=g++34 ./install

Configure the environmental variables for ns-2 and nam, and add the executables to the PATH so that we can use ns and nam directly.

Add to ~/.bashrc if you use bash

export PATH


Add to ~/.cshrc_user if you use c shell

setenv NS_HOME "/full/path/to/ns-allinone-2.34"
setenv PATH "${PATH}:${NS_HOME}/bin:${NS_HOME}/tcl8.4.18/unix:${NS_HOME}/tk8.4.18/unix"
setenv LD_LIBRARY_PATH "${NS_HOME}/otcl-1.13:${NS_HOME}/ns-2.34/lib:/usr/local/lib"
setenv TCL_LIBRARY "${NS_HOME}/tcl8.4.18/library"

The installation is done by this step. Open another shell and try our installation:

$ nam


$ ns

Install ns-3.12.1 on Fedora

Install needed packages

# yum install libxml2 libxml2-devel gcc gcc-c++ make automake 
autoconf binutils openssh-server openssh-clients openssl python 
python-devel mercurial bzr scons flex bison tcpdump valgrind gdb

Download the allinone pacakge for ns-3

$ mkdir tarballs
$ cd tarballs
$ wget
$ tar xjf ns-allinone-3.12.1.tar.bz2

Build ns-3

$ cd ns-allinone-3.12.1/
$ ./

We will now interact directly with Waf in the ns-3.12.1 directory

$ cd ns-3.12.1

Configuration with Waf

$ ./waf -d optimized configure --enable-examples; ./waf

Validate our installation by running one example

$ ./waf shell
$ cd build/optimized/examples/
$ udp/udp-echo

Use tcpdump to display the simulation result

$ tcpdump -tt -r udp-echo-0-1.pcap
The following two tabs change content below.
Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

0 Replies to “Installing ns-2 and ns-3 on Fedora Linux”

  1. Thanks for your tuorial :)
    I got a problem… I cannot find this path build/optimized/examples/
    Any suggestions on how to run udp-echo example ?

    thanks a lot!

  2. Install ns-allinone-2.35 in fedora 18
    NS2 stands for network simulator and it is not in fedora repository but it’s allinone package is available on isi.edurecently ns-2.35 RC7 is there with updated tcl and tk library but still it is not support gcc-4.5 series (does not like the X:() construct) so i made 2 patches.

    After apply those patches you can follow below steps.

    Installation of NS-2.35
    Open Terminal, Give the following command one by one
    su (press enter and enter your root or super user password)
    yum groupinstall “X Software Tools” {development software tools}
    exit (to come out of root user mode)
    Once installed, download the NS-2.35 allinone software from the following link.
    Copy that file to /home/pradeep (This is my home folder)
    Open terminal again and execute the following commands one by one
    tar zxvf ns-allinone-2.35.tar.gz
    cd ns-allinone-2.35

    Install Dependences : 
    yum install autoconf
    yum install automake
    yum install gcc-c++
    yum install libX11-devel
    yum install xorg-x11-proto-devel
    yum install libXt-devel
    yum install libXmu-devel

    Build ns-allinone-2.35 
    Go to you download directory and extract package (tar -xvf tarball), go to extracted directory and run

    You may possibly get one error during your installation is linkstate/ls.h error
    If you get the above error, open the file (~ns-2.35/linkstate/ls.h) using gedit or any text editor
    Go to line number 137 and change this line (void eraseAll() { erase(baseMap::begin(), baseMap::end()); })  to
    void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); }
    again you try the command ./install and this time the installation will be successful.
    Once installed the PATH information will be provided to you.
    Copy the PATH and LD_LIBRARY_PATH Variable to /home/madhurpremg/NS2/nsallinone-2.35/.bash_profile (see a dot in the beginning)
    Input the path information in .bash_profile file like this
    export PATH=$PATH: {don’t put}
    Once done, save the file and close
    execute the command
    source .bash_profile
    try ns or nam to see whether your installation succeeded.

    Add PATH in .bashrc
    vim ~/.bashrc
    Add the following lines to the end of it. Remember replace “/opt/” by your installation path like “/home/username”. And accordingly also change the version numbers. This is for ns 2.35.



    # PATH

    Let it take effect immediately

    source ~/.bashrc

    Note: the step described above is important; otherwise, you cannot run ns successfully.
    or you can restart your X windows.i.e. logout and then login, or reboot your system, to make it work.)

    Now, the installation has been completed. If you try:
    $ ns

    Then a “%” will appear on the screen.type “exit” to quit the mode and back to “$
    Validate ns-2.35 
    Go to ns-2.35 directory and run
    #./validate (take almost 1 hour so keep patience)

Leave a Reply

Your email address will not be published. Required fields are marked *