ns-allinone-2.35/ns-2.35/diffserv/dsPolicy.cc
int TBPolicy::applyPolicer(policyTableEntry *policy, policerTableEntry *policer, Packet* pkt) {
  hdr_cmn* hdr = hdr_cmn::access(pkt);

  double size = (double) hdr->size();

  if ((policy->cBucket - size) >= 0) {
    policy->cBucket -= size;
    return(policer->initialCodePt);
  } else{
    return(policer->downgrade1);
  }
}
/*----------------------------------------------------------------------------
int TBPolicy::applyPolicer(policyTableEntry *policy, int initialCodePt,
        Packet* pkt)
Pre: policy points to a policytableEntry that is using the Token Bucket policer
and whose state variable (cBucket) is up to date.  pkt points to a
newly-arrived packet.
Post: If policy's cBucket is at least as large as pkt's size, cBucket is
decremented by that size and the initial code point is retained.  Otherwise,
the code point is downgraded.
Returns: A code point to apply to the current packet.
Uses: Method downgradeOne().
-----------------------------------------------------------------------------*/
int TBPolicy::applyPolicer(policyTableEntry *policy, int initialCodePt,
Packet* pkt)
Pre: policy points to a policytableEntry that is using the Token Bucket policer
and whose state variable (cBucket) is up to date.  pkt points to a
newly-arrived packet.
Post: If policy's cBucket is at least as large as pkt's size, cBucket is
decremented by that size and the initial code point is retained.  Otherwise,
the code point is downgraded.
Returns: A code point to apply to the current packet.
Uses: Method downgradeOne().
int TBPolicy :: applyPolicer ( policyTableEntry * policy int initialCodePt Packet * pkt ) Pre : policy points to a policytableEntry that is using the Token Bucket policer and whose state variable ( cBucket ) is up to date . pkt points to a newly - arrived packet . Post : If policy ' s cBucket is at least as large as pkt ' s size cBucket is decremented by that size and the initial code point is retained . Otherwise the code point is downgraded . Returns : A code point to apply to the current packet . Uses : Method downgradeOne () .
int TBPolicy::applyPolicer(policyTableEntry *policy, policerTableEntry *policer, Packet* pkt) {
  hdr_cmn* hdr = hdr_cmn::access(pkt);
  double size = (double) hdr->size();
  if ((policy->cBucket - size) >= 0) {
    policy->cBucket -= size;
    return(policer->initialCodePt);
  } else{
    return(policer->downgrade1);
  }
}
int TBPolicy :: applyPolicer ( policyTableEntry * policy , policerTableEntry * policer , Packet * pkt ) { hdr_cmn * hdr = hdr_cmn :: access ( pkt ) ; double size = ( double ) hdr -> size ( ) ; if ( ( policy -> cBucket - size ) >= 0 ) { policy -> cBucket -= size ; return ( policer -> initialCodePt ) ; } else { return ( policer -> downgrade1 ) ; } }
int TBPolicy::applyPolicer(policyTableEntry *policy, int initialCodePt,
Packet* pkt)
Pre: policy points to a policytableEntry that is using the Token Bucket policer
and whose state variable (cBucket) is up to date.
int TBPolicy :: applyPolicer ( policyTableEntry * policy int initialCodePt Packet * pkt ) Pre : policy points to a policytableEntry that is using the Token Bucket policer and whose state variable ( cBucket ) is up to date .