Yesterday a friend asked me about how to install the famous network simulator NS2 on ubuntu. I did some digging this morning and came up with this.

Wouter Horré’s hosts a PPA on launchpad which contains the latest builds of ns2 from him. You can add this PPA by creating a file /etc/apt/sources.list.d/ns2.ppa.list and add the following to the file:

deb http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main
deb-src http://ppa.launchpad.net/wouterh/ppa/ubuntu karmic main

Now before you do an update, you must also fetch and add the PPA GPG Key,

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B3F3334F

Done? Yes, just do an update and then install ns2 like:

sudo apt-get update
sudo apt-get install ns nam xgraph

Installed, now to check run ns. This should leave you with a % prompt, if it does, you are in for treat, run exit and start bragging that you installed NS2 on ubuntu :P .

This is a lot easier than any previous methods which involved editing ~/.bashrc and setting up paths, then compiling and building tool. Good thing is as its a repository, ns2 will automatically get updated with rest of softwares if you do sudo apt-get upgrade.