Friday, November 6, 2009

Easiest way to install ns2 on ubuntu 9.10

hi!
As you know that ubuntu 9.10 is having lots of cool features and it's worth giving a try. But installing ns2 (The Network Simuator) through ns-allinone-2.3x package isn't easy on 9.10. While trying to install ns-allinone-2.3x, Firstly otcl doesn't compile with the latest gcc-4.4 (available with ubuntu 9.10). You need to compile it with gcc -4.3. If you get through this then also your problem is not solved, the ns-allinone-2.3x skips installing nam & xgraph as ubuntu 9.10 is not friendly with these packages available in ns-allinone-2.3x package.
I spent lots of time to fix this problem as one of my friend was doing his simulation on ns2 and finally ended up with an interesting lauchpad ppa for installing ns2 on Ubuntu.
Since Ubuntu 9.10 is already being shipped with tcl,otcl,tk... you need not to install these packages, Only ns, nam & xgraph are needed to install.
If you are behind a proxy, make sure you have $http_proxy variable configured in ~/.bashrc. [?]


Following are the simple steps to install ns2 on Ubuntu 9.10 through launchpad ppa.
1> Firstly remove all ns-allinone-2.3x directory (if you put it anywhere to install ns2) and revert back all the path changes you made in ~/.bashrc related to ns2.


2> Now export the Wouter HorrĂ©'s ppa repository key by typing the following command on terminal and enter:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B3F3334F

3> Now add the following ppa repository to source list [?]
deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
Reload repository information when prompted by "The information about available software is out-of-date" notification or reload it manually by following command on terminal:
sudo apt-get update
4> Now type the following command on terminal to install ns from the launchpad ppa repository:
sudo apt-get install ns nam xgraph
That's all. There is no need to set-up any path, environment variables or make any changes in ~/.bashrc .



Type ns to check:
you should see % at the command prompt (indicating successful installation)
Type exit if you get stuck with the %

Now Try to run any example tcl file [You can get it here]

To run a tcl file type the following command:
ns example-tcl-file.tcl
Hope this method would work for you. Just comment below whether you were successful in installation or if you face any problem.





[Added on Jan 15, 2010] I have received so many queries regarding the files that are available with ns-allinone-2.3x package. Actually ns-allinone-2.3x package has two main things; 1) ns & supporting libraries to RUN IT & 2) Sample files, examples & support for various scenario such as wireless etc... to HELP YOU IN YOUR SIMULATION.
At this point only first one is done, For second one you need to refer to the all in one package.
For that:
  • Extract the ns-allinone-2.3x directory from the archive
  • "DON'T RUN ./install" as ns2 is already installed on your system
  • Now you are ready to use the files present in "ns-allinone-2.3x/ns-2.3x/" directory. e.g.: to run example scripts available with the package goto "/ns-allinone-2.3x/ns-2.3x/tcl/ex/" and run respective tcl file.