Sunday 11 November 2012

How to Install and Configure NS-2 with Eclipse in Linux

Running NS-2

Ns-2 can be run both in windows or Linux platform.

Best option

  • Use Linux 

How to run NS-2 under Windows?

  • Using Cygwin (not recommended)
  • Using Virtual machine
    • Vmware station (not free)
    • WM player (free and recommended)
    • Virtualbox (free)
  • others



Installation Procedures for NS-2 (ns-allinone-2.34)


Step 1: Download

download the latest ns2 copy . their are two methods to do that
1. go to terminal and type
wget http://nchc.dl.sourceforge.net/sourceforge/nsnam/ns-allinone-2.34.tar.gz
2. u can download it from here
Step 2: Extract
extract the tar file in home directory  i.e. /home/username
OR
try this in terminal
tar -xzvf ns-allinone-2.34.tar.gz
step 3 :install
just type following commands

cd ns-allinone-2.34
sudo apt-get install build-essential autoconf automake libxmu-dev
./install
Step 4: Set environment variables
$ gedit ~/.bashrc
Add the following lines to the end of the file. Remember replace “/your/path” by the folder where you have stored extracted the ns-2 file

# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/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=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

Ensure that it immediately takes effect:
$ source ~/.bashrc

Note: the previous step is important; else you cannot successfully run ns-2.
(Alternatively, you may have to restart your X-windows, that is logout, and then login, or restart your computer.)
Now, the installation has been completed. Try:
$ ns
The “%” symbol appears on the screen. Type “exit” to quit.

Validation (optional)

To run the ns validation suite:
$ cd ns-2.34
$ ./validate