ns-allinone-2.35/ns-2.35/diffserv/ew.cc
void EWdetectorB::ravgSWin() {
  struct SWinEntry *p;
  float sum = 0;
  float t_weight = 0;

  //printf("Calculate running average over the sliding window:\n");
  p = swin.head;
  //printf("after p\n");

  while (p) {
    //printSWinEntry(p, i++);
    sum += p->rate * p->weight;
    t_weight += p->weight;
    p = p->next;
  }
  p = NULL;
  //printf("\n");  

  swin.ravg = (int)(sum / t_weight);

  //  printf("Ravg: %d\n", swin.ravg);
}
// Calculate the running average over the sliding window
Calculate the running average over the sliding window
Calculate the running average over the sliding window
void EWdetectorB::ravgSWin() {
  struct SWinEntry *p;
  float sum = 0;
  float t_weight = 0;
  p = swin.head;
  while (p) {
    sum += p->rate * p->weight;
    t_weight += p->weight;
    p = p->next;
  }
  p = NULL;
  swin.ravg = (int)(sum / t_weight);
}
void EWdetectorB :: ravgSWin ( ) { struct SWinEntry * p ; float sum = 0 ; float t_weight = 0 ; p = swin . head ; while ( p ) { sum += p -> rate * p -> weight ; t_weight += p -> weight ; p = p -> next ; } p = NULL ; swin . ravg = ( int ) ( sum / t_weight ) ; }
Calculate the running average over the sliding window
Calculate the running average over the sliding window
//printf("Calculate running average over the sliding window:\n"); //printf("after p\n"); //printSWinEntry(p, i++); //printf("\n");   //  printf("Ravg: %d\n", swin.ravg);