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.
# 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:/home/programmer/ns-allinone-2.33/xgraph-12.1/
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 (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

Then,

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

TroubleShooting

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,
+#endif
/* 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 ! :)




Get Tech Updates via eMail :

82 comments:

  1. Thanks dude,
    great post.
    really helped.
    though had to do a bit of googling to find a patch
    see this too...
    http://wirelesscafe.wordpress.com/2008/12/23/how-to-install-ns2-on-fedora-10-cambridge/

    ReplyDelete
  2. you mention that + sign is for adding and - sign is for delete

    i am confuse: i dont understand what to add and what to delete ?

    can u please explain me ??

    ReplyDelete
  3. I have updated the post, this might help you now !

    ReplyDelete
  4. Hey! thanks for the guide.
    But I am having a problem in running simple.tcl
    I copy & paste the above Hello program in text editor and save it as text file... but I think it should be in .tcl format to run... but I read some where that in ubuntu there is no need to save as in .tcl
    now in command prompt when I run this, I got error:-

    user@ubuntu8041:~$ ns simple.tcl
    couldn't read file "simple.tcl": no such file or directory

    I think it should be saved in .tcl but my text editor don't give me option to save as in .tcl...
    Please help me out as soon as possible.

    ReplyDelete
  5. I also found these errors when I open my command prompt:

    bash: LIB:/usr/local/lib: No such file or directory
    bash: ns-allinone-2.31/tcl8.4.14/unix:/home/user/ns-allinone-2.31/tk8.4.14/unix:/home/user/ns-allinone-2.31/xgraph-12.1/: No such file or directory

    I know that above guide is for ns2.33 but I found ns2.31 commands same as well...but I am encountering these errors after the command:
    $ gedit ~/.bashrc
    and copy & paste the given code in that file and saved it... please help me out!

    ReplyDelete
  6. (1) It's a good practice to save your file in tcl format, you can change the extension but just renaming the file and changing the extension. Even if you don't want to give tcl ext to file you have to write :

    ns simple.txt ( in case file extension is txt )

    and not

    ns simple.tcl

    (2)It gives the errors bcos you might have not supplied correct paths in the bashrc file. Correct them !

    ReplyDelete
  7. While i am executing tcl file with ns I have this error:
    ns: finish: couldn't execute "nam": permission denied
    while executing
    "exec nam out.nam &"
    (procedure "finish" line 5)
    invoked from within
    "finish"

    I have put NAM=/home/kamil/ns2/nam-1.14/ in to env varibles.

    Any suggestion where is a problem ??

    ReplyDelete
  8. Use sudo with the command you are giving, it will then ask you for root password and hence you will not get permission denied error.

    ReplyDelete
  9. Thanks, but I still having the error:

    bash: LIB:/usr/local/lib: No such file or directory

    and now I saved the exapmle as simple.tcl and now when I run it, this happen:

    user@ubuntu8041:~$ ns simple.tcl

    (_o5 cmd line 1)
    invoked from within
    "_o5 cmd at 1 “puts “Hello World!””"
    invoked from within
    "catch "$self cmd $args" ret"
    invoked from within
    "if [catch "$self cmd $args" ret] {
    set cls [$self info class]
    global errorInfo
    set savedInfo $errorInfo
    error "error when calling class $cls: $args" $..."
    (procedure "_o5" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o5 at 1 “puts “Hello World!””"
    ("eval" body line 1)
    invoked from within
    "eval $scheduler_ at $args"
    (procedure "_o3" line 3)
    (Simulator at line 3)
    invoked from within
    "$ns at 1 “puts \“Hello World!\””"
    (file "simple.tcl" line 2)

    Now what is happening here? I can't understand this output...

    ReplyDelete
  10. Hey! I run my own code named example.tcl and it was this:

    #Create a simulator object

    set ns [new Simulator]





    #Open the NAM and Trace file

    set nf [open out.nam w]

    $ns namtrace-all $nf

    set f0 [open out1.tr w]

    $ns trace-all $f0





    #Define different colors for data flows (for NAM)

    $ns color 1 Blue

    $ns color 2 Red





    #Create six nodes

    set n1 [$ns node]

    set n2 [$ns node]

    set n3 [$ns node]

    set n4 [$ns node]

    set n5 [$ns node]

    set n6 [$ns node]







    $ns duplex-link $n1 $n3 2Mb 10ms DropTail

    $ns duplex-link $n2 $n3 2Mb 10ms DropTail

    $ns duplex-link $n3 $n4 1Mb 10ms DropTail

    $ns duplex-link $n4 $n5 2Mb 10ms DropTail

    $ns duplex-link $n4 $n6 2Mb 10ms DropTail





    $ns duplex-link-op $n1 $n3 orient right-down

    $ns duplex-link-op $n2 $n3 orient right-up

    $ns duplex-link-op $n3 $n4 orient right

    $ns duplex-link-op $n4 $n5 orient right-up

    $ns duplex-link-op $n4 $n6 orient right-down







    #Set Queue Size of link (n3-n4) to 10

    $ns queue-limit $n3 $n4 10





    #Monitor the queue for link (n3-n4).

    $ns duplex-link-op $n3 $n4 queuePos 0.5





    #Setup a TCP connection

    set tcp [new Agent/TCP/Reno]

    #$tcp set packetsize_ 1000

    $ns attach-agent $n1 $tcp

    $tcp set class_ 1





    set sink [new Agent/TCPSink]

    $ns attach-agent $n5 $sink

    $ns connect $tcp $sink





    #Setup a FTP over TCP connection

    set ftp [new Application/FTP]

    $ftp attach-agent $tcp





    #Setup a UDP connection

    set udp [new Agent/UDP]

    $ns attach-agent $n2 $udp

    $udp set class_ 2



    set null0 [new Agent/Null]

    $ns attach-agent $n6 $null0

    $ns connect $udp $null0





    #Setup a CBR over UDP connection

    set cbr0 [new Application/Traffic/CBR]

    $cbr0 set packetSize_ 500

    $cbr0 set interval_ 0.01

    $cbr0 attach-agent $udp





    #Schedule events for the CBR and FTP agents

    $ns at 0.0 "$cbr0 start"

    $ns at 0.0 "$ftp start"

    $ns at 25.0 "$ftp stop"

    $ns at 30.0 "$cbr0 stop"





    #Define a 'finish' procedure

    proc finish {} {

    global ns nf f0

    $ns flush-trace

    #Close the NAM trace file

    close $nf

    close $f0

    #Execute NAM on the trace file

    exec nam out.nam &

    exit 0

    }





    $ns at 30.0 "finish"





    #Run the simulation

    $ns run

    I saved it as exapmle.tcl and the run it as:

    $ ns example.tcl

    Bingo! I got the output in nam and its running perfectly!
    I think there may any problem in code of simple.tcl ...
    Anyways thanks Shubham NeO ©® for the superb guide line. And those who have problem in running simple.tcl then try my above code and save it as example.tcl =)

    ReplyDelete
  11. X11_LIB=/usr/X11R6/lib is given in step 5. But there is no such path in ubuntu 9.04. in fact there is only one folder(bin) in X11R6 and that too is linked. so proper validation doesnt take place if i include bin.
    can someone pls help.

    ReplyDelete
  12. Thanks a lot for this guide.
    Installation was successful. I saw %.
    After i used the command:
    $ sudo ln -s /home/programmer/ns-allinone-2.33/ns-2.33/ns /usr/bin/ns
    It has stopped to operate. How can i cancel this command?
    Please, execuse me for my English. It's not my native language.

    ReplyDelete
  13. @bove I suppose this command should not halt the working of NS as it only creates symbolic link. Anywayz, if it is so then remove the file in /usr/bin/ named ns, if still it does not work, delete your NS folder and reinstall it.

    @bove @bove : You can neglect the validation as far as NS is working fine.

    ReplyDelete
  14. If its not too much trouble can you help me a little further?
    I've tried some of the tutorial lessons on the ns2 website but I get
    the following error.
    -----------------------------------------------------------------------------------------------------------------------------------
    mehernosh@machine:~$ ns example1a.tcl
    mehernosh@machine:~$ 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 {[string equal [tk windowingsystem] "classic"]
    || [string equal [tk windowingsystem] "aqua"]} {
    bind Listbox {
    %W yview scroll [expr {..."
    ----------------------------------------------------------------------------------------------------------------------------------------

    I get this error no matter what script I try, the simple hello world described above or more advanced ones available online. Its not that I am making a mistake in the Tcl code because I am tried using scripts available online at http://www.isi.edu/nsnam/ns/tutorial/index.html .
    Help!

    ReplyDelete
  15. I have a problem in the command
    $ source ~/.bashrc

    emna@emna-desktop:/usr/local$ source ~/.bashrc
    bash: :/usr/X11R6/lib:/usr/local/lib: Aucun fichier ou dossier de ce type

    can someone pls help

    ReplyDelete
  16. @bove : You can ignore this error if you are able to get % sign on running ns.

    ReplyDelete
  17. I am getting the below lines for any script I write....
    and I have installed ubuntu 9.10 version...
    please help me out to getrid of this....


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

    ReplyDelete
  18. That was an awesome guide...thanx a lot, Shubham, for posting it...really cool... :)
    I am writing this because some Ubuntu 9.10 users are also posting here.
    But ubuntu 9.10 users might still face some problems (I faced one :(..) while installing ns-2.34 (or probably even the older versions...).
    The trouble is that ubuntu 9.10 provides gcc-4.4 while otcl likes gcc-4.3.
    So,

    1. "sudo apt-get install gcc-4.3 gcc-4.3-base"

    2. Navigate to otcl folder. Edit Makefile.in file
    in line 7
    From :
    CC= @CC@

    to :
    CC= gcc-4.3

    3. Then move up one folder and then
    'CC=gcc-4.3 ./install'

    There is no g++ code in ns folder so there wont be any requirement in installing g++ stuff.

    4. ./validate

    Actually, there are no more changes except the gcc part. Rest of the procedure remains the same.

    Hope it helps...

    ReplyDelete
  19. Excellent post ~NeO~, I used your recipe from top to bottom and with the exception of some additional tweaks here and there due to my Ubuntu 9.10 system, I was able to install ns without "so much trouble". very well written and easy to follow

    Thanks a lot!

    ReplyDelete
  20. Install Network Simulator 2 ( NS2) Within 2 Minutes

    Hi Friendssss.......Now You can Install NS2 in Ubuntu within Two Minutes..No tedious task of Changing environment and all etc.. U just Download the link(.rar file) Provided below.. and Extract the Files and Just Double click on them ..thats it Dudes.. now you have installed Ns2 in Ubuntu in two Minutes.. to Check..it got installed or not just go to terminal and type ns then you will get % Symbol just exit the terminal.. to run a Tcl file go to terminal and type ns example1.tcl.....wow...... now U can see the Nam animator.. Congratsssssssss....
    Download Link..
    http://suneelshinde.blogspot.com

    ReplyDelete
  21. Hey guys,

    Can you please help out? After entering the variables and validated, i typed in ns at the prompt but didn't get the % sign. I got this instead:

    validate overall report: all tests passed
    lamy@lamy-desktop:~/ns-allinone-2.33/ns-2.33$ sudo ln -s /home/lamy/ns-allinone-2.33/ns-2.33/ns/usr/bin/ns
    [sudo] password for lamy:
    ln: creating symbolic link `./ns': File exists
    lamy@lamy-desktop:~/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 ...]]
    lamy@lamy-desktop:~/ns-allinone-2.33/ns-2.33$

    Does it have to do with my internet or something?

    Hope to hear from you guys soon

    Cheers

    ReplyDelete
  22. sir i run the tcl script wireless-test.tcl in ns2.34 verson. it creates two files trace and nam.
    then i run name file also. i want to save the nam output. but i dont know. plese respond to my question if u know.

    ReplyDelete
  23. Nice post was really helpful, and for those who want to install NS in Ubuntu 9.10 and having some other problem can learn it from
    http://pingusays.blogspot.com/2010/03/installing-ns-234-in-ubuntu-910.html

    ReplyDelete
  24. Hi,
    Found the following error while installing ns2-2.34 on ubuntu 9/04

    /home/rvce/Desktop/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1403: error: ‘TkBorder’ has no member named ‘resourceRefCount’
    /home/rvce/Desktop/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1405: error: ‘TkBorder’ has no member named ‘objRefCount’
    make: *** [tk3d.o] Error 1
    tk8.4.18 make failed! Exiting ...
    For problems with Tcl/Tk see http://www.scriptics.com

    Please do the needful.

    Harsha

    ReplyDelete
  25. hi dears i have installed the simulator but have an error when run example.tcl please help out
    % ns example.tcl
    error when calling class OldSim: example.tcl

    ReplyDelete
  26. thanks a lot ... i am done successfully with ubuntu 8.04 and ns 2.34 >(

    ReplyDelete
  27. when i installed and validated it, it was done ok. Then i followed step 7, it was also done but wen i followed step 8, it gave the following output:
    bash: :/usr/X11R6/lib:/usr/local/lib: No such file or directory

    can you please help?

    ReplyDelete
  28. hey when I install ns-allinone-2.33 on Ubuntu 9.04 I'm unable to get % sign that indicates successful installed instead I'm getting something like...
    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 ...]]
    Plz help me out of this.....

    ReplyDelete
  29. hey i have a source code of (cluster based routing protocol)cbrp implementation. it needs NS with cmu extension.
    can anybody please help me.

    i have got the i have got the ns-src with cmu extention but i have already installed ns2.34 how can i install the ns with cmu extension.

    help needed urgently.

    ReplyDelete
  30. hey i have a source code of (cluster based routing protocol)cbrp implementation. it needs NS with cmu extension.
    can anybody please help me.

    i have got the i have got the ns-src with cmu extention but i have already installed ns2.34 how can i install the ns with cmu extension.

    help needed urgently.

    ReplyDelete
  31. Hi, Thanks lot. This was really help me. Many Thanks...........................

    ReplyDelete
  32. hi
    anynone help me interating cbrp in ns2 and give me file .tcl of cbrp
    thank you very much

    ReplyDelete
  33. hey i have a source code of (cluster based routing protocol)cbrp implementation. it needs NS with cmu extension.
    can anybody please help me.

    i have got the i have got the ns-src with cmu extention but i have already installed ns2.34 how can i install the ns with cmu extension.

    ReplyDelete
  34. Hi
    first i thanks you about the procedure of installing
    How can run multi simulation by using loop(FOR) and in each simulation i want to implement proc.finish which have multi AWk steps and put the result of awk in new output text file for each simulation to use this data later

    ReplyDelete
  35. thanks for this guide
    my name is ahmed, i need your help
    how can i create multi simulation by using loop(For) and save the output of each simulation in a new text file

    ReplyDelete
  36. $ nam: no display name and no $DISPLAY environment variable

    can anyone help??

    ReplyDelete
  37. while running the sample.tcl file i get the following error :-
    "
    warning: using backward compatibility mode
    error when calling class OldSim: sample.tcl
    "

    can u help me plz ???

    ReplyDelete
  38. Greetings Friends i am using ubuntu-10.04.1 and i installed NS-2.34 .and i tried all the steps above its works until the step when i typ $ ns
    nothing happen the following message appear
    command not found
    can anyone please help me i really need to make it work

    ReplyDelete
  39. I tried to execute a ns2.33 program in ubuntu9.10, i got error only based on NAM file. How to install the 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..."

    ReplyDelete
  40. hai guys. My name is Sharul. im using ubuntu 10.04 lts and using ns2 2.34. just for info im really new with ns2 and also ubuntu. why am i getting the permission denied when running the simple.tcl example as given in the website. any one can help me with it? Thanks Guys.

    ReplyDelete
  41. Thanks Shubham for the help

    ReplyDelete
  42. % ns test-suite-wireless-lan.tcl
    warning: using backward compatibility mode
    error when calling class OldSim: test-suite-wireless-lan.tcl

    whene ever i try an example it shows me this : error when calling class OldSim
    pleeease can anyone help!!

    ReplyDelete
  43. hey shubham
    i was installing ns2.34 and i got this error

    Build OTcl-1.13

    install: 498: ./configure: Permission denied
    otcl-1.13 configuration failed! Exiting ...

    could you please tell me, why this is happening

    ReplyDelete
  44. can anyone give me the code to create VPN client in ns2

    ReplyDelete
  45. i have installed ns2 successfully... i am implementing VPN client in adhoc network please can someone provide me with code...

    ReplyDelete
  46. couldn't open "out.nam": permission denied
    while executing
    "open out.nam w"
    invoked from within
    "set nf [open out.nam w]"
    (file "example1b.tcl" line 5)

    ReplyDelete
  47. can anybody suggest solution for it.. I am facing following problem

    couldn't open "out.nam": permission denied
    while executing
    "open out.nam w"
    invoked from within
    "set nf [open out.nam w]"
    (file "example1b.tcl" line 5)

    ReplyDelete
  48. nice post, was really helpful
    http://www.google.com

    ReplyDelete
  49. avi@ravi-desktop:/$ source ~/.bashrc
    bash: allinone-2.34/libX11_LIB=/usr/X11R6/libUSR_LOCAL_LIB=/usr/local/libexport: No such file or directory
    bash: 2.34/bin:/home/ravi/ns-allinone-2.34/tcl8.4.18/unix:/home/ravi/ns-allinone-: No such file or directory
    bash: 2.34/tk8.4.18/unix:/home/ravi/ns-allinone-2.34/xgraph-12.1/NS=/home/ravi/ns-allinone-2.34/ns-: No such file or directory
    bash: 2.34/NAM=/home/ravi/ns-allinone-2.34/nam-1.13/export: No such file or directory




    please help me

    ReplyDelete
  50. i used ubuntu 10 nd ns 2.34

    ReplyDelete
  51. hey shubham
    i was installing ns2.34 and i got this error

    Build OTcl-1.13

    install: 498: ./configure: Permission denied
    otcl-1.13 configuration failed! Exiting ...

    could you please tell me, why this is happening

    ReplyDelete
  52. I tried to execute a ns2.33 program in ubuntu9.10, i got error only based on NAM file. How to install the 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..."

    ReplyDelete
  53. while running the sample.tcl file i get the following error :-
    "
    warning: using backward compatibility mode
    error when calling class OldSim: sample.tcl
    "

    can u help me plz ???

    ReplyDelete
  54. $ nam: no display name and no $DISPLAY environment variable

    can anyone help??

    ReplyDelete
  55. thanks for this guide
    my name is ahmed, i need your help
    how can i create multi simulation by using loop(For) and save the output of each simulation in a new text file

    ReplyDelete
  56. hey i have a source code of (cluster based routing protocol)cbrp implementation. it needs NS with cmu extension.
    can anybody please help me.

    i have got the i have got the ns-src with cmu extention but i have already installed ns2.34 how can i install the ns with cmu extension.

    help needed urgently.

    ReplyDelete
  57. when i installed and validated it, it was done ok. Then i followed step 7, it was also done but wen i followed step 8, it gave the following output:
    bash: :/usr/X11R6/lib:/usr/local/lib: No such file or directory

    can you please help?

    ReplyDelete
  58. Hi,
    Found the following error while installing ns2-2.34 on ubuntu 9/04

    /home/rvce/Desktop/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1403: error: ‘TkBorder’ has no member named ‘resourceRefCount’
    /home/rvce/Desktop/ns-allinone-2.34/tk8.4.18/unix/../generic/tk3d.c:1405: error: ‘TkBorder’ has no member named ‘objRefCount’
    make: *** [tk3d.o] Error 1
    tk8.4.18 make failed! Exiting ...
    For problems with Tcl/Tk see http://www.scriptics.com

    Please do the needful.

    Harsha

    ReplyDelete
  59. Hey guys,

    Can you please help out? After entering the variables and validated, i typed in ns at the prompt but didn't get the % sign. I got this instead:

    validate overall report: all tests passed
    lamy@lamy-desktop:~/ns-allinone-2.33/ns-2.33$ sudo ln -s /home/lamy/ns-allinone-2.33/ns-2.33/ns/usr/bin/ns
    [sudo] password for lamy:
    ln: creating symbolic link `./ns': File exists
    lamy@lamy-desktop:~/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 ...]]
    lamy@lamy-desktop:~/ns-allinone-2.33/ns-2.33$

    Does it have to do with my internet or something?

    Hope to hear from you guys soon

    Cheers

    ReplyDelete
  60. Install Network Simulator 2 ( NS2) Within 2 Minutes

    Hi Friendssss.......Now You can Install NS2 in Ubuntu within Two Minutes..No tedious task of Changing environment and all etc.. U just Download the link(.rar file) Provided below.. and Extract the Files and Just Double click on them ..thats it Dudes.. now you have installed Ns2 in Ubuntu in two Minutes.. to Check..it got installed or not just go to terminal and type ns then you will get % Symbol just exit the terminal.. to run a Tcl file go to terminal and type ns example1.tcl.....wow...... now U can see the Nam animator.. Congratsssssssss....
    Download Link..
    http://suneelshinde.blogspot.com

    ReplyDelete
  61. Excellent post ~NeO~, I used your recipe from top to bottom and with the exception of some additional tweaks here and there due to my Ubuntu 9.10 system, I was able to install ns without "so much trouble". very well written and easy to follow

    Thanks a lot!

    ReplyDelete
  62. That was an awesome guide...thanx a lot, Shubham, for posting it...really cool... :)
    I am writing this because some Ubuntu 9.10 users are also posting here.
    But ubuntu 9.10 users might still face some problems (I faced one :(..) while installing ns-2.34 (or probably even the older versions...).
    The trouble is that ubuntu 9.10 provides gcc-4.4 while otcl likes gcc-4.3.
    So,

    1. "sudo apt-get install gcc-4.3 gcc-4.3-base"

    2. Navigate to otcl folder. Edit Makefile.in file
    in line 7
    From :
    CC= @CC@

    to :
    CC= gcc-4.3

    3. Then move up one folder and then
    'CC=gcc-4.3 ./install'

    There is no g++ code in ns folder so there wont be any requirement in installing g++ stuff.

    4. ./validate

    Actually, there are no more changes except the gcc part. Rest of the procedure remains the same.

    Hope it helps...

    ReplyDelete
  63. If its not too much trouble can you help me a little further?
    I've tried some of the tutorial lessons on the ns2 website but I get
    the following error.
    -----------------------------------------------------------------------------------------------------------------------------------
    mehernosh@machine:~$ ns example1a.tcl
    mehernosh@machine:~$ 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 {[string equal [tk windowingsystem] "classic"]
    || [string equal [tk windowingsystem] "aqua"]} {
    bind Listbox {
    %W yview scroll [expr {..."
    ----------------------------------------------------------------------------------------------------------------------------------------

    I get this error no matter what script I try, the simple hello world described above or more advanced ones available online. Its not that I am making a mistake in the Tcl code because I am tried using scripts available online at http://www.isi.edu/nsnam/ns/tutorial/index.html .
    Help!

    ReplyDelete
  64. Thanks a lot for this guide.
    Installation was successful. I saw %.
    After i used the command:
    $ sudo ln -s /home/programmer/ns-allinone-2.33/ns-2.33/ns /usr/bin/ns
    It has stopped to operate. How can i cancel this command?
    Please, execuse me for my English. It's not my native language.

    ReplyDelete
  65. Thanks, but I still having the error:

    bash: LIB:/usr/local/lib: No such file or directory

    and now I saved the exapmle as simple.tcl and now when I run it, this happen:

    user@ubuntu8041:~$ ns simple.tcl

    (_o5 cmd line 1)
    invoked from within
    "_o5 cmd at 1 “puts “Hello World!””"
    invoked from within
    "catch "$self cmd $args" ret"
    invoked from within
    "if [catch "$self cmd $args" ret] {
    set cls [$self info class]
    global errorInfo
    set savedInfo $errorInfo
    error "error when calling class $cls: $args" $..."
    (procedure "_o5" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o5 at 1 “puts “Hello World!””"
    ("eval" body line 1)
    invoked from within
    "eval $scheduler_ at $args"
    (procedure "_o3" line 3)
    (Simulator at line 3)
    invoked from within
    "$ns at 1 “puts \“Hello World!\””"
    (file "simple.tcl" line 2)

    Now what is happening here? I can't understand this output...

    ReplyDelete
  66. I have updated the post, this might help you now !

    ReplyDelete
  67. hello,

    i tried your example but the following problem appears:

    ns: finish: couldn't execute "nam": no such file or directory

    while executing

    "exec nam out.nam &"

    (procedure "finish" line 15)

    invoked from within

    "finish"


    please help me.

    Thanks

    ReplyDelete
    Replies
    1. Ms Fatima did you get solutions if yes then please guide me for same

      Delete
  68. nice post, was really helpful
    http://www.google.com

    ReplyDelete
  69.  Dear all,I am new in working with Linux, and i have to install NS2 for doing a project in Telecommunications.I installed Fedora 7 on my laptop, and then i started with NS 2.31 allinone.The start was ok, and when i type the command ./install  something wrong. Here is a part of that:/home/kiki/locale/ns/ns-allinone-/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1164: error: invalid type argument of ‘->’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c: At top level:/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1189: error: static declaration of ‘Intersect’ follows non-static declaration/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:868: error: previous implicit declaration of ‘Intersect’ was here/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c: In function ‘Intersect’:/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1189: error: expected declaration specifiers before ‘XPoint’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1190: error: expected declaration specifiers before ‘XPoint’/home/kiki/locale/ns/ns-allinone-tk8.4.14/unix/../generic/tk3d.c:1206: error: invalid type argument of ‘->’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1211: error: invalid type argument of ‘->’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1231: error: invalid type argument of ‘->’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c: In function ‘Tk_Get3DBorderFromObj’:/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1281: error: ‘Tk_FakeWin’ has no member named ‘atts’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1281: error: ‘TkBorder’ has no member named ‘colormap’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1307: error: ‘Tk_FakeWin’ has no member named ‘display’/home/kiki/locale/ns/ns-allinone-/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1400: error: ‘TkBorder’ has no member named ‘nextPtr’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1403: error: ‘TkBorder’ has no member named ‘resourceRefCount’/home/kiki/locale/ns/ns-allinone-2.31/tk8.4.14/unix/../generic/tk3d.c:1405: error: ‘TkBorder’ has no member named ‘objRefCount’make: *** [tk3d.o] Error 1Can You help me with this? Thank You in advance,Best regards,Kristina Pelivanoska

    ReplyDelete
  70. hai shubham
    i was installing ns2.34 and i got this error

    Build OTcl-1.13

    install: 498: ./configure: Permission denied
    otcl-1.13 configuration failed! Exiting ...

    whats the sudo command to be used

    ReplyDelete
    Replies
    1. Hi,

      Just use sudo before your command, like sudo

      Delete
  71. ns: finish: couldn't execute "nam": no such file or directory
    while executing
    "exec nam out.nam &"
    (procedure "finish" line 7)
    invoked from within
    "finish"

    Help me for this step by step please

    ReplyDelete
  72. hello sir,
    I have intalled ns2 in ubuntu , nd it works on example properly, but when we make our new routing protocol it compiles properly.
    After that, If we run the TCL file it results in error….what should we do….

    The error is

    num_nodes is set 100

    (_o14 cmd line 1)
    invoked from within
    “_o14 cmd addr”
    invoked from within
    “catch “$self cmd $args” ret”
    invoked from within
    “if [catch "$self cmd $args" ret] {
    set cls [$self info class]
    global errorInfo
    set savedInfo $errorInfo
    error “error when calling class $cls: $args” $…”
    (procedure “_o14″ line 2)
    (SplitObject unknown line 2)
    invoked from within
    “_o14 addr”
    (“eval” body line 1)
    invoked from within
    “eval $node addr $args”
    (“default” arm line 2)
    invoked from within
    “switch -exact $routingAgent_ {
    DSDV {
    set ragent [$self create-dsdv-agent $node]
    }
    DSR {
    $self at 0.0 “$node start-dsr”
    }
    AODV {
    set ragent [$self cre..."
    (procedure "_o3" line 14)
    (Simulator create-wireless-node line 14)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    ("for" body line 2)
    invoked from within
    "for {set i 0} {$i < $val(nn) } { incr i } {
    set mnode_($i) [$ns node]
    }"
    (file "wfrp_802_15_4.tcl" line 74)
    reply me on piyushraj99@gmail.com
    plz help and overcome from me these difficulties.
    Thanks in advance

    ReplyDelete
  73. pooja@pooja:~/sim$ sudo apt-get install build-essential autoconf automake libxmu-dev
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package build-essential

    ReplyDelete
  74. can u help me out
    i m trying to install it from about 6 months but not able to do it .please help me out .this is my first post...........

    ReplyDelete
  75. Respected sir
    i have reached implementation phase of my project ALARM protocol .According to my guide i doing it in NS2. I have written RSA algm code in TCL, only for encryption. I would like to know if implementing it in TCL is appropriate or should i implement in C. Please do help me

    ReplyDelete

 

About Tech Guru

TechQuark
TechGuru is a leading technology site, dedicated to software, gadgets, tech news and reviews. The site offers articles, tutorials and how-to guides on all things related to personal technology, desktop applications, productive online tools, social networking sites, windows, office etc.

Founded in 2007, TechGuru features audience who have the passion for Software and Technology and seeks to promote awareness about the internet and computing.

Get News on the Go

Mobile TechQuarkTech Guru is a mobile-friendly website. Simply bookmark m.techquark.com in your mobile browser for free access anytime, anywhere.

Contact Us / Send a Tip

Use Contact Form, if you have Comments, Problems, Suggestions, Praise, Complains about the site. Your suggestions and articles are valuable to us.

Share & Save





Copyright © 2007-2014 Tech Guru - All rights reserved. No part of this blog be republished or written without prior permission of the author


Privacy Policy | Disclaimer | Contact | Advertise With Us


Designed and Maintained by Shubham Gupta