27
TOSSIM Dr. Gurdip Singh Pavan Kumar Nayini

Dr. Gurdip Singh Pavan Kumar Nayini

  • Upload
    pudn

  • View
    104

  • Download
    6

Embed Size (px)

DESCRIPTION

Tossim

Citation preview

Page 1: Dr. Gurdip Singh Pavan Kumar Nayini

TOSSIM

Dr. Gurdip Singh

Pavan Kumar Nayini

Page 2: 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.

Page 3: Dr. Gurdip Singh Pavan Kumar Nayini

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

Page 4: Dr. Gurdip Singh Pavan Kumar Nayini

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]

Page 5: Dr. Gurdip Singh Pavan Kumar Nayini

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

Page 6: Dr. Gurdip Singh Pavan Kumar Nayini

Compiling

• Makefile– COMPONENT = dll– Include ../Makerules

• Makerules

Page 7: Dr. Gurdip Singh Pavan Kumar Nayini

Lossy Channels

• Lossy.nss– [A]:[B]:[LossAB]– [A]:[C]:[LossAC]– [B]:[A]:[LossBA]– [B]:[C]:[LossBC]– [C]:[A]:[LossCA]– [C]:[B]:[LossCB]

Page 8: Dr. Gurdip Singh Pavan Kumar Nayini

Running

• Dll– Build

• Pc– Main.exe

• Main.exe [noOfNodes]

• Export dbg=USR1

Page 9: Dr. Gurdip Singh Pavan Kumar Nayini

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

Page 10: Dr. Gurdip Singh Pavan Kumar Nayini

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

Page 11: Dr. Gurdip Singh Pavan Kumar Nayini

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

Page 12: Dr. Gurdip Singh Pavan Kumar Nayini

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.

Page 13: Dr. Gurdip Singh Pavan Kumar Nayini

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();}

Page 14: Dr. Gurdip Singh Pavan Kumar Nayini

Modules

• Modules provide application code, implementing one or more interface.

• module BlinkM {  provides {    interface StdControl;  }  uses {    interface Timer;    interface Leds;  }}

Page 15: Dr. Gurdip Singh Pavan Kumar Nayini

Commands

• commands are the functions that the interface provider must implement.

• command result_t StdControl.init() {    call Leds.init();    return SUCCESS;  }

Page 16: Dr. Gurdip Singh Pavan Kumar Nayini

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;  }

Page 17: Dr. Gurdip Singh Pavan Kumar Nayini

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.

Page 18: Dr. Gurdip Singh Pavan Kumar Nayini

Blink

configuration Blink {}implementation { components Main, BlinkM, SingleTimer, LedsC; Main.StdControl -> SingleTimer.StdControl; Main.StdControl -> BlinkM.StdControl; BlinkM.Timer -> SingleTimer.Timer; BlinkM.Leds -> LedsC;}

Page 19: Dr. Gurdip Singh Pavan Kumar Nayini

BlinkMmodule 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; }}

Page 20: Dr. Gurdip Singh Pavan Kumar Nayini

Dll.ncconfiguration 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;}

Page 21: Dr. Gurdip Singh Pavan Kumar Nayini

dllM.ncincludes 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

Page 22: Dr. Gurdip Singh Pavan Kumar Nayini

Send.nc and Receive.nc

interface Send{

command result_t send(char* buff, uint32_t addr);}

interface Receive{

event result_t receive(char * data);}

Page 23: Dr. Gurdip Singh Pavan Kumar Nayini

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;

}}

Page 24: Dr. Gurdip Singh Pavan Kumar Nayini

App.nc

configuration app {} implementation {

components Main, dll, appM;

Main.StdControl ->dll; Main.StdControl ->appM; appM.Send -> dll.Send; appM.Receive -> dll.Receive;}

Page 25: Dr. Gurdip Singh Pavan Kumar Nayini

appM.ncmodule 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;

}}

Page 26: Dr. Gurdip Singh Pavan Kumar Nayini

Demo

• Compiling

• Running

• TinyViz

Page 27: Dr. Gurdip Singh Pavan Kumar Nayini

Questions