Installing Network Simulator(ns2.34) in Ubuntu10.10

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

This article is sponsored by Evansys Technologies.

Was this post helpful? Then thank me by clicking <this link>

You may also be interested in:

Advertisements

101 comments on “Installing Network Simulator(ns2.34) in Ubuntu10.10

  1. Hi

    it didnt work for me using 10.10 notebook edition
    err reads unable to locate package ns

    any help?

    thanks

  2. Hi Darsh!
    I suggest you update your ubuntu before installing ns.
    $sudo apt-get update
    then
    $sudo apt-get install ns nam xgraph

  3. 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

  4. 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?

  5. 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

  6. 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

  7. 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.

  8. 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

  9. @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

  10. @Randa
    run
    $sudo apt-get clean
    $sudo apt-get autoclean
    $sudo apt-get autoremove

    and begin the installation procedure again!

  11. 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/

  12. Please verify the version of the gcc compiler you are using.
    Also download the ns source file again and try installing!

  13. 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.

  14. 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

  15. 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

  16. 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 !!!!

  17. 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??

  18. 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

  19. 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…

  20. @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!

  21. 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….

  22. 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?

  23. i have to design an overlay network which can implement the basic functionalities like file n data transfer….

  24. 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………

  25. Thanks a lot.
    Worked for me.
    Pls give suggest a good website to learn about ns2 codes..
    I am a beginner

  26. Thanks a lot.
    Worked for me.
    Pls suggest a good website to learn about ns2 codes..
    I am a beginner

  27. 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”

  28. 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. 🙂

  29. 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.

  30. 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
    %

  31. 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

  32. 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.

  33. 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

  34. 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

  35. after completing all this step they show a error of ns archive file is not in this. what is the solution of this error

  36. 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

  37. 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

  38. 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

  39. 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?

  40. 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

  41. i’m working with the routing protocol noah in ns-2.34
    my project is repture of energy help me please

  42. 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.

  43. 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

  44. 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

  45. Thanks alot!

    Your post was really helpful, It worked and I am up and running with ns2 on my Ubuntu 10.10.

  46. 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…:)

  47. when i am installing ns2.33 in ubuntu10.10, i face a problem
    tk8.4.18 make failed

    so how can i overcome this

  48. 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

  49. 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….

  50. i just installed ns2.34 in ubuntu 10.10 successfully…. then also opened nam window by command then i tried to run code
    #Create a simulator object
    set ns [new Simulator]

    #Open the nam trace file
    set nf [open out.nam w]
    $ns namtrace-all $nf

    #Define a ‘finish’ procedure
    proc finish {} {
    global ns nf
    $ns flush-trace

    #Close the trace file
    close $nf

    #Execute nam on the trace file
    exec nam out.nam &
    exit 0
    }

    set n0 [$ns node]
    set n1 [$ns node]
    $ns duplex-link $n0 $n1 1Mb 10ms DropTail
    #Call the finish procedure after 5 seconds simulation time

    $ns at 5.0 “finish”

    #Run the simulation
    $ns run
    but it showed error that backword compatibility & error while calling class oldsim then i closed terminal & again opened & there when i typed ns it showed ” program ‘ns’ is currently not installed. You can install it by typing: sudo apt-get install ns2″ .
    please guide me…

  51. Hi,
    After error free installation i got this error in an attempt to run sample.tcl. Pls kindly assist me out of this

    % ns sample.tcl
    warning: using backward compatibility mode
    error when calling class OldSim: t.tcl
    %

  52. hi i follow your steps and it works mate!
    anyway can you give me WiMAX module or patch for NS 2.34?
    it’ll be a great help for me.
    Cheers mate!

  53. All my installation process have been successfull, but atlast after this code
    “# NS=/home/deepak/ns-allinone-2.34/ns-2.34/NAM=/home/deepak/ns-allinone-2.34/nam-1.14/PATH=$PATH:$XGRAPH:$NS:$NAM”
    you had said to give “$ source ~/.bashrc”
    It dint respond anything after this!
    Can u help me plz?!

  54. hi
    i am getting the following error while installing ns-2.31 on ubuntu 10.10.
    please help

    otcl.o: In function `OTclDispatch’:
    /root/ns-allinone-2.31/otcl-1.13/otcl.c:495: undefined reference to `__stack_chk_fail_local’
    otcl.o: In function `Otcl_Init’:
    /root/ns-allinone-2.31/otcl-1.13/otcl.c:2284: undefined reference to `__stack_chk_fail_local’
    ld: libotcl.so: hidden symbol `__stack_chk_fail_local’ isn’t defined
    ld: final link failed: Nonrepresentable section on output
    make: *** [libotcl.so] Error 1
    otcl-1.13 make failed! Exiting …
    See http://www.isi.edu/nsnam/ns/ns-problems.html for problems
    root@ubuntu:~/ns-allinone-2.31#

  55. Sir,
    I am working on NS2 and trying to run one script
    Shows error,
    ———————————————————————–
    invalid command name “Agent/LBR”
    while executing
    “Agent/LBR set maximum_failsafe 5”
    (file “nodes.tcl” line 22)
    ———————————————————————–
    Please suggest.

  56. Hi,
    I type the 3 commands install ns2 nam and xgraph and it’s succefully installed but i like to modify aodv.cc it’s necessary to install ns2 with the old installation??

  57. HI,
    after ns2 2.35 successfully installed this error message appears
    bash: :/usr/X11R6/lib:/usr/local/lib: No such file or directory
    plz help me

  58. I’m extremely impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you modify it yourself? Either way keep up the excellent quality writing, it’s rare to see a nice blog like this one these days.

  59. please give me a solution for the following error as soon as possible
    “backward compatibility mode error when calling a class oldsim”.This i got when iam trying to compile the sample program s.tcl in ns2.35 with ubuntu12

  60. im getting backward compatibility error whe calling class oldsim sample.tcl.

    pleass give me solution ASAP

  61. while am installing the cmd “$ sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3” am getting error like this and give me some solution

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Package autoconf 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 build-essential
    E: Package ‘autoconf’ has no installation candidate
    E: Unable to locate package automake
    E: Unable to locate package libxmu-dev
    E: Unable to locate package gcc-4.3
    E: Couldn’t find any package by regex ‘gcc-4.3’

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s