Hi,

For the resetInterval() in CtpRoutingEngineP.nc, I don't think it is doing its 
job when called from within BeaconTimer.fired(). Let me explain it by example:

Suppose that tHasPassed = false, thus BeaconTimer.fired() will call in order:
1 - updateRouteTask() 
2 - sendBeaconTask()

3 - remainingInterval()

Suppose that updateRouteTask() has this condition satisfied: 

        if (currentEtx - minEtx > 20)

            call CtpInfo.triggerRouteUpdate(); 

which finally calls resetInterval():

        currentInterval = 128        //minInterval value in CTP

        t = 64

        t = 78        //assume that Rand() % t  returned 14

        tHasPassed = FALSE;

       call BeaconTimer.startOneShot(78);

This means that after 78 time units fire the BeaconTimer to call 
updateRotueTask(), sendBeaconTask(), and remainingInterval() (remember 
tHasPassed = false)

However, after updateRotueTask() (step 1 above) returns, sendBeaconTask and 
remainingInterval (step 2 & 3) are called.

remainingInterval() basically will cancel the timer set in resetInterval():

        uint32_t remaining = 128;

        remaining = 128 - 78 = 50;

        tHasPassed = TRUE;

        call BeaconTimer.startOneShot(50);

So, firing timer at 78 is cancelled and reset 50 but to call decayInterval() 
instead

Accordingly, resetInterval() should set currentInterval = minInterval only 
without setting the beacon timer because it will be reset later. However this 
may conflict with other parts of the code which I didn't trace. Another 
possible solution is to modify CtpInfo.triggerRouteUpdate(); to set the 
currentInterval and not call resetInterval(). This will leave the rest of the 
code intact if resetInterval is needed as is and at the same time 
CtpInfo.triggerRouteUpdate();  is only called from with updateRotueTask().



Regards

Islam Hegazy


_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to