The ns2 version taken here is 2.34, if you downloaded any other version, please modify your version during installation
1)Uncompress the ns2
tar zxvf ns-allinone-2.34.tar.gz
gzip -d ns-allinone-2.34.tar.gz
tar xvf ns-allinone-2.34.tar
2) cd /opt/ns-allinone-2.34 (since /opt is the folder which is unused, so i have selected that folder to install, however you can install that in any folder)
3) ./install (execute the command)
4) If the installation fails in the middle, then try to install the linux packages that are necessary to run NS2. (In any linux (ubuntu or fedora or redhat or suse), install the TCL/TK, Perl packages during the installation of linux…)
5) Once the installation succeeded, then the path information will be provided by the NS2
6) Set the path in the /root/.bash_profile
If you are a user home/pradeep/.bash_profile (for example, if your the username is pradeep, then execute this command vi /home/pradeep/.bash_profile)
7) set the PATH and the LD_LIBRARY_PATH as per the output screen by NS2. (See the Video given below)
8. logout and login.
9) go to the terminal and try ns (you will get a % symbol indicating that the installation is Successful)
10) for running the examples comes along with the distribution of NS2
11. This is how you will see once the ns2 installation is success, from this information, you can put the PATH and LD_LIBRARY_PATH variable..