Experiment no.
SEMESTER: V(2017-18) DATE OF DECLARATION: 13/10/2017
SUBJECT: CN DATE OF SUBMISSION: 13/10/2017
NAME OF THE STUDENT: Mitali Butala ROLL NO.: 12
Aim To install and configure NS2 in Linux environment.
Learning The student will perform step by step NS2 installation and configuration in Linux
Objective environment.
Learning Outcome The student will install and configure NS2 in Linux environment.
Course Outcome C304.5: Install and configure an open source tool NS2
Program Outcome PO5: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools, including prediction and modelling to complex
engineering activities, with an understanding of the limitations.
Bloom's Remember
Taxonomy Level
Understand
Apply
Theory Ns is a discrete event simulator targeted at networking research. Ns provides
substantial support for simulation of TCP, routing, and multicast protocols over
wired and wireless (local and satellite) networks.
Ns began as a variant of the REAL network simulator in 1989 and has evolved
substantially over the past few years. In 1995 ns development was supported by
DARPA through the VINT project at LBL, Xerox PARC, UCB, and USC/ISI. Currently
ns development is support through DARPA with SAMAN and through NSF with
CONSER, both in collaboration with other researchers including ACIRI. Ns has
always included substantial contributions from other researchers, including
wireless code from the UCB Daedalus and CMU Monarch projects and Sun
Microsystems.
You can build ns either from the various packages (Tcl/Tk, otcl, etc.), or you can
download an 'all-in-one’ package.
Steps for installation:
Part I: Installation
• Remove network proxy with the password.
• Type 10.0.3.254.3142
• Copy Acquire::http {Proxy "http://10.0.3.254:3142";};
• Go to terminal and type cd/etc/apt/apt.conf.d/ and enter
• sudo vi 02proxy with the password.
• Paste Acquire::http {Proxy "http://10.0.3.254:3142";};
• Type sudo apt-get update
• sudo apt-get install ns2
Part II: Verifying
which ns
Steps for Configuration:
• Open new odt file.
• Write following script in that file
#! /bin/env tclsh
puts "Hello world!"
exit 0
• Save this file in /home/file system/username as sample.tcl
• On command prompt go to /username
• type ns sample.tcl
Lab Activities • Perform the step-by-step installation.
• Attach snapshot of the installation.
• Write and execute sample.tcl
• Attach output of sample.tcl.
Installation
Now we are ready to install ns2. To do so we first require root privileges and
then we can
run the install script. Use the following two commands:
sudo su cd ~/ns-allinone-2.35/./install
The image below shows how it looks upon successful execution
Once the installation is over, we have to make a change in the "ls.h"file. Use
the
following steps to make the changes:
Navigate to the folder "linkstate", use the following command. Here it is
assumed that the
ns folder extracted is in the home folder of your system.
cd ~/ns-allinone-2.35/ns-2.35/linkstate
Now open the file named "ls.h"and scroll to the 137th line. In that change the
word "error” to "this->error". The image below shows the line 137 (highlighted
in the
image below) after making the changes to the ls.h file. To open the file, use the
following
command:
gedit ls.h
Save that file and close it.
Now there is one more step that has to be done. We have to tell the ns which
version of GCC will be used. To do so, go to your ns folder and type the
following command:
Sudo gedit ns-allinone-2.34/otcl-1.13/Makefile.in
In the file, Change CC= @CC@ to CC=gcc-4.4,
Installation
Now we are ready to install ns2. To do so we first require root privileges and
then we can
run the install script. Use the following two commands:
sudo su cd ~/ns-allinone-2.35/./install
The image below shows how it looks upon successful execution
Setting the Environment Path
The final step is to tell the system, where the files for ns2 are installed or
present. To do
that, we have to set the environment path using the ".bashrc"file. In that file,
we need to
add a few lines at the bottom.
Do this for all the required lines.
sudo gedit ~/.bashrc
Lines to be added:
# LD_LIBRARY_PATH
OTCL_LIB=/home/akshay/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/akshay/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/akshay/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/akshay/ns-allinone-2.35/bin:/home/akshay/ns-allinone-
2.35/tcl8.5.10/unix:/home/akshay/ns-allinone-2.35/tk8.5.10/unix
#the above two lines beginning from xgraph and ending with unix should come
on the
same line
NS=/home/akshay/ns-allinone-2.35/ns-2.35/
NAM=/home/akshay/ns-allinone-2.35/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM
Once the changes have been made, save the file and restart the system.
Running ns2
Once the system has restarted, open a terminal and start ns2 by using the
following
command:
ns
If the installation is correct then the terminal looks like the image below :
For NAM installation
Copy nam-1.14.i586.tar.gz folder in home directory
1. extract it
2. type this in terminal
cd nam-1.14.i586/ &&sudo cp nam /usr/local/bin/
3. you can directly go to home directory
4. open nam-1.14.i586 folder
5. right click on nam and run it
open file with .nam extensionOutput:
The above image depicts a condition of buffer overflow
References • http://www.isi.edu/nsnam/ns/ns-build.html#allinone
• http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-
5/ns-allinone-2.35.tar.gz/download
• http://www.isi.edu/nsnam/ns/doc/ns_doc.pdf