Install ns-2.26 on Ubuntu

Background

Ah, ns-2…the bane of many grad student’s existence. NS-2 is useful for a variety of researches related to networking. However, there might be difficult to install all the necessary packages of ns-2 in any platform. Installing the latest version of ns-2 (ns-2.33) with gcc 4.1.2 isn’t difficult at all because the source code has mapped to the current gcc configuration. Even though there is a small bug in ./configure of tk, tcl, otcl, less attempt has been done compare to the older version. This guidance based on my own experience and information from website.

The old version such as ns-2.26 won’t compile successfully with current gcc 4.1.2. So we’ve to install the gcc-2.95.

HOWTO

  1. Download the all-in-one package of ns-2 and unzip it:
    cd /usr/local/dload;
    wget http://www.isi.edu/nsnam/dist/ns-allinone-2.26.tar.gz;
    tar -xzvf ns-allinone-2.26.tar.gz;
  2. I had to install the following Debian packages:
    • apt-get install gcc-2.95
    • apt-get install g++-2.95
    • apt-get install libstdc++2.10-glibc2.2
    • apt-get install libx11-dev
    • apt-get install libxt-dev
  3. In my shell (tcsh), there were several changes needed in the configure files to compensate for stricter parsing. All lines of the form:
    system=MP-RAS-`awk ‘{print }’ /etc/.relid’`

    need changed to:

    system=MP-RAS-`awk ‘{print }’ /etc/.relid`

    That is, the second to last character (') needs to be deleted. In ns-allinone-2.26, this occurs in four places (files and line numbers):

    ./tcl8.3.2/unix/configure:4701
    ./tcl8.3.2/unix/configure:5705
    ./tk8.3.2/unix/configure:1520
    ./otcl-1.0a8/configure:4167
  4. Set your compiler environment variables in the terminal in which you will run the install script such that they point to the 2.95 version of the tools instead of the default ones. In the C shell:
    setenv CC /usr/bin/gcc-2.95;
    setenv CPP /usr/bin/cpp-2.95;
    setenv CXX /usr/bin/g++-2.95;

    Use the paths appropriate for your system. If you use the bash shell, the general form for setting an environment variable is:

    export CC=/usr/bin/gcc-2.95;

    Now, the configure scripts will use these versions of the compiler tools.

  5. When compiling the TCL/C++ interface (e.g., tclcl-1.0b13), I received a warning that stopped the compilation that line 193 of /usr/include/sys/types.h does not declare anything. Though this is not generally recommended, I used the -fpermissive option for the compiler to continue compilation.

    In the file /usr/local/dload/ns-allinone-2.26/tclcl-1.0b13/Makefile.in, I changed the CCOPT parameter on line 56 to be:

    CCOPT = -fpermissive @V_CCOPT@
  6. At this point, I just had to run the install script an everything compiled (with lots of warnings) except for nam which I didn’t need since I don’t use the visualization tools in ns-2.
    /usr/local/dload/ns-allinone-2.26/install

    (Make sure you run this in the terminal in which the CC, CPP, and CXX variables are set appropriately)

  7. Now, to get your existing ns-2 code to compile (i.e., the code in /usr/local/ns-2.26), you need to reconfigure your Makefile by specifying the new paths:
    cd /usr/local/ns-2.26; ./configure –with-tcl=/usr/local/dload/ns-allinone-2.26/tcl8.3.2 –with-tk=/usr/local/dload/ns-allinone-2.26/tk8.3.2 –with-otcl=/usr/local/dload/ns-allinone-2.26/otcl-1.0a8 –with-tclcl=/usr/local/dload/ns-allinone-2.26/tclcl-1.0b13

    Note that this will overwrite your existing Makefile, so if there was anything specific that you needed in it, you should move those commands to the Makefile.in file in /usr/local/ns-2.26.

Having fun…..

4 Responses to “Install ns-2.26 on Ubuntu”

  1. Iyad Tumar Says:

    i followed the instructions to install ns-2.26 on ubuntu 8.4 but i got this error.

    tclcl-mappings.h: In static member function ‘static int TclObjectHelper::dispatch_(void*, Tcl_Interp*, int, char**)’:
    tclcl-mappings.h:51: error: incomplete type ‘Tcl’ used in nested name specifier
    tclcl-mappings.h:52: error: invalid use of incomplete type ‘struct Tcl’
    tclcl-mappings.h:41: error: forward declaration of ‘struct Tcl’
    tclcl-mappings.h:57: error: invalid use of incomplete type ‘struct Tcl’
    tclcl-mappings.h:41: error: forward declaration of ‘struct Tcl’

    do you have an idea? what is the ubuntu version that you used

  2. siva Says:

    I read your post and it was very helpful for us. i request you to give me a reply clarrifying that whether these steps are suitable for fedora or not?.
    Awaiting for your reply.
    Thank you.

  3. EHSAN Says:

    Hi ! I want install ns 2.33 , do you know a bout it ? have a different with ns 2.26
    thank’s

  4. Aiuto installazione programma | hilpers Says:

    [...] usare una versione specifica e non la pi recente; la procedura che dovrei seguire indicata qui: http://lycog.wordpress.com/2008/06/0…226-on-ubuntu/ il problema che sono alla prima esperienza con linux e quindi non capisco cosa devo fare! In [...]

Leave a Reply