transmitted messages via the DiagMsg interface. This feature is used in the
RF230Sniffer appliaction.
+TRAFFIC_MONITOR:
+
+If enabled, the TrafficMonitorLayer is included in the stack which keeps
+track of the average number of bytes sent, bytes received, the number of
+transmission errors, and the number of neighboors. If RADIO_DEBUG is enabled
+then this information is also printed.
+
typedef TRadio:
The radio stack uses a single hardware alarm/counter. The resolution of
* Returns the size of the collision window for this received message.
*/
async command uint16_t getCollisionWindowLength(message_t* msg);
-
- /**
- * This event should be called periodically to indicate the passing of
- * time (maybe we should use a timer)
- */
- tasklet_async event void timerTick();
}
/* ----- schedule selection ----- */
+ void printStats();
+
tasklet_async event bool SubReceive.header(message_t* msg)
{
return signal RadioReceive.header(msg);
uint16_t start = call Config.getCollisionWindowStart(msg);
uint16_t length = call Config.getCollisionWindowLength(msg);
- error1 -= error1 >> ERROR_DECAY;
+ error1 -= (error1 + (1<<ERROR_DECAY) - 1) >> ERROR_DECAY;
if( isBetween(exponent, schedule1, start, length) )
error1 += ERROR_COLLISION;
- error2 -= error2 >> ERROR_DECAY;
+ error2 -= (error1 + (1<<ERROR_DECAY) - 1) >> ERROR_DECAY;
if( isBetween(exponent, schedule2, start, length) )
error2 += ERROR_COLLISION;
schedule2 = getNextRandom();
}
- return signal RadioReceive.receive(msg);
- }
-
- void printStats();
-
- tasklet_async event void Config.timerTick()
- {
- if( error1 >= (1 << ERROR_DECAY) )
- error1 -= error1 >> ERROR_DECAY;
- else if( error1 > 0 )
- --error1;
-
- if( error2 >= (1 << ERROR_DECAY) )
- error2 -= error2 >> ERROR_DECAY;
- else if( error2 > 0 )
- --error2;
-
printStats();
+
+ return signal RadioReceive.receive(msg);
}
/* ------ transmit ------ */
call RadioAlarm.wait(backoff);
txTime = time + backoff;
+ printStats();
+
return SUCCESS;
}
tasklet_norace uint8_t count;
void printStats()
{
- if( ++count > 10 && call DiagMsg.record() )
+ if( ++count > 50 && call DiagMsg.record() )
{
count = 0;
* Returns the averaged error events during one update period.
*/
tasklet_async event uint8_t getErrorAverage();
-
- /**
- * This command is periodically called when the timer is fired and
- * the averages are updated
- */
- tasklet_async command void timerTick();
}
call NeighborhoodFlag.clearAll();
neighborCount = 0;
- call TrafficMonitorConfig.timerTick();
-
call Tasklet.resume();
#ifdef RADIO_DEBUG
// -------- Traffic Monitor
+#ifdef TRAFFIC_MONITOR
components TrafficMonitorLayerC;
+#else
+ components new DummyLayerC() as TrafficMonitorLayerC;
+#endif
TrafficMonitorLayerC.Config -> RF212ActiveMessageP;
- TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubState -> RF212DriverLayerC;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+ TrafficMonitorLayerC -> RF212DriverLayerC.RadioState;
// -------- CollisionAvoidance
tasklet_async command void SoftwareAckConfig.reportChannelError()
{
+#ifdef TRAFFIC_MONITOR
signal TrafficMonitorConfig.channelError();
+#endif
}
/*----------------- UniqueConfig -----------------*/
tasklet_async command void UniqueConfig.reportChannelError()
{
+#ifdef TRAFFIC_MONITOR
signal TrafficMonitorConfig.channelError();
+#endif
}
/*----------------- ActiveMessageConfig -----------------*/
return call IEEE154MessageLayer.getSrcAddr(msg);
}
- tasklet_async command void TrafficMonitorConfig.timerTick()
- {
- signal SlottedCollisionConfig.timerTick();
- }
-
/*----------------- RandomCollisionConfig -----------------*/
/*
return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
}
- default tasklet_async event void SlottedCollisionConfig.timerTick() { }
-
/*----------------- Dummy -----------------*/
async command void DummyConfig.nothing()
// -------- MessageBuffer
components MessageBufferLayerC;
- MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+ MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC;
MessageBufferLayerC.RadioReceive -> UniqueLayerC;
- MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+ MessageBufferLayerC.RadioState -> CollisionAvoidanceLayerC;
RadioChannel = MessageBufferLayerC;
// -------- UniqueLayer receive part (wired twice)
- UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
-
-// -------- Traffic Monitor
-
- components TrafficMonitorLayerC;
- TrafficMonitorLayerC.Config -> RF212ActiveMessageP;
- TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubState -> RF212DriverLayerC;
+ UniqueLayerC.SubReceive -> CollisionAvoidanceLayerC;
// -------- CollisionAvoidance
// -------- Traffic Monitor
+#ifdef TRAFFIC_MONITOR
components TrafficMonitorLayerC;
+#else
+ components new DummyLayerC() as TrafficMonitorLayerC;
+#endif
TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
- TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubState -> RF230DriverLayerC;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+ TrafficMonitorLayerC -> RF230DriverLayerC.RadioState;
// -------- CollisionAvoidance
tasklet_async command void SoftwareAckConfig.reportChannelError()
{
+#ifdef TRAFFIC_MONITOR
signal TrafficMonitorConfig.channelError();
+#endif
}
/*----------------- UniqueConfig -----------------*/
tasklet_async command void UniqueConfig.reportChannelError()
{
+#ifdef TRAFFIC_MONITOR
signal TrafficMonitorConfig.channelError();
+#endif
}
/*----------------- ActiveMessageConfig -----------------*/
return call IEEE154MessageLayer.getSrcAddr(msg);
}
- tasklet_async command void TrafficMonitorConfig.timerTick()
- {
- signal SlottedCollisionConfig.timerTick();
- }
-
/*----------------- RandomCollisionConfig -----------------*/
/*
return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
}
- default tasklet_async event void SlottedCollisionConfig.timerTick() { }
-
/*----------------- Dummy -----------------*/
async command void DummyConfig.nothing()
// -------- MessageBuffer
components MessageBufferLayerC;
- MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+ MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC;
MessageBufferLayerC.RadioReceive -> UniqueLayerC;
- MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+ MessageBufferLayerC.RadioState -> CollisionAvoidanceLayerC;
RadioChannel = MessageBufferLayerC;
// -------- UniqueLayer receive part (wired twice)
- UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
-
-// -------- Traffic Monitor
-
- components TrafficMonitorLayerC;
- TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
- TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubState -> RF230DriverLayerC;
+ UniqueLayerC.SubReceive -> CollisionAvoidanceLayerC;
// -------- CollisionAvoidance