Your rating: None Average: 4.8 (4 votes)

In this month's issue we will take a look into the installation of a very famous tool that is widely used in Network related researches. Network Simulator or NS as it is popularly called is formally defined as a "discrete event simulator". For a post graduate in Computer Engineering or a PhD scholar it is, in simple terms, a valuable tool that greatly aids in simulating their concepts in wired and wireless networks.

NS has progressed through several versions, of which the most widely used version under the NS2.x series is NS2.34, though there is NS3 available. There are some technical differences between NS2.X series and NS3.X series.

For every beginner in NS, the first major obstacle(apparently) is installing the simulator in Linux. So, I decided to write this article in simple terms so you get started with NS in a matter of minutes. Lets Go!

There are two methods to install NS in Linux. The version I am choosing is NS2.34 and the Linux distro I choose and recommend is Ubuntu(current version 10.10).

METHOD 1: {easy-quick start-not recommended}



Installing NS2.34 in Ubuntu 10.10 through the Terminal is like sliding a cube of ice. All you have to so is to run the following command in Terminal:

First update the Ubuntu repos:
$ sudo apt-get update

Then comes the installation:
$ sudo apt-get install ns2 nam xgraph

This single command is enough to install the NS2.34 along with Network Animator(NAM) and graph plotting tool Xgraph.
After this whenever you need to run a tcl script just type the following from the location where you have the tcl script:

$ ns somefile.tcl

Though this is a simple method, it has two major drawbacks.

First and foremost, the files that constitute the NS aren't installed, or atleast I havent found them yet ever since I installed it. This hinders the commonly done task of fine-tuning its constituent files for achieving major results.

Second, if, after installing NS through method 1, you install NS through method2, you should be a prepared for a headache. The NS executable installed through method 1 places a NS executable in the location /usr/bin/. Installing NS through method2 generates another NS executable that is placed in some local folder(say /home/user/ns-allinone-2.34/ns-2.34/).You may generate a new NS executable by recompiling its sources everytime you do changes to the NS files in the local folder. So when you execute a tcl script you should normally expect to see the NS in the local folder executing over the tcl script, but unfortunately, the NS in /usr/bin/ is what that would be acting on the tcl script and on the NS files, resulting in incorrect results.

To get rid of this problem try uninstalling through the following command the NS that was installed through the Terminal.

$ sudo apt-get autoremove ns2

METHOD 2 : {Little longer-highly recommended}



This method is the one where many noobs usually get stuck. But worry not! Just follow the steps explained here.

Step 1 : Download the ns-allinone-2.34 from this site:
http://bit.ly/downloadns

Step 2 : Place the ns-allinone-2.34.tar.gz package in your home folder(/home/micman in my case). Right click the package and extract the contents in the same folder.

Step 3: Next, open the Terminal (Applications --> Accessories --> Terminal)

Step 4: Change to ns-allinone2.34 directory
$ cd /home/micman/ns-allinone-2.34

Step 5: First install all the dependencies
$ sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3

NS2.34 installs smoothly with gcc compiler version 4.3. By default, Ubuntu10.10 ships with gcc-4.4.5. So we use a downgraded compiler version for the installation. This is done as follows :

Edit Makefile.in found at this location ns-allinone-2.34/otcl-1.13/Makefile.in as follows: 

Find the line that says:
CC= @CC@
and change it to:
CC= gcc-4.3

Step 6 : Begin ns2.34 installation
$ sudo su
# ./install

step7: Once the installation is successful i.e without any errors, we need to add the path information to the file /home/micman/.bashrc

$ sudo gedit /home/micman/.bashrc

I remind you once again that micman is my username, replace it with your username.

Step 8: Append the following lines to the file /home/micman/.bashrc (after replacing the instances where you find micman with your username)

# LD_LIBRARY_PATH
OTCL_LIB=/home/micman/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/micman/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/home/micman/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/micman/ns-allinone-2.34/bin:/home/micman/ns-allinone-
2.34/tcl8.4.18/unix:/home/micman/ns-allinone-2.34/tk8.4.18/unix

#the above two lines beginning from xgraph and ending with unix should come on the same line

NS=/home/micman/ns-allinone-2.34/ns-2.34/
NAM=/home/micman/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Step 9 : For the changes to take effect immediately, do the following:

$ sudo su
# source /home/micman/.bashrc

or simply quit the Terminal and open it again.

Thats all! 

After this, type ns to see % and type nam to show the nam startup window.

This proves that your installation has been successful.

See how simple it has been! See you next month with another interesting tech nugget, until then happy Whackking!

manoj1987's picture

A Software Engineer, who, apart from programming, is interested  in reading books on jungle ventures, history, auto-biographies depicting ancient India and of course the unavoidable net junkiing!

He is a big fan of Jim Corbett and Dr.Philo Irudhayanath … loves to blog,share knowledge, help his fellow men. He firmly believes in the benefit of being mutually helpful.


More Stuff By ManojKumar

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

To prevent automated spam submissions leave this field empty.
Anonymous's picture

After this, type ns to see %

After this, type ns to see % and type nam to show the nam startup window. !!!!!!!!!!!!!!!!!!!!!!!!
plz can u explain it for me?!!!!!!!!!!!!

Damrudhar's picture

Thanks for your suggestion,

Thanks for your suggestion, :-)

Anonymous's picture

i have problem with step 5..

.its not taking password.."sudo" function..plz do help...thanx in advance :) plz mail me ravipatilmj@gmail.com

seguya 's picture

nice intro

this is a very nice introduction to ns.

seguya 's picture

nice intro

i also have a problem with the ubuntu 11.10.
how do i find the start-up window

Popular content