User Tools

Site Tools


Installing the Network Simulator ns2 on Debian

Note For the wget commands below get the correct download URLs from the sites linked at

In the following I will download and unpack all needed sources to a directory named ns2install.

$> mkdir ns2install
$> cd ns2install

Debian Libraries

Besides the usual stuff for compiling programs like gcc, g++ and make you'll need some additional libraries for compiling and running ns2. Some of them are available as Debian packages.

#> apt-get install tcl8.4 tcl8.4-dev tk8.4 tk8.4-dev stow

Some of the libs and tools we're going to compile expect some of the TK and TCL Libraries at some other place than the Debian packages install them so we have to create some symlinks. Just ignore warnings about existing files in the second call.

#> ln -s /usr/include/tcl8.4 /usr/include/tk8.4
#> ln -s /usr/include/tcl8.4/tcl-private/generic/* /usr/include/tcl8.4/
#> ln -s /usr/lib/tcl8.4/http2.4 /usr/lib/tcl8.4/http2.3

To tell ldconfig that it can find shared libs in /usr/local/lib we have to add a line to /etc/

#> echo "/usr/local/lib" >> /etc/


The next thing we need is the OTCL Library. Note that the make install fails to create the needed directories so we do this our self before install.

$> wget otcl-1.13.tar.gz
$> tar -xzvf otcl-1.13.tar.gz
$> cd otcl-1.13
$> ./configure --prefix=/usr/local/stow/otcl-1.13 --with-tk=/usr
$> make
#> mkdir -p /usr/local/stow/otcl-1.13/bin
#> mkdir -p /usr/local/stow/otcl-1.13/lib
#> mkdir -p /usr/local/stow/otcl-1.13/include
#> make install
#> cd /usr/local/stow/
#> stow otcl-1.13
#> ldconfig


Okay let's just go on to the next one: TCLCL. Same thing here.

$> wget tclcl-src-1.19.tar.gz
$> tar -xzvf tclcl-src-1.19.tar.gz
$> cd tclcl-1.19
$> ./configure --prefix=/usr/local/stow/tclcl-1.19 --with-tk=/usr
$> make
#> mkdir -p /usr/local/stow/tclcl-1.19/include
#> mkdir -p /usr/local/stow/tclcl-1.19/bin
#> mkdir -p /usr/local/stow/tclcl-1.19/lib
#> make install
#> cd /usr/local/stow/
#> stow tclcl-1.19
#> ldconfig


Now we can actually begin to compile ns2 itself. You should abort the make test after a few tests - the whole run may take a very long time. Usually you should get some errors on the first test if missed something 'til this point.

$> wget ns-src-2.31.tar.gz
$> tar -xzvf ns-src-2.31.tar.gz
$> cd ns-2.31
$> ./configure --prefix=/usr/local/stow/ns-2.31 --with-tk=/usr
$> make
$> make test
#> mkdir -p /usr/local/stow/ns-2.31/bin
#> make install
#> cd /usr/local/stow
#> stow ns-2.31

nam and others

That's it so far. ns2 is ready for your simulations. However you may want to install some more tools. At least you should install nam which is needed for the ns2 Tutorial.

You'll need the additional library libxmu-dev for compiling and running nam.

#> apt-get install libxmu-dev

You may now proceed as before.

$> wget nam-src-1.13.tar.gz
$> tar -xzvf nam-src-1.13.tar.gz
$> cd nam-1.13
$> ./configure --prefix=/usr/local/stow/nam-1.13 --with-tk=/usr
$> make
#> mkdir -p /usr/local/stow/nam-1.13/bin
#> make install
#> cd /usr/local/stow
#> stow nam-1.13

There are some more suggested tools which are available as Debian Packages

#> apt-get install perl-tk xgraph graphviz

Now you are ready to run your network simulations. A good start is the Tutorial.

Building TCL and Tk from the sources

If you decided to build TCL and/or Tk from the sources at a linux-box with bash 3.1 you MUST patch the ./configure script as described in To put it in a simple way:

cd unix
cp -v configure{,.orig}
sed "s/relid'/relid/" configure.orig > configure
ns2.txt · Last modified: 2010/04/02 11:18 by