You are on page 1of 4

Why do you need a simulator ?

TOSSIM: The Tiny OS Simulator „ Allows you to effectively simulate a large


scale wireless network before
Nitish Jha deployment.
„ Provides a controlled environment for
tests.
Slides Based on „ Cost: Cheaper to Simulate in software.
TOSSIM: A Simulator for TinyOS Networks
TinyOS Tutorial at TinyOS.net
TOSSIM , SenSys,2003

Limitations of Simulations TOSSIM : Goals


„ Might not take into account all real-world „ Scalability
results. - Able to handle large scale networks >1000
nodes
„ Depends on several modeling
„ Completeness
assumptions. - Capture all the details and components
„ Fidelity
- Capture the network interaction at a fine grain
„ Bridging
- Ease the process of implementation of an
algorithm.

TOSSIM : Features TOSSIM:Features Continued


„ TinyOS mote simulator „ TOSSIM emulates the behavior of underlying
hardware of the mote like
„ Is Scaleable to thousands of motes
„ ADC
„ It compiles directly from source „ Clock
„ Simulates network at bitlevel (accurate) „ The transmit strength variable potentiometer.
„ The EEPROM
„ Allows for some real world phenomena
„ Several components of radio stack
like bit error.
„ Power Simulation using Power TOSSIM
TOSSIM : Discrete Event Simulator Radio Models
„ TOSSIM Models offers two radio models
- Simple Model
Every bit transmitted is received properly.
Good for initial debugging of code.
- Lossy Model
Lets you specify what the probability of
corruption is per bit.

Using TOSSIM Using TOSSIM


Compiling your application for the pc „ After Compiling the application for the pc you
can run
$ make pc „ $ build/pc/main.exe 1
This makes the executable The 1 tells how many nodes to simulate the
build/pc/main.exe application for.
All the debug messages will show up in the
terminal.

Using DBG variable Example


„ $ DBG=am,led build/pc/main.exe -t=20 1
„ The DBG environment variable allows you SIM: Random seed is 546875

to limit which debug messages are 0: LEDS: Red on.


0: LEDS: Red off.
shown. 0: LEDS: Red on.
0: LEDS: Red off.

„ This lets you limit the debug messages to 0: LEDS: Red on.
0: LEDS: Red off.
a particular user or particular events like 0: LEDS: Red on.
0: LEDS: Red off.
radio and count. 0: LEDS: Red on.
0: LEDS: Red off.
0: LEDS: Red on.
Simulation of 1 motes completed.
Main.exe options Main.exe options
Usage: ./build/pc/main.exe [options]
num_nodes -l=<scale> run sim at <scale> times real
[options] are: time (fp constant)
-h, --help Display this message. -r=<model> specifies a radio model (simple
is default)options: simple static lossy
-gui pauses simulation waiting for GUI to
connect -rf=<file> specifies file input for lossy
model (lossy.nss is default)
-a=<model> specifies ADC model (generic is
default)options: generic random -s=<num> only boot <num> of nodes
-b=<sec> motes boot over first <sec> -t=<sec> run simulation for <sec> virtual
seconds (default: 10) secondsnum_nodes number of nodes to
simulate
-ef=<file> use <file> for eeprom;otherwise
anonymous file is used

DBG Variable DBG Variable


all: Enable all available messages code: Packet encoding/decoding
boot: Simulation boot and StdControl radio: Low-level radio operations: bits and bytes
clock: The hardware clock logger: Non-volatile storage
adc: The ADC
task: Task enqueueing/dequeueing/running
i2c: The I2C bus
sched: The TinyOS scheduler
uart: The UART (serial port)
sensor: Sensor readings prog: Network reprogramming
led: Mote leds sounder: The sounder on the mica sensor board
crypto: Cryptographic operations (e.g., TinySec) time: Timerssim: TOSSIM internals
route: Routing systems queue: TOSSIM event queue
am: Active messages transmission/reception simradio: TOSSIM radio models
crc: CRC checks on active messages hardware: TOSSIM hardware abstractions
simmem: TOSSIM memory allocation/deallocation (for finding leaks)
packet: Packet-level transmission/receptionen
usr1: User output mode 1
code: Packet encoding/decoding
usr2: User output mode 2
usr3: User output mode 3
temp: For temporary use

Adding Debugging Statements Demo


„ Debugging statements can be easily
added to applications
„ example
dbg(DBG_TEMP, "Counter: Value is %i\n", (int)state);

This will print the counter value in the


command window.
Complete list of DBG modes is listed here
tos/types/dbg_modes.h
TinyViz
„ Provides a GUI for Debugging, Visualizing and
Interacting with TOSSIM simulations.
„ Use DBG variable in conjunction with tinyviz
„ Example
export DBG=usr1
tinyviz -run build/pc/main.exe 30

Patching TinyViz Demo


„ The Default TinyViz install does not work.
Need to patch it first before using.
„ Instructions for Patching
cd $TOSROOT
wget
http://www.5secondfuse.com/tinyos/tinyos-
sim-Makefile.patch
patch -p0 < tinyos-sim-Makefile.patch
 then
cd $TOSROOT/tools/java; make; make

TinyViz Questions ?
„ Many features can be added through
plugins.

You might also like