120 likes | 242 Views
Introduction to NS. Srinath Perur. This introduction…. Why NS NS and NAM Basic Tcl Basic OTcl Organization of a simulation Demos of wired and wireless simulations. Why NS?. Preliminary testing/validation in field Time, effort, money Internet scale testing
E N D
Introduction to NS Srinath Perur
This introduction… • Why NS • NS and NAM • Basic Tcl • Basic OTcl • Organization of a simulation • Demos of wired and wireless simulations
Why NS? • Preliminary testing/validation in field • Time, effort, money • Internet scale testing • Mobile computing – hardware, etc. • Slow to modify Therefore simulator! • NS • Easily available • Widely accepted
NS and NAM • NS – Network Simulator • Event driven simulator • Implemented in C++ • OTcl for command and configuration interface • NAM – Network AniMator • Graphical representation of NS output
C++ and OTcl Separation • C++ for “data” • Per packet action • OTcl for control • Periodic or triggered action • Compromise between composibility and speed • Learning and debugging
OTcl and C++: The Duality Pure OTcl objects Pure C++ objects C++/OTcl split objects C++ OTcl ns
Basic Tcl %ns > puts “Hello!” > Hello! >set a 5 > set b 4 >set c [expr $a + $b] >puts “The sum of $a and $b is $c”
Basic Tcl >proc print_list {list}{ set count 0 foreach element $list { incr count puts $element } return $count } >set list1 {a, b, c} > set num_elements [print_list $list]
Basic OTcl > Class Bun > set abun [new Bun] abun > $abun info class Bun > Bun info instances abun > Bun instproc init {args} { $self instvar toasted set toasted 0 eval $self next $args }
Basic OTcl > Bun instproc toast {} { $self instvar toasted incr toasted if {$toasted>1} then { error "something's burning!" } return {} } > $abun toast > $abun toast something's burning!
A simulation • Instantiate a simulator object • set global properties for simulation • Create nodes • create agents at nodes, set their properties • links • connecting nodes, set their properties
References • ns web pages • http://www.isi.edu/nsnam/ns/ • Mark Greis’ tutorial • recommended for starting • ns manual • ns workshop slides • ns mailing list archive • OTcl tutorial • Look at IT-605/IT-644 resources page