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

EWdetectorP Class Reference

#include <ew.h>

Inheritance diagram for EWdetectorP:

Inheritance graph
[legend]
Collaboration diagram for EWdetectorP:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EWdetectorP ()
virtual ~EWdetectorP ()
void updateStats (int)
double getRate ()
void setDb (int)
void setDt (int)
void setLink (int, int)
void setAlarm ()
void resetAlarm ()
int testAlarm ()
void setChange ()
void resetChange ()
void run (Packet *)

Public Attributes

int ew_src
int ew_dst
double now
int db_timer
int dt_timer
int dt_inv
int db_inv
double cur_rate
double avg_rate
int alarm
int change
HLF hlf

Private Member Functions

void measure (Packet *)
void detect ()
void updateCur ()
void updateAvg ()
void trace ()

Private Attributes

PktRec cur_p
PktRec last_p
PktRec last_p_db

Constructor & Destructor Documentation

EWdetectorP::EWdetectorP  ) 
 

Definition at line 851 of file ew.cc.

References PktRec::arrival, cur_p, PktRec::dept, PktRec::drop, last_p, and last_p_db.

00851                          : EWdetector() {
00852   // Packet stats
00853   cur_p.arrival = cur_p.dept = cur_p.drop = 0;
00854   last_p.arrival = last_p.dept = last_p.drop = 0;
00855   last_p_db.arrival = last_p_db.dept = last_p_db.drop = 0;
00856 }

EWdetectorP::~EWdetectorP  )  [virtual]
 

Definition at line 858 of file ew.cc.

References PktRec::arrival, cur_p, PktRec::dept, PktRec::drop, and last_p.

00858                          {
00859   // Packet stats
00860   cur_p.arrival = cur_p.dept = cur_p.drop = 0;
00861   last_p.arrival = last_p.dept = last_p.drop = 0;
00862 }


Member Function Documentation

void EWdetectorP::detect  )  [private, virtual]
 

Implements EWdetector.

Definition at line 891 of file ew.cc.

References EWdetector::alarm, EWdetector::avg_rate, EWdetector::cur_rate, EW_DETECT_RANGE, EWdetector::resetAlarm(), and EWdetector::setAlarm().

00891                          {
00892   if (cur_rate > avg_rate * (1 + EW_DETECT_RANGE)) {
00893     if (!alarm) {
00894       setAlarm();
00895     }
00896   } else if (cur_rate < avg_rate * (1 - EW_DETECT_RANGE)) {
00897     if (alarm)
00898       resetAlarm();
00899   }
00900 }

Here is the call graph for this function:

double EWdetectorP::getRate  ) 
 

Definition at line 865 of file ew.cc.

References EWdetector::cur_rate.

Referenced by EWPolicy::dropPacket().

00865                             {
00866   return(cur_rate);
00867 }

void EWdetectorP::measure Packet  )  [private, virtual]
 

Implements EWdetector.

Definition at line 919 of file ew.cc.

00919                                      {
00920   
00921 
00922   // stats on packet departure and drop are collect in policer 
00923 }

void EWdetector::resetAlarm  )  [inherited]
 

Definition at line 213 of file ew.cc.

References EWdetector::alarm, EWdetector::avg_rate, EWdetector::hlf, and HLF::reset().

Referenced by detect(), EWdetectorB::detect(), and EWdetector::EWdetector().

00213                             {
00214   alarm = 0;
00215 
00216   // Reset low and high gain filters' input values to the long-term avg
00217   // Actually, there is no change to low gain filter
00218   hlf.reset(avg_rate);
00219 };

Here is the call graph for this function:

void EWdetector::resetChange  )  [inherited]
 

Definition at line 226 of file ew.cc.

References EWdetector::change.

Referenced by EWPolicy::detect(), and EWdetector::EWdetector().

00226                              {
00227   change = 0;
00228 }

void EWdetector::run Packet  )  [inherited]
 

Definition at line 261 of file ew.cc.

References EWdetector::change, Scheduler::clock(), EWdetector::db_inv, EWdetector::db_timer, EWdetector::detect(), EWdetector::dt_inv, EWdetector::dt_timer, Scheduler::instance(), EWdetector::measure(), EWdetector::now, EWdetector::trace(), EWdetector::updateAvg(), and EWdetector::updateCur().

Referenced by EWPolicy::applyPolicer().

00261                                 {
00262   // get the time
00263   now = Scheduler::instance().clock();
00264   
00265   //printf("EW[%d:%d] run ", ew_src, ew_dst);
00266   // update the measurement 
00267   measure(pkt);
00268 
00269   // There is a timeout!
00270   if (now >= dt_timer) {
00271     // Start detection
00272     //printf("Detection timeout(%d)\n", (int)now);
00273     
00274     // 1. Update the current rate from measurement
00275     updateCur();
00276 
00277     // 2. Detect change and Trigger alarm if necessary
00278     // Compare the current rate with the long term average
00279     detect();
00280     
00281     // 3. Update the long term averages
00282     updateAvg();
00283 
00284     // setup the sleeping timer
00285     dt_timer = (int)now + dt_inv;
00286     //printf("%d\n", dt_inv);
00287 
00288     change = 1;
00289   }
00290   
00291   // Schedule debug
00292   if (db_inv && now >= db_timer) {
00293     //printf("debugB ");
00294     trace();
00295     db_timer = (int)now + db_inv;
00296   }
00297 }

Here is the call graph for this function:

void EWdetector::setAlarm  )  [inherited]
 

Definition at line 205 of file ew.cc.

References EWdetector::alarm, EWdetector::avg_rate, EWdetector::hlf, and HLF::reset().

Referenced by detect(), and EWdetectorB::detect().

00205                           {
00206   alarm = 1;
00207 
00208   // Reset low and high gain filters' input values to the long-term avg
00209   // Actually, there is no change to high gain filter
00210   hlf.reset(avg_rate);
00211 };

Here is the call graph for this function:

void EWdetector::setChange  )  [inherited]
 

Definition at line 222 of file ew.cc.

References EWdetector::change.

00222                            {
00223   change = 1;
00224 }

void EWdetector::setDb int   )  [inherited]
 

Definition at line 194 of file ew.cc.

References EWdetector::db_inv.

Referenced by EWPolicy::detectBr(), and EWPolicy::detectPr().

00194                               {
00195   db_inv = inv;
00196   //printf("DB: %d\n", db_inv);
00197 };

void EWdetector::setDt int   )  [inherited]
 

Definition at line 190 of file ew.cc.

References EWdetector::dt_inv.

Referenced by EWPolicy::detectBr(), and EWPolicy::detectPr().

00190                               {
00191   dt_inv = inv;
00192   //printf("DT: %d\n", dt_inv);
00193 };

void EWdetector::setLink int  ,
int 
[inherited]
 

Definition at line 199 of file ew.cc.

References EWdetector::ew_dst, and EWdetector::ew_src.

Referenced by EWPolicy::detectBr(), and EWPolicy::detectPr().

00199                                          {
00200   ew_src = src;
00201   ew_dst = dst;
00202   //printf("EW: (%d:%d)\n", ew_src, ew_dst);
00203 };

int EWdetector::testAlarm  )  [inherited]
 

Definition at line 231 of file ew.cc.

References EWdetector::alarm, EWdetector::change, and EW_UNCHANGE.

Referenced by EWPolicy::detect().

00231                           {
00232   if (!change)
00233     return(EW_UNCHANGE);
00234   else 
00235     return(alarm);
00236 }

void EWdetectorP::trace  )  [private, virtual]
 

Implements EWdetector.

Definition at line 926 of file ew.cc.

References EWdetector::alarm, PktRec::arrival, EWdetector::avg_rate, cur_p, EWdetector::cur_rate, PktRec::dept, PktRec::drop, last_p_db, and EWdetector::now.

00926                         {
00927   printf("P %d %.2f %.2f %d %d %d %d %d %d %d\n", 
00928          (int)now, cur_rate, avg_rate, alarm,
00929          cur_p.arrival - last_p_db.arrival,
00930          cur_p.dept - last_p_db.dept,
00931          cur_p.drop - last_p_db.drop,  
00932          cur_p.arrival, cur_p.dept, cur_p.drop);
00933 
00934   last_p_db.arrival = cur_p.arrival;
00935   last_p_db.dept = cur_p.dept;
00936   last_p_db.drop = cur_p.drop;
00937 }

void EWdetectorP::updateAvg  )  [private]
 

Reimplemented from EWdetector.

void EWdetectorP::updateCur  )  [private, virtual]
 

Implements EWdetector.

Definition at line 903 of file ew.cc.

References PktRec::arrival, cur_p, EWdetector::cur_rate, PktRec::dept, PktRec::drop, EWdetector::dt_inv, and last_p.

00903                             {
00904   // measure the accepted packet rate (rather than arrival rate)
00905   cur_rate = (cur_p.dept - last_p.dept) / dt_inv;
00906 
00907   // keep the current value
00908   last_p.arrival = cur_p.arrival;
00909   last_p.dept = cur_p.dept;
00910   last_p.drop = cur_p.drop;
00911 }

void EWdetectorP::updateStats int   ) 
 

Definition at line 870 of file ew.cc.

References PktRec::arrival, cur_p, PktRec::dept, PktRec::drop, PKT_ARRIVAL, PKT_DEPT, and PKT_DROP.

Referenced by EWPolicy::applyPolicer().

00870                                       {
00871   // Packet arrival
00872   if (flag == PKT_ARRIVAL) {
00873     cur_p.arrival++;
00874     return;
00875   }
00876 
00877   // Packet departure
00878   if (flag == PKT_DEPT) {
00879     cur_p.dept++;
00880     return;
00881   }
00882 
00883   // Packet dropped
00884   if (flag == PKT_DROP) {
00885     cur_p.drop++;
00886     return;
00887   }
00888 }


Member Data Documentation

int EWdetector::alarm [inherited]
 

Definition at line 201 of file ew.h.

Referenced by EWdetectorB::computeDropP(), detect(), EWdetectorB::detect(), EWdetector::resetAlarm(), EWdetector::setAlarm(), EWdetector::testAlarm(), trace(), EWdetectorB::trace(), and EWdetector::updateAvg().

double EWdetector::avg_rate [inherited]
 

Definition at line 198 of file ew.h.

Referenced by EWdetectorB::computeDropP(), detect(), EWdetectorB::detect(), EWdetector::EWdetector(), EWdetector::resetAlarm(), EWdetector::setAlarm(), trace(), EWdetectorB::trace(), and EWdetector::updateAvg().

int EWdetector::change [inherited]
 

Definition at line 203 of file ew.h.

Referenced by EWdetector::resetChange(), EWdetector::run(), EWdetector::setChange(), and EWdetector::testAlarm().

PktRec EWdetectorP::cur_p [private]
 

Definition at line 236 of file ew.h.

Referenced by EWdetectorP(), trace(), updateCur(), updateStats(), and ~EWdetectorP().

double EWdetector::cur_rate [inherited]
 

Definition at line 198 of file ew.h.

Referenced by EWdetectorB::computeDropP(), detect(), EWdetectorB::detect(), EWdetector::EWdetector(), getRate(), trace(), EWdetectorB::trace(), EWdetector::updateAvg(), updateCur(), and EWdetectorB::updateCur().

int EWdetector::db_inv [inherited]
 

Definition at line 195 of file ew.h.

Referenced by EWdetector::run(), and EWdetector::setDb().

int EWdetector::db_timer [inherited]
 

Definition at line 193 of file ew.h.

Referenced by EWdetector::EWdetector(), and EWdetector::run().

int EWdetector::dt_inv [inherited]
 

Definition at line 195 of file ew.h.

Referenced by EWdetector::run(), EWdetector::setDt(), EWdetectorB::timeoutAList(), and updateCur().

int EWdetector::dt_timer [inherited]
 

Definition at line 193 of file ew.h.

Referenced by EWdetector::EWdetector(), and EWdetector::run().

int EWdetector::ew_dst [inherited]
 

Definition at line 187 of file ew.h.

Referenced by EWdetector::EWdetector(), and EWdetector::setLink().

int EWdetector::ew_src [inherited]
 

Definition at line 187 of file ew.h.

Referenced by EWdetector::EWdetector(), and EWdetector::setLink().

HLF EWdetector::hlf [inherited]
 

Definition at line 206 of file ew.h.

Referenced by EWdetector::EWdetector(), EWdetector::resetAlarm(), EWdetector::setAlarm(), and EWdetector::updateAvg().

PktRec EWdetectorP::last_p [private]
 

Definition at line 236 of file ew.h.

Referenced by EWdetectorP(), updateCur(), and ~EWdetectorP().

PktRec EWdetectorP::last_p_db [private]
 

Definition at line 236 of file ew.h.

Referenced by EWdetectorP(), and trace().

double EWdetector::now [inherited]
 

Definition at line 190 of file ew.h.

Referenced by EWdetectorB::newAListEntry(), EWdetectorB::printAList(), EWdetectorB::printSWin(), EWdetector::run(), EWdetectorB::timeoutAList(), trace(), EWdetectorB::trace(), and EWdetectorB::updateAList().


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