From: mmaroti Date: Fri, 10 Apr 2009 08:33:20 +0000 (+0000) Subject: make traffic monitor optional X-Git-Tag: rc_6_tinyos_2_1_1~422 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=00e708814493e030803019f2a98f3fe7e707805d make traffic monitor optional --- diff --git a/tos/chips/rf2xx/README b/tos/chips/rf2xx/README index 985b79c5..a0a2de98 100644 --- a/tos/chips/rf2xx/README +++ b/tos/chips/rf2xx/README @@ -43,6 +43,13 @@ If enabled, then the radio driver will print out all received and 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 diff --git a/tos/chips/rf2xx/layers/SlottedCollisionConfig.nc b/tos/chips/rf2xx/layers/SlottedCollisionConfig.nc index 4b6b9931..5b3bec60 100755 --- a/tos/chips/rf2xx/layers/SlottedCollisionConfig.nc +++ b/tos/chips/rf2xx/layers/SlottedCollisionConfig.nc @@ -52,10 +52,4 @@ interface SlottedCollisionConfig * 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(); } diff --git a/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc b/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc index 500fef86..ce1610e7 100644 --- a/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc +++ b/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc @@ -73,6 +73,8 @@ implementation /* ----- schedule selection ----- */ + void printStats(); + tasklet_async event bool SubReceive.header(message_t* msg) { return signal RadioReceive.header(msg); @@ -112,11 +114,11 @@ implementation uint16_t start = call Config.getCollisionWindowStart(msg); uint16_t length = call Config.getCollisionWindowLength(msg); - error1 -= error1 >> ERROR_DECAY; + error1 -= (error1 + (1<> ERROR_DECAY; if( isBetween(exponent, schedule1, start, length) ) error1 += ERROR_COLLISION; - error2 -= error2 >> ERROR_DECAY; + error2 -= (error1 + (1<> ERROR_DECAY; if( isBetween(exponent, schedule2, start, length) ) error2 += ERROR_COLLISION; @@ -133,24 +135,9 @@ implementation 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 ------ */ @@ -196,6 +183,8 @@ implementation call RadioAlarm.wait(backoff); txTime = time + backoff; + printStats(); + return SUCCESS; } @@ -256,7 +245,7 @@ implementation tasklet_norace uint8_t count; void printStats() { - if( ++count > 10 && call DiagMsg.record() ) + if( ++count > 50 && call DiagMsg.record() ) { count = 0; diff --git a/tos/chips/rf2xx/layers/TrafficMonitorConfig.nc b/tos/chips/rf2xx/layers/TrafficMonitorConfig.nc index 0b7bc649..78f1437c 100755 --- a/tos/chips/rf2xx/layers/TrafficMonitorConfig.nc +++ b/tos/chips/rf2xx/layers/TrafficMonitorConfig.nc @@ -71,10 +71,4 @@ interface TrafficMonitorConfig * 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(); } diff --git a/tos/chips/rf2xx/layers/TrafficMonitorLayerP.nc b/tos/chips/rf2xx/layers/TrafficMonitorLayerP.nc index b5f152ad..99d73ca1 100644 --- a/tos/chips/rf2xx/layers/TrafficMonitorLayerP.nc +++ b/tos/chips/rf2xx/layers/TrafficMonitorLayerP.nc @@ -149,8 +149,6 @@ implementation call NeighborhoodFlag.clearAll(); neighborCount = 0; - call TrafficMonitorConfig.timerTick(); - call Tasklet.resume(); #ifdef RADIO_DEBUG diff --git a/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc b/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc index 46ef3b44..d6076abb 100644 --- a/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc @@ -150,11 +150,15 @@ implementation // -------- 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 diff --git a/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc b/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc index 86e74556..b641981c 100644 --- a/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc @@ -125,7 +125,9 @@ implementation tasklet_async command void SoftwareAckConfig.reportChannelError() { +#ifdef TRAFFIC_MONITOR signal TrafficMonitorConfig.channelError(); +#endif } /*----------------- UniqueConfig -----------------*/ @@ -147,7 +149,9 @@ implementation tasklet_async command void UniqueConfig.reportChannelError() { +#ifdef TRAFFIC_MONITOR signal TrafficMonitorConfig.channelError(); +#endif } /*----------------- ActiveMessageConfig -----------------*/ @@ -220,11 +224,6 @@ implementation return call IEEE154MessageLayer.getSrcAddr(msg); } - tasklet_async command void TrafficMonitorConfig.timerTick() - { - signal SlottedCollisionConfig.timerTick(); - } - /*----------------- RandomCollisionConfig -----------------*/ /* @@ -300,8 +299,6 @@ implementation return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC); } - default tasklet_async event void SlottedCollisionConfig.timerTick() { } - /*----------------- Dummy -----------------*/ async command void DummyConfig.nothing() diff --git a/tos/chips/rf2xx/rf212/RF212Ieee154MessageC.nc b/tos/chips/rf2xx/rf212/RF212Ieee154MessageC.nc index eb508fe2..765afbe2 100644 --- a/tos/chips/rf2xx/rf212/RF212Ieee154MessageC.nc +++ b/tos/chips/rf2xx/rf212/RF212Ieee154MessageC.nc @@ -108,22 +108,14 @@ implementation // -------- 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 diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc index deb5412b..e491ecae 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc @@ -150,11 +150,15 @@ implementation // -------- 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 diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc index 7758d865..0b07d1eb 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc @@ -125,7 +125,9 @@ implementation tasklet_async command void SoftwareAckConfig.reportChannelError() { +#ifdef TRAFFIC_MONITOR signal TrafficMonitorConfig.channelError(); +#endif } /*----------------- UniqueConfig -----------------*/ @@ -147,7 +149,9 @@ implementation tasklet_async command void UniqueConfig.reportChannelError() { +#ifdef TRAFFIC_MONITOR signal TrafficMonitorConfig.channelError(); +#endif } /*----------------- ActiveMessageConfig -----------------*/ @@ -220,11 +224,6 @@ implementation return call IEEE154MessageLayer.getSrcAddr(msg); } - tasklet_async command void TrafficMonitorConfig.timerTick() - { - signal SlottedCollisionConfig.timerTick(); - } - /*----------------- RandomCollisionConfig -----------------*/ /* @@ -300,8 +299,6 @@ implementation return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC); } - default tasklet_async event void SlottedCollisionConfig.timerTick() { } - /*----------------- Dummy -----------------*/ async command void DummyConfig.nothing() diff --git a/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc b/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc index ae17a957..856e2fa0 100644 --- a/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc +++ b/tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc @@ -108,22 +108,14 @@ implementation // -------- 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