How to Install Network Simulator 2 (ns2) on Linux

VN:F [1.9.22_1171]
Rating: 9.0/10 (5 votes cast)

Step by Step Installation of Network Simulator 2 (ns2) on Linux

How to Install Network Simulator 2 (ns2) on Linux is the first article on NS2. In this how-to we will install ns2 (stable) release under ubuntu Linux and then we will run a sample TCL script. We assume that you have already installed fully functional Linux desktop computer with Gnome. In our setup we are going to use ubuntu 9.10 (desktop edition). This is 32 bit environment.

1. Download the stable release of ns2

root@ubuntu:~# mkdir ns2
root@ubuntu:~# cd ns2/
root@ubuntu:~/ns2# wget http://citylan.dl.sourceforge.net/project/nsnam/allinone/ns-allinone-2.34/ns-allinone-2.34.tar.gz

2. Extract this Tar File

root@ubuntu:~/ns2# tar -xzf ns-allinone-2.34.tar.gz

Now you will have this directory ns-allinone-2.34.

3. Configuration and Installation of ns2

root@ubuntu:~/ns2# cd ns-allinone-2.34
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install autoconf
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install libc6-dev g++ gcc
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install build- essential
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install libx11-dev
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install x-dev
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install xorg-dev

Need to add patch for OTCL

For Ubuntu 9.10 (karmic), you may encounter this error in the linking of otcl: So,

root@ubuntu:~/ns2/ns-allinone-2.34# cd otcl-1.13
root@ubuntu:~/ns2/ns-allinone-2.34# cp configure configure.orig
Modify the following line
--- configure.orig 2009-11-02 12:14:52.556167945 -0800
+++ configure 2009-11-02 12:17:28.966706099 -0800
@@ -6301,7 +6301,7 @@
;;
Linux*)
SHLIB_CFLAGS="-fpic"
- SHLIB_LD="ld -shared"
+ SHLIB_LD="gcc -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""
root@ubuntu:~/ns2/ns-allinone-2.34# ./install

By executing this command all of the required ns2 software will be installed except xgraph. For xgraph installation execute the following command. By the way, I used gnuplot, gnuplot has more advanced features. So,

root@ubuntu:~/ns2# apt-get install xgraph
root@ubuntu:~/ns2/ns-allinone-2.34# apt-get install gnuplot

4. Export System Variables

Execute the following commands

root@ubuntu:~/ns2/ns-allinone-2.34# cp /root/.bashrc /root/.bashrc.bk
root@ubuntu:~/ns2/ns-allinone-2.34# vi /root/.bashrc

export PATH=$PATH:/root/ns2/ns-allinone-2.34/bin:/root/ns2/ns-allinone-2.34/tcl8.4.18/unix:/root/ns2/ns-allinone-2.34/tk8.4.18/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/ns2/ns-allinone-2.34/otcl-1.13:/root/ns2/ns-allinone-2.34/lib
export TCL_LIBRARY="/root/ns2/ns-allinone-2.34/tcl8.4.18/library"

5. NS2 Testing

Now, your ns2 system is ready for use, download a test script and test it.

root@ubuntu:~/ns2# wget http://nile.wpi.edu/NS/Example/ns-simple.tcl
root@ubuntu:~/ns2# ns ns-simple.tcl

NS-2-Demonstration

NS-2-Demonstration

How to Install Network Simulator 2 (ns2) on Linux, 9.0 out of 10 based on 5 ratings

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>