Example Application: Drip

Drip is a transport-layer component for epidemically disseminating
messages throughout a network.

Why Drip is better than Bcast:

- Reliable injection: Injecting a message is a dialog between the host
and the network. The host knows whether the message was injected or
not, detecting and preventing radio failures at the first hop.

- Epidemic reliable delivery. After sending a message, Drip will
continually retransmit to ensure that it eventually reaches every
node in the network.

- Neighborhood suppression: If a node transmits, its neighbors will
delay their own transmissions. This means that fewer messages will
be sent, as compared to Bcast.

- Trickle timers: Each time a node retransmits, it waits double the
amount of time until it retransmits again. This ensures that traffic
eventually drops down to a low base rate, while still maintaining
epidemic reliability. A new message kicks the transmit rate back up,
for fast dissemination.

- Transport layer: With Drip, the identifiers you use for Drip
messages are nested within the Drip header. This means you can only
collide identifiers with other Drip messages. With Bcast, you have
to place your message AM id within the top-level header by playing
wiring tricks.

http://www.tinyos.net/scoop/story/2005/2/16/174147/450

 

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

 

  1. Node Configuration

Drip example requires node 0 to be TOSBase and rest of the nodes to run DataCollector application.

#include "gen/cTOSBase_TinyOSModule.h"
#include "gen/cTOSBase_Main.h"
#include "gen/cTestDrip_TinyOSModule.h"
#include "gen/cTestDrip_Main.h"

if (getIndex() == 0)
{
cTOSBase_Main *m = new cTOSBase_Main(this,main,"Main",getIndex());
m->StdControl_init();
m->StdControl_start();
}
else
{
cTestDrip_Main *m = new cTestDrip_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 TOSBase.nc ../Application.nc
[root@sinan tictoc]# ./nesct.exe Application.nc
[root@sinan tictoc]# cd components/
[root@sinan components]# cp TestDrip.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

Let's enable USR1 and ROUTE 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,route
[root@sinan bin]# ./tictoc
 [1] 0:0:0.04199200:Sending id: 254
[2] 0:0:0.04785150:Sending id: 254
[2] 0:0:0.14199200:Received msg(id=254, seqno=2)
[2] 0:0:0.14199200:DripState received: currentSeqNo=2, incomingSeqNo=2
[1] 0:0:0.14785150:Received msg(id=254, seqno=2)
[1] 0:0:0.14785150:DripState received: currentSeqNo=2, incomingSeqNo=2
[2] 0:0:0.34082025:Sending id: 254
[1] 0:0:0.44082025:Received msg(id=254, seqno=2)
[1] 0:0:0.44082025:DripState received: currentSeqNo=2, incomingSeqNo=2
[2] 0:0:0.82910150:Sending id: 254
[1] 0:0:0.92910150:Received msg(id=254, seqno=2)
[1] 0:0:0.92910150:DripState received: currentSeqNo=2, incomingSeqNo=2
[2] 0:0:1.61035150:Sending id: 254
[1] 0:0:1.71035150:Received msg(id=254, seqno=2)
[1] 0:0:1.71035150:DripState received: currentSeqNo=2, incomingSeqNo=2
[1] 0:0:2.09277325:Sending id: 254
[2] 0:0:2.19277325:Received msg(id=254, seqno=4)
[2] 0:0:2.19277325:DripState received: currentSeqNo=2, incomingSeqNo=4
[2] 0:0:2.19628900:Sending id: 254
[1] 0:0:2.29628900:Received msg(id=254, seqno=4)
[1] 0:0:2.29628900:DripState received: currentSeqNo=4, incomingSeqNo=4
[2] 0:0:2.48925775:Sending id: 254
[1] 0:0:2.58925775:Received msg(id=254, seqno=4)
[1] 0:0:2.58925775:DripState received: currentSeqNo=4, incomingSeqNo=4
[2] 0:0:2.87988275:Sending id: 254

Open another command window and go to java directory under tictoc. Start Drip sniffer and see the following output:

[root@sinan tictoc]# cd java
[root@sinan java]#java net.tinyos.drip.DripSniff
incoming: id: 254 seqno: 26
incoming: id: 254 seqno: 26
incoming: id: 254 seqno: 26
incoming: id: 254 seqno: 28
incoming: id: 254 seqno: 28
incoming: id: 254 seqno: 28
incoming: id: 254 seqno: 28
incoming: id: 254 seqno: 28
incoming: id: 254 seqno: 30
incoming: id: 254 seqno: 30
incoming: id: 254 seqno: 30
incoming: id: 254 seqno: 30
incoming: id: 254 seqno: 30
incoming: id: 254 seqno: 32
incoming: id: 254 seqno: 32
incoming: id: 254 seqno: 32
incoming: id: 254 seqno: 32
incoming: id: 254 seqno: 32
incoming: id: 254 seqno: 34
incoming: id: 254 seqno: 34
incoming: id: 254 seqno: 34
incoming: id: 254 seqno: 34
incoming: id: 254 seqno: 34
incoming: id: 254 seqno: 36
incoming: id: 254 seqno: 36
incoming: id: 254 seqno: 36
incoming: id: 254 seqno: 36
incoming: id: 254 seqno: 36
incoming: id: 254 seqno: 38
incoming: id: 254 seqno: 38
incoming: id: 254 seqno: 38
incoming: id: 254 seqno: 38
incoming: id: 254 seqno: 38
incoming: id: 254 seqno: 40
incoming: id: 254 seqno: 40
incoming: id: 254 seqno: 40
incoming: id: 254 seqno: 40
incoming: id: 254 seqno: 40
incoming: id: 254 seqno: 42
incoming: id: 254 seqno: 42
incoming: id: 254 seqno: 42
incoming: id: 254 seqno: 42
incoming: id: 254 seqno: 42
 

 

 

 

 


                               

 


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