How to install ns-2

Windows(Cygwin 2.1.0-1)

Last update: 2015-07-30

Since ns-allinone is old, we can no longer install it as is. So, in order to install ns-2 on a windows environment, we have to proceed the following steps.

  1. Install Cygwin32 in your windows environment. ns-2 cannot be compiled by 64bit system.
  2. Obtain ns-allinone-2.35.tar.gz. Make a working directory at your Cygwin environment. Extract the files of ns-allinone-2.35 by using tar zxf command.
  3. We can no longer compile old tcl attached to ns-allinone on Cygwin 2.1.0-1. So remove both tcl and tk folders from ns-allinone directory.
  4. The following packages of Cygwin are required to compile ns-allinone:
    1. gcc-core
    2. gcc-g++
    3. make
    4. patch
    5. perl
    6. w32api-header
    7. w32api-runtime
    8. xorg-server
    9. xinit
    10. libx11-devel
    11. libxmu-devel
    12. tcl
    13. tcl-devel
    14. tcl-tk
    15. tcl-tk-devel
    Install these packages into the Cygwin environment by using setup-x86.exe.
  5. One of the header file of TCL has a problem. Then, revise the header file tclPort.h by applying the following patch file:
    --- /usr/include/tcl8.5/generic/tclPort.h.orig  2015-07-16 16:05:12.847300600 +0900
    +++ /usr/include/tcl8.5/generic/tclPort.h       2015-07-13 04:32:03.545287700 +0900
    @@ -20,7 +20,7 @@
     #if defined(_WIN32)
     #   include "tclWinPort.h"
     #else
    -#   include "tclUnixPort.h"
    +#   include "../unix/tclUnixPort.h"
     #endif
     #include "tcl.h"
    
    This revise must be applied by using a text editor manually. Otherwise, once one tried to apply this patch by using patch command, the patch command would not change the file with only reporting that the file is dangerous.
  6. In order to changing the name of libraries, make symbolic links by the following commands:
    
    	ln -s /usr/lib/libtcl.dll.a /usr/lib/libtcl.a
    	ln -s /usr/lib/libtk.dll.a /usr/lib/libtk.a
        
  7. Apply this patch file. First, put the patch file, pfile.txt, at the same directory where ns-allinone-2.35 directory is located. Second, move the current directory to the directory where pfile.txt exists. Finally, apply the following command:
    
        patch -p0 < pfile.txt
    
  8. Move the current directory to ns-allinone-2.35. Then, do ./install
  9. Type the following command, so that the results of finding dll files are saved into a file(say rebaselist).
    find . -iname '*.dll' > rebaselist
    Assume that the directory where the above command is proceeded is /home/username/ns-allinone-2.35. That is, the full path of the file is assumed to be /home/username/ns-allinone-2.35/rabeselist.
  10. Then, do rebaseall by the following steps:
    1. Terminate any Cygwin terminals.
    2. Start cmd.exe
    3. Move current directory to ${CYGWINDIR}\bin by using CD command as following:
      cd \cygwin\bin
    4. Start dash by applying the following command:
      .\dash
    5. Move the current directory to the directory where the rebase list file is placed:
      cd /home/usrname/ns-allinone-2.35
    6. Do rebaseall by the following command:
      /bin/rebaseall -T rebaselist -v
    7. Type exit, then you exit dash.
  11. Finally, now ns-2.35 is available! However, in order to pass the path, ns-allinone-2.35/bin, add the following line to .bash_profile
    PATH="${HOME}/ns-allinone-2.35/bin:${PATH}"

Note that validate fails at test-all-tcpLinux and test-all-simulteneous.

Usage

If you would like to use nam, then proceed the following commands in advance:


startxwin &
export DISPLAY=:0.0

This may cause Windows to ask you to permit to access some network port. If you are asked, then allow it.

Appendix

a bash script for making the patch file mkpatch.bash


Naoshi SAKAMOTO <sakamoto@c.dendai.ac.jp>
Department of Information and Communication Engineering, School of Engineering, Tokyo Denki University.