Installing ns-2 and ns-3 on Fedora Linux
Posted on In Linux, Network, Softwarens 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 http://downloads.sourceforge.net/project/nsnam/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz
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
NS_HOME=/full/path/to/ns-allinone-2.34 PATH=$NS_HOME/bin:$NS_HOME/tcl8.4.18/unix:$NS_HOME/tk8.4.18/unix:$PATH export PATH
or
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
and
$ 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 http://www.nsnam.org/release/ns-allinone-3.12.1.tar.bz2 $ tar xjf ns-allinone-3.12.1.tar.bz2
Build ns-3
$ cd ns-allinone-3.12.1/ $ ./build.py
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
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!
Glad that you find this tutorial useful.
Try ‘./build.py –enable-examples –enable-tests’ when building ns-3.
There is a more detailed tutorial for ns-3 now from nsnam.org: http://www.nsnam.org/docs/release/3.15/tutorial/singlehtml/index.html , I also suggest it.
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. https://dl.dropbox.com/u/24623828/ns-allinone-2.35.tar.gz
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
#./install
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}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: here.
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.
# LD_LIBRARY_PATH
OTCL_LIB=/home/madhurpremg/NS2//ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/madhurpremg/NS2//ns-allinone-2.35/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/home/madhurpremg/NS2//ns-allinone-2.35//tcl8.5.8/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/madhurpremg/NS2//ns-allinone-2.35/tcl8.5.8/unix:/home/madhurpremg/NS2//ns-allinone-2.35//tk8.5.8/unix
NS=/home/madhurpremg/NS2//ns-allinone-2.35/ns-2.35/
NAM=/home/madhurpremg/NS2//ns-allinone-2.35/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM
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)