Monday, June 14, 2010

How to install NS2 with Ubuntu 10.04 By Noor Zaman

How to install NS2 with Ubuntu 10.04 By Noor Zaman

This manual will work for NS2 allinone-2.34 with Ubuntu 10.4. As Ubuntus new version 10.04 needs following packages before any further installation, otherwise it will not work with it.
Please follow the following steps:

1. Install necessary tools for building:

sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3

2. It turns out that otcl does not like the version of gcc installed by default in Lucid. So go ahead and change ns-allinone-2.34/otcl-1.13/Makefile.in. Find the line that says:

CC= @CC@
and change it to:
CC= gcc-4.3
3. Now follow the following steps for installation of nsallinone 2.34 and it will work with your machine. (copy ns-allinone-2.34.tar.gz)

Suppose that there is "ns-allinone-2.33.tar.gz" in current directory (e.g. "~/" for me is "/home/noor").
All steps are done in Terminal, so open a terminal in Accessories/Terminal.To extract the file:
tar xvfz ./ns-allinone-2.33.tar.gz


4. Change your directory within terminal as following way

$ cd /home/noor$ cd /home/noor/ns-allinone-2.34

5. Download & install some packages from repository if needed (Now its optional)

$ sudo apt-get install build-essential autoconf automake libxmu-dev
6. Install the ns2

$ cd ns-allinone-2.34
$ ./install
7. Edit some paths

$ gedit ~/.bashrc
8. Put these lines on that file in the last. Off course, you might change /home/noor for it depends on where you extract ns-allinone-2.34.tar.

# LD_LIBRARY_PATHOTCL_LIB=/home/noor/ns-allinone-2.34/otcl-1.13NS2_LIB=/home/noor/ns-allinone-2.34/libX11_LIB=/usr/X11R6/libUSR_LOCAL_LIB=/usr/local/libexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB# TCL_LIBRARYTCL_LIB=/home/noor/ns-allinone-2.34/tcl8.4.18/libraryUSR_LIB=/usr/libexport TCL_LIBRARY=$TCL_LIB:$USR_LIB# PATHXGRAPH=/home/noor/ns-allinone-2.34/bin:/home/noor/ns-allinone-2.34/tcl8.4.18/unix:/home/noor/ns-allinone-2.34/tk8.4.18/unix:/home/noor/ns-allinone-2.34/xgraph-12.1/NS=/home/noor/ns-allinone-2.34/ns-2.34/NAM=/home/noor/ns-allinone-2.34/nam-1.13/export PATH=$PATH:$XGRAPH:$NS:$NAM

9. Validate it (take very long time compare to install process)
$ cd ns-2.33$ ./validate

10. Let it take effect immediately

$ source ~/.bashrc

11. Try to run it as following way, by just typing ns with terminal

$ ns
12. If the installation is successful, then you will be able to see % at the command prompt. Type following command to exit
% exit

13. Good luck and please keep remember me in your prays(Thanks in advance). Noor Zaman, King Faisal University, Saudi Arabia.

24 comments:

  1. unable to install
    it says


    ns command not found
    please help!

    ReplyDelete
  2. in step :9 cd ns-2.33 was not found(no such file or direcory)

    ReplyDelete
    Replies
    1. before typing the command "cd ns-2.33" you should have to be in directory ns-allinone-2.34.

      Delete
  3. I installed NS 2.34 in ubuntu 10.04 LTS. while I am trying to execute any ns program, it will give the error message. I put ns A1-stop-n-wait.tcl. It displayed the following messages. After that if I put nam then the file name I won't work. Pls help me.

    filtering...
    ns: finish: couldn't read file "../bin/namfilter.tcl": no such file or directory
    while executing
    "exec tclsh ../bin/namfilter.tcl A1-stop-n-wait.nam"
    (procedure "finish" line 7)
    invoked from within
    "finish"

    ReplyDelete
  4. Hi,
    I m was trying to install NS2.34 on Ubuntu 11.04, I got the below error during installation with ./install command.

    rm -f libotcl.a otcl.o
    gcc -c -g -O2 -DNDEBUG -DUSE_SHM -I. -I/home/in_st/ns-allinone-2.34/include -I/home/in_st/ns-allinone-2.34/include -I/home/in_st/ns-allinone-2.34/include -I/include otcl.c
    ar cq libotcl.a otcl.o
    ranlib libotcl.a
    rm -f libotcl.so otcl.o so_locations
    gcc -c -g -O2 -DNDEBUG -DUSE_SHM -fpic -I. -I/home/in_st/ns-allinone-2.34/include -I/home/in_st/ns-allinone-2.34/include -I/home/in_st/ns-allinone-2.34/include -I/include otcl.c
    ld -shared -o libotcl.so otcl.o
    otcl.o: In function `OTclDispatch':
    /home/in_st/ns-allinone-2.34/otcl-1.13/otcl.c:495: undefined reference to `__stack_chk_fail_local'
    otcl.o: In function `Otcl_Init':
    /home/in_st/ns-allinone-2.34/otcl-1.13/otcl.c:2284: undefined reference to `__stack_chk_fail_local'
    ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
    ld: final link failed: Nonrepresentable section on output
    make: *** [libotcl.so] Error 1
    otcl-1.13 make failed! Exiting ...
    See http://www.isi.edu/nsnam/ns/ns-problems.html for problems

    Any suggestion, what should I do to avoid this?

    Sonam

    ReplyDelete
  5. sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3

    AFTER EXECUTING THE ABOVE COMMAND M HAVING BELOW PROB.. KINDLY HELP ME HOW TO RESOLVE THIS PROBLEM... AT MY ID nidhi.jjmsn@gmail.com... as early as possible................................

    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package autoconf is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Unable to locate package build-essential
    E: Package 'autoconf' has no installation candidate
    E: Unable to locate package automake
    E: Unable to locate package libxmu-dev
    E: Unable to locate package gcc-4.3
    E: Couldn't find any package by regex 'gcc-4.3'
    angel@ubuntu:~$

    ReplyDelete
  6. ns command not found is the error i get..plzz help me

    ReplyDelete
  7. hey, when I run sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3

    I encounter E: couldn't find package build-essential

    Why??

    ReplyDelete
  8. I did all the steps, but when I write "ns" on terminal i get the bellow error. What is the problem? Can u help?

    ReplyDelete
  9. while i am installing ns2.34 in ubuntu 10.04 when i am using ./install cmd i am getting the following error plz help me urgent send reply to this id :mrajender0027@gmail.com

    configure: creating ./config.status
    config.status: creating Makefile
    rm -f libotcl.a otcl.o
    gcc -c -g -O2 -DNDEBUG -DUSE_SHM -I. -I/home/rajender/ns-allinone-2.34/include -I/home/rajender/ns-allinone-2.34/include -I/home/rajender/ns-allinone-2.34/include -I/include otcl.c
    ar cq libotcl.a otcl.o
    ranlib libotcl.a
    rm -f libotcl.so otcl.o so_locations
    gcc -c -g -O2 -DNDEBUG -DUSE_SHM -fpic -I. -I/home/rajender/ns-allinone-2.34/include -I/home/rajender/ns-allinone-2.34/include -I/home/rajender/ns-allinone-2.34/include -I/include otcl.c
    ld -shared -o libotcl.so otcl.o
    otcl.o: In function `OTclDispatch':
    /home/rajender/ns-allinone-2.34/otcl-1.13/otcl.c:495: undefined reference to `__stack_chk_fail_local'
    otcl.o: In function `Otcl_Init':
    /home/rajender/ns-allinone-2.34/otcl-1.13/otcl.c:2284: undefined reference to `__stack_chk_fail_local'
    ld: libotcl.so: hidden symbol `__stack_chk_fail_local' isn't defined
    ld: final link failed: Nonrepresentable section on output
    make: *** [libotcl.so] Error 1
    otcl-1.13 make failed! Exiting ...
    See http://www.isi.edu/nsnam/ns/ns-problems.html for problems

    ReplyDelete
  10. ns command not found
    error comes. plz help urgent..

    ReplyDelete
  11. hey ..
    i found the correct way to install ns2 on ubuntu 10.04.
    Visit this link...
    http://hilalkaratoy.wordpress.com/ns-2/

    ReplyDelete
  12. i have installed ns2.34 correctly on ubuntu 10.04 but when i enter ns it says command not found.. please help asap

    ReplyDelete
  13. people those who have error "ns command not found" should try this
    type $source ~./bashrc instead of $source ~/.bashrc

    also in step 8
    use the below code,replace your directory as said in step 8 itself


    # LD_LIBRARY_PATH
    OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
    NS2_LIB=/your/path/ns-allinone-2.34/lib
    X11_LIB=/usr/X11R6/lib
    USR_LOCAL_LIB=/usr/local/lib
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

    # TCL_LIBRARY
    TCL_LIB=/your/path/ns-allinone-2.34/tcl8.4.18/library
    USR_LIB=/usr/lib
    export TCL_LIBRARY=$TCL_LIB:$USR_LIB

    # PATH
    XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
    NS=/your/path/ns-allinone-2.34/ns-2.34/
    NAM=/your/path/ns-allinone-2.34/nam-1.14/
    PATH=$PATH:$XGRAPH:$NS:$NAM

    ReplyDelete
  14. problem was due to error in line spacing in code

    i got mine working now after this

    ReplyDelete
  15. sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3

    AFTER EXECUTING THE ABOVE COMMAND M HAVING BELOW PROB..
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Package build-essential is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    E: Package build-essential has no installation candidate
    please help me.
    how to solve this problem?
    my id is vinod242306@gmail.com
    thanks a lot...

    ReplyDelete
    Replies
    1. do step 5 and then step 1
      your problem will be solved

      Delete
  16. how to uninstall ns2.34????
    plz help

    ReplyDelete