Sie sind auf Seite 1von 10

NETWORK

SIMULATOR 2
T S PRADEEP KUMAR
VIT University – Chennai Campus
http://www.pradeepkumar.org
OVERVIEW
Introduction to NS2
OTCL and C++
Simple Wired and Wireless Example
Recompilation of NS2
Method 1 (Modifying the existing file)
Method 2 (Adding new set of files)
Research Problems in
Wireless Networks
Sensor Networks
INTRODUCTION TO NS2
It is event driven simulator
One set of events or a single event triggers the other events.
Rather than timer based, all the entities in the network
triggered as an event
Most of the networks in the world can be simulated (either through
the built in modules or third party modules)
Example: Routing of Adhoc networks, Bandwidth utilisation, energy
management in adhoc through the built it modules
Manna Sim integrated with NS2 to do simulations on Wireless Sensor
Networks
Click Modular router to integrate with NS2 (nsclick) and can make a machine
to act as a router
Some third party tools for simulation Wi Max and 4G Networks
OTCL AND C++
Otcl is the Front End (User Interface) – Interpreter
C++ is in the Back End (Simulation) – Compiler
OTCL AND C++
Use OTCL for
For configuration, setup or one time simulation
To run simulation with existing ns2 modules
Suitable for beginners
Use C++ for
When you are dealing with a packet
When you need to modify existing ns2 modules
Discourages most of the beginners
C++ STYLES
C++ uses three styles
Basic C++
Any change in the program should be compiled again
C++ with input arguments
Takes system parameters as arguments
No need for recompilation, just arguments can be changed
C++ with configuration files
Greater flexibility
To change system parameters, just configuration file can be edited
OTCL EXAMPLE
Consider a general network node. When equipped with mobility
this nodes becomes mobile node . Declaration of a class Node
and its child class Mobile is shown below. This declaration allows
class Mobile to inherit capabilities of class Node (eg receiving
packets) and to include more capabilities (eg moving) to itself.
OTCL EXAMPLE
Class Node
Class Mobile -superclass Node
Node instproc recv {pkt} {
$self instvar state
set state 1
# $self process-pkt $pkt
}
OTCL EXAMPLE
Mobile instproc move {x y} {
$self instvar location
set location[0] $x
set location[1] $y
}
Node instproc init {} {
$self instvar state
set state 0
}
OTCL EXAMPLE
Mobile instproc init {} {
$self next
$self instvar location
set location[0] 0
set location[1] 0
}
Node n
puts "The instance of class Node is [Node info instances]"
puts "The class of n is [n info class]"

Das könnte Ihnen auch gefallen