Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

SmacCounterTimer Class Reference

#include <smac.h>

Inheritance diagram for SmacCounterTimer:

Inheritance graph
[legend]
Collaboration diagram for SmacCounterTimer:

Collaboration graph
[legend]
List of all members.

Public Types

enum  TimerStatus { TIMER_IDLE, TIMER_PENDING, TIMER_HANDLING }

Public Member Functions

 SmacCounterTimer (SMAC *a, int i)
void sched (double t)
void expire (Event *e)
double timeToSleep ()
int busy ()
void resched (double delay)
void cancel ()
void force_cancel ()
int status ()

Protected Member Functions

virtual void handle (Event *)

Protected Attributes

int index_
int value_
int syncTime_
int dataTime_
int listenTime_
int sleepTime_
int cycleTime_
double tts_
double stime_
SMACa_
int status_
Event event_

Friends

class SMAC

Member Enumeration Documentation

enum TimerHandler::TimerStatus [inherited]
 

Enumeration values:
TIMER_IDLE 
TIMER_PENDING 
TIMER_HANDLING 

Definition at line 66 of file timer-handler.h.


Constructor & Destructor Documentation

SmacCounterTimer::SmacCounterTimer SMAC a,
int  i
[inline]
 

Definition at line 321 of file smac.h.

References index_.

00321 : SmacTimer(a) {index_ = i;}


Member Function Documentation

int SmacTimer::busy  )  [inherited]
 

Definition at line 64 of file smac.cc.

References TimerHandler::status_, and TimerHandler::TIMER_PENDING.

Referenced by SMAC::checkToSend(), SMAC::handleCounterTimer(), and SMAC::recv().

00065 {
00066         if (status_ != TIMER_PENDING)
00067                 return 0;
00068         else
00069                 return 1;
00070 }

void TimerHandler::cancel  )  [inherited]
 

Definition at line 31 of file timer-handler.cc.

References TimerHandler::_cancel(), abort(), TimerHandler::status_, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by BayFullTcpAgent::cancel_rtx_timeout(), PushbackTimer::cancelStatus(), SmacCsTimer::checkToCancel(), LmsReceiver::delete_nak(), QA::get_data(), SMAC::handleACK(), SMAC::handleCTS(), SMAC::handleSYNC(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), DelAckSink::recv(), TcpAsymSink::recv(), AbsDelAckSink::recv(), MIPMHAgent::recv(), FtpClientAgent::recv(), PushbackTimer::removeEvents(), DelAckSink::reset(), FackTcpAgent::send_much(), TcpSessionAgent::set_rtx_timer(), TcpFsAgent::set_rtx_timer(), TrafficGenerator::stop(), SA_Agent::stop(), RTCPAgent::stop(), RapAgent::stop(), QA::stop(), LandmarkAgent::stop(), Estimator::stop(), NeighborCache::~NeighborCache(), PacketTypeLog::~PacketTypeLog(), QA::~QA(), and TBF::~TBF().

00032 {
00033         if (status_ != TIMER_PENDING) {
00034                 fprintf(stderr,
00035                   "Attempting to cancel timer at %p which is not scheduled\n",
00036                   this);
00037                 abort();
00038         }
00039         _cancel();
00040         status_ = TIMER_IDLE;
00041 }

Here is the call graph for this function:

void SmacCounterTimer::expire Event e  )  [virtual]
 

Implements SmacTimer.

Definition at line 169 of file smac.cc.

References SmacTimer::a_, SMAC::handleCounterTimer(), index_, stime_, and tts_.

00169                                       {
00170         tts_ = stime_ = 0;
00171         a_->handleCounterTimer(index_);
00172 }

Here is the call graph for this function:

void TimerHandler::force_cancel  )  [inline, inherited]
 

Definition at line 60 of file timer-handler.h.

References TimerHandler::_cancel(), TimerHandler::status_, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by TcpAgent::cancel_rtx_timer(), TcpSessionAgent::cancel_rtx_timer(), TcpFsAgent::cancel_rtx_timer(), AbsTcpAgent::cancel_timer(), TcpAgent::cancel_timers(), TcpSessionAgent::cancel_timers(), FullTcpAgent::cancel_timers(), TcpFsAgent::cancel_timers(), SinkAgent::command(), UnslottedAlohaMac::end_of_contention(), GAFAgent::processDiscoveryMsg(), RTPAgent::rate_change(), TfrcAgent::stop(), RTPAgent::stop(), and SinkAgent::stop().

00060                                    {    // cancel!
00061                 if (status_ == TIMER_PENDING) {
00062                         _cancel();
00063                         status_ = TIMER_IDLE;
00064                 }
00065         }

Here is the call graph for this function:

void TimerHandler::handle Event  )  [protected, virtual, inherited]
 

Implements Handler.

Reimplemented in EmpFtpTrafSession, EmpWebPage, EmpWebTrafSession, HBTimer, WebPage, and WebTrafSession.

Definition at line 69 of file timer-handler.cc.

References abort(), TimerHandler::expire(), TimerHandler::status_, TimerHandler::TIMER_HANDLING, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by WebTrafSession::handle(), WebPage::handle(), HBTimer::handle(), EmpWebTrafSession::handle(), EmpWebPage::handle(), and EmpFtpTrafSession::handle().

00070 {
00071         if (status_ != TIMER_PENDING)   // sanity check
00072                 abort();
00073         status_ = TIMER_HANDLING;
00074         expire(e);
00075         // if it wasn't rescheduled, it's done
00076         if (status_ == TIMER_HANDLING)
00077                 status_ = TIMER_IDLE;
00078 }

Here is the call graph for this function:

void TimerHandler::resched double  delay  )  [inherited]
 

Definition at line 60 of file timer-handler.cc.

References TimerHandler::_cancel(), TimerHandler::_sched(), TimerHandler::status_, and TimerHandler::TIMER_PENDING.

Referenced by UnslottedAlohaMac::backoff(), SinkAgent::bcast_interest(), PIQueue::calculate_p(), SMAC::collision(), MIPMHAgent::command(), MIPBSAgent::command(), GAFAgent::command(), SinkAgent::command(), LmsReceiver::create_nak(), GAFAgent::duty_timeout(), PacketTypeLog::expire(), QSTimer::expire(), OmniMcastSendBufTimer::expire(), OmniMcastArpBufferTimer::expire(), QATimer::expire(), PromotionTimer::expire(), SendBufferTimer::expire(), SendBufTimer::expire(), ArpBufferTimer::expire(), EnergyTimer::expire(), DiffusionRate::GradientTimeOut(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), RapAgent::IpgTimeout(), RapAgent::LossHandler(), DiffusionRate::NegReinfTimeOut(), TfrcAgent::nextpkt(), TfrcSinkAgent::nextpkt(), RBPRenoTcpAgent::paced_send_one(), RBPVegasTcpAgent::paced_send_one(), QSNewRenoTcpAgent::paced_send_one(), PacketTypeLog::PacketTypeLog(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), LogWebTrafPool::processLog(), PushbackQueue::PushbackQueue(), QSAgent::QSAgent(), RTPAgent::rate_change(), TfrcAgent::recv(), DelAckSink::recv(), FullTcpAgent::recv(), BayFullTcpAgent::recv(), TcpAsymSink::recv(), AbsDelAckSink::recv(), TBF::recv(), SMAC::recv(), SA_Agent::recv(), FtpClientAgent::recv(), TfrcAgent::reduce_rate_on_no_feedback(), MIPMHAgent::reg(), SinkAgent::report(), LivenessTimer::resched(), HBTimer::resched(), RapAgent::RttTimeout(), sched(), PushbackTimer::schedule(), WebServer::schedule_next_job(), GAFAgent::schedule_wakeup(), TcpFsAgent::send_helper(), TcpAsymAgent::send_helper(), TcpAgent::send_much(), TcpSessionAgent::send_much(), Sack1TcpAgent::send_much(), SackRHTcpAgent::send_much(), IntTcpAgent::send_much(), FullTcpAgent::send_much(), BayFullTcpAgent::send_much(), FackTcpAgent::send_much(), UnslottedAlohaMac::sendDown(), UnslottedAlohaMac::sendUp(), TcpAgent::set_rtx_timer(), TcpSessionAgent::set_rtx_timer(), TcpFsAgent::set_rtx_timer(), AbsTcpAgent::set_timer(), REMQueue::set_update_timer(), TrafficGenerator::start(), TfrcAgent::start(), RTPAgent::start(), RTCPAgent::start(), FtpClientAgent::start(), Estimator::start(), SinkAgent::start(), DiffusionRate::Start(), DiffusionProb::Start(), TrafficGenerator::timeout(), TrafficTrace::timeout(), TelnetApp::timeout(), FullTcpAgent::timeout(), BayFullTcpAgent::timeout(), TBF::timeout(), SA_Agent::timeout(), RTPAgent::timeout(), RTCPAgent::timeout(), PushbackQueue::timeout(), MIPMHAgent::timeout(), MIPBSAgent::timeout(), LmsReceiver::timeout(), GAFAgent::timeout(), EXPOO_Traffic::timeout(), Estimator::timeout(), SinkAgent::timeout(), CBR_PP_Traffic::timeout(), WirelessPhy::UpdateIdleEnergy(), SMAC::updateNav(), SMAC::updateNeighNav(), and WirelessPhy::WirelessPhy().

00061 {
00062         if (status_ == TIMER_PENDING)
00063                 _cancel();
00064         _sched(delay);
00065         status_ = TIMER_PENDING;
00066 }

Here is the call graph for this function:

void SmacCounterTimer::sched double  t  ) 
 

Reimplemented from TimerHandler.

Definition at line 128 of file smac.cc.

References CLKTICK2SEC, Scheduler::clock(), dataTime_, Scheduler::instance(), listenTime_, TimerHandler::resched(), TimerHandler::sched(), sleepTime_, TimerHandler::status_, stime_, syncTime_, TimerHandler::TIMER_IDLE, tts_, and value_.

Referenced by SMAC::handleCounterTimer(), SMAC::handleSYNC(), and SMAC::setMySched().

00128                                         {
00129         // the cycle timer assumes that all time shall be scheduled with time "left to sleep" 
00130         // and not the absolute time for a given state (sleep, sync or data). Thus inorder 
00131         // to schedule for a sleep state, need to schedule with aggregate time CYCLETIME 
00132         // (sleeptime+synctime+dadatime).
00133         // Similarly for sync state, schedule with listenTime_ (synctime+datattime)
00134         // This is implemented to be in step with the counter used in actual smac.
00135 
00136         tts_ = time; // time before it goes to sleep again
00137         stime_ = Scheduler::instance().clock();
00138   
00139         if (time <= CLKTICK2SEC(cycleTime_) && time > CLKTICK2SEC(listenTime_)) { // in sleep state
00140                 value_ = sleepTime_;
00141                 if (status_ == TIMER_IDLE)
00142                         TimerHandler::sched(time - CLKTICK2SEC(listenTime_)); 
00143                 else
00144                         TimerHandler::resched(time - CLKTICK2SEC(listenTime_)); 
00145     
00146         } else if ( time <= CLKTICK2SEC(listenTime_) && time > CLKTICK2SEC(dataTime_)) { // in sync state
00147                 value_ = syncTime_;
00148                 if (status_ == TIMER_IDLE)
00149                         TimerHandler::sched(time - CLKTICK2SEC(dataTime_)); 
00150                 else
00151                         TimerHandler::resched(time - CLKTICK2SEC(dataTime_)); 
00152     
00153         } else { // in data state
00154                 assert(time <= CLKTICK2SEC(dataTime_));
00155                 value_ = dataTime_;
00156                 if (status_ == TIMER_IDLE)
00157                         TimerHandler::sched(time); 
00158                 else
00159                         TimerHandler::resched(time); 
00160     
00161         }
00162 
00163 }

Here is the call graph for this function:

int TimerHandler::status  )  [inline, inherited]
 

Definition at line 67 of file timer-handler.h.

References TimerHandler::status_.

Referenced by TcpSessionAgent::add_pkts(), BayFullTcpAgent::cancel_rtx_timeout(), HttpMInvalCache::command(), FullTcpAgent::foutput(), QA::get_data(), TcpAgent::output(), VegasTcpAgent::output(), RFC793eduTcpAgent::output(), QSNewRenoTcpAgent::output(), BayFullTcpAgent::output(), DelAckSink::recv(), FullTcpAgent::recv(), BayFullTcpAgent::recv(), TcpAsymSink::recv(), AbsDelAckSink::recv(), MIPMHAgent::recv(), DelAckSink::reset(), TcpAgent::send_much(), TcpSessionAgent::send_much(), Sack1TcpAgent::send_much(), SackRHTcpAgent::send_much(), IntTcpAgent::send_much(), FullTcpAgent::send_much(), BayFullTcpAgent::send_much(), FackTcpAgent::send_much(), TcpSessionAgent::set_rtx_timer(), TcpFsAgent::set_rtx_timer(), RapAgent::stop(), QA::stop(), and QA::~QA().

00067 { return status_; };

double SmacCounterTimer::timeToSleep  ) 
 

Definition at line 165 of file smac.cc.

References Scheduler::clock(), Scheduler::instance(), stime_, and tts_.

Referenced by SMAC::handleSYNC(), and SMAC::sendSYNC().

00165                                      {
00166         return ((stime_ + tts_) - Scheduler::instance().clock()) ;
00167 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class SMAC [friend]
 

Definition at line 320 of file smac.h.


Member Data Documentation

SMAC* SmacTimer::a_ [protected, inherited]
 

Definition at line 260 of file smac.h.

Referenced by expire(), SmacCsTimer::expire(), SmacNeighNavTimer::expire(), SmacNavTimer::expire(), SmacSendTimer::expire(), SmacRecvTimer::expire(), SmacGeneTimer::expire(), and SmacTimer::SmacTimer().

int SmacCounterTimer::cycleTime_ [protected]
 

Definition at line 332 of file smac.h.

Referenced by SMAC::SMAC().

int SmacCounterTimer::dataTime_ [protected]
 

Definition at line 329 of file smac.h.

Referenced by sched(), and SMAC::SMAC().

Event TimerHandler::event_ [protected, inherited]
 

Definition at line 75 of file timer-handler.h.

Referenced by TimerHandler::_cancel(), TimerHandler::_sched(), WebPage::start(), and EmpWebPage::start().

int SmacCounterTimer::index_ [protected]
 

Definition at line 326 of file smac.h.

Referenced by expire(), and SmacCounterTimer().

int SmacCounterTimer::listenTime_ [protected]
 

Definition at line 330 of file smac.h.

Referenced by sched(), and SMAC::SMAC().

int SmacCounterTimer::sleepTime_ [protected]
 

Definition at line 331 of file smac.h.

Referenced by sched(), and SMAC::SMAC().

int TimerHandler::status_ [protected, inherited]
 

Definition at line 74 of file timer-handler.h.

Referenced by SmacTimer::busy(), TimerHandler::cancel(), SmacCsTimer::checkToCancel(), TimerHandler::force_cancel(), TimerHandler::handle(), TimerHandler::resched(), TimerHandler::sched(), sched(), WebPage::start(), EmpWebPage::start(), TimerHandler::status(), TimerHandler::TimerHandler(), EmpFtpTrafSession::~EmpFtpTrafSession(), EmpWebTrafSession::~EmpWebTrafSession(), and WebTrafSession::~WebTrafSession().

double SmacCounterTimer::stime_ [protected]
 

Definition at line 334 of file smac.h.

Referenced by expire(), sched(), and timeToSleep().

int SmacCounterTimer::syncTime_ [protected]
 

Definition at line 328 of file smac.h.

Referenced by sched(), and SMAC::SMAC().

double SmacCounterTimer::tts_ [protected]
 

Definition at line 333 of file smac.h.

Referenced by expire(), sched(), and timeToSleep().

int SmacCounterTimer::value_ [protected]
 

Definition at line 327 of file smac.h.

Referenced by SMAC::handleCounterTimer(), and sched().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:24:03 2004 for NS2.26SourcesOriginal by doxygen 1.3.3