Friday, November 6, 2009

Easiest way to install ns2 on ubuntu 9.10

hi!
As you know that ubuntu 9.10 is having lots of cool features and it's worth giving a try. But installing ns2 (The Network Simuator) through ns-allinone-2.3x package isn't easy on 9.10. While trying to install ns-allinone-2.3x, Firstly otcl doesn't compile with the latest gcc-4.4 (available with ubuntu 9.10). You need to compile it with gcc -4.3. If you get through this then also your problem is not solved, the ns-allinone-2.3x skips installing nam & xgraph as ubuntu 9.10 is not friendly with these packages available in ns-allinone-2.3x package.
I spent lots of time to fix this problem as one of my friend was doing his simulation on ns2 and finally ended up with an interesting lauchpad ppa for installing ns2 on Ubuntu.
Since Ubuntu 9.10 is already being shipped with tcl,otcl,tk... you need not to install these packages, Only ns, nam & xgraph are needed to install.
If you are behind a proxy, make sure you have $http_proxy variable configured in ~/.bashrc. [?]


Following are the simple steps to install ns2 on Ubuntu 9.10 through launchpad ppa.
1> Firstly remove all ns-allinone-2.3x directory (if you put it anywhere to install ns2) and revert back all the path changes you made in ~/.bashrc related to ns2.


2> Now export the Wouter Horré's ppa repository key by typing the following command on terminal and enter:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B3F3334F

3> Now add the following ppa repository to source list [?]
deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
Reload repository information when prompted by "The information about available software is out-of-date" notification or reload it manually by following command on terminal:
sudo apt-get update
4> Now type the following command on terminal to install ns from the launchpad ppa repository:
sudo apt-get install ns nam xgraph
That's all. There is no need to set-up any path, environment variables or make any changes in ~/.bashrc .



Type ns to check:
you should see % at the command prompt (indicating successful installation)
Type exit if you get stuck with the %

Now Try to run any example tcl file [You can get it here]

To run a tcl file type the following command:
ns example-tcl-file.tcl
Hope this method would work for you. Just comment below whether you were successful in installation or if you face any problem.





[Added on Jan 15, 2010] I have received so many queries regarding the files that are available with ns-allinone-2.3x package. Actually ns-allinone-2.3x package has two main things; 1) ns & supporting libraries to RUN IT & 2) Sample files, examples & support for various scenario such as wireless etc... to HELP YOU IN YOUR SIMULATION.
At this point only first one is done, For second one you need to refer to the all in one package.
For that:
  • Extract the ns-allinone-2.3x directory from the archive
  • "DON'T RUN ./install" as ns2 is already installed on your system
  • Now you are ready to use the files present in "ns-allinone-2.3x/ns-2.3x/" directory. e.g.: to run example scripts available with the package goto "/ns-allinone-2.3x/ns-2.3x/tcl/ex/" and run respective tcl file.

105 comments:

  1. thank you so much for you support.But if i install NS-2 by
    download pack-age and change the enviroment variable,i can see the directory that contain the folder ns-allinon.
    following your way,i don't know where i istalled.
    Can you tell me to know more.
    Thank you so much !

    ReplyDelete
  2. By this method no ns-allinone package is created on your system.. packages are installed separately .

    the ns is located in "/usr/bin/"

    while tcl8.4 & tk8.4 can be found in:
    "/usr/share/tcltk/"

    If you are looking for some example/docs in ns-allinone package, you can refer to ns-allinone package.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. thank u so much dude!!
    was waiting for a post from anyone on installin ns2 on ubuntu 9.10,since the day koala was released.
    thank u so much

    ReplyDelete
  5. where do we find 802.11.{cc,h} files? could you please help me find that? Thanks

    ReplyDelete
  6. Hi, thanks for this tutorial. My question is , now how can i patch some protocol like umts?? This is my first time with ns2 and understood that i need to copy some file in the ns2 dir for apply patch but how i do if i don't know where is the file ??

    ReplyDelete
  7. @peppe & madakasira

    buddy i am not using ns2 for my project, i got to know abt the wouterh's ppa while trying to install ns2 for one of my friend for his simulation work. Thought this info may help others also in installing ns2 and I posted it.

    If you know the exact file name that is to be patched, you can easily find its location by the "locate filename" command... and if you don't find it, you can refer to the ns-allinone package also as ns-allinone is having lots of sample files and much more.

    ReplyDelete
  8. Hi,

    This does not work for me, and I have added the sources.... Running 9.10

    tomehb@tomehb-desktop:~$ sudo apt-get install ns nam
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package ns

    ReplyDelete
  9. @tomehb
    follow steps 1-4 carefully....
    If u miss any step, It won't work...

    In ur case it seems that u didn't reload the repository information mentioned in Step 3.

    ReplyDelete
  10. I am having the same problem as tomehb... I reloaded the sources and I followed the steps too.

    ReplyDelete
  11. The installation is done, but which folder do i put my tcl files to run and where will my nam and tr files be outputed to

    ReplyDelete
  12. I get the same problem. It says that the signatures couldn't be verified because the key is not valid...

    Any help with that?

    ReplyDelete
  13. W: GPG error: http://ppa.launchpad.net jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7D2C7A23BF810CD5

    ReplyDelete
  14. It's a great and fantastic solution! Tanx alot for it!

    ReplyDelete
  15. AMAZING! VERY VERY GOOD and fast!
    WE ARE STUDENTS FROME GREECE, GOT REALLY HELPED!
    PLEASE SPREAD THE TRICK!

    BRAVO!

    ReplyDelete
  16. Hello !
    I am a B.Tech student at NIT Kurukshetra, I have a project to analyse video transmission over UDP and then compare the performance over TCP transmission.

    Can anybody help me out ??
    I am not able to use codecs in NS-2 to convert the video file to packets and then transmit them to be re-coded and played as a video.

    Please help me out...

    ReplyDelete
  17. thanx a lot
    it worked !!!
    heyy !! By the way I'm from MNNIT as well; 3rd yr CS actually & i was wondering if u were free to help me out with a simulation project ?

    ReplyDelete
  18. hey I tried installing on fresh installation of ubuntu 9.10
    Even then it says E:Couldn't find package ns
    I hav followed every step that u hav specified above..
    plz help me..!!

    ReplyDelete
  19. @Athreya
    To install ns2 on ur system, u need to follow above mentioned steps in order.

    Make sure you have exported the repository key, added the source and then have updated it.

    In your case, It looks like you haven't updated it (see step 3).

    ReplyDelete
  20. @ALL

    welcome... :-)

    hope you all end up with a good simulation work.

    ReplyDelete
  21. i followed all ur instruction and got the % sign also..really thanks for that..
    bt as u mentioned tht we ll need to extract allinone for the sample files n all..can u pls xplain me how i can do tht..
    sorry!!! just started using linux.. :(

    ReplyDelete
  22. @bornagain

    Since ns-allinone-2.3x comes in a .tar.gz compressed archive, firstly u need to extract(decompress) it to use.

    If you already have an allinone package, you may extract it by following command:
    "tar -xzvf ns-allinone-2.xx.tar.gz" (replace x with the version of your allinone).
    Hope you got it!!...

    ReplyDelete
  23. how to implement MAODV with your step by step easiest way to install ns2 in ubuntu 9.10?? i been confused about it... please help me...

    ReplyDelete
  24. thank you .. it was of great help

    ReplyDelete
  25. Awesome...This one worked. I tried so many methods to install NS2. None of them worked. Thanks a lot.

    ReplyDelete
  26. Hello! This is very useful! Can I copy it to my MSN space? I will mark the original link to here. Thank U!!

    If do not allow me to republish your blog, plz tell me by email: xmucaiwei@gmail.com . In case of that, I will delete it.

    Thank you!

    ReplyDelete
  27. Thanks Yasir!!!!!!!!!

    It works.....

    ReplyDelete
  28. THanks Yasir!!....Your article was very helpful...

    ReplyDelete
  29. Hi
    thanx for the tutorial..
    i am able to successfully install ns from the above method and the files of ns, xgraph & nam are present in usr/bin

    now i am unable to run the example and receive following error:
    % ns examplename.tcl
    error when calling class Oldsim: example2.tcl

    ReplyDelete
  30. @Moeed
    Hey! Looks like firstly you are entering into ns (typing ns & hitting enter) and then trying to run example2.tcl over there, DON'T DO THAT.

    instead direct the operation of cd installation path /......./ examples, and then run "ns example2.tcl" by the terminal itself...

    $ ns
    % ns examplename.tcl <~~~~ DON'T

    $ ns examplename.tcl <~~~~ DO

    ReplyDelete
  31. Hi there. Thanks a million for your tutorial. Installing ns2 in ubuntu 9.10 is really a pain in the ass. Now that I have ns2 installed through repository, I ran into a new issue that I don't know where it is actually installed. I have only been able to locate the ns file in /usr/bin. It seems to be a binary file. But where is all the libraries and other files come with ns2? Thanks a lot!

    ReplyDelete
  32. Hi there ......

    I installed UM OLSR patch ot ns 2.33 by refering to http://lector-note.org/modules/smartsection/item.php?itemid=140

    And then i gave ./configure in the ns-2.33 folder. There i got the following error message.....

    Can u pls help me out !!!!!

    ===============================================
    vinoth@vinoth-desktop:~/ns-allinone-2.33/ns-2.33$ ./configure
    No .configure file found in current directory
    Continuing with default options...
    checking build system type... i686-pc-linux-gnu
    checking host system type... i686-pc-linux-gnu
    checking target system type... i686-pc-linux-gnu
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ANSI C... none needed
    checking for g++... g++
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++ accepts -g... yes
    checking how to run the C preprocessor... gcc -E
    checking for egrep... grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for string.h... (cached) yes
    checking for main in -lXbsd... no
    checking for socket in -lsocket... no
    checking for gethostbyname in -lnsl... yes
    checking for dcgettext in -lintl... no
    checking for getnodebyname in -ldnet_stub... no
    checking that g++ can handle -O2... no
    checking if C++ libraries work without any namespace... no
    checking if C++ libraries work with namespace std... yes
    checking if STL works without any namespace... no
    checking if STL works with namespace std... yes
    checking should use STL... yes
    checking for tcl.h... -I../include
    checking for libtcl8.4... -L../lib -ltcl8.4
    checking for init.tcl... ../lib/tcl8.4
    checking for tclsh8.4.18... no
    checking for tclsh8.4... ../bin/tclsh8.4
    checking for tk.h... -I../include
    checking for libtk8.4... -L../lib -ltk8.4
    checking for tk.tcl... ../lib/tk8.4
    checking for otcl.h... -I../otcl-1.13
    checking for libotcl1.13... -L../otcl-1.13 -lotcl
    checking for tclcl.h... -I../tclcl-1.19
    checking for libtclcl... no
    checking for tcl2c++... /usr/bin
    configure: error: Installation of tclcl seems incomplete or can't be found automatically.
    Please correct the problem by telling configure where tclcl is
    using the argument --with-tclcl=/path/to/package
    (perhaps after installing it),
    or the package is not required, disable it with --with-tclcl=no.
    =====================================================

    And whe i tried to execute a tcl script for OLSR i get the following error message.......

    Pls help me buddy!!!!

    =====================================================

    invalid command name "Agent/OLSR"
    while executing
    "Agent/OLSR set use_mac_ false"
    (file "olsr_example.tcl" line 44)

    =====================================================

    ReplyDelete
    Replies
    1. even i got the same error......can you please tell me what exactly is the error?

      Delete
  33. hi dude!!!
    i need an urgent help!!! while working in ns2 in linux platform, i need to attach a file to the agent and transmit that file between nodes!! instead of created traffic i want this file to be the traffic and to transmit it between nodes!!!! kindly do help me!!!

    with regards,
    siva

    my mail id : siva19789@gmail.com

    ReplyDelete
  34. I am a newbiew, can you please clarify, what has to be done in step 3 more clearly..

    I planned on clicking the QUESTION mark on step 3 whihc opens a new page in another TAB.

    There, STEP 6 is not very clear as what line has to be pasted...??
    Where do I get the second line from ? Can you please help, I really need ns 2 on my ubuntu 9.10

    Thanks,

    Vijaya

    ReplyDelete
  35. Hello Yasser,

    I just followed your steps, and I actually pasted

    deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main

    deb-src http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main

    As you said..

    I also got ns 2 installed.. i guess SINCE when I type ns at $ prompt on my terminal.

    I get a $ prompt, and I have to type exit to get out of it to get back to my Normal $ prompt.

    Now. WHAT does not work , is the when I try to run a sample tcl code, while entering the code, I got no errors.

    However while running it I got:

    warning: using backward compatibility mode
    error when calling class OldSim: ns-simple.tcl

    ReplyDelete
  36. Hello,

    THANK YOU so MUCH for your Awesome POST..!!

    I finally got it working.

    I Entered the command directly at the home prompt, and NOT at first open ns.
    Here's what I'm saying:

    [USERNAME@localhost ~]$ ns example1.tcl

    Cheers..!!

    Vijaya

    ReplyDelete
  37. hello,
    i install ns2 on ubuntu 9.1 according to this guide but after installation, i type "ns example-tcl-file.tcl" in terminal but i saw this "couldn't read file "example-tcl-file.tcl": no such file or directory"

    please help me.
    thank you.
    mohammad

    ReplyDelete
  38. hey there,
    i was trying to install ns2 on my friends laptop, i got stuck in the 3rd step.. it shows the following error:
    rahul@rahul-laptop:~$ deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
    No command 'deb' found, did you mean:
    Command 'debc' from package 'devscripts' (main)
    Command 'derb' from package 'libicu-dev' (main)
    Command 'dab' from package 'bsdgames' (universe)
    Command 'debi' from package 'devscripts' (main)
    deb: command not found
    dunno wat to do?? m new to linux..

    ReplyDelete
  39. oK .. got it working now.. thanks..

    ReplyDelete
  40. I have found the same error
    $ deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
    No command 'deb' found, did you mean:
    Command 'debc' from package 'devscripts' (main)
    Command 'derb' from package 'libicu-dev' (main)
    Command 'dab' from package 'bsdgames' (universe)
    Command 'debi' from package 'devscripts' (main)
    deb: command not found
    So what is the solution please i need your help??
    thks

    ReplyDelete
  41. hi after adding the two addresses in source packages i clicked the revert button.. but nothing happened.. wat i must do

    ReplyDelete
  42. @yasir
    thanx a lot man...


    cheers!!!

    GAUTAM

    ReplyDelete
  43. Hello,
    First I like to really thank you for putting time and effort into this help page. I followed the steps you have said and it seemed that I had a successful installation. But When I go to the directory ns-2.34 and do ./validate all the tests fail. I get the message that the test files are not found.

    Please help me with this problem

    ReplyDelete
  44. @mnekoui
    there is no need to run ./validate.
    The ./validate works only when u install it through ns-allinone package.

    and yeah! u can't make changes to C++ source files to recompile it...
    Make it clear that you installed it through ppa not by ns-allinone package, so ns-allinone files is of no use except for using examples and protocols already implemented.

    ReplyDelete
  45. Большое тебе спасибо...
    Thank you very much!

    ReplyDelete
  46. Thanks yasir, but do you have any idea what I should do if I need to change the original C++ codes and recompile ns2.34 with my ubuntu 9.10?
    Appreciate your time!

    ReplyDelete
  47. where can i download ns2
    I am Srinath, masters student at UAHuntsville at Alabama USA.
    I really need your help for performing a comparison of protocols in Ad Hoc wireless networks.
    What I expect your help is in
    1> How to download and install ns2 in ubuntu 9.10, I am layman in command lines, please help me with step wise instructions.
    2> A simple example on ns2 which you have performed to test and understand how ns2 works

    This is all, Thank you very much and please let me know how I can help you in return.

    Can I also call you on phone if I am stu

    ReplyDelete
  48. Thank you!!! Works great!! First tutorial that actually makes sense and works!!

    ReplyDelete
  49. hi yasir,
    i wnt a help 4 my proj.my proj is bout showing routing of data packets in network layer nd also comparing various routin algorithms .wchich has 2 be done using ns2 on ubuntu 9.10.

    i hv done the above steps nd got the % sign .
    bt nw how to start wid ns2 i'm not gettn .where are the packages aftr being installed.
    it will b a great help if u reply.....

    ReplyDelete
  50. Hi I am a novice to NS2 and Ubuntu.

    Wanted to run a file at

    ~ns/indep-utils/propagation/threshold.cc

    but when I type cd ns

    it says no file or directory found.

    and I dont see any NS directory in home folder which I would have found otherwise.

    Can you please explain clearly how to about it. hope you dont mind doing it

    Thanks,
    Manoj

    ReplyDelete
  51. hey when i'm extracting the ns2.33
    i'm gettng an error as: "u dont hv right permission 2 extract".
    nd if i'm opening it with GDebi package installer the it is askng for reinstallation.
    shud i reinstall it
    as i'm new to ns2 nd linux plz help...

    ReplyDelete
  52. dear all,

    let say i wish to make modification on aodv.cc which is located inside the aodv folder.Where can i search for this aodv folder?Because normally we install the ns2,this folder will be included inside...But if i follow yasir's method to install ns2,i cant locate it...Kindly pls reply me,i really need to know..thanks

    ReplyDelete
  53. Thanks for the detailed instruction.....
    I need to add new protocol to NS2 by adding a cpp files in the SRC folder of "ns-allinone-2.33" & how i can proceed doing with this method of installation?

    ReplyDelete
  54. S/A
    Dear Yasir,
    you said 'and yeah! u can't make changes to C++ source files to recompile it...
    Make it clear that you installed it through ppa not by ns-allinone package, so ns-allinone files is of no use except for using examples and protocols already implemented'

    this means that if I need to create a new protocol which is not included in NS2 packages or to update in an existing one, then I couldn't use the above steps to install NS2, therefor I should go to ns2-allinone package...

    If so, could u tell me what is the diffrences??

    Thanks in advance,
    Mariam

    ReplyDelete
  55. thanx a lot my friend, i have just install ns2 on 2 machines under virtual machine

    ReplyDelete
  56. I get this error when trying to install ns2

    Unpacking ns (from .../ns_2.33-0ubuntu1_i386.deb) ...
    dpkg: error processing /var/cache/apt/archives/ns_2.33-0ubuntu1_i386.deb (--unpack):
    trying to overwrite '/usr/bin/ns', which is also in package host 0:20000331-9
    dpkg-deb: subprocess paste killed by signal (Broken pipe)
    Processing triggers for man-db ...
    Errors were encountered while processing:
    /var/cache/apt/archives/ns_2.33-0ubuntu1_i386.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    Any help to fix this issue would be awesome

    Christon.

    ReplyDelete
  57. Muito Bom !!

    Funcionou perfeitamente !

    ReplyDelete
  58. Hi all readers
    thanks yasir very much(Jazakallaho khair)
    i tried several stuff about installing ns2 on ubuntu
    indeed i followed ur link but at first it appeared me gr8 but when i followed it, at the end i used to get "ns commant not found" i said to myself (ye b kaam ka nahi ha)
    i tried again, the man cobweb is step 3
    guys u should follow step 3 and there is a hidden link "?" click on this "?" add ppa and then comback to step 3,
    if remaining 2 of 3 command fails (deb ....bla bla > no prob cz it failed with me by saying command not found)

    but at last i got "%" this magical symbol

    now i m taking rest,will work on my simulation 2morw

    t.c all

    bye dears
    bilal

    ReplyDelete
  59. hello
    i have a problem when use olsr
    i have linux 9.10 ns 2.34 olsr 0.8.8

    my error is

    invalid command name "Agent/OLSR"
    while executing
    "Agent/OLSR set use_mac true"

    help me please
    thank's
    my adr:fethididi@yahoo.fr

    fethi

    ReplyDelete
  60. I have found the same error
    $ deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
    No command 'deb' found, did you mean:
    Command 'debc' from package 'devscripts' (main)
    Command 'derb' from package 'libicu-dev' (main)
    Command 'dab' from package 'bsdgames' (universe)
    Command 'debi' from package 'devscripts' (main)
    deb: command not found
    So what is the solution please i need your help??
    thks

    ReplyDelete
  61. Yasir,

    It doesn't install on ubuntu 64 bits.

    many problems experienced by the above users such as:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Couldn't find package ns

    are due to incompatibilities between 32/64 bits OS versions.

    thank you anyway for your post

    ReplyDelete
  62. Hi Friend,

    I am getting following error while running nam. Can u suggest some solution?


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



    Thanks
    Sumit

    ReplyDelete
  63. Hi,
    i have install it using the method mentioned above now tell me how to uninstall it .
    Thanks

    ReplyDelete
  64. Hi,
    Getting problem in installing um-olsr in ns-2.33
    Plz help me out

    ReplyDelete
  65. Hey ya,
    Thanx for the installation steps using that i installed successfully. But now i need to make some changes in aodv.h file Plz tell me where will i find it??
    Its urgent!!!!!!!

    ReplyDelete
  66. Hey this worked great for me however I am trying to add a UMTS and 3GPP module to ns-2.34 but the authors of the module say that it should be untared in the ns-2.3* in ns-allinone-2.34 directory then should run install and make in the super directory again. But as ns-2 is already installed I assume this is not possible?

    Can you tell me how I can install a new module using your method?

    Cheers,

    Andy

    ReplyDelete
  67. I don't know where the protocol files are stored like aodv.cc,aodv.h etc. Please tell me where are the files used by ns stored if we use this method.

    ReplyDelete
  68. I use ubuntu lucid.

    Followed many approaches to install the simulator but this approach worked for me with no problem!

    Thanks and wish you luck!

    ReplyDelete
  69. Did every thing but still when enter command
    >ns
    it says ns:command not found.
    i had this problem , but i solved it . because i was having problem in my synoptic manager
    System>Administration>Synoptic Package manager
    when you open it, and you receive a message like some packages are broken,
    make sure you have to fix borken packages because this will prevent ns from installing.

    here is how to fix it

    https://help.ubuntu.com/community/SynapticHowto
    search for how to fix broken packages.
    follow the instructions and then

    follow The author steps in this tutorial.
    this is one problem that was causing me
    ns:command not found
    may b you have other problems.
    plz report when u succeed
    t.c
    bye

    ReplyDelete
  70. How to add step2)
    deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
    deb-src http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main

    these are not command which you have to apply in terminal,

    but instead
    in terminal apply:
    sudo gedit /etc/apt/sources.list

    then copy above two lines to the end of sources.list file

    save it. and continue....

    ReplyDelete
  71. i installed it.....
    but when i am trying to run AODV script,
    these error occur.
    please help!


    % invalid command name "-llType"
    % invalid command name "-macType"
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    # wireless-aodv.tcl
    # A 3 nodes example for ad hoc simulation with AODV
    # Define options
    set val(chan) Channel/WirelessChannel;# channel type
    set val(prop) Propagation/TwoRayGround;# radio-propagation model
    set val(netif) Phy/WirelessPhy ;# network interface type
    set val(mac) Mac/802_11 ;# MAC type
    set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
    set val(ll) LL ;# link layer type
    set val(ant) Antenna/OmniAntenna ;# antenna model
    set val(ifqlen) 50 ;# max packet in ifq
    set val(nn) 3 ;# number of mobilenodes
    set val(rp) AODV ;# routing protocol
    set val(x) 500 ;# X dimension of topography
    set val(y) 400 ;# Y dimension of topography
    set val(stop) 150 ;# time of simulation end
    set ns [new Simulator]
    set tracefd [open simple.tr w]
    set namtrace [open simwrls.nam w]
    $ns trace-all $tracefd
    $ns namtrace-all-wireless $namtrace $val(x) $val(y)

    proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
    }


    # set up topography object
    set topo [new Topography]
    $topo load_flatgrid $val(x) $val(y)
    create-god $val(nn)
    # Create nn mobilenodes [$val(nn)] and attach them to the channel.
    set chan_1_ [new $val(chan)]
    # configure the nodes
    $ns node-config -adhocRouting $val(rp) \
    -llType $val(ll) \
    -macType $val(mac) \
    -channel $chan_1_ \
    -ifqType $val(ifq) \
    -ifqLen $val(ifqlen) \
    -antType $val(ant) \
    -propType $val(prop) \
    -phyType $val(netif) \
    -topoInstance $topo \
    -agentTrace ON \
    -routerTrace ON \
    -macTrace OFF \
    -movementTrace ON \

    for {set i 0} {$i <$val(nn) } { incr i } {
    set node_($i) [$ns node]
    }
    # Provide initial location of mobilenodes
    $node_(0) set X_ 5.0
    $node_(0) set Y_ 5.0
    $node_(0) set Z_ 0.0
    $node_(1) set X_ 490.0
    $node_(1) set Y_ 285.0
    $node_(1) set Z_ 0.0
    $node_(2) set X_ 150.0
    $node_(2) set Y_ 240.0
    $node_(2) set Z_ 0.0
    # Generation of movements
    #$ns at 10.0 “$node_(0) setdest 250.0 250.0 3.0”
    #$ns at 15.0 “$node_(1) setdest 45.0 285.0 5.0”
    #$ns at 110.0 “$node_(0) setdest 480.0 300.0 5.0”
    # Set a TCP connection between node (0) and node (1)
    set tcp [new Agent/TCP/Newreno]
    $tcp set class_ 2
    set sink [new Agent/TCPSink]
    $ns attach-agent $node_(0) $tcp
    $ns attach-agent $node_(1) $sink
    $ns connect $tcp $sink
    set ftp [new Application/FTP]
    $ftp attach-agent $tcp
    $ns at 10.0 “$ftp start”
    # Define node initial position in nam
    for {set i 0} {$i <$val(nn)} { incr i } {
    # 30 defines the node size for nam
    $ns initial_node_pos $node_($i) 30
    }
    # Telling nodes when the simulation ends
    for {set i 0} {$i <$val(nn) } { incr i } {
    $ns at $val(stop) “$node_($i) reset”;
    }
    # ending nam and the simulation
    $ns at $val(stop) “$ns nam-end-wireless $val(stop)”
    $ns at $val(stop) “stop”
    $ns at 150.01“puts “end simulation” ; $ns halt”

    $ns run

    ReplyDelete
  72. i installed it
    But when i am trying to run AODV script,
    these error occur.
    Please help!


    % invalid command name "-llType"
    % invalid command name "-macType"
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    # wireless-aodv.tcl
    # A 3 nodes example for ad hoc simulation with AODV
    # Define options
    set val(chan) Channel/WirelessChannel;# channel type
    set val(prop) Propagation/TwoRayGround;# radio-propagation model
    set val(netif) Phy/WirelessPhy ;# network interface type
    set val(mac) Mac/802_11 ;# MAC type
    set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
    set val(ll) LL ;# link layer type
    set val(ant) Antenna/OmniAntenna ;# antenna model
    set val(ifqlen) 50 ;# max packet in ifq
    set val(nn) 3 ;# number of mobilenodes
    set val(rp) AODV ;# routing protocol
    set val(x) 500 ;# X dimension of topography
    set val(y) 400 ;# Y dimension of topography
    set val(stop) 150 ;# time of simulation end
    set ns [new Simulator]
    set tracefd [open simple.tr w]
    set namtrace [open simwrls.nam w]
    $ns trace-all $tracefd
    $ns namtrace-all-wireless $namtrace $val(x) $val(y)

    proc stop {} {
    global ns tracefd namtrace
    $ns flush-trace
    close $tracefd
    close $namtrace
    }


    # set up topography object
    set topo [new Topography]
    $topo load_flatgrid $val(x) $val(y)
    create-god $val(nn)
    # Create nn mobilenodes [$val(nn)] and attach them to the channel.
    set chan_1_ [new $val(chan)]
    # configure the nodes
    $ns node-config -adhocRouting $val(rp) \
    -llType $val(ll) \
    -macType $val(mac) \
    -channel $chan_1_ \
    -ifqType $val(ifq) \
    -ifqLen $val(ifqlen) \
    -antType $val(ant) \
    -propType $val(prop) \
    -phyType $val(netif) \
    -topoInstance $topo \
    -agentTrace ON \
    -routerTrace ON \
    -macTrace OFF \
    -movementTrace ON \

    for {set i 0} {$i <$val(nn) } { incr i } {
    set node_($i) [$ns node]
    }
    # Provide initial location of mobilenodes
    $node_(0) set X_ 5.0
    $node_(0) set Y_ 5.0
    $node_(0) set Z_ 0.0
    $node_(1) set X_ 490.0
    $node_(1) set Y_ 285.0
    $node_(1) set Z_ 0.0
    $node_(2) set X_ 150.0
    $node_(2) set Y_ 240.0
    $node_(2) set Z_ 0.0
    # Generation of movements
    #$ns at 10.0 “$node_(0) setdest 250.0 250.0 3.0”
    #$ns at 15.0 “$node_(1) setdest 45.0 285.0 5.0”
    #$ns at 110.0 “$node_(0) setdest 480.0 300.0 5.0”
    # Set a TCP connection between node (0) and node (1)
    set tcp [new Agent/TCP/Newreno]
    $tcp set class_ 2
    set sink [new Agent/TCPSink]
    $ns attach-agent $node_(0) $tcp
    $ns attach-agent $node_(1) $sink
    $ns connect $tcp $sink
    set ftp [new Application/FTP]
    $ftp attach-agent $tcp
    $ns at 10.0 “$ftp start”
    # Define node initial position in nam
    for {set i 0} {$i <$val(nn)} { incr i } {
    # 30 defines the node size for nam
    $ns initial_node_pos $node_($i) 30
    }
    # Telling nodes when the simulation ends
    for {set i 0} {$i <$val(nn) } { incr i } {
    $ns at $val(stop) “$node_($i) reset”;
    }
    # ending nam and the simulation
    $ns at $val(stop) “$ns nam-end-wireless $val(stop)”
    $ns at $val(stop) “stop”
    $ns at 150.01“puts “end simulation” ; $ns halt”

    $ns run

    ReplyDelete
  73. on installing ns this massage com can any body help me..
    (Reading database ... 166817 files and directories currently installed.)
    Unpacking ns (from .../ns_2.33-0ubuntu1_i386.deb) ...
    dpkg: error processing /var/cache/apt/archives/ns_2.33-0ubuntu1_i386.deb (--unpack):
    trying to overwrite '/usr/bin/ns', which is also in package host 0:20000331-9
    dpkg-deb: subprocess paste killed by signal (Broken pipe)
    Processing triggers for man-db ...
    Errors were encountered while processing:
    /var/cache/apt/archives/ns_2.33-0ubuntu1_i386.deb

    ReplyDelete
  74. the tcl code i am trying for AODV runs perfectly but the same with AOMDV is resulting in folloing error...

    plz help

    Error:

    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"
    invoked from within
    "set node_(0) [$ns node]"
    (file "scripts/aomdv100.tcl" line 78)

    ReplyDelete
  75. hi, i want to rum maodv in ns2.34,ubuntu 9.10

    i dont know how to usens2,i m new to it,but i have installed ns2.34. please help me as soon as possible ,how to simulate maodv in this

    ReplyDelete
  76. i want resource allocation code using ns2

    ReplyDelete
  77. hello everybody!
    pleaaaase, I do need your help
    the problem is that , in the 3rd step, deb is not known as a command
    what can i do?
    thanks a lot

    ReplyDelete
  78. i have just found the solution, so for those who have the same problem, try to do it in graphic way: http://khaled063011.wordpress.com/

    ReplyDelete
  79. Really got the ns2 installed after a nightmare and amazing it is easily by that blog-post.
    A lot of thanks. Insha-Allah it will be rewarded.
    I am from Motihari,Bihar.
    Now I have to do some project on simulation on various protocols.Please help me how to start.
    Again a lot of thanks.

    ReplyDelete
  80. hi yasir it worked man thanks a lot.As i am new to using this tool could you tell me how write a new protocol taking a simple example,just give the steps and commands
    i hope you will help out in this please yar i have taken Efficient N to 1 multipath routing protocol as my m.tech final year project
    plzzzzzzz dude this is my email id snehalokha@yahoo.co.in

    ReplyDelete
  81. how install ns-2.29 help me plz this is my
    plz contact me plzzzzzzzzzzzzzzzzzzz
    im try but didn't worked with me plz help mmmmmmmmmmmmmmmmmmmmmmmeeeeeeeeeeeee

    ReplyDelete
  82. Hi

    i m avin, working on video streaming on ns2 whic is my mtech final year proj..i have prob regarding codecs n .exe files which r to be runned in the terminal fr proper exec..
    i hav tried to install ns2 latest verison in usr/local but it was isnt executing fully..
    i hav tried alot but its isnt working..and moreover der is lo of confusion in undrstnding da code n working of da code..
    plz help of out of this..

    if u hav any info reg video streaming (like code, working etc) plz do mail me at avin.yudi@gmail.com..

    ReplyDelete
  83. Salaam,
    Thank you Yasir, I installed it but I get this error: "error when calling class $cls: $args" $..." for the last line of such a code:

    set udp1 [new Agent/UDP]
    $ns attach-agent $s1 $udp1
    $udp1 set packetSize_ $packetSize
    $udp1 set_filename sd

    yours,
    Mehdi
    Semsar80@yahoo.com

    ReplyDelete
  84. plz help me in firgure out my problem
    i got this error
    warning: using backward compatibility mode
    error when calling class OldSim: ns-simple.tcl

    plz write some step which i can figure out my problem,

    ReplyDelete
  85. hi
    i m m.tech student my work on cooperative caching
    in manet if any work to related pls help me

    ReplyDelete
  86. i installed ns2 on Ubuntu 9.10 through launchpad ppa. now i like to change that nam 1.13 into extended nam 1.14.. but i cant upgrade it....can you please help me...

    ReplyDelete
  87. Hi Yasir,

    I had just started working on NS2 till now i had managed to get it installed but now i am looking for how to start with it. Could you please suggest me some directions i want to work WSN. Working on Ubuntu 9.10. I am totally a lay man for NS2.

    Please help.

    ReplyDelete
  88. Dear sir,
    while executing the first command i am getting.....
    gpg: keyserver timed out
    gpg: keyserver receive failed: keyserver error

    can u tell what is my problem

    ReplyDelete
  89. /ns-allinone-2.34/ns-2.34$ ./configure
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking how to run the C preprocessor... gcc -E
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking minix/config.h usability... no
    checking minix/config.h presence... no
    checking for minix/config.h... no
    checking whether it is safe to define __EXTENSIONS__... yes
    No .configure file found in current directory
    Continuing with default options...
    checking build system type... i686-pc-linux-gnu
    checking host system type... i686-pc-linux-gnu
    checking target system type... i686-pc-linux-gnu
    checking for gcc... (cached) gcc
    checking whether we are using the GNU C compiler... (cached) yes
    checking whether gcc accepts -g... (cached) yes
    checking for gcc option to accept ISO C89... (cached) none needed
    checking for g++... g++
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++ accepts -g... yes
    checking for ANSI C header files... (cached) yes
    checking for string.h... (cached) yes
    checking for main in -lXbsd... no
    checking for socket in -lsocket... no
    checking for gethostbyname in -lnsl... yes
    checking for dcgettext in -lintl... no
    checking for getnodebyname in -ldnet_stub... no
    checking that g++ can handle -O2... no
    checking if C++ libraries work without any namespace... no
    checking if C++ libraries work with namespace std... yes
    checking if STL works without any namespace... no
    checking if STL works with namespace std... yes
    checking should use STL... yes
    checking for tcl.h... -I../include
    checking for tclInt.h... -I../include
    checking for libtcl8.4... -L../lib -ltcl8.4
    checking for init.tcl... ../lib/tcl8.4
    checking for http.tcl... ../lib/tcl8.4/http1.0
    checking Tcl http.tcl library... yes
    checking for tclsh8.4.18... no
    checking for tclsh8.4... ../bin/tclsh8.4
    checking for tk.h... -I../include
    checking for libtk8.4... -L../lib -ltk8.4
    checking for tk.tcl... ../lib/tk8.4
    checking for otcl.h... -I../otcl-1.13
    checking for libotcl1.13... -L../otcl-1.13 -lotcl
    checking for tclcl.h... -I../tclcl-1.19
    checking for libtclcl... no
    checking for tcl2c++... no
    configure: error: Installation of tclcl seems incomplete or can't be found automatically.
    Please correct the problem by telling configure where tclcl is
    using the argument --with-tclcl=/path/to/package
    (perhaps after installing it),
    or the package is not required, disable it with --with-tclcl=no.
    umesha@umesha-Lenovo-B460:~/yashu/ns-allinone-2.34/ns-2.34$

    am getting error, whats the problem can u please sir

    ReplyDelete
  90. Is there is a easy way to install ns simulator in ubuntu 11.10

    ReplyDelete
  91. Hello;
    i am a beginners
    help me please how to install ns in ubuntu 10.4

    ReplyDelete
  92. Hi
    help me please how to add a new protocol in mac of ns2

    ReplyDelete
  93. hi..
    i tried adding my module into ns niracle. i get no error while doing make. but i get following error when i execute my tcl file

    couldn't find procedure energy_Init
    while executing
    "load libenergy.so"

    why do i get such error can i get suggestion for this?

    ReplyDelete
  94. Salam Yasir
    I am using ns2.35, ubuntu 12-04 LTS and gcc4.4.6
    I want to run dsr using linkcache
    When I use make to recompile ns2, it give me the following error:

    dsr/linkcache.cc:56:18: fatal error: list.h: No such file or directory
    compilation terminated.

    please can you help me?
    Give me any suggestions on how to fix this error. I have several months try to fix this error.
    I appreciate any help

    ReplyDelete
  95. Hi all!
    I am using ns-2.35 in linux mint 17.3.
    Though i had a successful installation, I find the following error while executing the simple "hello world" tcl script :
    (_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)

    Plz help me solving the problem.

    ReplyDelete