ns-allinone-2.35/ns-2.35/diffserv/dsPolicy.cc
void SRTCMPolicy::applyMeter(policyTableEntry *policy, Packet *) {
  double now = Scheduler::instance().clock();
  double tokenBytes;
  
  tokenBytes = (double) policy->cir * (now - policy->arrivalTime);
  if (policy->cBucket + tokenBytes <= policy->cbs)
    policy->cBucket += tokenBytes;
  else {
    tokenBytes = tokenBytes - (policy->cbs - policy->cBucket);
    
    policy->cBucket = policy->cbs;
    if (policy->eBucket + tokenBytes <= policy->ebs)
      policy->eBucket += tokenBytes;
    else
      policy->eBucket = policy->ebs;
  }
  policy->arrivalTime = now;
}
// Begining of SRTCM
/*-----------------------------------------------------------------------------
void SRTCMPolicy::applyMeter(policyTableEntry *policy)
Pre: policy's variables cBucket, eBucket, cir, cbs, ebs, and arrivalTime hold
  valid values.
Post: Increments policy's srTCM state variables cBucket and eBucket according
  to the elapsed time since the last packet arrival.  cBucket is filled at a
  rate equal to CIR, capped at an upper bound of CBS.  When cBucket is full
  (equal to CBS), eBucket is filled at a rate equal to CIR, capped at an upper
  bound of EBS.
      This method also sets arrivalTime equal to the current
  simulator time.
Note: See the Internet Draft, "A Single Rate Three Color Marker" (Heinanen et
  al; May, 1999) for a description of the srTCM.
-----------------------------------------------------------------------------*/
Begining of SRTCM
void SRTCMPolicy::applyMeter(policyTableEntry *policy)
Pre: policy's variables cBucket, eBucket, cir, cbs, ebs, and arrivalTime hold
valid values.
Post: Increments policy's srTCM state variables cBucket and eBucket according
to the elapsed time since the last packet arrival.  cBucket is filled at a
rate equal to CIR, capped at an upper bound of CBS.  When cBucket is full
(equal to CBS), eBucket is filled at a rate equal to CIR, capped at an upper
bound of EBS.
This method also sets arrivalTime equal to the current
simulator time.
Note: See the Internet Draft, "A Single Rate Three Color Marker" (Heinanen et
al; May, 1999) for a description of the srTCM.
Begining of SRTCM void SRTCMPolicy :: applyMeter ( policyTableEntry * policy ) Pre : policy ' s variables cBucket eBucket cir cbs ebs and arrivalTime hold valid values . Post : Increments policy ' s srTCM state variables cBucket and eBucket according to the elapsed time since the last packet arrival . cBucket is filled at a rate equal to CIR capped at an upper bound of CBS . When cBucket is full ( equal to CBS ) eBucket is filled at a rate equal to CIR capped at an upper bound of EBS . This method also sets arrivalTime equal to the current simulator time . Note : See the Internet Draft " A Single Rate Three Color Marker " ( Heinanen et al ; May 1999 ) for a description of the srTCM .
void SRTCMPolicy::applyMeter(policyTableEntry *policy, Packet *) {
  double now = Scheduler::instance().clock();
  double tokenBytes;
  tokenBytes = (double) policy->cir * (now - policy->arrivalTime);
  if (policy->cBucket + tokenBytes <= policy->cbs)
    policy->cBucket += tokenBytes;
  else {
    tokenBytes = tokenBytes - (policy->cbs - policy->cBucket);
    policy->cBucket = policy->cbs;
    if (policy->eBucket + tokenBytes <= policy->ebs)
      policy->eBucket += tokenBytes;
    else
      policy->eBucket = policy->ebs;
  }
  policy->arrivalTime = now;
}
void SRTCMPolicy :: applyMeter ( policyTableEntry * policy , Packet * ) { double now = Scheduler :: instance ( ) . clock ( ) ; double tokenBytes ; tokenBytes = ( double ) policy -> cir * ( now - policy -> arrivalTime ) ; if ( policy -> cBucket + tokenBytes <= policy -> cbs ) policy -> cBucket += tokenBytes ; else { tokenBytes = tokenBytes - ( policy -> cbs - policy -> cBucket ) ; policy -> cBucket = policy -> cbs ; if ( policy -> eBucket + tokenBytes <= policy -> ebs ) policy -> eBucket += tokenBytes ; else policy -> eBucket = policy -> ebs ; } policy -> arrivalTime = now ; }
Begining of SRTCM
void SRTCMPolicy::applyMeter(policyTableEntry *policy)
Pre: policy's variables cBucket, eBucket, cir, cbs, ebs, and arrivalTime hold
valid values.
Begining of SRTCM void SRTCMPolicy :: applyMeter ( policyTableEntry * policy ) Pre : policy ' s variables cBucket eBucket cir cbs ebs and arrivalTime hold valid values .