Thursday, 29 May 2008

Install NS2 on Ubuntu 8.04 Hardy

This semester I got an assignment from Wireless/Mobile Computing lecture. It's all about NS2, the most popular network simulator. Today I tried to install it on my Ubuntu 8.04. And, here is the story :)

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 ==a
$ 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.
# LD_LIBRARY_PATH
OTCL_LIB=/home/programmer/ns-allinone-2.33/otcl-1.13
NS2_LIB=/home/programmer/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=/home/programmer/ns-allinone-2.33/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

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

6. Validate it
$ 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. Try to run it (and pray :)
$ ns


Cheers.. ^__~

23 comments:

raizamn said...

Ha! Sama dong pake ns2, untungnya buat Mac ada package ns2 allinone precompiled universalbinary

anggriawan said...

@raizamn:
Wah, enak dong, mas, sudah ada yang bikin package .dmg nya..
Ntar deh klo sempet, ini mau iseng-iseng bikin package .deb untuk ns2 .. =D hehe..

mbi said...

Bila run %ns
hasilnya ini, betul ke?
--------------------------

mbi@spp:~/ns-allinone-2.33/ns-2.33$ ns
Usage: host [-v] [-a] [-t querytype] [options] name [server]
Listing: host [-v] [-a] [-t querytype] [options] -l zone [server]
Hostcount: host [-v] [options] -H [-D] [-E] [-G] zone
Check soa: host [-v] [options] -C zone
Addrcheck: host [-v] [options] -A host
Listing options: [-L level] [-S] [-A] [-p] [-P prefserver] [-N skipzone]
Common options: [-d] [-f|-F file] [-I chars] [-i|-n] [-q] [-Q] [-T] [-Z]
Other options: [-c class] [-e] [-m] [-o] [-r] [-R] [-s secs] [-u] [-w]
Special options: [-O srcaddr] [-j minport] [-J maxport]
Extended usage: [-x [name ...]] [-X server [name ...]]

anggriawan said...

@mbi:
yup :)

Anonymous said...

1) I have installed ns2 on ubuntu 8.04. same like u.

when i run %ns, the output is ;

Usage: host [-v] [-a] [-t querytype] [options] name [server]
Listing: host [-v] [-a] [-t querytype] [options] -l zone [server]
Hostcount: host [-v] [options] -H [-D] [-E] [-G] zone
Check soa: host [-v] [options] -C zone
Addrcheck: host [-v] [options] -A host
Listing options: [-L level] [-S] [-A] [-p] [-P prefserver] [-N skipzone]
Common options: [-d] [-f|-F file] [-I chars] [-i|-n] [-q] [-Q] [-T] [-Z]
Other options: [-c class] [-e] [-m] [-o] [-r] [-R] [-s secs] [-u] [-w]
Special options: [-O srcaddr] [-j minport] [-J maxport]
Extended usage: [-x [name ...]] [-X server [name ...]]

But i look at another source, the output must be %. So which one is right?
I'm very confuse......

2) If the output is right, what the basic command. What must i do to doing the simple example. I'am very new in this ns2..

anggriawan said...

@Anonymous:
please use google to find any NS2 tutorial..
here I just give NS2 installation tutorial on Ubuntu..
moreover, I have no advance experience with NS2 :)

NS noob said...

Everything was find, i got it validated but when is run ns, this is what i get:

fabian@fabian-laptop:~$ ns
% ns
warning: using backward compatibility mode
wrong # args: should be {ns message ?args...?}

any ideas why?

Anonymous said...

hi,
i install ns2.33 on ubunto 6.06 as you are mentionned, eveything is good but at the end of the installation i have this message:
tk8.4.18 installation failed
can you please help me ?
thanks

Anonymous said...

hi @ mbi and others who are getting the host stuff
when entering ns at the cmd line, its because you have
a software called host installed on ur system, which is invoked by the cmd line option ns

SO just remove it by using sudo apt-get remove host
or you could invoke ns by using its absolute path.

Anonymous said...

Great description. Worked for me perfectly.

Milisdad said...

@raizamn : ternyata dah gak isa didownload :(

jai said...

thnx buddy u proved to be a grrt help fr me...it wrkd

Okan said...

Thanks a lot

krittaya said...

Hi, i have a problem with ns2. the tora code is not working when i try to simulate using tora.tcl.. while it does work for aodv and dsdv protocols. is it becuz the code from the ns2 package wrong? if so where can i get the correct code? i've been searching for it. and my proj just doesn't move!!
so pls help!!!!
thanks in advance

yat81 said...

anggriawan, perfectly worked for me...just the output must be %, not some host...u should all remove that by apt-get removed host....

It's feeling good to complete the 1st step....more to come...

Anonymous said...

Bon avant tous je tien a remercie infiniment celui qui a ecrit ce tuto; car vraimnt c trés intéréssent mais!!!!
aprés suivre toutes les étapes j'ai encore un autre probléme c que il me donne tjr ce mssg:
exemple.tcl does not exist, try again
Donc jai rien a compri il me dit que le fichier .tcl n'éxiste pas!!! malgré qu'il existe vraiment...
SVP si qlqun peux maider j'attend au plus tot la réponse et merci pour toute personne qui participe a m'aider...
Mon adresse mail c'est: ammarahmi@hotmail.com

Anonymous said...

thansk a lot, from morocco !

Anonymous said...

kanapa ya, d kompi ki selalu eror pas install tcl nya.. binun

Anonymous said...

Hi, the ORIGINAL post.. which suggests doing sudo apt-get ... has a minor correction. The command is to be writen AFTER doing cd ns2-allinone.

Anonymous said...

Thanks a lot for the post. It works great.

Anonymous said...

i use ur procedure but i didn't get %

wibisana jaka said...

wah makasih Mas atas infonya, saya coba pake ns2 di CentOS tapi bingung waktu bikin path-nya

Ternyata setelah dicoba pake langkah 5 tersebut tetep bisa:D

Finance Dissertation Writing said...

Whenever i see the post like your's i feel that there are still helpful people who share information for the help of others, it must be helpful for other's. thanx and good job.

Finance Dissertations Help

Post a Comment