Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

EWPolicy Class Reference

#include <ew.h>

Inheritance diagram for EWPolicy:

Inheritance graph
[legend]
Collaboration diagram for EWPolicy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EWPolicy ()
 ~EWPolicy ()
void init (int, int, int)
void applyMeter (policyTableEntry *policy, Packet *pkt)
int applyPolicer (policyTableEntry *policy, policerTableEntry *policer, Packet *pkt)
int dropPacket (Packet *)
void detect (Packet *pkt)
void detectPr ()
void detectPr (int)
void detectPr (int, int)
void detectBr ()
void detectBr (int)
void detectBr (int, int)
void limitPr ()
void limitPr (double)
void limitBr ()
void limitBr (double)
void coupleEW (EWPolicy *)
void coupleEW (EWPolicy *, double)

Public Attributes

EWdetectorBewB
EWdetectorBcewB
EWdetectorPewP
EWdetectorPcewP
TBrateLimitorrlP
TBrateLimitorrlB

Private Attributes

double now
int ew_adj
int qsrc
int qdst
int max_p
int max_b
int alarm
int pre_alarm
int change

Constructor & Destructor Documentation

EWPolicy::EWPolicy  ) 
 

Definition at line 941 of file ew.cc.

References alarm, cewB, cewP, change, ewB, ewP, max_b, max_p, pre_alarm, rlB, and rlP.

00941                    : Policy() {
00942   // Initialize detectors
00943   ewB = cewB = NULL;
00944   ewP = cewP = NULL;
00945   
00946   // Initialize rate limitor
00947   rlP = rlB = NULL;
00948 
00949   max_p = max_b = 0;
00950   alarm = pre_alarm = 0;
00951   change = 0;
00952 }

EWPolicy::~EWPolicy  ) 
 

Definition at line 955 of file ew.cc.

References cewB, cewP, ewB, and ewP.

00955                    {
00956   if (ewB)
00957     free(ewB);
00958 
00959   if (ewP)
00960     free(ewP);
00961 
00962   if (cewB)
00963     free(cewB);
00964 
00965   if (cewP)
00966     free(cewP);
00967 }


Member Function Documentation

void EWPolicy::applyMeter policyTableEntry policy,
Packet pkt
[virtual]
 

Implements Policy.

Definition at line 979 of file ew.cc.

00979                                                                {
00980   return;
00981 }

int EWPolicy::applyPolicer policyTableEntry policy,
policerTableEntry policer,
Packet pkt
[virtual]
 

Implements Policy.

Definition at line 986 of file ew.cc.

References hdr_cmn::access(), Scheduler::clock(), policerTableEntry::downgrade1, dropPacket(), ewB, ewP, policerTableEntry::initialCodePt, Scheduler::instance(), now, PKT_ARRIVAL, PKT_DEPT, PKT_DROP, PT_ACK, hdr_cmn::ptype(), EWdetector::run(), and EWdetectorP::updateStats().

00986                                                                                             {
00987   //printf("enter applyPolicer ");
00988 
00989   // can't count/penalize ACKs:
00990   //   with resp: may cause inaccurate calculation with TSW(??)
00991   //   with req:  may cause resp retransmission.
00992   // just pass them through
00993   hdr_cmn *th = hdr_cmn::access(pkt);
00994   if (th->ptype() == PT_ACK)
00995     return(policer->initialCodePt);
00996 
00997   // for other packets...
00998 
00999   // Get time
01000   now = Scheduler::instance().clock();
01001 
01002   // keep arrival packet stats
01003   if (ewP)
01004     ewP->updateStats(PKT_ARRIVAL);
01005 
01006   // For other packets:
01007   if (dropPacket(pkt)) {
01008     // keep packet stats
01009     if (ewP)
01010       ewP->updateStats(PKT_DROP);
01011     
01012     //printf("downgrade!\n");   
01013     return(policer->downgrade1);
01014   } else {
01015     // keep packet stats
01016     if (ewP)
01017       ewP->updateStats(PKT_DEPT);
01018 
01019     // conduct EW detection
01020     if (ewP)
01021       ewP->run(pkt);
01022     
01023     if (ewB)
01024       ewB->run(pkt);    
01025 
01026     //printf("initial!\n");     
01027     return(policer->initialCodePt);
01028   }
01029 }

Here is the call graph for this function:

void EWPolicy::coupleEW EWPolicy ,
double 
 

Definition at line 1193 of file ew.cc.

References cewB, ewB, and limitPr().

01193                                                    {
01194   // couple the EW detector 
01195   cewB = ewpc->ewB;
01196   
01197   // Setup rate limitor with the default limit
01198   if (rate)
01199     limitPr(rate);
01200   else
01201     limitPr();
01202 }

Here is the call graph for this function:

void EWPolicy::coupleEW EWPolicy  ) 
 

Definition at line 1188 of file ew.cc.

Referenced by edgeQueue::command().

01188                                       {
01189   coupleEW(ewpc, 0);
01190 }

void EWPolicy::detect Packet pkt  ) 
 

Definition at line 1032 of file ew.cc.

References alarm, cewB, change, EW_UNCHANGE, ewP, pre_alarm, EWdetector::resetChange(), and EWdetector::testAlarm().

Referenced by dropPacket().

01032                                  {
01033   int alarm_b, alarm_p;
01034 
01035   alarm_b = alarm_p = 0;
01036 
01037   if (!ewP || ! cewB)
01038     return;
01039   
01040   alarm_b = cewB->testAlarm();
01041   alarm_p = ewP->testAlarm();
01042   
01043 
01044   if (alarm_p == EW_UNCHANGE || alarm_b == EW_UNCHANGE)
01045     return;
01046 
01047   // Need to get info from both parts to make a decision
01048   // Reset change flags
01049   ewP->resetChange();
01050   cewB->resetChange();
01051 
01052   change = 1;
01053   // keep the old value of alarm
01054   pre_alarm = alarm;
01055 
01056   // As long as alarm_b is 0, reset the alarm
01057   if (alarm_b == 0)
01058     alarm = 0;
01059   else if (alarm_p == 0)
01060     alarm = 0;
01061   else 
01062     alarm = 1;
01063 
01064   printf("ALARM %d %d\n", pre_alarm, alarm);
01065 }

Here is the call graph for this function:

void EWPolicy::detectBr int  ,
int 
 

Definition at line 1149 of file ew.cc.

References ew_adj, ewB, EWdetectorB::init(), qdst, qsrc, EWdetector::setDb(), EWdetector::setDt(), and EWdetector::setLink().

01149                                               {
01150   ewB = new EWdetectorB;
01151   ewB->init(ew_adj);
01152   ewB->setLink(qsrc, qdst);
01153   ewB->setDt(dt_inv);
01154   ewB->setDb(db_inv);
01155 }

Here is the call graph for this function:

void EWPolicy::detectBr int   ) 
 

Definition at line 1157 of file ew.cc.

References detectBr().

01157                                   {
01158   detectBr(dt_inv, dt_inv);
01159 }

Here is the call graph for this function:

void EWPolicy::detectBr  ) 
 

Definition at line 1161 of file ew.cc.

References EW_DB_INV, and EW_DT_INV.

Referenced by edgeQueue::command(), and detectBr().

01161                         {
01162   detectBr(EW_DT_INV, EW_DB_INV);
01163 }

void EWPolicy::detectPr int  ,
int 
 

Definition at line 1133 of file ew.cc.

References ewP, qdst, qsrc, EWdetector::setDb(), EWdetector::setDt(), and EWdetector::setLink().

01133                                               {
01134   ewP = new EWdetectorP;
01135   ewP->setLink(qsrc, qdst);
01136   ewP->setDt(dt_inv);
01137   ewP->setDb(db_inv);
01138 }

Here is the call graph for this function:

void EWPolicy::detectPr int   ) 
 

Definition at line 1140 of file ew.cc.

References detectPr().

01140                                   {
01141   detectPr(dt_inv, dt_inv);
01142 }

Here is the call graph for this function:

void EWPolicy::detectPr  ) 
 

Definition at line 1144 of file ew.cc.

References EW_DB_INV, and EW_DT_INV.

Referenced by edgeQueue::command(), and detectPr().

01144                         {
01145   detectPr(EW_DT_INV, EW_DB_INV);
01146 }

int EWPolicy::dropPacket Packet  ) 
 

Definition at line 1068 of file ew.cc.

References hdr_tcp::access(), TBrateLimitor::adjustRate(), TBrateLimitor::adjustScore(), alarm, cewB, change, detect(), ewP, hdr_tcp::flags(), EWdetectorP::getRate(), pre_alarm, TBrateLimitor::resetScore(), rlP, TBrateLimitor::run(), TBrateLimitor::setRate(), and TH_SYN.

Referenced by applyPolicer().

01068                                     {
01069   // 1. arrival stats is measured in meter (departure and drops here)
01070   // 2. No penalty to response traffic!!
01071   // 3. need to protect existing connections
01072 
01073   // pass EW if there is any
01074   if (cewB && ewP) {
01075     // protecting existing connections
01076     //  drop requests for new connection (SYN packet)
01077     //    if (cewB->exFlow(pkt))
01078     hdr_tcp *tcph = hdr_tcp::access(pkt);
01079     // Protecting non-SYN packets: existing connections
01080     if ((tcph->flags() & TH_SYN) == 0) {
01081       //return(0);
01082     }
01083 
01084     // Check alarm
01085     detect(pkt);
01086 
01087     if (change) {
01088       // for new incoming requests:
01089       //   use EW measurement to adjust the rate limit (to current Rq)
01090       // see if the alarm should be reset
01091       
01092       if (pre_alarm) {
01093         if (alarm) {
01094           // The rate is not right:
01095           //   too low: too few connection admitted;
01096           //   too high: congestion in response
01097           // Adjustment is needed.
01098           if (rlP)
01099             rlP->adjustRate();
01100         } else {
01101           // the current rate is ok, award the current choice
01102           if (rlP)
01103             rlP->adjustScore(1);
01104         }
01105       } else {
01106         if (alarm) {
01107           if (rlP) {
01108             // Start a new round
01109             rlP->resetScore();
01110             // Use current request rate as the rate limit
01111             rlP->setRate(ewP->getRate());
01112           }
01113         } else {
01114           // the current rate is ok
01115         }
01116       }    
01117       
01118       change = 0;
01119     }  
01120   }
01121 
01122   // Passing rate limitor if there is any
01123   if (rlP) {
01124     // rate limiting
01125     return(rlP->run(1));
01126   };
01127   
01128   // through by default
01129   return(0);
01130 }

Here is the call graph for this function:

void EWPolicy::init int  ,
int  ,
int 
 

Definition at line 970 of file ew.cc.

References ew_adj, qdst, and qsrc.

00970                                              {
00971   ew_adj = adj;
00972   qsrc = src;
00973   qdst = dst;
00974 }

void EWPolicy::limitBr double   ) 
 

Definition at line 1172 of file ew.cc.

References rlB.

01172                                   {
01173   //printf("BR %d\n", rate);
01174   rlB = new TBrateLimitor(rate);
01175 };

void EWPolicy::limitBr  ) 
 

Definition at line 1183 of file ew.cc.

References DEFAULT_TB_RATE_B.

Referenced by edgeQueue::command().

01183                        {
01184   limitBr(DEFAULT_TB_RATE_B);
01185 };

void EWPolicy::limitPr double   ) 
 

Definition at line 1166 of file ew.cc.

References rlP.

01166                                   {
01167   //printf("PR %d\n", rate);
01168   rlP = new TBrateLimitor(rate);
01169 };

void EWPolicy::limitPr  ) 
 

Definition at line 1178 of file ew.cc.

References DEFAULT_TB_RATE_P.

Referenced by edgeQueue::command(), and coupleEW().

01178                        {
01179   limitPr(DEFAULT_TB_RATE_P);
01180 };


Member Data Documentation

int EWPolicy::alarm [private]
 

Definition at line 390 of file ew.h.

Referenced by detect(), dropPacket(), and EWPolicy().

EWdetectorB * EWPolicy::cewB
 

Definition at line 374 of file ew.h.

Referenced by coupleEW(), detect(), dropPacket(), EWPolicy(), and ~EWPolicy().

EWdetectorP * EWPolicy::cewP
 

Definition at line 375 of file ew.h.

Referenced by EWPolicy(), and ~EWPolicy().

int EWPolicy::change [private]
 

Definition at line 391 of file ew.h.

Referenced by detect(), dropPacket(), and EWPolicy().

int EWPolicy::ew_adj [private]
 

Definition at line 384 of file ew.h.

Referenced by detectBr(), and init().

EWdetectorB* EWPolicy::ewB
 

Definition at line 374 of file ew.h.

Referenced by applyPolicer(), coupleEW(), detectBr(), EWPolicy(), and ~EWPolicy().

EWdetectorP* EWPolicy::ewP
 

Definition at line 375 of file ew.h.

Referenced by applyPolicer(), detect(), detectPr(), dropPacket(), EWPolicy(), and ~EWPolicy().

int EWPolicy::max_b [private]
 

Definition at line 387 of file ew.h.

Referenced by EWPolicy().

int EWPolicy::max_p [private]
 

Definition at line 387 of file ew.h.

Referenced by EWPolicy().

double EWPolicy::now [private]
 

Definition at line 381 of file ew.h.

Referenced by applyPolicer().

int EWPolicy::pre_alarm [private]
 

Definition at line 390 of file ew.h.

Referenced by detect(), dropPacket(), and EWPolicy().

int EWPolicy::qdst [private]
 

Definition at line 384 of file ew.h.

Referenced by detectBr(), detectPr(), and init().

int EWPolicy::qsrc [private]
 

Definition at line 384 of file ew.h.

Referenced by detectBr(), detectPr(), and init().

TBrateLimitor * EWPolicy::rlB
 

Definition at line 377 of file ew.h.

Referenced by EWPolicy(), and limitBr().

TBrateLimitor* EWPolicy::rlP
 

Definition at line 377 of file ew.h.

Referenced by dropPacket(), EWPolicy(), and limitPr().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:46:13 2004 for NS2.26SourcesOriginal by doxygen 1.3.3