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

RateLimitStrategy Class Reference

#include <rate-limit-strategy.h>

Collaboration diagram for RateLimitStrategy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RateLimitStrategy (double rate, int ptype, double share, double estimate)
 ~RateLimitStrategy ()
double process (Packet *p, int mine, int lowDemand)
void restrictPacketType (int type, double share, double actual)
double getDropRate ()
double getArrivalRate ()
void reset ()

Public Attributes

double target_rate_
double reset_time_
RateEstimatorrateEstimator_
RateLimiterrateLimiter_
int ptype_
double ptype_share_
RateEstimatorptypeRateEstimator_
RateLimiterptypeRateLimiter_
PacketTypeLogptypeLog_

Constructor & Destructor Documentation

RateLimitStrategy::RateLimitStrategy double  rate,
int  ptype,
double  share,
double  estimate
 

Definition at line 39 of file rate-limit-strategy.cc.

References Scheduler::clock(), Scheduler::instance(), ptype_, ptype_share_, ptypeLog_, ptypeRateEstimator_, ptypeRateLimiter_, rateEstimator_, rateLimiter_, reset_time_, and target_rate_.

00039                                                                                           {
00040   
00041   target_rate_ = rate;
00042   reset_time_ = Scheduler::instance().clock();
00043   
00044   ptype_ = ptype;
00045   ptype_share_ = share;
00046   
00047 //  if (debug_)
00048 //    printf("TB: Starting a token bucket at %g with rate %g bps\n", Scheduler::instance().clock(), rate);
00049   rateEstimator_ = new RateEstimator(estimate);
00050   rateLimiter_ = new TokenBucketRateLimiter();
00051   
00052   ptypeRateEstimator_ = new RateEstimator();
00053   ptypeRateLimiter_ = new TokenBucketRateLimiter();
00054   
00055   ptypeLog_ = new PacketTypeLog(this);
00056 }

Here is the call graph for this function:

RateLimitStrategy::~RateLimitStrategy  ) 
 

Definition at line 114 of file rate-limit-strategy.cc.

References ptypeLog_, ptypeRateEstimator_, ptypeRateLimiter_, rateEstimator_, and rateLimiter_.

00114                                       {
00115   delete(rateLimiter_);
00116   delete(ptypeRateLimiter_);
00117   delete(rateEstimator_);
00118   delete(ptypeRateEstimator_);
00119   delete(ptypeLog_);
00120 }


Member Function Documentation

double RateLimitStrategy::getArrivalRate  ) 
 

Definition at line 102 of file rate-limit-strategy.cc.

References RateEstimator::estRate_, and rateEstimator_.

Referenced by RateLimitSession::getArrivalRateForStatus().

00102                                   {
00103   return rateEstimator_->estRate_;
00104 }

double RateLimitStrategy::getDropRate  ) 
 

Definition at line 94 of file rate-limit-strategy.cc.

References RateEstimator::estRate_, rateEstimator_, and target_rate_.

Referenced by RateLimitSession::getDropRate().

00094                                {
00095   double inRate = rateEstimator_->estRate_;
00096   double dropRate = (inRate - target_rate_)/inRate;
00097   if (dropRate < 0) dropRate=0;
00098   return dropRate;
00099 }

double RateLimitStrategy::process Packet p,
int  mine,
int  lowDemand
 

Definition at line 59 of file rate-limit-strategy.cc.

References RateEstimator::estimateRate(), RateEstimator::estRate_, HDR_CMN, PacketTypeLog::log(), hdr_cmn::ptype(), ptype_, ptype_share_, ptypeLog_, ptypeRateEstimator_, ptypeRateLimiter_, rateEstimator_, RateLimiter::rateLimit(), rateLimiter_, and target_rate_.

Referenced by RateLimitSession::log().

00059                                                              {
00060   
00061   rateEstimator_->estimateRate(p);
00062   ptypeLog_->log(p);
00063   
00064   hdr_cmn* hdr = HDR_CMN(p);
00065     
00066   int dropped = 0;
00067   if (hdr->ptype() == ptype_) {
00068     ptypeRateEstimator_->estimateRate(p);
00069     dropped = ptypeRateLimiter_->rateLimit(p, ptypeRateEstimator_->estRate_, 
00070                                            target_rate_*ptype_share_, mine, lowDemand);
00071   }
00072 
00073   if (dropped) return 1;
00074   
00075   dropped = rateLimiter_->rateLimit(p, rateEstimator_->estRate_, target_rate_, mine, lowDemand);
00076   return dropped;
00077 }

Here is the call graph for this function:

void RateLimitStrategy::reset  ) 
 

Definition at line 107 of file rate-limit-strategy.cc.

References ptypeRateEstimator_, ptypeRateLimiter_, rateEstimator_, rateLimiter_, RateEstimator::reset(), and RateLimiter::reset().

Referenced by RateLimitSession::pushbackOn().

00107                          {
00108   rateLimiter_->reset();
00109   ptypeRateLimiter_->reset();
00110   rateEstimator_->reset(); 
00111   ptypeRateEstimator_->reset();
00112 }

Here is the call graph for this function:

void RateLimitStrategy::restrictPacketType int  type,
double  share,
double  actual
 

Definition at line 80 of file rate-limit-strategy.cc.

References RateEstimator::estRate_, Scheduler::instance(), ptype_, ptype_share_, ptypeRateEstimator_, and rateEstimator_.

Referenced by PacketTypeLog::expire().

00080                                                                            {
00081   
00082   if (type == ptype_) {
00083     return;
00084   }
00085   
00086   printf("RLSt: Restricting type %d to %g hogging=%g at %g \n",  type, share, actual, 
00087          Scheduler::instance().clock());
00088   ptype_ = type;
00089   ptype_share_ = share;
00090   ptypeRateEstimator_->estRate_ = rateEstimator_->estRate_*actual;
00091 }

Here is the call graph for this function:


Member Data Documentation

int RateLimitStrategy::ptype_
 

Definition at line 63 of file rate-limit-strategy.h.

Referenced by process(), RateLimitStrategy(), and restrictPacketType().

double RateLimitStrategy::ptype_share_
 

Definition at line 64 of file rate-limit-strategy.h.

Referenced by process(), RateLimitStrategy(), and restrictPacketType().

PacketTypeLog* RateLimitStrategy::ptypeLog_
 

Definition at line 68 of file rate-limit-strategy.h.

Referenced by process(), RateLimitStrategy(), and ~RateLimitStrategy().

RateEstimator* RateLimitStrategy::ptypeRateEstimator_
 

Definition at line 65 of file rate-limit-strategy.h.

Referenced by process(), RateLimitStrategy(), reset(), restrictPacketType(), and ~RateLimitStrategy().

RateLimiter* RateLimitStrategy::ptypeRateLimiter_
 

Definition at line 66 of file rate-limit-strategy.h.

Referenced by process(), RateLimitStrategy(), reset(), and ~RateLimitStrategy().

RateEstimator* RateLimitStrategy::rateEstimator_
 

Definition at line 60 of file rate-limit-strategy.h.

Referenced by getArrivalRate(), getDropRate(), RateLimitSession::merge(), process(), RateLimitStrategy(), reset(), restrictPacketType(), and ~RateLimitStrategy().

RateLimiter* RateLimitStrategy::rateLimiter_
 

Definition at line 61 of file rate-limit-strategy.h.

Referenced by process(), RateLimitStrategy(), reset(), and ~RateLimitStrategy().

double RateLimitStrategy::reset_time_
 

Definition at line 58 of file rate-limit-strategy.h.

Referenced by RateLimitStrategy().

double RateLimitStrategy::target_rate_
 

Definition at line 57 of file rate-limit-strategy.h.

Referenced by getDropRate(), PushbackAgent::initialUpdate(), RateLimitSession::merge(), process(), PushbackAgent::pushbackCheck(), PushbackAgent::pushbackRefresh(), RateLimitStrategy(), PushbackAgent::refreshUpstreamLimits(), and RateLimitSession::setLimit().


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