Saturday, 18 April 2015

Install Ns2.35 on Ubuntu 14.04 (step by step)

This installation guide is on  Ubuntu 14.04

Note* (all commands are in red color)

#########################
[step 1]
 #########################
   First Download NS2 source file from here.Then you will get a file   named “ns-allinone-2.35.tar.gz“

#########################
[step 2]
#########################
 copy  ns-allinone-2.35.tar.gz file to location you want.

In my case i am keeping it in my home folder(/home/mahesh/).

#########################
[step 3]
#########################
 From terminal go to the folder where the ns-allinone file  is placed and type the following command to  extract
  
       tar -xzf ns-allinone-2.35.tar.gz 

#########################
[step 4]
#########################
 We need to do changes in ls.h file to avoid installation error
 
go to ns-allinone-2.35/ns-2.35/linkstate/ls.h

use following two commands

cd ns-allinone-2.35/ns-2.35/linkstate/ls.h

gedit ls.h

this will open ls.h file in editor

now replace  line 137 

i.e.  void eraseAll() {erase(baseMap::begin(), baseMap::end()); } 

with  following line

void eraseAll() {this->erase(baseMap::begin(), baseMap::end()); }

 save it and close the editor.
 
#########################
[step 5]
#########################
 Before installation we need to update  system packages and install some essential softwares:(needs internet connection)


use following command one by one

sudo apt-get update

sudo apt-get install build-essential autoconf automake

#########################
[step 6]
#########################
 Now we are ready to install ns2. Go to the  ns-allineone-2.35/ directory. Use the following two commands:
 
cd ns-allinone-2.35

./install

#########################
[step 7]
#########################
  Set the environment variable to tell the system, where the files for ns2 are installed .We need to add following lines at the end of .bashrc file.

Note : Replace /home/mahesh/ with the path where you have kept  
 ns-allinone-2.35

Type following command

gedit ~/.bashrc


Lines to be added are:

# LD_LIBRARY_PATH
OTCL_LIB=/home/mahesh/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/mahesh/ns-allinone-2.35/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY

TCL_LIB=/home/mahesh/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
NS=/home/mahesh/ns-allinone-2.35/ns-2.35/
NAM=/home/mahesh/ns-allinone-2.35/nam-1.15/
PATH=$PATH:$NS:$NAM


 save the file. 
 
 Type ns in terminal
 
 ns

 It will show % symbol.Thats all, you have successfully installed ns2.
 
 Best Luck.

No comments:

Post a Comment