Loosing 2% is not too bad actually, but under your ideal conditions
you should be doing better. Your surmise about send contention is
probably correct, but the only way I know to fix it is to implement
some kind of ACK-retry mechanism.
MS
Wojciech Czylok wrote:
Hello,
we are working on a research projekt about wireless sensor networks and
got a problem with packet loss under TinyOS 2.0.1
We use micaz family motes and our goal was to build a network topology
like a repeater.
The mote A sends packets (containing its TOS_NODE_ID and a counter) to
its neighbour mote B.
We used the application BlinkToRadio for this purpose.
Mote B uses our application BlinkToRadioReceive. It receives the packet
from "A", reads its information and sends a
new packet with this information to its neighbour C. This Mote does the
same thing as Mote B. The last mote in this
chain uses the programm BaseStation and receives the packet. We use the
java program Listen to read the packages
from the serial port.
If we set up a 1-to-1 connection between BlinkToRadio and BaseStation
(without any repeating motes in between), then we have no packet loss at
all.
For every mote we add to the chain, the packet loss rises about 2%. The
packet loss even occurs, if the motes are lying
right next to each other. It also doesn't depend on the period of the
timer, which tells the first mote to send packets.
The percentage of packet loss remains.
We wrote a few other test programs to examine this behaviour. So we
checked the following:
- storing received packets on the forwarding motes before sending
- using tasks instead of functions in the events
But after all, the packet loss did not improve. The packet loss always
rises about 2% for each mote we add.
We assume that there is a problem when a mote receives a message and
wants to send at the same time.
Output example from Listen. The last two bytes represent the counter:
00 00 00 00 00 04 00 06 00 01 00 35
00 00 00 00 00 04 00 06 00 01 00 36
00 00 00 00 00 04 00 06 00 01 00 37
//PAKETLOSS!
00 00 00 00 00 04 00 06 00 01 00 3A
00 00 00 00 00 04 00 06 00 01 00 3B
// ... //
00 00 00 00 00 04 00 06 00 01 00 83
00 00 00 00 00 04 00 06 00 01 00 84
00 00 00 00 00 04 00 06 00 01 00 85
//PAKETLOSS!
00 00 00 00 00 04 00 06 00 01 00 87
00 00 00 00 00 04 00 06 00 01 00 88
Does anyone have some ideas for a solution or experiences the same problem?
Thanks for you help,
Marco Dreier & Wojciech Czylok
Attachement:
You will find the code of our BlinkToRadioReceiveC.nc attached, which
should forward the packets.
The wiring is found in BlinkToRadioReceiveApp.nc, but we don't attach it
because it should be ok.
//BlinkToRadioReceiveC.h
#ifndef BLINKTORADIORECEIVE_H
#define BLINKTORADIORECEIVE_H
enum
{
AM_BLINKTORADIOMSG = 6,
TIMER_PERIOD_MILLI = 250
};
typedef nx_struct BlinkToRadioMsg
{
nx_uint16_t nodeid;
nx_uint16_t counter;
}
BlinkToRadioMsg;
#endif
//BlinkToRadioReceive.nc
#include "BlinkToRadioReceive.h"
module BlinkToRadioReceiveC
{
uses interface Boot;
uses interface Leds;
uses interface Packet;
uses interface AMPacket;
uses interface AMSend;
uses interface SplitControl as AMControl;
uses interface Receive;
}
implementation
{
bool busy = FALSE;
message_t pkt;
uint16_t counter = 0;
uint16_t received_counter = 0;
uint16_t received_id = 0;
task void Task_sendPacket()
{
if (!busy)
{
//packing new packet with received information
BlinkToRadioMsg* new_btrpkt = (BlinkToRadioMsg*)(call
Packet.getPayload(&pkt, NULL));
new_btrpkt->nodeid = received_id;
new_btrpkt->counter = received_counter;
//send packet to neigbour mote
if (call AMSend.send(0x02, &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS)
{
call Leds.led2Toggle();
busy = TRUE;
}
}
}
event void Boot.booted()
{
call AMControl.start();
}
event void AMControl.startDone(error_t err)
{
if (err != SUCCESS)
{
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err)
{}
event void AMSend.sendDone(message_t* msg, error_t error)
{
if (&pkt == msg)
{
busy = FALSE;
}
}
event message_t* Receive.receive(message_t* msg, void* payload,
uint8_t len)
{
if (len == sizeof(BlinkToRadioMsg))
{
//get information from packet
BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
received_counter = btrpkt->counter;
received_id = btrpkt->nodeid;
call Leds.led1Toggle();
// call task to send packet to next mote
post Task_sendPacket();
}
return msg;
}
}
And here is the slightly modified version of BlinkToRadio (also without
wiring):
//BlinkToRadio.h
#ifndef BLINKTORADIO_H
#define BLINKTORADIO_H
enum
{
AM_BLINKTORADIOMSG = 6,
TIMER_PERIOD_MILLI = 250
};
typedef nx_struct BlinkToRadioMsg
{
nx_uint16_t nodeid;
nx_uint16_t counter;
}
BlinkToRadioMsg;
#endif
//BlinkToRadioC.nc
#include <Timer.h>
#include "BlinkToRadio.h"
module BlinkToRadioC
{
uses interface Boot;
uses interface Leds;
uses interface Timer<TMilli> as Timer0;
uses interface Packet;
uses interface AMPacket;
uses interface AMSend;
uses interface SplitControl as AMControl;
uses interface Receive;
}
implementation
{
bool busy = FALSE;
bool *pbusy = &busy;
message_t pkt;
uint16_t counter = 0;
task void Task_sendMessage()
{
if (call AMSend.send(0x02, &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS)
{
*pbusy = TRUE;
call Leds.led2Toggle();
}
else
{
call Leds.led0Toggle();
}
}
task void Task_packMessage()
{
if (!busy)
{
BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call
Packet.getPayload(&pkt, NULL));
btrpkt->nodeid = TOS_NODE_ID;
btrpkt->counter = counter;
post Task_sendMessage();
}
}
event void Boot.booted()
{
call AMControl.start();
}
event void AMControl.startDone(error_t err)
{
if (err == SUCCESS)
{
call Timer0.startPeriodic(TIMER_PERIOD_MILLI);
}
else
{
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err)
{}
event void Timer0.fired()
{
counter++;
call Leds.led1Toggle();
post Task_packMessage();
}
event void AMSend.sendDone(message_t* msg, error_t error)
{
if (&pkt == msg)
{
busy = FALSE;
}
}
event message_t* Receive.receive(message_t* msg, void* payload,
uint8_t len)
{
if (len == sizeof(BlinkToRadioMsg))
{
//call Leds.led1Toggle();
}
return msg;
}
}
------------------------------------------------------------------------
Wissenswertes zum Thema PC, Zubehör oder Programme. *BE A BETTER
INTERNET-GURU!*
<http://de.rd.yahoo.com/evt=48734/*http://de.promotions.yahoo.com/clever/be-a-better/internet-guru.html>
------------------------------------------------------------------------
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help