You are on page 1of 27

TOSSIM

Dr. Gurdip Singh


Pavan Kumar Nayini
Tinyos
• TinyOS is an open-source operating system
designed for wireless embedded sensor
networks.
• component-based architecture.
• library includes network protocols,
distributed services, sensor drivers, and
data acquisition tools.
Tossim
• TOSSIM - TinyOS mote simulator
• TOSSIM scales to thousands of nodes
• Compiles directly from TinyOS code
• Developers can test not only their
algorithms, but also their implementations
Installation
• Cygwin
– Removal of cygwin
– rmdir /s /q C:\cygwin
– regdit -s rmcygwin.reg
– REGEDIT4
– [-HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions]
– [-HKEY_CURRENT_USER\Software\Cygnus Solutions]
Installation
• Path
– Set path for c:\tinyos\cygwin
– Set path for c:\tinyos\cygwin\bin
– Set path for c:\tinyos\cygwin\opt\tinyos-
1.x\tools\java\net\tinyos\sim
Compiling
• Makefile
– COMPONENT = dll
– Include ../Makerules
• Makerules
Lossy Channels
• Lossy.nss
– [A]:[B]:[LossAB]
– [A]:[C]:[LossAC]
– [B]:[A]:[LossBA]
– [B]:[C]:[LossBC]
– [C]:[A]:[LossCA]
– [C]:[B]:[LossCB]
Running
• Dll
– Build
• Pc
– Main.exe

• Main.exe [noOfNodes]
• Export dbg=USR1
Running
• Main [options] num_nodes
-gui For tinyViz
-a=<model> ADC model (generic,random)
-b=<sec> boot time
-l=<scale> Scales Realtime
-r=<model> simple/lossy
-rf=<file> files for loss(Default lossy.nss)
-s=<num> no of nodes to boot
-t=<sec> virtual seconds
num_nodes number of nodes to simulate
TinyViz
• TinyViz: GUI tool for TOSSIM
• Plugin Model (You can write your own plugin)
• Plugins:
– Neighborhood graph
– Radio links
– Sent radio packets
– Calamari
– Directed Graph
NesC
• nesC (pronounced "NES-see") is an extension to
the C programming language designed to embody
the structuring concepts and execution model of
TinyOS.
– Components
– Interfaces
– Modules
– Configuration
– Commands
– Events
Components
• A nesC application consists of one or more
components linked together to form an
executable.
• A component provides and uses interfaces.
• These interfaces are the only point of access
to the component and are bi-directional.
Interfaces

• Defines the commands and the events to be


implemented by a Provider/User of the
interface.
• interface StdControl {
command result_t init();
command result_t start();
command result_t stop();
}
Modules

• Modules provide application code, implementing


one or more interface.
• module BlinkM {
provides {
interface StdControl;
}
uses {
interface Timer;
interface Leds;
}
}
Commands
• commands are the functions that the
interface provider must implement.
• command result_t StdControl.init() {
call Leds.init();
return SUCCESS;
}
Events

• events are the functions that the interface user


must implement.
• NOTE: For a component to call the commands in
an interface, it must implement the events of that
interface.
• event result_t Timer.fired()
{
call Leds.redToggle();
return SUCCESS;
}
Configuration

• Configurations are used to assemble other


components together, connecting interfaces
used by components to interfaces provided
by others.
• This is called wiring.
• Every nesC application is described by a
top-level configuration that wires together
the components inside.
Blink
configuration Blink {
}
implementation {
components Main, BlinkM, SingleTimer, LedsC;
Main.StdControl -> SingleTimer.StdControl;
Main.StdControl -> BlinkM.StdControl;
BlinkM.Timer -> SingleTimer.Timer;
BlinkM.Leds -> LedsC;
}
module BlinkM {
BlinkM
provides {
interface StdControl;
}
uses {
interface Timer;
interface Leds;
}
}
implementation {
command result_t StdControl.init() {
call Leds.init();
return SUCCESS;
}

command result_t StdControl.start() {


return call Timer.start(TIMER_REPEAT, 1000);
}

command result_t StdControl.stop() {


return call Timer.stop();
}

event result_t Timer.fired()


{
call Leds.redToggle();
return SUCCESS;
}
}
Dll.nc
configuration dll {
provides {
interface StdControl;
interface Send;
interface Receive;
}
} implementation {

components Main, dllM, GenericComm as Comm;

Main.StdControl ->dllM;
Main.StdControl ->Comm;

dllM.SendMsg -> Comm.SendMsg[100];


dllM.ReceiveMsg -> Comm.ReceiveMsg[100];

StdControl = dllM;
Send = dllM;
Receive = dllM;
}
dllM.nc
includes dll;
module dllM {
provides {
interface StdControl;
interface Send;
interface Receive;
}
uses {
interface ReceiveMsg;
interface SendMsg;
}
}
implementation {
struct TOS_Msg data;

command result_t StdControl.init() {


dbg(DBG_USR1, "Control Initialized \n");
return SUCCESS;
}

command result_t StdControl.start() {


dbg(DBG_USR1, "Control Started \n");
call Send.send ("pavan",1);
return SUCCESS;
}

command result_t StdControl.stop() {


dbg(DBG_USR1, "Control Stopped \n");
return SUCCESS;
}
…………………Contd
Send.nc and Receive.nc
interface Send
{
command result_t send(char* buff, uint32_t addr);
}

interface Receive
{
event result_t receive(char * data);
}
dllM.nc
command result_t Send.send(char* buff, uint32_t addr) {
int i=0;
Msg * message = (Msg *)data.data;
message->val = "hello";
while(i<10)
{
i++;
dbg(DBG_USR1, "Sending Message \n");
if(TOS_LOCAL_ADDRESS != 1)
call SendMsg.send(1,sizeof(Msg),&data);
}
return SUCCESS;
}

default event result_t Receive.receive(char* datareceived) {


dbg(DBG_USR1,"Dll Data received");
return SUCCESS;
}

event result_t SendMsg.sendDone(TOS_MsgPtr msg, bool success) {


dbg(DBG_USR1, "Message Sent\n");
return SUCCESS;
}

event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr recv_packet) {


dbg(DBG_USR1, "Received Message \n");
signal Receive.receive("Data");
return recv_packet;
}
}
App.nc
configuration app {
} implementation {

components Main, dll, appM;

Main.StdControl ->dll;
Main.StdControl ->appM;

appM.Send -> dll.Send;


appM.Receive -> dll.Receive;
}
appM.nc
module appM {
provides {
interface StdControl;
}
uses {
interface Receive;
interface Send;
}
}
implementation {
command result_t StdControl.init() {
dbg(DBG_USR1, "Application Control Initialized \n");
return SUCCESS;
}

command result_t StdControl.start() {


dbg(DBG_USR1, "Application Control Started \n");
dbg(DBG_USR1, "Application Control Sending Message \n");
call Send.send ("pavan",1);
return SUCCESS;
}

command result_t StdControl.stop() {


dbg(DBG_USR1, "Application Control Stopped \n");
return SUCCESS;
}
event result_t Receive.receive(char * data1)
{
dbg(DBG_USR1, "Application control received Message \n");
return SUCCESS;
}
}
Demo

• Compiling
• Running
• TinyViz
Questions

You might also like