ns-allinone-2.35/ns-2.35/diffserv/dsPolicy.cc
int TSW2CMPolicy::applyPolicer(policyTableEntry *policy, policerTableEntry *policer, Packet *) {
  if ((policy->avgRate > policy->cir)
      && (Random::uniform(0.0, 1.0) <= (1-(policy->cir/policy->avgRate)))) {
    return(policer->downgrade1);
  }
  else {
    return(policer->initialCodePt);
  }
}
/*-----------------------------------------------------------------------------
int TSW2CMPolicy::applyPolicer(policyTableEntry *policy, int initialCodePt, Packet *pkt)
Pre: policy points to a policytableEntry that is using the TSW2CM policer and
  whose state variables (avgRate and cir) are up to date.
Post: If policy's avgRate exceeds its CIR, this method returns an out-of-profile
  code point with a probability of ((rate - CIR) / rate).  If it does not
  downgrade the code point, this method simply returns the initial code point.
Returns: A code point to apply to the current packet.
Uses: Method downgradeOne().
-----------------------------------------------------------------------------*/
int TSW2CMPolicy::applyPolicer(policyTableEntry *policy, int initialCodePt, Packet *pkt)
Pre: policy points to a policytableEntry that is using the TSW2CM policer and
whose state variables (avgRate and cir) are up to date.
Post: If policy's avgRate exceeds its CIR, this method returns an out-of-profile
code point with a probability of ((rate - CIR) / rate).  If it does not
downgrade the code point, this method simply returns the initial code point.
Returns: A code point to apply to the current packet.
Uses: Method downgradeOne().
int TSW2CMPolicy :: applyPolicer ( policyTableEntry * policy int initialCodePt Packet * pkt ) Pre : policy points to a policytableEntry that is using the TSW2CM policer and whose state variables ( avgRate and cir ) are up to date . Post : If policy ' s avgRate exceeds its CIR this method returns an out - of - profile code point with a probability of (( rate - CIR ) / rate ) . If it does not downgrade the code point this method simply returns the initial code point . Returns : A code point to apply to the current packet . Uses : Method downgradeOne () .
int TSW2CMPolicy::applyPolicer(policyTableEntry *policy, policerTableEntry *policer, Packet *) {
  if ((policy->avgRate > policy->cir)
      && (Random::uniform(0.0, 1.0) <= (1-(policy->cir/policy->avgRate)))) {
    return(policer->downgrade1);
  }
  else {
    return(policer->initialCodePt);
  }
}
int TSW2CMPolicy :: applyPolicer ( policyTableEntry * policy , policerTableEntry * policer , Packet * ) { if ( ( policy -> avgRate > policy -> cir ) && ( Random :: uniform ( 0.0 , 1.0 ) <= ( 1 - ( policy -> cir / policy -> avgRate ) ) ) ) { return ( policer -> downgrade1 ) ; } else { return ( policer -> initialCodePt ) ; } }
int TSW2CMPolicy::applyPolicer(policyTableEntry *policy, int initialCodePt, Packet *pkt)
Pre: policy points to a policytableEntry that is using the TSW2CM policer and
whose state variables (avgRate and cir) are up to date.
int TSW2CMPolicy :: applyPolicer ( policyTableEntry * policy int initialCodePt Packet * pkt ) Pre : policy points to a policytableEntry that is using the TSW2CM policer and whose state variables ( avgRate and cir ) are up to date .