Example Application: SeMA

A sensor querying mechanism (SQS) provides local query optimization and in-network message concatenation for energy efficient response delivery. The protocol is designed to operate as the lowest tier of a hierarchical architecture that enables access to tiny sensors in the target domain from a monitoring application via a service aware ad hoc backbone. The project classifies SQS queries relative to data generation characteristics and explains the components of the querying system in this contex

In this study, the sensor nodes are assumed to be deployed in an ad hoc fashion in the target field and a reverse multicast tree is constructed among the nodes. The sink node disseminates a query and responses are collected through the reverse multicast tree.

Considering the characteristics of sensor networks, a sender initiated path switching algorithm is presented in this project. The algorithm enables the immediate sender to change a packet's route dynamically when the parent on the reverse multicast tree is down. The overall effect of path switching on the survivability of the network is analyzed as a measure of reliable event delivery.

http://cse.yeditepe.edu.tr/tnl/sqs.php?lang=en

http://cse.yeditepe.edu.tr/tnl/rewise.php?lang=en

http://cse.yeditepe.edu.tr/tnl/sema.php?lang=en

 

  1. Node Configuration
  2. Code Generation
  3. Updating Makefile
  4. Build
  5. Run

 

  1. Node Configuration

#include "gen/csmRouterTest_TinyOSModule.h"
#include "gen/csmRouterTest_Main.h"

   csmRouterTest_Main *m = new csmRouterTest_Main(this,main,"Main",getIndex());
   m->StdControl_init();
   m->StdControl_start();
 
  1. Code Generation

NesCT is going to build all the classes in gen directory. Replace "cp" with "copy" and slash (/) with backslash (\) for windows operating system at the following instructions.



[root@sinan tictoc]# cd components/
[root@sinan components]# cp smRouterTest.nc ../Application.nc
[root@sinan components]# cd ..
[root@sinan tictoc]# ./nesct.exe Application.nc

done.

  1. Updating Makefile

  Type makemake.bat/makemake.sh to create new Makefile for Win32/Linux.
  1. Build

Type "make" to build the binary.


[root@sinan tictoc]# make
g++ -c -g -fpermissive -fPIC -DWITH_NETBUILDER -w -DTOSNODES=1000 -DLINUX -DPLATFORM_OMNETPP -I./include -I/root/projects/tinyos-1.x/tos/interfaces -I./include_tos -I/opt/omnetpp-3.2/include simstart.cc
g++ tictoc1_n.o debug.o simstart.o tinyos.o tinyosmain.o tossim.o txc1.o -g -L/opt/omnetpp-3.2/lib -lenvir -lcmdenv -lsim_std -lnedxml -lxml2 -ldl -lstdc++ -lpthread -o tictoc
echo>.tstamp

  1. Run

Edit omnetpp.ini file and change wait-for-sf to true. After enabling this option, the simulation will wait 10 seconds before starting to allow sf to connect.

Start SerialForwarder by running ./bin/sf_sim . For windows, you may need to enter the contents of the file yourself in a console windows (cygwin). The exceptions will be lost once we start the simulator.

[root@sinan tictoc]# ./bin/sf_sim
Listening to tossim-serial
SF enabled, 0 clients, 0 packets read, 0 packets written getenv JNI library not found. Env.getenv will not work
(please consult installation directions in
tinyos-1.x/tools/java/net/tinyos/util/Env.INSTALL)
Platform avrmote
Opening tossim-serial source
Connecting to Tossim event port at localhost:10585
Listening for client connections on port 9001
SF enabled, 0 clients, 0 packets read, 0 packets written java.net.ConnectException: Connection refused

Start another console window, enter java directory and run the driver.

[root@sinan tictoc]#cd java
[root@sinan tictoc]#java driver.Driver
Created server socket

Thread starting to wait for mote to pc connection

Thread starting to wait for pc to mote connection

Let's enable USR1,USR2 and USR3 options for demonstration purposes. Use "export" keyword for linux and "set" keyword for windows to change environment variable. You should see an output similar to this in TK window.

                           

The simulation screen should like this.

[root@sinan bin]# export DBG=usr1,usr2,usr3
[root@sinan bin]# ./tictoc
 
SeMA application by default sets all the sensor nodes to sleep mode with radio interfaces enabled. Whenever a sensor node receives a radio message, that node wakes up and starts to process the message. Therefore, none of the nodes will do anything until you inject a message from the pc. SeMA protocol suite includes a pc side software named "inject_listener" that injects a message to the network and dumps the incoming messages on the console window. 

To proceed with the demo, open another console window ( has to be a cygwin window for windows, we are going to use make filesystem) and go to project directory, tictoc.

$ pwd
/z/projects/src/tictoc

Enter msg_inject directory
$ cd 3rdparty/sema/msg_inject

Type make listener to build the tool

$ make listener
gcc main.c -c -g -DLISTENER
gcc main.o fileio.o -g -lm -DLISTENER -o inject_listener.exe
 

Inject_listener reads the query paramers from a file named "params.in". You can change these values according to your simulation needs.

These are the default values and they are overridden by the parameters from "params.in" file. To summarize, a setup message is sent to the network. This message says that a SeMA querying network has to be constructed that's going to last for 60 seconds and the setup message needs to propagate to a maximum of 20 hops. We do not want sensor readings to be either concatenated or acknowledged on the way. So this is a best effort delivery. The sensor node will poll the sensing interface every 5 seconds and return the results each timer. therefore we'll receive 12 messages from each node at the pc side. The sensing query that we ask for is to get any sensor reading from Temperature sensor. That's it. You can ask for a sensor node id or neighbor count meanwhile processing the sensing requests. Usually, you need this kind of information for adaptation purposes. Check out smTypes.h for other available querying types.

u16 local_node_id = 0xfffa;
u16 destionation_id = 0;
u16 message_type = SETUP_MESSAGE;
u16 region_id = 1;
u16 hop_count = 0;
u16 flooding_degree = 20;
u16 query_timeout_type = SEMA_SECOND;
u16 query_timeout_value = 60;
u16 concatenate_flag = 0;
u16 acknowledge_flag = 0;
u16 continuous_flag = 1;
u16 query_type = SENSING_RELATED;
u16 query_frequency_type = SEMA_SECOND;
u16 query_frequency_value = 5;
u16 subquery_count = 1;

u16 subquery_type = SENSING_RELATED;
u16 subquery_sensor_type = TEMPERATURE_SENSOR;
u16 subquery_sample_count = 1;
u16 subquery_compilation_function = LOWER;
u16 subquery_compilation_data = 65535;


Once you run the inject_listener, you should see an output like this:

$ ./inject_listener.exe
src_id 65533
dest_id 65535
message_type 0
region_id 5
hop_count 0
flooding_degree 20
query_timeout_type 2
query_timeout_value 60
concatenate_flag 0
acknowledge_flag 0
continuous_flag 1
query_frequency_type 2
query_frequency_value 5
subquery_count 1
subquery_type 0
subquery_sensor_type 2
subquery_sample_count 1
subquery_compilation_function 7
subquery_compilation_data 65535
subquery_type_2 0
subquery_sensor_type_2 0
subquery_sample_count_2 0
subquery_compilation_function_2 0
subquery_compilation_data_2 0
subquery_type_3 0
subquery_sensor_type_3 0
subquery_sample_count_3 0
subquery_compilation_function_3 0
subquery_compilation_data_3 0
subquery_type_4 0
subquery_sensor_type_4 0
subquery_sample_count_4 0
subquery_compilation_function_4 0
subquery_compilation_data_4 0
ff ff 14 7d 0f 00 01 7f ff ff ff 45 00 10 78 50 0a 88 05 ff ff c0 00 00 00 00 0
00 00 00 00 00 00 00 00 00
connected to server , socket 3
0 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:1 datacnt:1 tm:10949 data[0]:41
1 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:10960 data[0]:18467
2 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:10960 data[0]:6334
3 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:1 datacnt:1 tm:5005 data[0]:26500
4 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:19169
5 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:15724
6 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:1 datacnt:1 tm:5005 data[0]:11478
7 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:29358
8 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:26962
9 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:1 datacnt:1 tm:5005 data[0]:24464
10 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:5705
11 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:28145
12 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:1 datacnt:1 tm:5005 data[0]:23281
13 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:16827
14 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:9961
15 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:1 datacnt:1 tm:5005 data[0]:491
16 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:2995
17 m.type:1 reg_id:5 msg_id:0 resp_cnt:1 hc:2 datacnt:1 tm:5016 data[0]:11942

 

 

 

 


                               

 


This project has been supported by Featherlight project at University of Twente, the Netherlands and European Embedded WiseNt project at Yeditepe University.