[Smac-users] regarding listenTime_ and cycleTime_ in ns2 smac program

Yuan Li liyuan at pollux.usc.edu
Wed Jul 14 16:21:31 PDT 2004


Hi,

As you mentioned,
listenTime_ = syncTime_ + dataTime_;
cycleTime_ = listenTime_ + sleepTime_;
All these variables represent "durations" of certain phases in S-MAC.

SmacCounterTimer uses "time left to go into sleep phase" to track nodes'
sleep/wake up schedules, and switch among "SYNC", "DATA", "SLEEP" phases.
You might be interested in reading function SMAC::handleCounterTimer where
this timer is set up several times.

Thanks

Yuan


On Wed, 14 Jul 2004, [gb2312] Õ÷ ºé wrote:

> Recently I am reading SMAC program in ns2. IN my opinion,
> sync   data       sleep      sync    data
> -------|-----------|-----------------|--------|-----------
>    listenTime        sleeptime
> listenTime=synctime+datattime;
>
> In the program, I wonder what the variables listenTime_, dataTime_,cycleTime_ stand for? Do they stand for " beginning of the  listen period ", " beginning of the data transfer period " or " end of the listen period " and " end of the data transfer period " ? But what does cycleTime_ mean?
>
> As we can see from the original program,
> if (time <= CLKTICK2SEC(cycleTime_) && time > CLKTICK2SEC(listenTime_))
> the commentary is "in sleep state",
> I am puzzled here. Can anyone help me clarify the three variables.
>
> Thanks a lot!
>
> ***********************************************************************************
> void SmacCounterTimer::sched(double time) {
>  // the cycle timer assumes that all time shall be scheduled with time "left to sleep"
>  // and not the absolute time for a given state (sleep, sync or data). Thus inorder
>  // to schedule for a sleep state, need to schedule with aggregate time CYCLETIME
>  // (sleeptime+synctime+dadatime).
>  // Similarly for sync state, schedule with listenTime_ (synctime+datattime)
>  // This is implemented to be in step with the counter used in actual smac.
>  tts_ = time; // time before it goes to sleep again
>  stime_ = Scheduler::instance().clock();
>
>  if (time <= CLKTICK2SEC(cycleTime_) && time > CLKTICK2SEC(listenTime_)) { // in sleep state
>   value_ = sleepTime_;
>   if (status_ == TIMER_IDLE)
>    TimerHandler::sched(time - CLKTICK2SEC(listenTime_));
>   else
>    TimerHandler::resched(time - CLKTICK2SEC(listenTime_));
>
>  } else if ( time <= CLKTICK2SEC(listenTime_) && time > CLKTICK2SEC(dataTime_)) { // in sync state
>   value_ = syncTime_;
>   if (status_ == TIMER_IDLE)
>    TimerHandler::sched(time - CLKTICK2SEC(dataTime_));
>   else
>    TimerHandler::resched(time - CLKTICK2SEC(dataTime_));
>
>  } else { // in data state
>   assert(time <= CLKTICK2SEC(dataTime_));
>   value_ = dataTime_;
>   if (status_ == TIMER_IDLE)
>    TimerHandler::sched(time);
>   else
>    TimerHandler::resched(time);
>
>  }
> }
>
>
>
>
> ---------------------------------
> Do You Yahoo!?
> ÃÀÅ®Ã÷ÐÇÓ¦Óо¡ÓУ¬"Ò»ËÑ"ËѱéÃÀͼ¡¢ÑÞͼºÍ¿áͼ
> 100Õ×ÓÊÏä¹»²»¹»Óã¿ÑÅ»¢µçÓÊ×ÔÖúÀ©ÈÝ£¡
>



More information about the Smac-users mailing list