Header Ads

Install NS-2 on Ubuntu 9.04

I'm doing my final year project on Wireless Ad-Hoc networks and was required to Install NS-2 (Network Simulator) on Ubuntu 9.04 - the Jaunty Jackalope. I thought it would be easy to install NS-2, using the shell script file "Install", but it didn't work and failed. I tried many tricks and searched the web, but didn't find a good tutorial for the same, and thought to write one.

The procedure for installing NS-2 in Ubuntu 9.04
1. Download ns-allinone-2.33.tar from here.
2. Place it in somewhere, e.g. /home/programmer, then extract it.
$ cd /home/programmer
$ tar -xvf ns-allinone-2.33.tar

3. Download & install some packages from repository
$ sudo apt-get install build-essential autoconf automake libxmu-dev

4. Install the ns2
$ cd ns-allinone-2.33
$ ./install

5. Edit some paths
$ gedit ~/.bashrc

Put these lines on that file. Off course, you might change /home/programmer for it depends on where you extract ns-allinone-2.33.tar.



6. Validate it (take very long time compare to install process)
$ cd ns-2.33
$ ./validate

7. (Optionally) Create a symlink, so that ns can be called from everywhere
$ sudo ln -s /home/programmer/ns-allinone-2.33/ns-2.33/ns /usr/bin/ns

8. Let it take effect immediately
$ source ~/.bashrc

9. Try to run it (and pray :) )
$ ns

10. If the installation success, you will see % at the command prompt. Type following command to exit
% exit

Testing ns2 Installation

Use the following ns batch command

set ns [new Simulator]
$ns at 1 “puts \“Hello World!\””
$ns at 1.5 “exit”
$ns run


1. Copy the commands above and paste in the text editor
2. Save the file as simple.tcl
3. Type command in command prompt
$ ns simple.tcl

4. It will show
Hello World in the line below


1. Problem : The system cannot find Tcl or it tells that Tcl does not install correctly

Solution 1 : Check your ns tcl nam ... version, check folder name. If it is not correct, edit the .bashrc
Solution 2 : run ./install again

2. Problem : nam does not work

Solution 1 : In fact, you need to change that particular file in your Linux manually.

Here is what you should do.

Apply the following patch :
--- tk8.4.18-orig/generic/tkBind.c 2006-07-21 08:26:54.000000000 +0200
+++ tk8.4.18/generic/tkBind.c 2008-07-05 12:17:10.000000000 +0200
@@ -586,6 +586,9 @@
/* ColormapNotify */ COLORMAP,
/* ClientMessage */ 0,
/* MappingNotify */ 0,
+#ifdef GenericEvent
+ /* GenericEvent */ 0,
/* VirtualEvent */ VIRTUAL,
/* Activate */ ACTIVATE,
/* Deactivate */ ACTIVATE,

Create a file with the above lines and name it : abc.patch. To apply the patch navigate to ns directory and execute the following command in terminal:

patch -b < abc.patch

Then run $ ./install to compile and install ns2 again. Hope this helps, drop in your comment for HELP ! :)