Wednesday, December 29, 2010

Changing environment variables in ns-2

The installation procedure given in the previous post allows you to run the ns2 codes only by placing these codes in the /ns-2.34/bin folder. By editing the environment variables it is possible to simulate the tcl codes present anywhere in the filesystem.


1.     First enter the ns-2.34-allinone folder
$ cd ns-2.34-allinone

2.     We have to edit bashrc file
$ gedit ~/.bashrc

3.    Add the following lines to this file. Change /home/programmer according to where your ns-2 has been installed.


# LD_LIBRARY_PATH

OTCL_LIB=/home/programmer/ns-allinone-2.33/otcl-1.13

NS2_LIB=/home/programmer/ns-allinone-2.33/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/programmer/ns-allinone-2.33/tcl8.4.18/library

USR_LIB=/usr/lib

export TCL_LIBRARY=$TCL_LIB:$USR_LIB


# PATH

XGRAPH=/home/programmer/ns-allinone-2.33/bin:/home/programmer/ns-allinone-2.33/tcl8.4.18/unix:/home/programmer/ns-allinone-2.33/tk8.4.18/unix:/home/programmer/ns-allinone-2.33/xgraph-12.1/

NS=/home/programmer/ns-allinone-2.33/ns-2.33/

NAM=/home/programmer/ns-allinone-2.33/nam-1.13/

export PATH=$PATH:$XGRAPH:$NS:$NAM

4.     To let this change take effect, type the following command
$source ~/.bashrc


To run your tcl script use the following command
$ns filename.tcl

No comments:

Post a Comment