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

EWdetectorB Class Reference

#include <ew.h>

Inheritance diagram for EWdetectorB:

Inheritance graph
[legend]
Collaboration diagram for EWdetectorB:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EWdetectorB ()
virtual ~EWdetectorB ()
void init (int)
int exFlow (Packet *)
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 updateCur ()
void updateAvg ()
void detect ()
void updateAList (Packet *)
AListEntrygetMaxAList ()
void sortAList ()
void timeoutAList ()
AListEntrysearchAList (int, int, int)
AListEntrynewAListEntry (int, int, int)
int getMedianAList (int, int)
int getRateAList (int)
void resetAList ()
void printAListEntry (struct AListEntry *, int)
void printAList ()
int computeARR ()
void computeDropP ()
void decSInv ()
void incSInv ()
void trace ()
void updateSWin (int)
void ravgSWin ()
void resetSWin ()
void printSWin ()
void printSWinEntry (struct SWinEntry *, int)

Private Attributes

float adjustor
float drop_p
int arr_count
AList alist
SWin swin

Constructor & Destructor Documentation

EWdetectorB::EWdetectorB  ) 
 

Definition at line 303 of file ew.cc.

References adjustor, alist, arr_count, SWin::count, AList::count, drop_p, SWin::head, AList::head, SWin::ravg, swin, SWin::tail, and AList::tail.

00303                          : EWdetector() {
00304   drop_p = 0;
00305   arr_count = 0;
00306 
00307   adjustor = 1.0;
00308 
00309   // Initialize ALIST
00310   alist.head = alist.tail = NULL;
00311   alist.count = 0;
00312 
00313   swin.head = swin.tail = NULL;
00314   swin.count = swin.ravg = 0;
00315 }

EWdetectorB::~EWdetectorB  )  [virtual]
 

Definition at line 318 of file ew.cc.

References resetAList(), and resetSWin().

00318                          {
00319   resetAList();
00320   resetSWin();
00321 }

Here is the call graph for this function:


Member Function Documentation

int EWdetectorB::computeARR  )  [private]
 

Definition at line 423 of file ew.cc.

References alist, arr_count, AList::count, getRateAList(), sortAList(), and timeoutAList().

Referenced by trace(), and updateCur().

00423                             {
00424   int i, agg_rate;
00425 
00426   // Explicit garbage collection first 
00427   //  before both choosing HBFs and searching AList
00428   //printf("before timeout ");
00429   timeoutAList();
00430   //printf("after timeout ");
00431 
00432   // do nothing if no entry exists
00433   if (!alist.count) 
00434     return 0;
00435 
00436   // Pick the 10% highest bandwidth flows
00437   arr_count = (int) (alist.count * 0.1 + 1);
00438 
00439   // Sort AList first
00440   sortAList();
00441 
00442   // Calculate the ARR for HBFs
00443   // Use mean
00444   agg_rate = 0;
00445   for (i = 0; i < arr_count; i++) {
00446     agg_rate += getRateAList(i);
00447   }
00448   
00449   if (i)
00450     agg_rate = (int) (agg_rate / i);
00451   else {
00452     printf("No MAX returned from ALIST!!!\n");
00453   }
00454   
00455   // Use median (the median for the list or median for HBFs?)
00456   //agg_rate = getMedianAList(0, k);
00457   //printf("%f %d %d %d\n", now, k, agg_rate, getMedianAList(0, k));
00458   
00459   return(agg_rate);
00460 }

Here is the call graph for this function:

void EWdetectorB::computeDropP  )  [private]
 

Definition at line 732 of file ew.cc.

References adjustor, EWdetector::alarm, EWdetector::avg_rate, EWdetector::cur_rate, drop_p, EW_FADING_FACTOR, EW_MAX_DROP_P, and EW_MIN_DROP_P.

00732                                {
00733   double p = 0;
00734 
00735   if (alarm) {
00736     // Compute the dropping probability as a linear function of current rate
00737     //  p is computed towards the current measurement.
00738     p = 1;
00739     if (cur_rate)
00740       p = (avg_rate - cur_rate) * adjustor / cur_rate;
00741     
00742     // p could be greater than 1
00743     if (p > 1)
00744       p = 1;
00745     // p could also be negative
00746     if (p < 0)
00747       p = 0;
00748     
00749     // Compute the actual drop probability
00750     drop_p = EW_FADING_FACTOR * drop_p + (1 - EW_FADING_FACTOR) * p;    
00751     // adjust drop_p
00752     if (drop_p < EW_MIN_DROP_P)
00753       drop_p = EW_MIN_DROP_P;
00754     if (drop_p > EW_MAX_DROP_P)
00755       drop_p = EW_MAX_DROP_P;
00756   } else {
00757     // Fade out the drop_p when no alarm
00758     if (drop_p > 0) {
00759       if (drop_p <= EW_MIN_DROP_P)
00760         drop_p = 0;
00761       else {
00762         drop_p = EW_FADING_FACTOR * drop_p;
00763       }
00764     }
00765   }
00766 }

void EWdetectorB::decSInv  )  [private]
 

Definition at line 769 of file ew.cc.

00769                           {
00770   // Need some investigation for the min allowed detection interval
00771   //  if (s_inv / 2 > EW_MIN_SAMPLE_INTERVAL) {
00772   // s_inv = s_inv / 2;
00773     
00774     //printf("SINV decreased by 2.\n");
00775   //}
00776 }

void EWdetectorB::detect  )  [private, virtual]
 

Implements EWdetector.

Definition at line 703 of file ew.cc.

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

00703                          {
00704   // When ALARM:
00705   //  detect if it is the time to release the alarm
00706   // When NO ALARM:
00707   //  detect if it is the time to trigger the alarm
00708   if (alarm) {
00709     // Determine if an alarm should be released
00710     if (cur_rate > avg_rate * (1 + EW_DETECT_RANGE)) {
00711       // reset alarm
00712       resetAlarm();
00713     } 
00714   } else {
00715     // Determine if an alarm should be triggered
00716     //   need to be conservative!
00717     if (cur_rate < avg_rate) {
00718       setAlarm();
00719       
00720       // Initial drop_p to the MAX value whenever alarm triggered
00721       if (drop_p < EW_MAX_DROP_P)
00722         drop_p = EW_MAX_DROP_P;
00723     } else {
00724     }
00725   }
00726   
00727   // Determine the dropping probability
00728   //computeDropP();
00729 }

Here is the call graph for this function:

int EWdetectorB::exFlow Packet  ) 
 

Definition at line 345 of file ew.cc.

00345                                    {
00346   // Should check SYN packets to protect existing connections
00347   //   need to use FullTCP
00348   return(0);
00349 }

struct AListEntry * EWdetectorB::getMaxAList  )  [private]
 

Definition at line 513 of file ew.cc.

References alist, AList::head, and max.

Referenced by sortAList().

00513                                              {
00514   struct AListEntry *p, *pp, *max, *pm;
00515 
00516   //printAList();
00517   // find the max entry and remove
00518   p = pp = alist.head;
00519   max = pm = p;
00520   
00521   while (p) {
00522     if (p->avg_rate > max->avg_rate) {
00523       pm = pp;
00524       max = p;
00525     }
00526     
00527     pp = p;
00528     p = p->next;
00529   }
00530   
00531   // remove max from AList
00532   if (alist.head == max)
00533     alist.head = max->next;
00534   
00535   if (pm != max)
00536     pm->next = max->next;
00537   
00538   max->next = NULL;
00539   //printAList();
00540 
00541   return(max);
00542 }

int EWdetectorB::getMedianAList int  ,
int 
[private]
 

Definition at line 386 of file ew.cc.

References getRateAList(), and sortAList().

Referenced by trace().

00386                                                     {
00387   int m;
00388   
00389   if (!count)
00390     return 0;
00391 
00392   sortAList();
00393   //printAList();
00394 
00395   // Pick the entry with median avg_rate
00396   m = (int) (count / 2);
00397   if (2 * m == count) {
00398     return((getRateAList(index + m - 1) + getRateAList(index + m)) / 2);
00399   } else {
00400     return(getRateAList(index + m));
00401   }
00402 }

Here is the call graph for this function:

int EWdetectorB::getRateAList int   )  [private]
 

Definition at line 405 of file ew.cc.

References alist, AList::head, and AListEntry::next.

Referenced by computeARR(), and getMedianAList().

00405                                        {
00406   struct AListEntry *p;
00407 
00408   //printf("%d\n", index);
00409   p = alist.head;
00410   for (int i = 0; i < index; i++) {
00411     if (p)
00412       p = p->next;
00413   }
00414   
00415   if (p)
00416     return ((int)p->avg_rate);
00417 
00418   printf("Error in AList!\n");
00419   return(0);
00420 }

void EWdetectorB::incSInv  )  [private]
 

Definition at line 779 of file ew.cc.

00779                           {
00780   //if(s_inv * 2 <= init_s_inv) {
00781   //  s_inv = s_inv * 2;
00782   
00783   //printf("SINV increased by 2.\n");
00784   // }
00785 }

void EWdetectorB::init int   ) 
 

Definition at line 324 of file ew.cc.

References adjustor.

Referenced by EWPolicy::detectBr().

00324                                  {
00325   // EW adjustor (g = resp rate / request rate)
00326   adjustor = ew_adj;
00327 }

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

Implements EWdetector.

Definition at line 330 of file ew.cc.

References updateAList().

00330                                      {
00331   //printf(" before UA");
00332   // Conduct detection continously
00333   updateAList(pkt);
00334   //printf(" after UA");
00335 }

Here is the call graph for this function:

struct AListEntry * EWdetectorB::newAListEntry int  ,
int  ,
int 
[private]
 

Definition at line 484 of file ew.cc.

References alist, AListEntry::avg_rate, AList::count, AListEntry::dst_id, AListEntry::f_id, AList::head, AListEntry::last_update, AListEntry::next, EWdetector::now, AListEntry::src_id, AListEntry::t_front, AList::tail, and AListEntry::win_length.

Referenced by updateAList().

00484                                                                                {
00485   AListEntry *p;
00486 
00487   p = new AListEntry;
00488   p->src_id = src_id;
00489   p->dst_id = dst_id;
00490   p->f_id = f_id;
00491   p->last_update = now;
00492   p->avg_rate = 0;
00493   // Since we are doing random sampling, 
00494   // the t_front should set to the beginning of this period instead of 0.
00495   p->t_front = now;
00496   p->win_length = 1;
00497   p->next = NULL;
00498   
00499   // Add new entry to AList
00500   if (alist.tail)
00501     alist.tail->next = p;
00502   alist.tail = p;
00503   
00504   if (!alist.head)
00505     alist.head = p;
00506   
00507   alist.count++;
00508 
00509   return(p);
00510 }

void EWdetectorB::printAList  )  [private]
 

Definition at line 818 of file ew.cc.

References alist, AList::count, AList::head, EWdetector::now, and printAListEntry().

00818                              {
00819   struct AListEntry *p;
00820   printf("%f AList(%d):\n", now, alist.count);
00821 
00822   p = alist.head;
00823   int i = 0;
00824   while (p) {
00825     printAListEntry(p, i);
00826     i++;
00827     p = p->next;
00828   }
00829   p = NULL;
00830   printf("\n");
00831 }

Here is the call graph for this function:

void EWdetectorB::printAListEntry struct AListEntry ,
int 
[private]
 

Definition at line 808 of file ew.cc.

References AListEntry::avg_rate, AListEntry::dst_id, AListEntry::f_id, AListEntry::last_update, and AListEntry::src_id.

Referenced by printAList().

00808                                                              {
00809   if (!p)
00810     return;
00811 
00812   printf("[%d] %d (%d %d) %.2f %.2f\n", i, p->f_id, p->src_id, p->dst_id, 
00813          p->avg_rate, p->last_update);
00814 }

void EWdetectorB::printSWin  )  [private]
 

Definition at line 788 of file ew.cc.

References SWin::count, SWin::head, EWdetector::now, printSWinEntry(), SWin::ravg, and swin.

00788                             {
00789   struct SWinEntry *p;
00790   printf("%f SWIN[%d, %d]", now, swin.ravg, swin.count);
00791   p = swin.head;
00792   int i = 0;
00793   while (p) {
00794     printSWinEntry(p, i++);
00795     p = p->next;
00796   }
00797   p = NULL;
00798   printf("\n");
00799 }

Here is the call graph for this function:

void EWdetectorB::printSWinEntry struct SWinEntry ,
int 
[private]
 

Definition at line 802 of file ew.cc.

References SWinEntry::rate, and SWinEntry::weight.

Referenced by printSWin().

00802                                                            {
00803   if (p)
00804     printf("[%d: %d %.2f] ", i, p->rate, p->weight);
00805 }

void EWdetectorB::ravgSWin  )  [private]
 

Definition at line 677 of file ew.cc.

References SWin::head, SWinEntry::rate, SWin::ravg, and swin.

00677                            {
00678   struct SWinEntry *p;
00679   float sum = 0;
00680   float t_weight = 0;
00681 
00682   //printf("Calculate running average over the sliding window:\n");
00683   p = swin.head;
00684   //printf("after p\n");
00685 
00686   while (p) {
00687     //printSWinEntry(p, i++);
00688     sum += p->rate * p->weight;
00689     t_weight += p->weight;
00690     p = p->next;
00691   }
00692   p = NULL;
00693   //printf("\n");  
00694 
00695   swin.ravg = (int)(sum / t_weight);
00696 
00697   //  printf("Ravg: %d\n", swin.ravg);
00698 }

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 EWdetectorP::detect(), 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 EWdetectorB::resetAList  )  [private]
 

Definition at line 617 of file ew.cc.

References alist, AList::count, AList::head, AListEntry::next, and AList::tail.

Referenced by ~EWdetectorB().

00617                              {
00618   struct AListEntry *ap, *aq;
00619 
00620   ap = aq = alist.head;
00621   while (ap) {
00622     aq = ap;
00623     ap = ap->next;
00624     free(aq);
00625   }
00626   
00627   ap = aq = NULL;
00628   alist.head = alist.tail = NULL;  
00629   alist.count = 0;
00630 }

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 EWdetectorB::resetSWin  )  [private]
 

Definition at line 635 of file ew.cc.

References SWin::count, SWin::head, SWinEntry::next, SWin::ravg, swin, and SWin::tail.

Referenced by ~EWdetectorB().

00635                             {
00636   struct SWinEntry *p, *q;
00637 
00638   p = q = swin.head;
00639   while (p) {
00640     q = p;
00641     p = p->next;
00642     free(q);
00643   }
00644   
00645   p = q = NULL;
00646   swin.head = swin.tail = NULL;  
00647   swin.count = swin.ravg = 0;
00648 }

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:

struct AListEntry * EWdetectorB::searchAList int  ,
int  ,
int 
[private]
 

Definition at line 463 of file ew.cc.

References alist, AListEntry::dst_id, AListEntry::f_id, AList::head, AListEntry::next, AListEntry::src_id, and timeoutAList().

Referenced by updateAList().

00463                                                                             {
00464   AListEntry *p;
00465 
00466   // Explicit garbage collection first.
00467   //printf("before timeout ");
00468   timeoutAList();
00469   //printf("after timeout ");
00470   // Use src and dest pair and flow id:
00471   //   aggregate flows within the same request-response exchange
00472   // Timeout need to be set to a very small value in order to
00473   //   seperate different exchanges.
00474   p = alist.head;
00475   while (p && 
00476          (p->f_id != f_id || p->src_id != src_id || p->dst_id != dst_id)) {
00477     p = p->next;
00478   }
00479   
00480   return(p);
00481 }

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 EWdetectorP::detect(), and 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 };

void EWdetectorB::sortAList  )  [private]
 

Definition at line 545 of file ew.cc.

References alist, getMaxAList(), AList::head, max, and AList::tail.

Referenced by computeARR(), and getMedianAList().

00545                             {
00546   struct AListEntry *max, *head, *tail;
00547   
00548   if (!alist.head)
00549     return;
00550 
00551   //printAList();
00552   head = tail = NULL;
00553 
00554   while (alist.head) {
00555     // Get the entry with the max avg_rate
00556     max = getMaxAList();
00557     //printAListEntry(max, i);
00558     
00559     if (max) {
00560       // Add max to the tail of the new list
00561       if (tail)
00562         tail->next = max;
00563       tail = max;
00564       
00565       if (!head)
00566         head = max;
00567     }
00568   }
00569 
00570   alist.head = head;
00571   alist.tail = tail;
00572 
00573   //printAList();
00574 }

Here is the call graph for this function:

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 EWdetectorB::timeoutAList  )  [private]
 

Definition at line 577 of file ew.cc.

References alist, AList::count, EWdetector::dt_inv, EW_FLOW_TIME_OUT, AList::head, AListEntry::last_update, AListEntry::next, EWdetector::now, and AList::tail.

Referenced by computeARR(), searchAList(), and trace().

00577                                {
00578   AListEntry *p, *q;
00579   float to;
00580 
00581   to = EW_FLOW_TIME_OUT;
00582   if (dt_inv)
00583     to = dt_inv;
00584 
00585   // Expire the old entries in AList
00586   p = q = alist.head;
00587   while (p) {
00588     // Garbage collection
00589     if (p->last_update + to < now){
00590       // The coresponding flow is expired.      
00591       if (p == alist.head){
00592         if (p == alist.tail) {
00593           alist.head = alist.tail = NULL;
00594           free(p);
00595           p = q = NULL;
00596         } else {
00597           alist.head = p->next;
00598           free(p);
00599           p = q = alist.head;
00600         }
00601       } else {
00602         q->next = p->next;
00603         if (p == alist.tail)
00604           alist.tail = q;
00605         free(p);
00606         p = q->next;
00607       }
00608       alist.count--;
00609     } else {
00610       q = p;
00611       p = q->next;
00612     }
00613   }
00614 }

void EWdetectorB::trace  )  [private, virtual]
 

Implements EWdetector.

Definition at line 834 of file ew.cc.

References EWdetector::alarm, alist, arr_count, EWdetector::avg_rate, computeARR(), AList::count, EWdetector::cur_rate, getMedianAList(), EWdetector::now, and timeoutAList().

00834                         {
00835   double db_rate = 0;
00836   double m_rate = 0;
00837 
00838   timeoutAList();
00839   m_rate = getMedianAList(0, alist.count);
00840   //printf("B ");
00841   db_rate = computeARR();
00842 
00843   if (!m_rate || !db_rate);
00844     //printAList();
00845 
00846   printf("B %d %.2f %.2f %d %d %.2f %.2f\n", 
00847          (int)now, cur_rate, avg_rate, arr_count, alarm, db_rate, m_rate);
00848 }

Here is the call graph for this function:

void EWdetectorB::updateAList Packet  )  [private]
 

Definition at line 352 of file ew.cc.

References hdr_ip::access(), hdr_cmn::access(), AListEntry::avg_rate, hdr_ip::daddr(), AListEntry::dst_id, AListEntry::f_id, hdr_ip::flowid(), newAListEntry(), EWdetector::now, hdr_ip::saddr(), searchAList(), hdr_cmn::size(), AListEntry::src_id, AListEntry::t_front, and AListEntry::win_length.

Referenced by measure().

00352                                          {
00353   hdr_cmn* hdr = hdr_cmn::access(pkt);
00354   hdr_ip* iph = hdr_ip::access(pkt);
00355   int dst_id = iph->daddr();
00356   int src_id = iph->saddr();
00357   int f_id = iph->flowid(); 
00358 
00359   // Get the corresponding id.
00360   //printf("EW[%d:%d] in detector\n", ew_src, ew_dst);
00361 
00362   AListEntry *p;
00363   p = searchAList(src_id, dst_id, f_id);
00364 
00365   // Add new entry to AList
00366   // keep the bytes sent by each aggregate in AList
00367   if (!p) {
00368     p = newAListEntry(src_id, dst_id, f_id);
00369   }
00370 
00371   // update the existing (or just created) entry in AList
00372   assert(p && p->f_id == f_id && p->src_id == src_id && p->dst_id == dst_id);
00373 
00374   // update the flow's arrival rate using TSW
00375   double bytesInTSW, newBytes;
00376   bytesInTSW = p->avg_rate * p->win_length;
00377   newBytes = bytesInTSW + (double) hdr->size();
00378   p->avg_rate = newBytes / (now - p->t_front + p->win_length);
00379   p->t_front = now;
00380 
00381   //printAListEntry(p, 0);
00382 }

Here is the call graph for this function:

void EWdetectorB::updateAvg  )  [private]
 

Reimplemented from EWdetector.

void EWdetectorB::updateCur  )  [private, virtual]
 

Implements EWdetector.

Definition at line 338 of file ew.cc.

References computeARR(), and EWdetector::cur_rate.

00338                             {
00339   //printAList();
00340   // Record current aggregated response rate
00341   cur_rate = computeARR();
00342 }

Here is the call graph for this function:

void EWdetectorB::updateSWin int   )  [private]
 

Definition at line 651 of file ew.cc.

References SWin::count, EW_SWIN_SIZE, SWin::head, SWinEntry::next, swin, and SWin::tail.

00651                                      {
00652   struct SWinEntry *p, *new_entry;
00653 
00654   new_entry = new SWinEntry;
00655   new_entry->rate = rate;
00656   new_entry->weight = 1;
00657   new_entry->next = NULL;
00658   
00659   if (swin.tail)
00660     swin.tail->next = new_entry;
00661   swin.tail = new_entry;
00662   
00663   if (!swin.head)
00664     swin.head = new_entry;
00665 
00666   // Reset current rate.
00667   if (swin.count < EW_SWIN_SIZE) {
00668     swin.count++;
00669   } else {
00670     p = swin.head;
00671     swin.head = p->next;
00672     free(p);
00673   }
00674 }


Member Data Documentation

float EWdetectorB::adjustor [private]
 

Definition at line 265 of file ew.h.

Referenced by computeDropP(), EWdetectorB(), and init().

int EWdetector::alarm [inherited]
 

Definition at line 201 of file ew.h.

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

struct AList EWdetectorB::alist [private]
 

Definition at line 271 of file ew.h.

Referenced by computeARR(), EWdetectorB(), getMaxAList(), getRateAList(), newAListEntry(), printAList(), resetAList(), searchAList(), sortAList(), timeoutAList(), and trace().

int EWdetectorB::arr_count [private]
 

Definition at line 268 of file ew.h.

Referenced by computeARR(), EWdetectorB(), and trace().

double EWdetector::avg_rate [inherited]
 

Definition at line 198 of file ew.h.

Referenced by computeDropP(), EWdetectorP::detect(), detect(), EWdetector::EWdetector(), EWdetector::resetAlarm(), EWdetector::setAlarm(), EWdetectorP::trace(), 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().

double EWdetector::cur_rate [inherited]
 

Definition at line 198 of file ew.h.

Referenced by computeDropP(), EWdetectorP::detect(), detect(), EWdetector::EWdetector(), EWdetectorP::getRate(), EWdetectorP::trace(), trace(), EWdetector::updateAvg(), EWdetectorP::updateCur(), and 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().

float EWdetectorB::drop_p [private]
 

Definition at line 266 of file ew.h.

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

int EWdetector::dt_inv [inherited]
 

Definition at line 195 of file ew.h.

Referenced by EWdetector::run(), EWdetector::setDt(), timeoutAList(), and EWdetectorP::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().

double EWdetector::now [inherited]
 

Definition at line 190 of file ew.h.

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

struct SWin EWdetectorB::swin [private]
 

Definition at line 273 of file ew.h.

Referenced by EWdetectorB(), printSWin(), ravgSWin(), resetSWin(), and updateSWin().


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