t e c h i e - t a l k s ::: technology at its best

technology at its best

t e c h i e  -  t a l k s ::: technology at its best header image 2

HOW TO: Install Network Simulator 2 & Network animator (NSnam) on Ubuntu Hardy

August 29th, 2008 · 49 Comments

So I’ve been given a Final Year Project that deals with vehicular communication on a VANET (Vehicle Ad-hoc Network). It involves hardware implementation of an embedded system modules to a car’s CAN-BUS so as to communicate with the car’s ECUs and between cars themselves. If everything goes well, this would probably be implemented in luxury cars such as Audis & BMWs (we’re testing using the AUDI cars) - or maybe not.

Anyway, to cut the long story short, opensource is the way to go and thus, I needed free softwares to simulate changing network topology and routing algorithms. After a few considerations, NS2/Nam is my prefered choice. Installing it in Fedora 9 seems to be a breeze but Ubuntu has its setbacks. However, it is not difficult to overcome.

First, you have to download the NS2 allinone installation file from here and untar the compressed file (I’m using release ns2-2.33). Common to Ubuntu distribution, the OS is lack of developer tools like compilers and stuffs. Thus, make sure you already have installed your build essentials. If you haven’t,

sudo apt-get install build-essential

Next, you’ll need some dependencies which will allow the installation process to be successful. Else, you’ll probably get a “make: *** [tk3d.o] Error 1 tk8.4.14 make failed!” error.

sudo apt-get install autoconf automake libxmu-dev

After installation is successful, it’s time to install the NS2/Nam program

cd ns-allinone-2.33
./install

The installation process will take several minutes (depending on your machine’s processing power) with lots of installation verbose on your terminal. When the installation has ended, it will tell the user that installation is successful.

Next, you’ll need to change some Environment values in order to make your program work correctly.

sudo gedit ~/.bashrc

Add these lines to your bashrc file. Replace “your directory” with the installation directory of your ns2 program.

#environment values for NS2/NAM
# LD_LIBRARY_PATH
OTCL_LIB=/your directory/ns-allinone-2.33/otcl-1.13
NS2_LIB=/your directory/ns-allinone-2.33/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=/your directory/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/your directory/ns-allinone-2.33/bin:/your directory/ns-allinone-2.33/tcl8.4.18/unix:/your directory/ns-allinone-2.33/tk8.4.18/unix
NS=/your directory/ns-allinone-2.33/ns-2.33/
NAM=/your directory/ns-allinone-2.33/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM

Then type,

source ~/.bashrc

Next, you would want to validate the installation process. Go to the library and,

cd ns-2.33
./validate

This will take a much longer time than the first installation command (./install). After installation, a validation confirmation “validate overall report: all tests passed” will be shown.

To use ns2 simulator, just type,

  $> ns

Hope this help for those who are planning to use the NS-2.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: HOW TO guides

49 responses so far ↓

  • 1 allison // Sep 12, 2008 at 9:11 pm

    Excellent advice.

    One typo… I’ll clarify for the NB’s;
    The following line:
    source ~./bashrc
    should actually be:
    source ~/.bashrc
    (bashrc is a hidden file)

  • 2 firdooze // Sep 26, 2008 at 10:59 am

    Thanks for pointing out the mistake. Fixed it! =)

  • 3 Craft // Oct 23, 2008 at 2:33 pm

    Hi,

    I also tried to install ns-allinone on ArchLinux. I’ve followed your tips, but I have a little problem with nam. Can you use your nam ? Mine’s showing this error:

    [code omitted because of length]
    : 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…”

  • 4 Sandilya // Oct 24, 2008 at 1:58 pm

    Hey ,
    I really owe u guys…I was stuck at some point when i was installing NS2 on my Ubuntu OS. There was some problem with the nam binary. But I figured out a lot after reading your instructions. I have read through a lot of instructions but i felt urs were the best and simplest for people who havent dealt with NS2 earlier.Thanx a million and God bless. Thanx again.Cherio. ;)

    Best Regards,
    Sandilya.

  • 5 Sully // Nov 11, 2008 at 1:45 am

    Works great for me on Hardy. Thanks!

  • 6 sujay // Nov 11, 2008 at 1:06 pm

    thank you, u saved me a day’s work

  • 7 rajeswaran // Nov 14, 2008 at 4:02 pm

    i installed opensusue 10.2
    i want to install and work NS2 for VANET.
    please send the procedure to my mailid

  • 8 moad // Nov 16, 2008 at 8:34 am

    Its good thanks for help

  • 9 Ashwath // Nov 20, 2008 at 3:09 pm

    Was very helpful, will recommend to my friends too!
    Thanks.

  • 10 firdooze // Dec 3, 2008 at 4:37 pm

    Hey guys, no problem man. I am glad to help! Just that I’m kinda busy with school work (mainly working on some VANET routing protocol), thus I may take sometime to reply back. Sorry bout that.

    @Craft: My NAM works fine. Did your validation process went without error messages? Worse-case would be to change to another distro. I’ve tried it on Ubuntu and Fedora with 100% success. :)

    @Rajeswaran: The installation process should be similar.

  • 11 Ufuk // Dec 30, 2008 at 4:56 pm

    NAM=/your directory/FYP/ns-allinone-2.33/nam-1.13/

    FYP ??? what does it mean? is it ur dir’s name?
    thnx in advance

  • 12 firdooze // Jan 15, 2009 at 1:20 pm

    oh sorry, ignore the FYP. It was part of my directory. heeh..

  • 13 arun // Jan 19, 2009 at 6:13 pm

    hey.. i followed the steps you have said for nstalling ns2 on ubuntu. But after everything is finished, when I type ns nothing happens. I don’t get any % symbol… please help!

    P.S. I use ubuntu on virtualbox software.

  • 14 firdooze // Jan 20, 2009 at 2:01 am

    arun > I am guessing that you might have forgotten to edit and use the bashrc file.

  • 15 blorent // Feb 4, 2009 at 11:40 pm

    Hi,

    I have the same issue as Craft, running Arch Linux too. I suspect this is caused by a wrong X11_LIB (/usr/X11R6/lib doesn’t exist on Arch)

    I tried several other possibilities but no success se far

    If anyone can help…

  • 16 tomy // Feb 25, 2009 at 1:55 am

    good evening,
    first thank you for your effort, i have some problem with the instruction ./validate, it’s return me:
    validate overall report: some portable tests failed:
    ./test-all-red
    to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

    any idea how to procede?
    thank you very much ^^

  • 17 2009_Beginner // Feb 27, 2009 at 9:06 pm

    Hello !

    I hope you can help me with this problem. I was trying to do some mobile ad hoc simulations but now I have a problem. After starting the simulation I cannot see it in NAM. It gives error like this:

    invalid command name “n”
    while executing

    “n -t * -s 0 -x 0 -y 0 -Z 0 -z 100 -v circle -c black”
    (file “mobile100.nam” line 1)

    I am using NAM version 1.13, for ns2.32 on Linux (Fedora 8 and kernel 2.6). I have installed it as allinone version.

    If you have experience with this kind of problems please help.

    Thank you in advance!

  • 18 firdooze // Feb 28, 2009 at 1:11 am

    @Beginner: Maybe you could try running the nam file on command line rather than automatically after the ns2 simulation. If it was generated successfully by NS2, I don’t see why there would be an error.

    @tomy: Do check your installation output file and try run the specific test name as instructed by the installer.

    @Blorrent: Just wondering whether are your running a x64 machine? Because I had some similar problem with X11 files on an 64bit server running in a cluster. I had to chance the ./configure files to include the 64 environment library in the x11 line. (/usr/X11/lib64)

  • 19 nicko // Mar 1, 2009 at 11:53 pm

    great!
    it works thanks to your explanations

  • 20 Rajeswaran // Mar 3, 2009 at 1:15 pm

    Need help to install and run ns2 step by step procedure on opensuse 10.2

  • 21 sean // Mar 13, 2009 at 7:28 pm

    I’ve the same problem as craft. When I try to run nam I get:

    $ nam:
    [code omitted because of length]
    : 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…”

    Any Ideas?

  • 22 30fillos // Mar 16, 2009 at 8:39 am

    thx
    for me work exelent

  • 23 sachin // Mar 17, 2009 at 6:29 am

    Me too have same problem like sean and craft

  • 24 firdooze // Mar 20, 2009 at 10:02 pm

    You guys installed the all-inone version right?
    Did the validate process throw up any errors?

  • 25 lyat // Mar 24, 2009 at 9:34 pm

    I found a solution here : http://forums.fedoraforum.org/showthread.php?t=206795
    and it works for me.
    I’m running ns on archlinux

  • 26 lyat // Mar 24, 2009 at 10:24 pm

    little precision
    when I execute ./validate some tests failed but ns works well
    enjoy!

  • 27 Lynn Hsan // Apr 8, 2009 at 8:00 am

    Hi,
    i’ve already install NS simulator what you said above and wrote tcl file. i want to know is where do i put my tcl file under ns directory..when i run ns i got error messages as follows:

    hanlinnhsan@hanlinnhsan-laptop:~/Desktop/ns-allinone-2.33$ ls
    bin include nam-1.13 README tclcl zlib-1.2.3
    cweb install ns-2.33 sgb tclcl-1.19
    dei80211mr-1.1.4 INSTALL.WIN32 otcl share tk8.4.18
    gt-itm lib otcl-1.13 tcl8.4.18 xgraph-12.1
    hanlinnhsan@hanlinnhsan-laptop:~/Desktop/ns-allinone-2.33$ ns run
    couldn’t read file “run”: no such file or directory

  • 28 I. A. Musbah // Apr 15, 2009 at 11:33 pm

    Hi guys ,,,

    I am working on ns2.29.2 based on Cygwin, I have problem with NAM it dose not work with it gives me

    code omitted because of length no event type or button or keysym
    while executing
    bind Listbox {
    %W yview scroll [expr {- (%D / 120) * 4}] units
    . . . . .

    please anyone have faced this problem help me .

    thanks

  • 29 shahzad // Jun 5, 2009 at 12:57 pm

    i install ns2.29.3 on ubuntu and got no problem even upto the command ns and i get the % on the terminal. but When I run validate, it reports like this:
    validate overall report: some tests failed: ./test-all-red
    to re-run a specific test, cd tcl/test; ../../ns test-all TEST-NAME
    Notice that some tests in webcache will fail on freebsd when -O is turned on.
    This is due to some event reordering, which will disappear when -g is turned on.
    please help me to get out from this problem i have tried to install ns2 for a number of times since a week.
    and also tell me the link where can i download examples of WLAN and LAN simulations for ns.

  • 30 sunil // Jul 22, 2009 at 4:58 pm

    Hi guys ,,,

    I am working on ns2.2.3 on fedora 10 , I have problem with installation of NAM please give me the procedure to install it

  • 31 asmahan // Jul 31, 2009 at 8:20 pm

    hi all
    i tried to install ns2 allinone-2.33
    but i faced some problems
    can anyone help me
    i need the exact steps to install it in fedora 8

  • 32 sara // Oct 4, 2009 at 2:14 pm

    hi!
    i hv got the same pbm as shahzad…….
    when i try to run nam
    an error occurs as “bad command”.
    plz help me…..
    thanks

  • 33 durga // Oct 11, 2009 at 5:43 pm

    hey, thanks for that! The steps actually worked.
    Putting reference in my blog as well :) just incase any of my friends want to follow your steps

  • 34 Network Simulator NS2 - CrazyEngineers Forum // Oct 17, 2009 at 8:57 pm

    […] post checks as well and found its OK. except that I have not yet started to program here you go. HOW TO: Install Network Simulator 2 & Network animator (NSnam) on Ubuntu Hardy __________________ cheers durga […]

  • 35 karthik // Oct 29, 2009 at 12:55 am

    hi!
    i am using Ubuntu9.04 to install ns-2.33, and i used the procedure provided by u guys but when I type
    “source ~/.bashrc” the terminal says that no such file or directory exists and it also says that command cannot be found!!!!!
    plz help me……

  • 36 uday // Nov 17, 2009 at 7:06 am

    Im trying to install 2.34 in ubuntu 9.10 and when I try to validate using ./validate it doesnt validate and also the ns is not a valid command it seems the error message goes like this
    ” ./validate : No such file or directory”

  • 37 manoj // Nov 30, 2009 at 1:05 am

    [code omitted because of length]
    : 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 am getting this problem kindly solve please

  • 38 Raman // Dec 31, 2009 at 6:48 am

    hello friends,
    am using ubuntu9.10, when am trying to install ns2-2.34 in it, am getting the following error at the end of installation

    “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”

    pls help me to solve this problem.

  • 39 emna // Jan 5, 2010 at 7:27 pm

    i am using ubuntu 9.04 to install ns2.33
    i have a problem with ./validate

    validate overall report: some portable tests failed:
    ./test-all-xcp
    to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

    and when i type
    ./test-all-TEST-NAME
    the answer is
    bash: ./test-all-TEST-NAME: Aucun fichier ou dossier de ce type
    please some help

  • 40 suren // Jan 6, 2010 at 1:56 am

    /home/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1400: error: ‘TkBorder’ has no member named ‘nextPtr’
    /home/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1403: error: ‘TkBorder’ has no member named ‘resourceRefCount’
    /home/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1405: error: ‘TkBorder’ has no member named ‘objRefCount’
    make: *** [tk3d.o] Error 1
    tk8.4.14 make failed! Exiting …

    when i install ns2-2.31 in ubuntu 9 i m gettin d above error… plz help me.. when i run ./configure it says “tk” package cannot b found…

  • 41 Adulya // Jan 7, 2010 at 12:36 pm

    HELP!!!!!!!!!
    i have to use NS2 for my project. Unfortunately , our college labs do not providew any assistance. I followed instructions from : http://osiris.sunderland.ac.uk/~cb3psh/q2part1.html
    The instructions are almost similar to yours.
    After i execute ./install though the following instructions show up.
    http://osiris.sunderland.ac.uk/~cb3psh/q2part1.html

    I am a novice in working with Linux. And i havent been able to find out enough info to set env variables. The last time we re-coded the Bash file, the entire OS commands were destroyed.

    I WOULD GREATLY APPRECIATE UR ASSISTANCE WITH THIS PROBLEM AT THE EARLIEST!! :(

  • 42 Ali // Feb 8, 2010 at 4:36 am

    Same Problem of Craft, Sean, and Manoj

    I installed ns2.26 all in one
    the solution proposed for ns2.33 can not be apply

    anyone can help me

  • 43 Anandharaj. G // Feb 13, 2010 at 7:28 pm

    student2@ubuntu:~$ nam
    nam:
    [code omitted because of length]
    : 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 am getting this problem kindly solve please pls pls

  • 44 firdooze // Mar 10, 2010 at 12:30 am

    hmm guys it’s quite diff to figure out whats the problem without actually knowing what the problem is..

    for compiling NS2 on ubuntu, make sure that you have all your build essentials.

    i.e apt-get install build-essentials

    here: http://www.isi.edu/nsnam/ns/ns-problems.html

    the above site is a good place to start looking @ debugging the problem.

    if you are building it from the source, look at this site: http://www.isi.edu/nsnam/ns/ns-build.html

    Anyway dudes, in my short time doing programming on Linux, I feel that Fedora has never failed me when it comes to cryptic debug errors. But I won’t say don’t use Ubuntu but be prepared to do a lil more work on finding solutions to certain build issues. Cheers!

    P.S I hope to do and update of this how-to in the near future.

  • 45 Network Simulator installation 2 « routerxyz // Apr 24, 2010 at 7:06 pm

    […] Network Simulator installation 2 Filed under: tools — routerxyz @ 9:38 am I had tried various sites for the steps to be followed to install NS 2. I continously had issues with the source packages and finally one of my friend ( precisely Sachin) suggested this site: STEPS TO INSTALL NETWORK SIMULATOR2.33 […]

  • 46 Nameless_sg // Jan 12, 2011 at 8:55 pm

    Hi, anyone can help me to install the NS-2 Software on Window 7?

  • 47 manikandan // Jul 14, 2011 at 4:03 pm

    Hai all. How to install NS in RH EL 5.5

  • 48 Nikumani Choudhury // Oct 5, 2011 at 11:00 am

    Hi,
    I am a new opensuse user.Currently am working with opensuse 11.I have followed your instructions and have successfully installe dand validated the NS2.34.But i don’t know now how should i invoke,i.e how should i start the application.i tried witind ns and nam in the terminal but without success.Please help me i this regard.

  • 49 sassou // Oct 9, 2011 at 6:23 am

    Hi friends,

    I want to install Ubuntu 7.10 on ns2.31 but I get errors during installation:
    1) error messages are:
    impossible to find the-dev packages (libxt-dev-dev libsm libice libxmu-dev-dev), these packages are not in synaptic!
    2) Another message is: tk8.4.14 make failed! exiting

    if anyone has any idea thank you for giving me a hand!

    thank you in advance

    here is my @mail: bouhejbaa_sassou@yahoo.fr

Leave a Comment



Your Ad Here