Você está na página 1de 20

TOSSIM TinyOS Sinumlator

CSE 591 Spring 10

Why we need TOSSIM?


Distributed systems are hard to debug Effectively simulate large scale wireless networks before deployment Controlled environment for tests Cost: Cheaper to simulate in S/W

Goals of TOSSIM
Scalability
Able to handle large scale networks > 1000 nodes

Completeness
Capture all details and components

Fidelity
Capture the network interaction at a fine grain

Bridging
Ease the process of implementation of an algorithm

What is TOSSIM?
Simulator for TinyOS applications Discrete event simulator Compiles directly from source code Simulates network at the bit level Allows for some real world phenomena bit error

What is TOSSIM?
TOSSIM emulates the behavior of underlying hardware
ADC Clock EEPROM Radio stack

Power simulation using Power TOSSIM

TOSSIM Architecture
Five parts
1. Compiling components into simulation architecture 2. Discrete event queue 3. Few reimplemented hardware abstractions 4. Extensible radio and ADC models 5. Communications service for external programs

Key Points
Time at mote instruction cycle frequency 4MHz = 4 x 106 ticks/second Radio models external to TOSSIM; Models network as a directed graph of bit error probabilities Almost perfect simulation of TinyOS networking stack at bit level Communication service: Allows user to drive, monitor, debug simulation

Radio Models
Network is modeled as a directed graph with bit error probabilities for each edge (u,v) in the graph Signal is either a 1 or 0 All signals have equal strength No propagation model, no collision model

Radio Models
Simple:
every mote in one cell, bits perfectly transmitted

Lossy:
connectivity determined at startup

Compiling TOSSIM
Code: tos/lib/tossim Simulation implementations of packages are in optional sim subdirectory of component To compile:
Make micaz sim Note: micaz is only platform supported by TOSSIM

Running your Simulation


Two options: Python or C++ Python
Script it Interactively

Python Script
$ From TOSSIM import * $ T = Tossim([])
- Square brackets are for optional arguments

$ M = T.getNode(12)
- Create a node id 12

$ M.bootAtTime(4* T.ticksPerSecond() + 192834)


- Specify when the node turns on (random so not all nodes sync create odd results)

$ T.runNextEvent()
- Returns 1 if there is an event, 0 if no event to run

Mote Calls
Can turn motes on/off
m.turnOn() m.turnOff()

Check status of mote


m.isOn() m.isOff()

TOSSIM Utility Functions

Debugging Statements
Debugging output system dbg Four Calls:
1. dbg
Node ID, debugging statement

2. dbg_clear
Debugging statement (good for complex types)

3. dbgerror
Node ID, error statement

4. dbgerror_clear

Debugging Statements
Ex:
Event void Boot.booted() { call Leds.led0On(); dbg(Boot, Application booted.\n); call AMControl.start(); }
Output Channel Message (sprintf format)

Debugging Statements
Print out current simulation time
dbg(Blink, Time: $s\n, sim_time_string());

Channels by default are dropped, must specify where to direct channel output
import sys T.addChannel(Boot, sys.stdout) F = open(log.txt, w) T.addChannel(Blink, F)

Configuring a Network
To communicate between nodes
Create a network topology

Default TOSSIM radio model is signal strength based Simulates RF noise and interference Can input trace models or noise topo.txt
Source_id, Dest_id, radio_gain

Configuring the network


With topo.txt add each radio to the simulation Default MAC protocol is CSMA
Mac = T.mac() Can modify the backoff paramters

Conclusions
Basic workings of TOSSIM Use simulations to test programs under varying scenarios TinyViz (not in 2.0)

Você também pode gostar