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

BackoffTimer Class Reference

#include <mac-timers.h>

Inheritance diagram for BackoffTimer:

Inheritance graph
[legend]
Collaboration diagram for BackoffTimer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 BackoffTimer (Mac802_11 *m, double s)
void start (int cw, int idle)
void handle (Event *e)
void pause (void)
void resume (double difs)
virtual void start (double time)
virtual void stop (void)
virtual void resume (void)
int busy (void)
int paused (void)
double expire (void)

Protected Attributes

Mac802_11mac
int busy_
int paused_
Event intr
double stime
double rtime
double slottime

Private Attributes

double difs_wait

Constructor & Destructor Documentation

BackoffTimer::BackoffTimer Mac802_11 m,
double  s
[inline]
 

Definition at line 76 of file mac-timers.h.

References difs_wait.

00076 : MacTimer(m, s), difs_wait(0.0) {}


Member Function Documentation

int MacTimer::busy void   )  [inline, inherited]
 

Definition at line 57 of file mac-timers.h.

References MacTimer::busy_.

Referenced by Mac802_11::backoffHandler(), Mac802_11::check_pktRTS(), Mac802_11::check_pktTx(), Mac802_11::collision(), Mac802_11::deferHandler(), Mac802_11::dump(), Mac802_11::recvACK(), Mac802_11::recvDATA(), Mac802_11::recvRTS(), Mac802_11::RetransmitDATA(), Mac802_11::RetransmitRTS(), Mac802_11::rx_resume(), Mac802_11::send(), Mac802_11::set_nav(), and Mac802_11::tx_resume().

00057 { return busy_; }

double MacTimer::expire void   )  [inline, inherited]
 

Definition at line 59 of file mac-timers.h.

References Scheduler::clock(), Scheduler::instance(), MacTimer::rtime, and MacTimer::stime.

Referenced by Mac802_11::collision(), and Mac802_11::dump().

00059                                    {
00060                 return ((stime + rtime) - Scheduler::instance().clock());
00061         }

Here is the call graph for this function:

void BackoffTimer::handle Event e  )  [virtual]
 

Implements MacTimer.

Definition at line 204 of file mac-timers.cc.

References Mac802_11::backoffHandler(), MacTimer::busy_, difs_wait, MacTimer::mac, MacTimer::paused_, MacTimer::rtime, and MacTimer::stime.

00205 {
00206         busy_ = 0;
00207         paused_ = 0;
00208         stime = 0.0;
00209         rtime = 0.0;
00210         difs_wait = 0.0;
00211 
00212         mac->backoffHandler();
00213 }

Here is the call graph for this function:

void BackoffTimer::pause void   )  [virtual]
 

Reimplemented from MacTimer.

Definition at line 245 of file mac-timers.cc.

References MacTimer::busy_, Scheduler::cancel(), Scheduler::clock(), difs_wait, Scheduler::instance(), MacTimer::intr, MacTimer::mac, MacTimer::paused_, Mac802_11::phymib_, MacTimer::rtime, PHY_MIB::SlotTime, and MacTimer::stime.

00246 {
00247         Scheduler &s = Scheduler::instance();
00248 
00249         //the caculation below make validation pass for linux though it
00250         // looks dummy
00251 
00252         double st = s.clock();
00253         double rt = stime + difs_wait;
00254         double sr = st - rt;
00255         double mst = (mac->phymib_->SlotTime);
00256 
00257         int slots = int (sr/mst);
00258 
00259     //int slots = (int) ((s.clock() - (stime + difs_wait)) / mac->phymib_->SlotTime);
00260         if(slots < 0)
00261                 slots = 0;
00262         assert(busy_ && ! paused_);
00263 
00264         paused_ = 1;
00265         rtime -= (slots * mac->phymib_->SlotTime);
00266         assert(rtime >= 0.0);
00267 
00268         difs_wait = 0.0;
00269 
00270         s.cancel(&intr);
00271 }

Here is the call graph for this function:

int MacTimer::paused void   )  [inline, inherited]
 

Definition at line 58 of file mac-timers.h.

References MacTimer::paused_.

Referenced by Mac802_11::dump(), and Mac802_11::navHandler().

00058 { return paused_; }

virtual void MacTimer::resume void   )  [inline, virtual, inherited]
 

Definition at line 55 of file mac-timers.h.

00055 { assert(0); }

void BackoffTimer::resume double  difs  ) 
 

Definition at line 275 of file mac-timers.cc.

References MacTimer::busy_, Scheduler::clock(), difs_wait, Scheduler::instance(), MacTimer::intr, MacTimer::paused_, MacTimer::rtime, Scheduler::schedule(), and MacTimer::stime.

Referenced by Mac802_11::navHandler().

00276 {
00277         Scheduler &s = Scheduler::instance();
00278 
00279         assert(busy_ && paused_);
00280 
00281         paused_ = 0;
00282         stime = s.clock();
00283 
00284         /*
00285          * The media should be idle for DIFS time before we start
00286          * decrementing the counter, so I add difs time in here.
00287          */
00288         difs_wait = difs;
00289         /*
00290 #ifdef USE_SLOT_TIME
00291         ROUND_TIME();
00292 #endif
00293         */
00294         assert(rtime + difs_wait >= 0.0);
00295         s.schedule(this, &intr, rtime + difs_wait);
00296 }

Here is the call graph for this function:

void MacTimer::start double  time  )  [virtual, inherited]
 

Reimplemented in DeferTimer.

Definition at line 71 of file mac-timers.cc.

References MacTimer::busy_, Scheduler::clock(), Scheduler::instance(), MacTimer::intr, MacTimer::paused_, MacTimer::rtime, Scheduler::schedule(), and MacTimer::stime.

Referenced by Mac802_11::collision(), Mac802_11::recv(), and Mac802_11::set_nav().

00072 {
00073         Scheduler &s = Scheduler::instance();
00074         assert(busy_ == 0);
00075 
00076         busy_ = 1;
00077         paused_ = 0;
00078         stime = s.clock();
00079         rtime = time;
00080         assert(rtime >= 0.0);
00081 
00082 
00083         s.schedule(this, &intr, rtime);
00084 }

Here is the call graph for this function:

void BackoffTimer::start int  cw,
int  idle
 

Definition at line 216 of file mac-timers.cc.

References MacTimer::busy_, Scheduler::clock(), difs_wait, Scheduler::instance(), MacTimer::intr, MacTimer::mac, MacTimer::paused_, Mac802_11::phymib_, Random::random(), ROUND_TIME, MacTimer::rtime, Scheduler::schedule(), PHY_MIB::SlotTime, and MacTimer::stime.

Referenced by Mac802_11::check_pktRTS(), Mac802_11::check_pktTx(), Mac802_11::recvACK(), Mac802_11::RetransmitDATA(), Mac802_11::RetransmitRTS(), and Mac802_11::send().

00217 {
00218         Scheduler &s = Scheduler::instance();
00219 
00220         assert(busy_ == 0);
00221 
00222         busy_ = 1;
00223         paused_ = 0;
00224         stime = s.clock();
00225         
00226 
00227         rtime = (Random::random() % cw) * mac->phymib_->SlotTime;
00228 
00229 
00230 #ifdef USE_SLOT_TIME
00231         ROUND_TIME();
00232 #endif
00233         difs_wait = 0.0;
00234 
00235         if(idle == 0)
00236                 paused_ = 1;
00237         else {
00238                 assert(rtime >= 0.0);
00239                 s.schedule(this, &intr, rtime);
00240         }
00241 }

Here is the call graph for this function:

void MacTimer::stop void   )  [virtual, inherited]
 

Definition at line 87 of file mac-timers.cc.

References MacTimer::busy_, Scheduler::cancel(), Scheduler::instance(), MacTimer::intr, MacTimer::paused_, MacTimer::rtime, and MacTimer::stime.

Referenced by Mac802_11::collision(), Mac802_11::recvACK(), Mac802_11::recvCTS(), Mac802_11::recvDATA(), Mac802_11::recvRTS(), and Mac802_11::set_nav().

00088 {
00089         Scheduler &s = Scheduler::instance();
00090 
00091         assert(busy_);
00092 
00093         if(paused_ == 0)
00094                 s.cancel(&intr);
00095 
00096         busy_ = 0;
00097         paused_ = 0;
00098         stime = 0.0;
00099         rtime = 0.0;
00100 }

Here is the call graph for this function:


Member Data Documentation

int MacTimer::busy_ [protected, inherited]
 

Definition at line 65 of file mac-timers.h.

Referenced by MacTimer::busy(), handle(), IFTimer::handle(), TxTimer::handle(), RxTimer::handle(), NavTimer::handle(), DeferTimer::handle(), MacTimer::MacTimer(), pause(), resume(), start(), DeferTimer::start(), MacTimer::start(), and MacTimer::stop().

double BackoffTimer::difs_wait [private]
 

Definition at line 83 of file mac-timers.h.

Referenced by BackoffTimer(), handle(), pause(), resume(), and start().

Event MacTimer::intr [protected, inherited]
 

Definition at line 67 of file mac-timers.h.

Referenced by pause(), resume(), start(), DeferTimer::start(), MacTimer::start(), and MacTimer::stop().

Mac802_11* MacTimer::mac [protected, inherited]
 

Definition at line 64 of file mac-timers.h.

Referenced by handle(), IFTimer::handle(), TxTimer::handle(), RxTimer::handle(), NavTimer::handle(), DeferTimer::handle(), MacTimer::MacTimer(), pause(), and start().

int MacTimer::paused_ [protected, inherited]
 

Definition at line 66 of file mac-timers.h.

Referenced by handle(), IFTimer::handle(), TxTimer::handle(), RxTimer::handle(), NavTimer::handle(), DeferTimer::handle(), MacTimer::MacTimer(), pause(), MacTimer::paused(), resume(), start(), DeferTimer::start(), MacTimer::start(), and MacTimer::stop().

double MacTimer::rtime [protected, inherited]
 

Definition at line 69 of file mac-timers.h.

Referenced by MacTimer::expire(), handle(), IFTimer::handle(), TxTimer::handle(), RxTimer::handle(), NavTimer::handle(), DeferTimer::handle(), MacTimer::MacTimer(), pause(), resume(), start(), DeferTimer::start(), MacTimer::start(), and MacTimer::stop().

double MacTimer::slottime [protected, inherited]
 

Definition at line 70 of file mac-timers.h.

Referenced by MacTimer::MacTimer().

double MacTimer::stime [protected, inherited]
 

Definition at line 68 of file mac-timers.h.

Referenced by MacTimer::expire(), handle(), IFTimer::handle(), TxTimer::handle(), RxTimer::handle(), NavTimer::handle(), DeferTimer::handle(), MacTimer::MacTimer(), pause(), resume(), start(), DeferTimer::start(), MacTimer::start(), and MacTimer::stop().


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