Installing NS2:
In ubuntu, there are two ways of installing NS2.
First to to download ns-allinone2.35 or the latest version at http://sourceforge.net. Direct link to
NS-2.35 is http://sourceforge.net/projects/nsnam/.
Extract the downloaded file into a folder and go to .../ns-allinone-2.35/ns-2.35/allinone folder, in which "install" file will be there. Double click it and run in terminal.
Terminal is opened in ubuntu by cntr+alt+t
Second way is to open terminal and type:
sudo apt-get install ns2
sudo apt-get install nam
sudo apt-get install xgraph
After this type ns in your Terminal, if you don't end up with a error command then you are ready to have fun with NS2.
The installation is enough for basic simulation, but for advanced simulation, we need to install C++, using sudo apt-get install g++ command in terminal.
In windows, NS2 is used using Cygwin.
To install, download ns-allinone-2.35 or latest version as discussed and go to ../ns-allinone-2.35/ns-2.35/allinone where INSTALL.WIN32 is present. Install it in cmd window.