Friday, 19 July 2013

Installation steps for Ns2 under fedora8

Step 1:
Download ns-allinone-2.34.tar.gz from the following link
http://sourceforge.net/project/showfiles.php?group_id=149743&package_id=169689&release_id=684492

Step 2:
Execute the following commands to install ns2.34 from the terminal. You must login as root.

$cp ns-allinone-2.34.tar /opt/
$cd /opt/
$tar -xzf ns-allinone-2.34.tar.gz
$cd ns-allinone-2.34
$./install

Step 3:
After a long wait and a whole lot of text, you should see the installation finish up with text like the following:

Please put /opt/ns-allinone-2.34/bin:/opt/ns-allinone-2.34/tcl8.4.18/unix:/opt/ns-allinone-2.34/tk8.4.18/unix
into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.

IMPORTANT NOTICES:

(1) You MUST put /opt/ns-allinone-2.34/otcl-1.13, /opt/ns-allinone-2.34/lib,
    into your LD_LIBRARY_PATH environment variable.
    If it complains about X libraries, add path to your X libraries
    into LD_LIBRARY_PATH.
    If you are using csh, you can set it like:
                setenv LD_LIBRARY_PATH <paths>
    If you are using sh, you can set it like:
                export LD_LIBRARY_PATH=<paths>

(2) You MUST put /opt/ns-allinone-2.34/tcl8.4.18/library into your TCL_LIBRARY environmental
    variable. Otherwise ns/nam will complain during startup.



Step 4:
To change PATH environment & others execute following commands in terminal.

$cd /etc
$gedit ~/.bashrc &

Step 5:
Add following lines at the end of bashrc file.

# LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ns-allinone-2.34/otcl-1.13:/opt/ns-allinone-2.34/lib

# TCL_LIBRARY
export TCL_LIBRARY=$TCL_LIBRARY:/opt/ns-allinone-2.34/tcl8.4.18/library

# PATH
export PATH=$PATH:/opt/ns-allinone-2.34/bin:/opt/ns-allinone-2.34/tcl8.4.18/unix:/opt/ns-allinone-2.34/tk8.4.18/unix

Step 6:
To make the change in the path & others permanent, type the following command in terminal.
$ source ~/.bashrc

You can check what is written in your path by writing
$echo $PATH
$echo $LD_LIBRARY_PATH
$echo $TCL_LIBRARY

Step 7:
Now, the installation has been completed. If you try:
$ns

Then a "%" will appear on the screen. Type "exit" to quit the mode.

Step 8:
You can test/validate the installation by doing the following: [It is not necessary]
$cd /opt/ns-allinone-2.34/ns-2.34/
$./validate
Note that this validation takes a really long time. If it starts out ok, you probably have a good installation.

Step 9:
Simple ns2 Simulation program

$cd /opt/ns-allinone-2.34/ns-2.34/tcl/ex
$ns wireless-demo-csci694.tcl
$nam 694demo.nam

If output comes, then everything is ok :)

Testing:
Way 1:

$ns
%set ns [new Simulator]
%$ns at 1 "puts \"Hello World!\""
%$ns at 1.5 "exit"
%$ns run


Way 2:

Step 1: Create a file named sample.tcl & add the following lines in the file.
set ns [new Simulator]
$ns at 1 "puts \"Hello World!\""
$ns at 1.5 "exit"
$ns run

Step 2: Run the file by executing following command
$ns sample.tcl

Step 3: Output will be: Hello World!

No comments:

Post a Comment