Docsity

Introduction to NS: Why Use Network Simulator and Basic Concepts, Slides of Mobile Communication Systems

Partial preview of the text

Download Introduction to NS: Why Use Network Simulator and Basic Concepts and more Slides Mobile Communication Systems in PDF only on Docsity!

Introduction to NS

This introduction…

• Why NS

• NS and NAM

• Basic Tcl

• Basic OTcl

• Organization of a simulation

• Demos of wired and wireless simulations

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

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

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