]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
make traffic monitor optional
authormmaroti <mmaroti>
Fri, 10 Apr 2009 08:33:20 +0000 (08:33 +0000)
committermmaroti <mmaroti>
Fri, 10 Apr 2009 08:33:20 +0000 (08:33 +0000)
tos/chips/rf2xx/README
tos/chips/rf2xx/layers/SlottedCollisionConfig.nc
tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc
tos/chips/rf2xx/layers/TrafficMonitorConfig.nc
tos/chips/rf2xx/layers/TrafficMonitorLayerP.nc
tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc
tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc
tos/chips/rf2xx/rf212/RF212Ieee154MessageC.nc
tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc
tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc
tos/chips/rf2xx/rf230/RF230Ieee154MessageC.nc

index 985b79c550021e0fe84f9e5ecc4e834bd67f13a1..a0a2de989ebf828fc69f3968bb91797c6443e547 100644 (file)
@@ -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.
 
 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 
 typedef TRadio:
 
 The radio stack uses a single hardware alarm/counter. The resolution of 
index 4b6b993180edacf72c7b5fb0de72eb1478ade7fc..5b3bec60212bbeafc1b925f8a521ede3c48b2c93 100755 (executable)
@@ -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);
         * 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();
 }
 }
index 500fef8673c28845b627ecf4e62c3f9e3a754394..ce1610e7425f63009b9150fe11667000bc13f386 100644 (file)
@@ -73,6 +73,8 @@ implementation
 
 /* ----- schedule selection ----- */
 
 
 /* ----- schedule selection ----- */
 
+       void printStats();
+
        tasklet_async event bool SubReceive.header(message_t* msg)
        {
                return signal RadioReceive.header(msg);
        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);
 
                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; 
 
                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;
 
                if( isBetween(exponent, schedule2, start, length) )
                        error2 += ERROR_COLLISION;
 
@@ -133,24 +135,9 @@ implementation
                        schedule2 = getNextRandom();
                }
 
                        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();
                printStats();
+
+               return signal RadioReceive.receive(msg);
        }
 
 /* ------ transmit ------ */
        }
 
 /* ------ transmit ------ */
@@ -196,6 +183,8 @@ implementation
                call RadioAlarm.wait(backoff);
                txTime = time + backoff;
 
                call RadioAlarm.wait(backoff);
                txTime = time + backoff;
 
+               printStats();
+
                return SUCCESS;
        }
 
                return SUCCESS;
        }
 
@@ -256,7 +245,7 @@ implementation
        tasklet_norace uint8_t count;
        void printStats()
        {
        tasklet_norace uint8_t count;
        void printStats()
        {
-               if( ++count > 10 && call DiagMsg.record() )
+               if( ++count > 50 && call DiagMsg.record() )
                {
                        count = 0;
 
                {
                        count = 0;
 
index 0b7bc649e25d9d8966a3343b04ca869c5e64e58c..78f1437cd7885e43f79cb114fd755150a5760dee 100755 (executable)
@@ -71,10 +71,4 @@ interface TrafficMonitorConfig
         * Returns the averaged error events during one update period.
         */
        tasklet_async event uint8_t getErrorAverage();
         * 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();
 }
 }
index b5f152adc984c8bc246669b7ae01b580bbbcb5b6..99d73ca1afbc7644b9c7f6b86b143cffc756c005 100644 (file)
@@ -149,8 +149,6 @@ implementation
                call NeighborhoodFlag.clearAll();
                neighborCount = 0;
 
                call NeighborhoodFlag.clearAll();
                neighborCount = 0;
 
-               call TrafficMonitorConfig.timerTick();
-
                call Tasklet.resume();
 
 #ifdef RADIO_DEBUG
                call Tasklet.resume();
 
 #ifdef RADIO_DEBUG
index 46ef3b44c7f38f92dbb34828ef17f6d2129d4e84..d6076abbf23f194107301e351af3d46316dea9c8 100644 (file)
@@ -150,11 +150,15 @@ implementation
 
 // -------- Traffic Monitor
 
 
 // -------- Traffic Monitor
 
+#ifdef TRAFFIC_MONITOR
        components TrafficMonitorLayerC;
        components TrafficMonitorLayerC;
+#else
+       components new DummyLayerC() as TrafficMonitorLayerC;
+#endif
        TrafficMonitorLayerC.Config -> RF212ActiveMessageP;
        TrafficMonitorLayerC.Config -> RF212ActiveMessageP;
-       TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
-       TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
-       TrafficMonitorLayerC.SubState -> RF212DriverLayerC;
+       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+       TrafficMonitorLayerC -> RF212DriverLayerC.RadioState;
 
 // -------- CollisionAvoidance
 
 
 // -------- CollisionAvoidance
 
index 86e74556f32ed5c6fdfe508b63dbc9e2215d1593..b641981ced3c25ae5b626663f229b209424fd2ca 100644 (file)
@@ -125,7 +125,9 @@ implementation
 
        tasklet_async command void SoftwareAckConfig.reportChannelError()
        {
 
        tasklet_async command void SoftwareAckConfig.reportChannelError()
        {
+#ifdef TRAFFIC_MONITOR
                signal TrafficMonitorConfig.channelError();
                signal TrafficMonitorConfig.channelError();
+#endif
        }
 
 /*----------------- UniqueConfig -----------------*/
        }
 
 /*----------------- UniqueConfig -----------------*/
@@ -147,7 +149,9 @@ implementation
 
        tasklet_async command void UniqueConfig.reportChannelError()
        {
 
        tasklet_async command void UniqueConfig.reportChannelError()
        {
+#ifdef TRAFFIC_MONITOR
                signal TrafficMonitorConfig.channelError();
                signal TrafficMonitorConfig.channelError();
+#endif
        }
 
 /*----------------- ActiveMessageConfig -----------------*/
        }
 
 /*----------------- ActiveMessageConfig -----------------*/
@@ -220,11 +224,6 @@ implementation
                return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
                return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
-       tasklet_async command void TrafficMonitorConfig.timerTick()
-       {
-               signal SlottedCollisionConfig.timerTick();
-       }
-
 /*----------------- RandomCollisionConfig -----------------*/
 
        /*
 /*----------------- RandomCollisionConfig -----------------*/
 
        /*
@@ -300,8 +299,6 @@ implementation
                return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
        }
 
                return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
        }
 
-       default tasklet_async event void SlottedCollisionConfig.timerTick() { }
-
 /*----------------- Dummy -----------------*/
 
        async command void DummyConfig.nothing()
 /*----------------- Dummy -----------------*/
 
        async command void DummyConfig.nothing()
index eb508fe2dcdb574c223ed26cfd07389fd3536346..765afbe281c64aa128abf3107ddd652fbb96be24 100644 (file)
@@ -108,22 +108,14 @@ implementation
 // -------- MessageBuffer
 
        components MessageBufferLayerC;
 // -------- MessageBuffer
 
        components MessageBufferLayerC;
-       MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+       MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC;
        MessageBufferLayerC.RadioReceive -> UniqueLayerC;
        MessageBufferLayerC.RadioReceive -> UniqueLayerC;
-       MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+       MessageBufferLayerC.RadioState -> CollisionAvoidanceLayerC;
        RadioChannel = MessageBufferLayerC;
 
 // -------- UniqueLayer receive part (wired twice)
 
        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
 
 
 // -------- CollisionAvoidance
 
index deb5412be333991420203e67ba98db8efe0224d8..e491ecae04cb3f57c024553d664d377f4fac89be 100644 (file)
@@ -150,11 +150,15 @@ implementation
 
 // -------- Traffic Monitor
 
 
 // -------- Traffic Monitor
 
+#ifdef TRAFFIC_MONITOR
        components TrafficMonitorLayerC;
        components TrafficMonitorLayerC;
+#else
+       components new DummyLayerC() as TrafficMonitorLayerC;
+#endif
        TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
        TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
-       TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
-       TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
-       TrafficMonitorLayerC.SubState -> RF230DriverLayerC;
+       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+       TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+       TrafficMonitorLayerC -> RF230DriverLayerC.RadioState;
 
 // -------- CollisionAvoidance
 
 
 // -------- CollisionAvoidance
 
index 7758d865d2de36310e97c196703b153f132cece8..0b07d1eb5948b8b40a74dd147344b750c8a7a7c7 100644 (file)
@@ -125,7 +125,9 @@ implementation
 
        tasklet_async command void SoftwareAckConfig.reportChannelError()
        {
 
        tasklet_async command void SoftwareAckConfig.reportChannelError()
        {
+#ifdef TRAFFIC_MONITOR
                signal TrafficMonitorConfig.channelError();
                signal TrafficMonitorConfig.channelError();
+#endif
        }
 
 /*----------------- UniqueConfig -----------------*/
        }
 
 /*----------------- UniqueConfig -----------------*/
@@ -147,7 +149,9 @@ implementation
 
        tasklet_async command void UniqueConfig.reportChannelError()
        {
 
        tasklet_async command void UniqueConfig.reportChannelError()
        {
+#ifdef TRAFFIC_MONITOR
                signal TrafficMonitorConfig.channelError();
                signal TrafficMonitorConfig.channelError();
+#endif
        }
 
 /*----------------- ActiveMessageConfig -----------------*/
        }
 
 /*----------------- ActiveMessageConfig -----------------*/
@@ -220,11 +224,6 @@ implementation
                return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
                return call IEEE154MessageLayer.getSrcAddr(msg);
        }
 
-       tasklet_async command void TrafficMonitorConfig.timerTick()
-       {
-               signal SlottedCollisionConfig.timerTick();
-       }
-
 /*----------------- RandomCollisionConfig -----------------*/
 
        /*
 /*----------------- RandomCollisionConfig -----------------*/
 
        /*
@@ -300,8 +299,6 @@ implementation
                return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
        }
 
                return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
        }
 
-       default tasklet_async event void SlottedCollisionConfig.timerTick() { }
-
 /*----------------- Dummy -----------------*/
 
        async command void DummyConfig.nothing()
 /*----------------- Dummy -----------------*/
 
        async command void DummyConfig.nothing()
index ae17a95757331be28b18c9b9e9de4257e8744214..856e2fa07916d7da50d592caee71c7a620a6d0b9 100644 (file)
@@ -108,22 +108,14 @@ implementation
 // -------- MessageBuffer
 
        components MessageBufferLayerC;
 // -------- MessageBuffer
 
        components MessageBufferLayerC;
-       MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+       MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC;
        MessageBufferLayerC.RadioReceive -> UniqueLayerC;
        MessageBufferLayerC.RadioReceive -> UniqueLayerC;
-       MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+       MessageBufferLayerC.RadioState -> CollisionAvoidanceLayerC;
        RadioChannel = MessageBufferLayerC;
 
 // -------- UniqueLayer receive part (wired twice)
 
        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
 
 
 // -------- CollisionAvoidance