ns-allinone-2.35/ns-2.35/diffserv/dsPolicy.cc
void TSW2CMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt) {
  double now, bytesInTSW, newBytes;
  hdr_cmn* hdr = hdr_cmn::access(pkt);
  
  bytesInTSW = policy->avgRate * policy->winLen;
  newBytes = bytesInTSW + (double) hdr->size();
  now = Scheduler::instance().clock();
  policy->avgRate = newBytes / (now - policy->arrivalTime + policy->winLen);
  policy->arrivalTime = now;
}
// The beginning of the definition of TSW2CM
/*-----------------------------------------------------------------------------
void TSW2CMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt)
Pre: policy's variables avgRate, arrivalTime, and winLen hold valid values; and
  pkt points to a newly-arrived packet.
Post: Adjusts policy's TSW state variables avgRate and arrivalTime (also called
  tFront) according to the specified packet.
Note: See the paper "Explicit Allocation of Best effor Delivery Service" (David
  Clark and Wenjia Fang), Section 3.3, for a description of the TSW Tagger.
-----------------------------------------------------------------------------*/
The beginning of the definition of TSW2CM
void TSW2CMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt)
Pre: policy's variables avgRate, arrivalTime, and winLen hold valid values; and
pkt points to a newly-arrived packet.
Post: Adjusts policy's TSW state variables avgRate and arrivalTime (also called
tFront) according to the specified packet.
Note: See the paper "Explicit Allocation of Best effor Delivery Service" (David
Clark and Wenjia Fang), Section 3.3, for a description of the TSW Tagger.
The beginning of the definition of TSW2CM void TSW2CMPolicy :: applyMeter ( policyTableEntry * policy Packet * pkt ) Pre : policy ' s variables avgRate arrivalTime and winLen hold valid values ; and pkt points to a newly - arrived packet . Post : Adjusts policy ' s TSW state variables avgRate and arrivalTime ( also called tFront ) according to the specified packet . Note : See the paper " Explicit Allocation of Best effor Delivery Service " ( David Clark and Wenjia Fang ) Section 3 . 3 for a description of the TSW Tagger .
void TSW2CMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt) {
  double now, bytesInTSW, newBytes;
  hdr_cmn* hdr = hdr_cmn::access(pkt);
  bytesInTSW = policy->avgRate * policy->winLen;
  newBytes = bytesInTSW + (double) hdr->size();
  now = Scheduler::instance().clock();
  policy->avgRate = newBytes / (now - policy->arrivalTime + policy->winLen);
  policy->arrivalTime = now;
}
void TSW2CMPolicy :: applyMeter ( policyTableEntry * policy , Packet * pkt ) { double now , bytesInTSW , newBytes ; hdr_cmn * hdr = hdr_cmn :: access ( pkt ) ; bytesInTSW = policy -> avgRate * policy -> winLen ; newBytes = bytesInTSW + ( double ) hdr -> size ( ) ; now = Scheduler :: instance ( ) . clock ( ) ; policy -> avgRate = newBytes / ( now - policy -> arrivalTime + policy -> winLen ) ; policy -> arrivalTime = now ; }
The beginning of the definition of TSW2CM
void TSW2CMPolicy::applyMeter(policyTableEntry *policy, Packet *pkt)
Pre: policy's variables avgRate, arrivalTime, and winLen hold valid values; and
pkt points to a newly-arrived packet.
The beginning of the definition of TSW2CM void TSW2CMPolicy :: applyMeter ( policyTableEntry * policy Packet * pkt ) Pre : policy ' s variables avgRate arrivalTime and winLen hold valid values ; and pkt points to a newly - arrived packet .