List Info

Thread: I found a bug in wireless-phy.cc !!!




I found a bug in wireless-phy.cc !!!
user name
2006-10-25 14:47:26
Dear All:
     Recently I am doing simulations with ns2.30. I found a
bug in
wireless-phy.cc, the bug is in the two functions below:
void
WirelessPhy::node_wakeup()
{

    if (status_== IDLE)
        return;

    if (em() == NULL)
            return;

        if ( NOW > update_energy_time_ &&
(status_== SLEEP) ) {
        //the power consumption when radio goes from SLEEP
mode to IDLE mode
       
em()->DecrTransitionEnergy(T_transition_,P_transition_);

        em()->DecrSleepEnergy(NOW-update_energy_time_,
                      P_sleep_);
        status_ = IDLE;
            update_energy_time_ = NOW;

        // log node energy
        if (em()->energy() > 0) {
            ((MobileNode *)node_)->log_energy(1);
            } else {
            ((MobileNode *)node_)->log_energy(0);
            }
    }
}

void
WirelessPhy::node_sleep()
{
//
//        node_on_= FALSE;
//
    if (status_== SLEEP)
        return;

    if (em() == NULL)
            return;

        if ( NOW > update_energy_time_ &&
(status_== IDLE) ) {
    //the power consumption when radio goes from IDLE mode
to SLEEP mode
       
em()->DecrTransitionEnergy(T_transition_,P_transition_);

            em()->DecrIdleEnergy(NOW-update_energy_time_,
                                P_idle_);
        status_ = SLEEP;
            update_energy_time_ = NOW;

    // log node energy
        if (em()->energy() > 0) {
            ((MobileNode *)node_)->log_energy(1);
            } else {
            ((MobileNode *)node_)->log_energy(0);
            }
    }
}
---------------------------------------------------------
  in the functions node_wakeup() and node_sleep(),  when the
conditions (
NOW > update_energy_time_ && (status_== IDLE) ) 
are satisfied, the variable
status_ can change.  During the debug period, I found that
there were
situations which  satisfied NOW = update_energy_time_
&& status_ == IDLE,
under such situations, the variable status_ didn't change
and I think it is
wrong  not to change the variable status_;

  The solutions is to change  "NOW >
update_energy_time_"  to "NOW >=
update_energy_time_".
  Then using my test tclscript, I can get different results.

I wonder whether I am right.  Any suggestions will be
appreciated.
Best regards!
David
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )