Nov 23, 2011

Install ns2.1b9a + TENS in Ubuntu 10.04


ns2.1b9a which is an old version NS2 has very strong OS dependency, so I choose Ubuntu 10.04(64-bit).


-------------------------------------Install NS2-----------------------------------------------------------


1) First of all, download the NS-2 package ns-allinone-2.1b9a-gcc32. http://www.isi.edu/nsnam/dist/ns-allinone-2.1b9a-gcc32.tar.gz

2) Install "build-essential" and "libxmu-dev"

sudo apt-get install build-essential

sudo apt-get install libxmu-dev


3) Because in Ubuntu10.04, the gcc compiler version is gcc-4.4 which is too high to compile ns2.19b, we have to install gcc-3.3 and g++-3.3 by ourselves.

Go to http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-3.3/ and download

"cpp-3.3_3.3.6-15ubuntu6_amd64.deb" "g++-3.3_3.3.6-15ubuntu6_amd64.deb" "gcc-3.3-base_3.3.6-15ubuntu6_amd64.deb" "gcc-3.3_3.3.6-15ubuntu6_amd64.deb" and " libstdc++5-3.3-dev_3.3.6-15ubuntu6_amd64.deb"

. (Depend on your system, the version may be different) Then install them by sudo dpkg --force-depends -i xxx.deb

To check compiler version, we use ls /usr/bin/gcc* -ll or ls /usr/bin/g++* -ll. We also can add the compiler options

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-3.3

To change the default gcc version, we use

ln -sf /usr/bin/gcc-3.3 /usr/bin/gcc

ln -sf /usr/bin/g++-3.3 /usr/bin/g++

4) Now we are able to install NS2. First of all, tar xzvf ns-allinone-2.1b9a-gcc32.tar.gz and touch ns-allinone-2.1b9a/tcl8.3.2/generic/tclStubInit.c

5) Before running "./install", we have to modify some files (This is very important!!). Go to ns-allinone folder,

find . -name configure

You will see a list of configure files. Replace any line which is like system=MP-RAS-`awk '{print $3}' /etc/.relid'` to system=MP-RAS-`awk '{print $3}' /etc/.relid`


The original one will cause the error in tcl8.3.2, tk8.3.2 and otcl-1.8, checking system version (for dynamic loading)... ./configure: 1: Syntax error: Unterminated quoted string tcl8.3.2 configuration failed! Exiting



6) Modify otcl-xx/config.sub, tclcl-xx/config.sub and configure file in Nam folder.

Where "| x86 |"
appears, you must put "| x86 | x86_64 |". Where "| x86-* |" appears, you must put "| x86-* | x86_64-* |".


In nam config.sub file, it may not have "|86|", so just find out "case $basic_machine in"


It will cause the error, checking build system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized configure: error: /bin/sh ./config.sub x86_64-unknown-linux-gnu failed otcl-1.8 configuration failed! Exiting ... or x86_64-unknown-linux-gnu failed nam1.0a11a configuration failed!


7) After the modification, ns2 may be compiled successfully. Just run ./install

8) When it is done, edit .bashrc file and configure environment variables. Put them at the end of file.
export NS_HOME=/home/XX/ns-allinone-2.1b9a

export PATH=$PATH:$NS_HOME/bin:$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NS_HOME/otcl-1.0a8:$NS_HOME/lib:$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix

export TCL_LIBRARY=$NS_HOME/tcl8.3.2/library/


9) Finally, source .bashrc

cd ns-2.1b9a

./validate


The Test may not be successful, but it will not effect too much.


--------------------------------------Install TENS------------------------------------------------------------


10) After the NS2 installation, we will start to make The Enhanced Network Simulator (TENS). So just follow the tutorial (http://www.cse.iitk.ac.in/users/braman/tens/)


The only thing is that when type in make depend, it may have an error pcap.h is not found. So open the Ubuntu Software Center, search libpcap and install all the related packages.


11) Congratulation! It is done!

13 comments:

  1. sir can email me a computer nwt program....n how can i install ns2 for 64 bit in windows 7??
    keshab_das_semc@yahoo.in
    i will be very much thankful
    frm
    keshab

    ReplyDelete
    Replies
    1. Hi Keshab,

      Can I know which nwt program do you mean?

      To install ns2 in win7, you have to install cygwin at first. There are some tutorials online to tell you how to do it, such as this one http://www.scribd.com/doc/42038608/Cygwin-Ns2-Complete-Installation-Guide.

      But I don`t suggest cygwin + ns2. There were many unknown errors when I did it.

      Delete
  2. Also send me ur email id ..so that i can contact u further
    frm
    keshab

    ReplyDelete
  3. Hi, can Tens be installed under ns2.34? I found cumulative interference is not supported in ns2.1b9a but I also need the directional antenna part. Thanks you very much!

    ReplyDelete
    Replies
    1. Hi,

      As far as I know, TENS can only work on ns2.1b9a since some libraries are changed in the new one. If it works on ns2.34, please let me know.

      THX.

      Delete
  4. Hi,When I type ln -sf /usr/bin/gcc-3.3 /usr/bin/gcc ,I am getting the following problem
    ln: failed to create symbolic link `/usr/bin/gcc': File exists
    I have done all the other steps. when i type ./install,I get the error-
    checking whether the C compiler (gcc ) works... no
    configure: error: installation or configuration problem: C compiler cannot create executables.
    tcl8.3.2 configuration failed! Exiting ...
    Tcl is not part of the ns project.

    ReplyDelete
    Replies
    1. Hi,

      Can I ask what is the output of "ls /usr/bin/gcc* -ll " or "ls /usr/bin/g++* -ll" ?

      Delete
  5. Sir plz tell me steps to install ns2.29 on ubuntu 10.4 with Mannasim patch

    ReplyDelete
    Replies
    1. my is is rohinisharmaohlan@gmail.com

      Delete
  6. hi, I have done all the steps. when i type ./install,I get the error-
    checking whether the C compiler (gcc ) works... no
    configure: error: installation or configuration problem: C compiler cannot create executables.
    tcl8.3.2 configuration failed! Exiting ...
    Tcl is not part of the ns project. This is the output of ls /usr/bin/gcc* -ll:

    lrwxrwxrwx 1 root root 16 Jul 13 16:02 /usr/bin/gcc -> /usr/bin/gcc-3.3
    -rwxr-xr-x 1 root root 80916 May 8 2008 /usr/bin/gcc-3.3
    -rwxr-xr-x 1 root root 224544 Apr 16 2012 /usr/bin/gcc-4.4
    -rwxr-xr-x 1 root root 306200 Apr 16 2012 /usr/bin/gcc-4.6
    -rwxr-xr-x 1 root root 15970 May 8 2008 /usr/bin/gccbug-3.3

    This is the output of ls /usr/bin/g++* -ll:
    /usr/bin/g++ /usr/bin/g++-3.3

    Thank you.

    ReplyDelete
  7. same error as above trying to install this on ubuntu 12 with the steps given above ....
    checking for ranlib... ranlib
    checking for gcc... gcc
    checking whether the C compiler (gcc ) works... no
    configure: error: installation or configuration problem: C compiler cannot create executables.
    tcl8.3.2 configuration failed! Exiting ...
    Tcl is not part of the ns project. Please see www.Scriptics

    ReplyDelete
  8. Hi,
    What we need to do to make ns2.1b9a work on ubuntu14.04

    thanks,

    ReplyDelete