Professional Documents
Culture Documents
Overview
What we need? How much effort should we put? Some existing network simulators. SensorSim. NS-2 primer. NS-2 issues and conclusion.
-The first 90% of project takes 90% of the time, the last 10% takes the other 90% of the time.
What we want?
It should perform simulations of our algorithms. (obviously) It should have models for wireless transmissions and battery models. It should be extremely scalable. It should be efficient for large simulations. There should be technical support.
-A bug in the code is worth two in the documentation.
JavaSim
Pros
Very modular Easy to use
Cons
Geared for wired internetworks No wireless support
GlomoSim
Specific for mobile wireless networks. Built as a set of libraries. The libraries are built in Parsec( a C-based discrete event simulation language). Layered architecture with easy plug-in capability.
-Any program that runs right is obsolete.
GloMoSim Library
Data Plane
Application Processing Application
Modular, extensible library for network models Model each layer using abstract or detailed model Built-in statistics collection at each layer Cons : Fixed protocol layers.
Transport IP Network
IP OSPF, AODV,
NS - 2
De facto standard for network simulations Discrete Event Simulator Packet-level Wired and Wireless Size : (Current release adds around 10%)
100K lines of C++ 70K lines of OTcl 30K lines of test suites 20K lines of documentation
NS Architecture
Object-oriented (C++, OTcl) Scalability + Extensibility
Control/data separation Split C++/OTcl object
Modular approach
Fine-grained object composition Reusability
-You are making progress if each mistake is a new one.
C++ ns
OTcl
SensorSim
Extension to NS - 2. Provides battery models, radio propagation models and sensor channel models. Provides a lightweight protocol stack. Has support for hybrid simulation. To be integrated with NS - 2.
-There can never be a computer language in which you cannot write a bad program.
SensorSim Architecture
monitor and control hybrid network (local or remote)
app
real sensor apps on virtual sensor nodes
GUI
app
app
socket comm serial comm RS232
GUI Interface
HS Interface
ns
Ethernet
V V V V R R
Wireless Channel
Sensor Channel
-There are two ways to write error-free programs; only the third one works.
BZR event
Off
BZR event
transmit done
receive done
Idle
receive
SensorSim Problems
Still at pre-release stage. No Documentation. The software currently has a very specific application hard-coded. It caters to only one base station.
-The definition of an upgrade: Take old bugs out, put new ones in.
NS-2 primer
-Reference Manual: Object that raises the monitor to eye level. Also used to compensate for that short table leg.
Basic tcl
set a 43 set b 27 proc test { a b } { set c [expr $a + $b] set d [expr [expr $a - $b] * $c] for {set k 0} {$k < 10} {incr k} { if {$k < 5} { puts k < 5, pow = [expr pow($d, $k)] } else { puts k >= 5, mod = [expr $d % $k] } } } test 43 27 -MACINTOSH stands for Most Applications Crash If Not The
Operating System Hangs.
Basic OTcl
Class Mom Mom instproc greet {} { $self instvar age_ puts $age_ years old mom: How are you doing? } Class Kid -superclass Mom Kid instproc greet {} { $self instvar age_ puts $age_ years old kid: Whats up, dude? }
-It works! Now if only I could remember what I did...
set mom [new Mom] $mom set age_ 45 set kid [new Kid] $kid set age_ 15 $mom greet $kid greet
Elements of ns-2
Create the event scheduler [Turn on tracing] Create network Setup routing Create transport connection Create traffic / Schedule events Transmit application-level data Start simulation
-It is easier to write an incorrect program than understand a correct one.
-I finally made my stupid computer faster; I dropped it out of the window, and it went really fast.
An Example Step 1
# Define Global Variables # create simulator set ns [new Simulator] # define traces set tracefd [open simple.tr w] $ns_ trace-all $tracefd # create a topology in a 100m x 100m area set topo [new Topography] $topo load_flatgrid 100 100
-If at first you don't succeed, call it version 1.0.
An Example Step 2
# Create God create-god $val(nn) # Create channel set chan_1_ [new $val(chan)]
-For any problem there is a solution that is simple, quick, and ultimately worse than the problem.
An Example Step 3
$ns_ node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channel $chan_1_ \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF -energyModel "EnergyModel" \ -initialEnergy $val(initialenergy) \ -rxPower $val(receivepower) \ -txPower $val(transmitpower) \ -idlePower $val(idlepower)
An Example Step 4
# Generating nodes for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] } # Provide initial for mobilenodes $node_(0) set X_ $node_(0) set Y_ $node_(0) set Z_ $node_(1) set X_ : : (X,Y, for now Z=0) co-ordinates 94.85 12.75 0.0 60.79
-Computers can figure out all kinds of problems, except the things in the world that just don't add up.
An Example Step 5
#Create two ping agents and attach them to the nodes n0 and n2 set p0 [new Agent/Ping] $ns attach-agent $n0 $p0 set p1 [new Agent/Ping] $ns attach-agent $n2 $p1 #Connect the two agents $ns connect $p0 $p1
-Computer Science is no more about computers than astronomy is about telescopes. E. W. Dijkstra
An Example Step 6
#Schedule events $ns_ at 100.0 "puts \"hell-O\" " $ns_ at 10.2 "$p0 send" $ns_ at 10.4 "$p1 send" : : #Run the Simulation puts "Starting Simulation..." $ns_ run
-Build a system that even a fool can use, and only a fool will use it.
Ping Protocol
Check out the handout. To add a new protocol :
Define packet header (PT_PING) Define new agent class as a subclass of Agent in header file (ping.h) Implement at least the following functions:
int command ( int argc, const char*const* argc) void recv ( Packet * pkt, Handler* h)
-To err is human, but to really foul things up requires a computer.
NS - 2 (contd.)
Cons :
Comparatively difficult to learn and use. Supposedly more useful for getting statistics for lower level protocols. Originally built for wired networks, later extended for wireless. Supposedly, does not work well for large topologies.
-To err is human--and to blame it on a computer is even more so.
23MB 412 MB
Scalability of NS-2
Maximum number of nodes depends upon the traffic. Should be able to up to 500 nodes with reasonable(?) traffic. Running time?
To use NS..
Dont worry about Otcl. Its easy.. Forget about Nam traces. Join the ns-user mailing list. Get started as soon as possible. learning to use and modify it can take time. Just adding new protocols might not do. Some internal changes might need to be made.
Conclusion
Use SensorSim if you can. NS-2 can be used for simulation of the order of hundreds of nodes. Not possible with motes. Can build more advanced protocols, for future motes which might have more memory.
-ASCII stupid question, get a stupid ANSI!
URLs
This presentation: http://www.cs.virginia.edu/~sb2jb/rese arch/ns NS-2 home: http://www.isi.edu/nsnam/ns
Questions?