Install network simulator on ubuntu

This blog post is regarding installing network simulator on Ubuntu.

Make sure you have the following packages installed:

build-essential autoconf automake libxt-dev libx11-dev libxmu-dev

Download ns-allinone-2.34.tar.gz. Then execute the following using command prompt:

tar -xzf ns-allinone-2.34.tar.gz 
cd ns-allinone-2.34

For Ubuntu 9.10 (karmic), you may encounter this error in the linking of otcl:

otcl.o: In function `OTclDispatch':
  /your/path/ns-allinone-2.34/otcl/otcl.c:495: undefined reference to
  otcl.o: In function `Otcl_Init':
  /your/path/ns-allinone-2.34/otcl/otcl.c:2284: undefined reference to
  ld: hidden symbol `__stack_chk_fail_local' isn't defined
  ld: final link failed: Nonrepresentable section on output
  make: *** [] Error 1

This error is because the linker being used is “ld -shared” instead of “gcc -shared”. If you edit one line in otcl-1.13/configure, and rerun install, it should work:

--- configure.orig      2009-11-02 12:14:52.556167945 -0800
 +++ configure   2009-11-02 12:17:28.966706099 -0800
 @@ -6301,7 +6301,7 @@
 -        SHLIB_LD="ld -shared"
 +        SHLIB_LD="gcc -shared"

After a long wait and a whole lot of text, you should see the installation finish up with text like the following:

Nam has been installed successfully.
Ns-allinone package has been installed successfully.
Here are the installation places:
tcl8.4.11:      /your/path/ns-allinone-2.34/{bin,include,lib}
tk8.4.11:               /your/path/ns-allinone-2.34/{bin,include,lib}
otcl:           /your/path/ns-allinone-2.34/otcl-1.13
tclcl:          /your/path/ns-allinone-2.34/tclcl-1.19
ns:             /your/path/ns-allinone-2.34/ns-2.34/ns
nam:    /your/path/ns-allinone-2.34/nam-1.14/nam
xgraph: /your/path/ns-allinone-2.34/xgraph-12.1
gt-itm:   /your/path/ns-allinone-2.34/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns

Please put /your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.19/unix:/your/path/ns-allinone-2.29/tk8.4.18/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.


(1) You MUST put /your/path/ns-allinone-2.34/otcl-1.13, /your/path/ns-allinone-2.34/lib, 
    into your LD_LIBRARY_PATH environment variable.
    If it complains about X libraries, add path to your X libraries 
    If you are using csh, you can set it like:
                setenv LD_LIBRARY_PATH 
    If you are using sh, you can set it like:
                export LD_LIBRARY_PATH=

(2) You MUST put /your/path/ns-allinone-2.34/tcl8.4.19/library into your TCL_LIBRARY environmental
    variable. Otherwise ns/nam will complain during startup.

(3) [OPTIONAL] To save disk space, you can now delete directories tcl8.4.18 
    and tk8.4.18. They are now installed under /your/path/ns-allinone-2.34/{bin,include,lib}

After these steps, you can now run the ns validation suite with
cd ns-2.34; ./validate

For trouble shooting, please first read ns problems page Also search the ns mailing list archive
for related posts.

If your ubuntu version is 9.10, you must change the variable of environment CC if not set

$ export CC=gcc-4.3

Now, You have to set environment variables

$ gedit ~/.bashrc 

Replace /your/path with the path to parent directory of ns-allinone-2.34.




Ensure that it immediately takes effect:

$ source ~/.bashrc

Validation of the installation can be tested by:

$ cd ns-2.34
$ ./validate

Now, installation of network simulator is done. Enjoy coding.

15 thoughts on “Install network simulator on ubuntu”

  1. Thank you very much!!! This is the best installation guide I’ve found! Finally I understand, why there is an error, installing ns on Ubuntu 9.10.

  2. i still have trouble installing NS2 all-in-one. Iam using ubuntu 10.04 and ns-allinone-2.34.
    Nam is not getting installed. i get the following error:

    vengatesan@ubuntu:~/ns-allinone-2.34/ns-2.34$ nam

    : no event type or button # or keysym
    while executing
    “bind Listbox {
    %W yview scroll [expr {- (%D / 120) * 4}] units
    invoked from within
    “if {[tk windowingsystem] eq “classic” || [tk windowingsystem] eq “aqua”} {
    bind Listbox {
    %W yview scroll [expr {- (%D)}] units
    bind Li…”

    1. ns is installed. i verified by typing ns and got a % at the command prompt (indicating successful installation).
    2. i googled the error and found that tcl and tk installed through synaptics would cause error. i removed them completely from there and reinstalled ns2 & validated. But the same error (as above) was still present.

      1. Hi

        I am new to this network Simulator programing. All the configuration part has been done successfully. Can you please tell me how to start ??


  3. Dear Sir,
    I have installed NS-2 in ubuntu 11.04 and I did all modifications as specified. I got ns % prompt. But after i ran a script i got this warning and error message. Plz help me solve this
    warning: using backward compatibility mode
    error when calling class OldSim

  4. Dear Sir,
    I have installed NS-2.35 in ubuntu 11.04. I cant run ns command, . example when i wan to run ns wireless.tcl an error comes out. Plz help me solve this
    warning: using backward compatibility mode
    error when calling class OldSim

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s