Download the following installation steps as a pdf manual <here>. This manual also contains the steps to install ns2.34 in Fedora 12.
Read this article in Scribd <here>

PROCEDURE 1:
The nightmare days are over!
Now you dont have to spend hours on your linux distro(ubuntu) installing and validating ns2.x
Ubuntu 10.10 has greatly simplified things. You can now install ns,nam and xgraph by just a single command in the Terminal:
$ sudo apt-get install ns2 nam xgraph
You will be prompted for the user password. Enter it and watch Ubuntu 10.10 do the things for You!
Happy Ubuntuing
PROCEDURE 2:
On heeding to my blog visitors requests, I would like to update this post with the steps to install ns2.34, the traditional way.
Step1: Download ns-allinone-2.34 package from this <site>. I will be using ns version 2.34.
Step2: Place the ns-allinone-2.34.tar.gz file in your home folder(/home/micman in my case). Right click on the package and extract the contents in the same home folder.
Step3: Next, open the Terminal(Applications–>Accessories–>Terminal in ubuntu)
Step4: Change to ns-allinone-2.34 directory
$ cd /home/micman/ns-allinone-2.34
Step5: First, Install the dependencies
$ sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3
Note that we are downgrading the gcc version, as ns2.34 works well with gcc4.3
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
Step6: 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 ~/.bashrc
$ gedit ~/.bashrc
Step8: Append the following lines to the file ~/.bashrc
# 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 # Note: the above two lines starting from XGRAPH should come in 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
Here replace /home/micman with the path to your home folder.
Step9: For the changes to take effect immediately, do the following:
$ source ~/.bashrc
Thats all!
type ns to see % and type nam to show the nam startup window. This shows your installation has been successful.
Troubleshooting
- If the tk compilation failed, especially for tk3d.c, make sure you have installed libx11-dev package.
- If the otcl configuration failed, make sure you have installed x-dev and xorg-dev packages.
Error:
nsbash: ns: command not found
Solution:
This could be because you have not set the $PATH variable. Therefore, the OS does not know where to look for the command “ns“. more detailed solution <here>
Error:
Segmentation Fault
Solution:
found here
Error:
Undefined reference to vtable
Solution:
found here
—
You may also be interested in:
—



it didn’t work for me !!
ns
% set ns[new Simulator]
can’t read “ns_o4″: no such variable
I guess the problem is in your code and not in your installation.
Hi
it didnt work for me using 10.10 notebook edition
err reads unable to locate package ns
any help?
thanks
Hi Darsh!
I suggest you update your ubuntu before installing ns.
$sudo apt-get update
then
$sudo apt-get install ns nam xgraph
I agree, thanks for sharing this..
hi,
I tried everything on my Ubuntu 10.10 but ns2 is not getting installed. Pls help me as i dnt know much about unix.
Its really urgent
Try
sudo apt-get install ns2 nam xgraph
This worked for me
hey thank u so much….it worked for me
it didnt work for me using 10.10 notebook edition
err reads unable to locate package ns
annd i typed
$sudo apt-get update
then
$sudo apt-get install ns nam xgraph
didn’t work also.
wht to do?
Failed to fetch http://us.archive.ubuntu.com/ubuntu/dists/maverick/universe/binary-i386/Packages.gz Hash Sum mismatch
E: Some index files failed to download, they have been ignored, or old ones used instead.
this was the error
it almost work for me; there is some error in install but i could execute NS & nam
and is validate step important as mentioned in ns site because /.validate doesn’t work for me too
i am using version ubuntu 10.10 but i can not find what is error i am doing project in ns2… i need a guide give details
This is to inform you that I have updated the ns installation manual linked at the beginning of this post!
Typographical errors have been corrected and Instructions to install ns in fedora has been updated.
@kary
validation is not necessary.
You should have validated using the following command:
./validate
hi
i try all your steps for ubuntu 10.10 but when i arrived to % i type nam i have: wrong # args: should be “namespace subcommand ?arg….?”
please i need u’r help i’m a student and need ns2 for my project
thanks
i just wanna know if after having % i successfully installed ns2?
thanks for answering me
@Leila
There is nothing wrong with your installation. It is successful.
You received the error because you have not executed the tcl script in the proper way.
To confirm that your installation was successful, just run the script simple-wireless.tcl in the location /home/yourHomeFolder/ns-allinone2.34/ns2.34/tcl/ex
@Randa
run
$sudo apt-get clean
$sudo apt-get autoclean
$sudo apt-get autoremove
and begin the installation procedure again!
helllo,
i simply type $ sudo ./install it say ‘command not found’ now what we have to do plz rply
Thats usually because in the Terminal you havent switched to the directory containing the install script.
$ cd /home/vishal/ns-allinone-2.34/
$ sudo su
$ ./install
Here I have assumed your home folder to be “vishal”. Replace it with the correct one(your username) if its wrong.
I suggest you first learn how to use Ubuntu(or any Linux distro), before trying to do your project.
This guide might help you: http://linuxreviews.org/beginner/
thanks bandhalpalli balaji it worked for me too:)
hii… after
./install
m getting an error msg that
tk8.4.18 make failed! exiting…
what to do??
Please verify the version of the gcc compiler you are using.
Also download the ns source file again and try installing!
Hi. I’m following your instructions on how to setup ns-2.34 in ubuntu, but the first procedure cannot find the ns file. I’m switched already to the right directory. Thanks.
At which step did you get this error?
Hello,
My working directory path is /home/ubuntu/aditi/ns-allinone-2.34.
I have Ubuntu 10.10 edition and am trying to install Ns-2. When i reach step 5 to install dependencies, it shows an error as –
root@ubuntu:/home/ubuntu/aditi/ns-allinone-2.34# sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package gcc-4.3
E: Couldn’t find any package by regex ‘gcc-4.3′
what could be the reason for this? ignoring this i proceeded further but the installation failed with tk compilation errors and many more. Please guide me how to get the step5 done successfully.
thanks
Follow these steps in order.
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3
I hope that would help. If you still have any problems, I suggest that you manually download and install gcc 4.3
from here
Hello Guys. Thank you so much for the help. It all got worked out by just one line of command. Thanks a lot.
$sudo apt-get update
then
$sudo apt-get install ns nam xgraph
Awesome Stuff !!!!
I would to say thank you very much for the help,, procedure 1 its really simplified thing
but i have the problem to patch the wimax module on it, since i can’t find the ns folder that contain the files that need to patched,
can you help me please??
thanx ….
for the installation step
thanks ..
this blog very he
thanks ..
this is very helpful
i.e. provides the installation process very easy..
Hi. I need help…
How can I install WiMAX module for NS-2 under ubuntu 10.10?
“sudo apt-get install ns2 nam xgraph” will be ok. Thanks
So many thanks for sharing this…
I solved my problem with this steps
That almost saved my life
… Thanks alot for ur guidance… I mean it..
Hi,
I m not able to install wimax module on ns2.34. It is showing some installation errors. I followed the procedure mentioned on the link http://www.lrc.ic.unicamp.br/wimax_ns2/
Can you please tell me if the wimax module at the above link is compatible with ns2.34? If not, can you please provide me the appropriate link.
Thanks
Tanuj Batra
Tanuj! My knowledge in ns2 is limited. I am not familiar with wimax module.
hey manoj i m new to ns2 and know nothing about it my xams are approachin n i hav to submit a project in 2 monts which requires knowledge of ns2 can u help….
plz provide ur e-mail…
@sachin
Sorry sachin, I cannot do your homework.
What have you been doing so long?
You don’t seem to have taken any step to work on your project!
hey manoj it wasn’t my fault the faculty who was to assist with the project has left to complete his p.hd… n i dnt knw why but he is nt willing to help me out any more… i m nt asking u to do everything 4 me just guid me where n how to start….
Step1: Install ubuntu 10.10
Step2: Install ns2.34 as directed in this article. Follow PROCEDURE 2.
What is your project about?
What the modules? What is the code level functionality expected in each module?
i have to design an overlay network which can implement the basic functionalities like file n data transfer….
i hav completed the above steps
hi i am chethan from karnataka i followed the steps that u hv mentioned here it worked from me thank u very much for that,could u plz give me steps to add a new routing protocol
plz help me………
Thanks a lot.
Worked for me.
Pls give suggest a good website to learn about ns2 codes..
I am a beginner
Thanks a lot.
Worked for me.
Pls suggest a good website to learn about ns2 codes..
I am a beginner
Everything is ok but I have a problem about xgraph.If I try to use xgraph in tcl scripts it says:
ns: finish: couldn’t execute “xgraph”: no such file or directory
while executing
“exec xgraph out0.tr out1.tr out2.tr -geometry 800×400 &”
(procedure “finish” line 8)
invoked from within
“finish”
Thank you sir. Really nice post. But I got error like “Unable to locate package ns” when I typed command suggested by you. So just replaced ns with ns2 in the command like this “$sudo apt-get install ns2 nam xgraph” & it worked fine.
Thank you so much for your valuable tip Vatsal!
I will correct this post accordingly!
Thanks brother. Great help……..
Livelong Livehappy.
Hi,
Thanks for the nice article.
The pdf file and scribd file says that, for ubuntu 10.10
sudo apt-get install ns nam xgraph
but ns is not there in 10.10, and ns2 is available.
it should be as following
sudo apt-get install ns2 nam xgraph
seeing the blog is updated and pdf file is yet to be updated.
Please update it.
Thanks a lot for sharing your knowledge.
Yes its right!
It should be:
$ sudo apt-get install ns2 nam xgraph
I should thank you so much for your great efforts (-:
thanks you!
dude after installing i got the following error during ns2 compilation can u help me how to solve this
% ns t.tcl
warning: using backward compatibility mode
error when calling class OldSim: t.tcl
%
hi help me how to solve this problem after installing ns2
% ns t.tcl
warning: using backward compatibility mode
error when calling class OldSim: t.tcl
i have successfully installed ns2.34, and my ns command are also working but for nam, i geitng this error ::
nam:
: no event type or button # or keysym
while executing
“bind Listbox {
%W yview scroll [expr {- (%D / 120) * 4}] units
}”
invoked from within
“if {[tk windowingsystem] eq “classic” || [tk windowingsystem] eq “aqua”} {
bind Listbox {
%W yview scroll [expr {- (%D)}] units
}
bind Li…
i dont now why i m getting this error, even ns2.34 and all dependencies and path variable are properly installed.
hello, i accessed to the home/administrator/ns-allinone-2.34/ns-2.34/tcl/ex
then i made a new simulator and a nam file.
when i enter ns filename.tcl, the following error appears:
% ns ff.tcl
error when calling class Simulator: runns ff.tcl
Please help me thanks
When i enter to the folder in which the tcl file exists the following problem appears:
running nam…
ns: finish: couldn’t execute “nam”: permission denied
while executing
“exec nam out.nam &”
(procedure “finish” line 8)
invoked from within
“finish”
please help.
Thanks
Thank you very much……….
Its is WORKING awesome
after completing all this step they show a error of ns archive file is not in this. what is the solution of this error
thanx so much man……..
getting error while installing ns2
command :sudo apt-get update
E:could not get lock /var/lib/apt/list/lock- open(11: resource temporarily unavailable)
E:Unable to lock directory /var/li/apt/lists
log out of ubuntu, then log in again and open only the terminal and do the update process!
ok i done as you told, i log off, log in
executeed sudo apt-get update
it asked password i gave
the media change:please insert the disc labeled
‘ Ubuntu 10.10 _Maverick Meerkat_-Release i386(20101007)’
in the drive ‘/cdrom/’ and press enter
i got this, so i inserted ubuntu 10.10 i press enter ,but still getting same problem
please help me , getting problem while installing ,i log off, log in
executeed sudo apt-get update
it asked password i gave
the media change:please insert the disc labeled
‘ Ubuntu 10.10 _Maverick Meerkat_-Release i386(20101007)’
in the drive ‘/cdrom/’ and press enter
i got this, so i inserted ubuntu 10.10 i press enter ,but still getting same problem
I find a problem of install ns While I do this command find
thoraya@ubuntu:~$ sudo apt-get install ns nam xgraph
Lecture des listes de paquets… Fait
Construction de l’arbre des dépendances
Lecture des informations d’état… Fait
E: Impossible de trouver le paquet ns
impossibl found the packet ns
why?
i reinstalled ubuntu now command
sudo apt-get update working
but second command
$ sudo apt-get install ns2 nam xgraph if i execute this getting
reading packages list……. done
reading information ……….done
E:unable to locate package graph
is it error or can proceed? please replay me soon
thanks a lot:) installed it successfully….
i’m working with the routing protocol noah in ns-2.34
my project is repture of energy help me please
Hi, i got the following messages when i open the terminal
bash: 2.34/tcl8.4.18/unix:/home/rony/ns-allinone-2.34/tk8.4.18/unix: No such file or directory.
please help me out.
hey manoj,i’m a new of NS2 and very beginner user of that software.i have tried many times to install NS2 on ubuntu 10.04 but always failed, and now i got your link which is guide how to install NS2 on ubuntu 10.10.
i installed ubuntu 10.10 on virtual box, is that NS2 could success install on virtual box?
please reply to help me get into NS2 soon and can run ns2 successfully.
thank you in advance
Hi Manoj Kumar
Thanks a lot man!!!
I could install the ns2 successfully
which ns (ns-2.33 or ns-2.34) this command
$ sudo apt-get install ns2 nam xgraph
installs??
Hi manoj…
i got the messages “wrong # args: should be “namespace subcommand ?arg….?”” too…
and u wrote above “To confirm that your installation was successful, just run the script simple-wireless.tcl in the location /home/yourHomeFolder/ns-allinone2.34/ns2.34/tcl/ex”
my question is How to run the script simple-wireless.tcl ?
thx a lot
Thanks alot!
Your post was really helpful, It worked and I am up and running with ns2 on my Ubuntu 10.10.
hi…ive been trying this procedure but afte i give the following command
sudo apt-get install ns2 nam xgraph
I get the following…
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package xgraph is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Unable to locate package ns2
E: Unable to locate package nam
E: Package ‘xgraph’ has no installation candidate
Need help asap…:)
hi i m boopathi. i want to install wimax in ns2 2.33 please help me..
there an expert here to help us for what the command
apt-get install ns2 nam graph
does not work
when i am installing ns2.33 in ubuntu10.10, i face a problem
tk8.4.18 make failed
so how can i overcome this
hi
may i ask how i executed tcl in proper way ?
thanks
hi
please could any person have any resources about ns2 any any resource about MANET help me please because i begin in research untill now i coudnt understand ns2
thinks
Hi i am getting error at step5 itself ,the error is as follows:
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package gcc-4.3
E: Couldn’t find any package by regex ‘gcc-4.3′
please help me as soon as possible….