-   Linux - Newbie (
-   -   Problem installing ns2 on Ubuntu (

Aden09 04-18-2011 11:01 AM

Problem installing ns2 on Ubuntu

I am trying to install ns2 on my Ubuntu machine and I followed the steps as mentioned on:

After I set the path variables, (I did change the your/path), I tried executing the ns command.

I should have gotten a % in return but i get the following text.

Usage: host [-v] [-a] [-t querytype] [options] name [server]
Listing: host [-v] [-a] [-t querytype] [options] -l zone [server]
Hostcount: host [-v] [options] -H [-D] [-E] [-G] zone
Check soa: host [-v] [options] -C zone
Addrcheck: host [-v] [options] -A host
Listing options: [-L level] [-S] [-A] [-p] [-P prefserver] [-N skipzone]
Common options: [-d] [-f|-F file] [-I chars] [-i|-n] [-q] [-Q] [-T] [-Z]
Other options: [-c class] [-e] [-m] [-o] [-r] [-R] [-s secs] [-u] [-w]
Special options: [-O srcaddr] [-j minport] [-J maxport]
Extended usage: [-x [name ...]] [-X server [name ...]]

What am I doing wrong?


knudfl 04-18-2011 01:38 PM

Welcome to LQ.

The mentioned error happens sometimes. You are not the first asking for a solution.
I have never experienced it here, I think, with a hundred ns2 installs done OK.
Besides that, you may not need the % prompt. The most commands are done with :
'ns file.tcl'.

What happens if you do : 'cd ns-allinone-2.34/ns-2.34/ && ./ns' ?

About setting a path : Usually not required since ns-2.26.
'cd ns-allinone-2.34/ns-2.34/ && sudo make install' copies 'ns' to /usr/local/bin.
cd ../nam-<version>/ && sudo make install : nam is copied to /usr/local/bin.
Then 'ns' and 'nam' are in a system PATH.

Today ns and nam are statically compiled, and depend on libs in /usr/lib/ only.
And /usr/lib/ is already in the LD_LIBRARY_PATH.

Also : If you had 2 or 3 versions of ns2 installed,
adding a path to the .bashrc wouldn't work.


Aden09 04-18-2011 02:20 PM


When i run 'cd ns-allinone-2.34/ns-2.34/ && ./ns' I get %.! Yay..!

I was looking into other forums and it turns out that when I ran "ns" I was running the name service and not network simulator.

I then tried creating and running a simple tcl and I am getting an error. I can see the tcl file in the directory but when i run "$ns xxx.tcl" I keep getting the error " xxx.tcl does not exist, try again ".

Any ideas about whats going wrong?

knudfl 04-18-2011 02:27 PM

May be this will help :

1) The first command is : pwd
It will tell your location.

2) cd <path-to-folder-with-xxx.tcl>/

3) ns xxx.tcl

Aden09 04-18-2011 02:45 PM

I was running "ns xxx.tcl" in the correct directory. It gives an error with "ns xxx.tcl" but works fine with "./ns xxx.tcl".

Whats the difference between just "ns" and "./ns" ?

Thanks for all your help :)

knudfl 04-18-2011 03:23 PM

Did you install ( or copy ) 'ns' to /usr/local/bin/ ?

And what is your location of ns-allinone-2.34/ ?
Default is : /home/<user-name>/ns(2)/ns-allinone-2.34/
( Or any other folder in /home/<user-name>/ ).

The above location for the binary 'ns' and for the application
is usually the safe choice.
( And you can't do './ns2' in all locations, unless you have a link
or a copy of 'ns' in all the used directories.)


Aden09 04-18-2011 04:21 PM

The location of my ns-allinone-2.34 is /home/Aden/Desktop/ns-allinone-2.
I unzipped and installed everything here.

I did run this line, which said it would allow me to run "ns" from everywhere.

"$ sudo ln -s /home/Aden/Desktop/ns-allinone-2.34/ns-2.34/ns/usr/bin/ns" from

knudfl 04-18-2011 06:01 PM


sudo ln -s /home/Aden/Desktop/ns-allinone-2.34/ns-2.34/ns/usr/bin/ns
Except that a <space> is missing. It should be :

sudo ln -s /home/Aden/Desktop/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns

And : /usr/bin/ or /usr/local/bin/, not that important.
But it is /usr/local/bin/, that is meant for your own files,
i.e. software, which is not installed with the Package Manager.
Never used links like that. May work.
Still : The safe method is : cd ns-2.34/ && sudo make install

Also have in mind, that you can never know, how experienced the author is when
he/she writes a blog. Some write a HOWTO right after installing their first ns2.


All times are GMT -5. The time now is 05:37 PM.