ns-allinone-2.35/ns-2.35/diffserv/dsPolicy.cc
void TRTCMPolicy::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
    policy->cBucket = policy->cbs;
  
  tokenBytes = (double) policy->pir * (now - policy->arrivalTime);
  if (policy->pBucket + tokenBytes <= policy->pbs)
    policy->pBucket += tokenBytes;
  else
    policy->pBucket = policy->pbs;
  
  policy->arrivalTime = now;
}
// Beginning of TRTCM
/*----------------------------------------------------------------------------
void TRTCMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt)
Pre: policy's variables cBucket, pBucket, cir, pir, cbs, pbs, and arrivalTime
  hold valid values.
Post: Increments policy's trTCM state variables cBucket and pBucket 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.  pBucket is filled at a
  rate equal to PIR, capped at an upper bound of PBS.
      This method also sets arrivalTime equal to the current simulator time.
Note: See the Internet Draft, "A Two Rate Three Color Marker" (Heinanen et al;
  May, 1999) for a description of the srTCM.
---------------------------------------------------------------------------*/
Beginning of TRTCM
void TRTCMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt)
Pre: policy's variables cBucket, pBucket, cir, pir, cbs, pbs, and arrivalTime
hold valid values.
Post: Increments policy's trTCM state variables cBucket and pBucket 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.  pBucket is filled at a
rate equal to PIR, capped at an upper bound of PBS.
This method also sets arrivalTime equal to the current simulator time.
Note: See the Internet Draft, "A Two Rate Three Color Marker" (Heinanen et al;
May, 1999) for a description of the srTCM.
Beginning of TRTCM void TRTCMPolicy :: applyMeter ( policyTableEntry * policy Packet * pkt ) Pre : policy ' s variables cBucket pBucket cir pir cbs pbs and arrivalTime hold valid values . Post : Increments policy ' s trTCM state variables cBucket and pBucket 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 . pBucket is filled at a rate equal to PIR capped at an upper bound of PBS . This method also sets arrivalTime equal to the current simulator time . Note : See the Internet Draft " A Two Rate Three Color Marker " ( Heinanen et al ; May 1999 ) for a description of the srTCM .
void TRTCMPolicy::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
    policy->cBucket = policy->cbs;
  tokenBytes = (double) policy->pir * (now - policy->arrivalTime);
  if (policy->pBucket + tokenBytes <= policy->pbs)
    policy->pBucket += tokenBytes;
  else
    policy->pBucket = policy->pbs;
  policy->arrivalTime = now;
}
void TRTCMPolicy :: 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 policy -> cBucket = policy -> cbs ; tokenBytes = ( double ) policy -> pir * ( now - policy -> arrivalTime ) ; if ( policy -> pBucket + tokenBytes <= policy -> pbs ) policy -> pBucket += tokenBytes ; else policy -> pBucket = policy -> pbs ; policy -> arrivalTime = now ; }
Beginning of TRTCM
void TRTCMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt)
Pre: policy's variables cBucket, pBucket, cir, pir, cbs, pbs, and arrivalTime
hold valid values.
Beginning of TRTCM void TRTCMPolicy :: applyMeter ( policyTableEntry * policy Packet * pkt ) Pre : policy ' s variables cBucket pBucket cir pir cbs pbs and arrivalTime hold valid values .