0% found this document useful (0 votes)
47 views

Computer Networks Project Based Lab

This document discusses the NS-2 network simulator. It provides background on NS-2, describing how it was developed beginning in 1989 and is now developed collaboratively. It also summarizes the key components of NS-2, including that it uses Tcl and C++, with Tcl used for scripts and C++ used for the backend logic. Finally, it provides a brief example of creating a simple network topology using NS-2.

Uploaded by

Beverly Norton
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Computer Networks Project Based Lab

This document discusses the NS-2 network simulator. It provides background on NS-2, describing how it was developed beginning in 1989 and is now developed collaboratively. It also summarizes the key components of NS-2, including that it uses Tcl and C++, with Tcl used for scripts and C++ used for the backend logic. Finally, it provides a brief example of creating a simple network topology using NS-2.

Uploaded by

Beverly Norton
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

COMPUTER NETWORKS

PROJECT BASED LAB


V.PRUDHVI KRISHNA(12003472)
K.SRINIDHI(12003163)
KVS.UDAY
BHASKAR(12003458)
B.ARUN KUMAR(12003288)

BACKGROUND TO NS2
NS began development in 1989 as a variant of REAL
network simulator.
By 1995, ns had gained support from DARPA, the
VINT project at LBL, Xerox PARC, UCB and USC/ISI.
Ns is now developed in collaboration between
number of different researchers and institution,
including SAMAN (supported by DARPA), CONSER
(through the NSF), and ICIR (former ACIRI).
Long-running contributions have also come from Sun
Microsystems and the UCB Daedelus and Carnegie
Mellon Monarch projects, cited by the ns homepage
for wireless code additions.
Ns is based on two languages, an object oriented
simulator written in C++ and an Otcl interpreter, used
to execute users command scripts. Ns has a rich
library network and protocol objects. There are two
class hierarchies: the compiled c++ hierarchy and the
interpreted Otcl one, with one to one correspondence
between them.
ns (from network simulator) is a name for series of
discrete event network simulators, specifically ns-
1, ns-2 and ns-3. All of them are discrete-event
network simulator, primarily used in research and
teaching. ns-3 is free software, publicly available
under the GNU GPLv2 license for research,
development, and use.

The goal of the ns-3 project is to create an open
simulation environment for networking research that
will be preferred inside the research community.
It should be aligned with the simulation needs of
modern networking research.
It should encourage community contribution, peer
review, and validation of the software.
Since the process of creation of a network simulator
that contains a sufficient number of high-quality
validated, tested and actively maintained models
requires a lot of work, ns-3 project spreads this
workload over a large community of users and
developers.

Ns-2 contains the following components:
Tcl: Creating Layouts.
C++: for back end logic
NAM (Network Animator): to see results or
simulation environment.
Otcl: Network Protocols design
TclCL: linking C++ and Tcl code.
X- graph: For analysis (optional).

NS2 ARCHITECHTURE

As shown in the
simplified users view
of figure below. NS is
an Object-oriented
Tcl (OTCl) script
interpreter that has a
simulation event
scheduler and
network component
object libraries and
network set-up
(plumbing) module
libraries.

What Languages are used with NS-2?
Split -Language programming is used.
Scripting Language(Tcl Tool Command Language
and pronounced tickle)
System Programming Language (C/C++)
Ns is a Tcl interpreter to run Tcl Scripts.
By using C++ / OTcl, the network simulator is
completely object oriented.


NS2 INSTALLATION DESCRIPTION 2.35
Here we are going to describe how a ns2 can be installed in
an ubuntu environment.
In order to do that these are the requirements:-
i)Hardware requirements:-
A system with dual core processor 1.9ghz, minimum 512 Mb
of ram,
20 gb of Hard disk space

*Internet should be connected
ii)Software requirements:-
Pre installed ubuntu version 12.04 Lts(later), Ns-allinone-
2.35 software
INSTALLATION PROCEDURE
Step 1: -
For ns2 installation we need to install four packages they are

1)sudo apt-get install build-essential
next we want to enter a password of the ubuntu after entering the
password the process of installing the package completed
2) sudo apt-get install libx11-dev
by entering this we can install second package
3)sudo apt-get install libxt-dev
by this we can complete the installation of third package
4)sudo apt-get install lidxum-dev
by this fourth package is completed
Step 2: -

i) Extract the ns-allinone-2.35 and keep it on desktop
ii) Next open terminal and type the following command
iii) cd Desktop/ns-allinone-2.35 and press enter
iv) now type ./install
v) The installation process starts and continuous for a while
and then continue the the procedure
vi) By typing cd nam-1.15 and press enter-This command is used for the
installation of the essential software packages for the animation display
vii) Now type sudo make install
viii) After completing this type cd -
ix) Now type xgraph-12.2 -This command is for the sake of graphical
display
x) And enter sudo make install
xi) after that if the software is successfully installed
xii) Now we have to enter the command ns if percentage (%) symbol is
appeared is installation is completed.

NAM (NETWORK ANIMATOR)

NAM provides a visual interpretation of the network
topology created. The application was developed as part
of the VINT project. Its features are as follows. Fig
displays the NAM application and its components.

Provides a visual interpretation of the network created
Can be executed directly from a Tcl script
Controls include play, stop ff ,rw, pause, a display speed
controller and a packet monitor facility.
Presents information such as throughput, number
packets on each link.
Provides a drag and drop interface for creating
topologies.
NAM is a Tcl/TK based animation tool for viewing
network simulation traces and real world packet trace
data.
The design theory behind nam was to create an
animator that is able to read large animation data
sets and be extensible enough so that it could be
used indifferent network visualization situations.
Under this constraint nam was designed to read
simple animation event commands from a large trace
file. In order to handle large animation data sets a
minimum amount of information is kept in memory.
.
Event commands are kept in the file and
reread from the file whenever necessary.
The first step to use nam is to produce the
trace file. The trace file contains topology
information, e.g.nodes. Links, as well as
packet traces. Usually, the trace file is
generated by ns.
During an ns simulation, user can produce
topology configurations, layout information,
and packet traces using tracing events in ns.
CREATING A SIMPLE TOPOLOGY
Source code:
set ns [new Simulator]

$ns color 0 blue
$ns color 1 red
$ns color 2 white

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]

set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

$ns duplex-link $n0 $n2 5Mb 2ms DropTail
$ns duplex-link $n1 $n2 5Mb 2ms DropTail
$ns duplex-link $n2 $n3 1.5Mb 10ms DropTail

$ns duplex-link-op $n0 $n2 orient right-up
$ns duplex-link-op $n1 $n2 orient right-down
$ns duplex-link-op $n2 $n3 orient right

$ns duplex-link-op $n2 $n3 queuePos 0.5

set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0

set udp1 [new Agent/UDP]
$ns attach-agent $n3 $udp1
$udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1

set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
set null1 [new Agent/Null]
$ns attach-agent $n1 $null1

$ns connect $udp0 $null0
$ns connect $udp1 $null1

$ns at 1.0 "$cbr0 start"
$ns at 1.1 "$cbr1 start"

set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp
$ns attach-agent $n3 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns at 1.2 "$ftp start"
$ns at 1.35 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"

puts [$cbr0 set packetSize_]
puts [$cbr0 set interval_]

$ns at 3.0 "finish"

proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf

puts "running nam..."
exec nam out.nam &
exit 0
}

$ns run

SCREEN SHOTS

You might also like