ns-allinone-2.35/ns-2.35/diffserv/ew.cc
void EWdetectorB::computeDropP() {
  double p = 0;

  if (alarm) {
    // Compute the dropping probability as a linear function of current rate
    //  p is computed towards the current measurement.
    p = 1;
    if (cur_rate)
      p = (avg_rate - cur_rate) * adjustor / cur_rate;
    
    // p could be greater than 1
    if (p > 1)
      p = 1;
    // p could also be negative
    if (p < 0)
      p = 0;
    
    // Compute the actual drop probability
    drop_p = ALPHA * drop_p + (1 - ALPHA) * p;    
    // adjust drop_p
    if (drop_p < EW_MIN_DROP_P)
      drop_p = EW_MIN_DROP_P;
    if (drop_p > EW_MAX_DROP_P)
      drop_p = EW_MAX_DROP_P;
  } else {
    // Fade out the drop_p when no alarm
    if (drop_p > 0) {
      if (drop_p <= EW_MIN_DROP_P)
        drop_p = 0;
      else {
        drop_p = ALPHA * drop_p;
      }
    }
  }
}
// Determine the dropping probability based on current measurement
Determine the dropping probability based on current measurement
Determine the dropping probability based on current measurement
void EWdetectorB::computeDropP() {
  double p = 0;
  if (alarm) {
    p = 1;
    if (cur_rate)
      p = (avg_rate - cur_rate) * adjustor / cur_rate;
    if (p > 1)
      p = 1;
    if (p < 0)
      p = 0;
    drop_p = ALPHA * drop_p + (1 - ALPHA) * p;    
    if (drop_p < EW_MIN_DROP_P)
      drop_p = EW_MIN_DROP_P;
    if (drop_p > EW_MAX_DROP_P)
      drop_p = EW_MAX_DROP_P;
  } else {
    if (drop_p > 0) {
      if (drop_p <= EW_MIN_DROP_P)
        drop_p = 0;
      else {
        drop_p = ALPHA * drop_p;
      }
    }
  }
}
void EWdetectorB :: computeDropP ( ) { double p = 0 ; if ( alarm ) { p = 1 ; if ( cur_rate ) p = ( avg_rate - cur_rate ) * adjustor / cur_rate ; if ( p > 1 ) p = 1 ; if ( p < 0 ) p = 0 ; drop_p = ALPHA * drop_p + ( 1 - ALPHA ) * p ; if ( drop_p < EW_MIN_DROP_P ) drop_p = EW_MIN_DROP_P ; if ( drop_p > EW_MAX_DROP_P ) drop_p = EW_MAX_DROP_P ; } else { if ( drop_p > 0 ) { if ( drop_p <= EW_MIN_DROP_P ) drop_p = 0 ; else { drop_p = ALPHA * drop_p ; } } } }
Determine the dropping probability based on current measurement
Determine the dropping probability based on current measurement
// Compute the dropping probability as a linear function of current rate //  p is computed towards the current measurement. // p could be greater than 1 // p could also be negative // Compute the actual drop probability // adjust drop_p // Fade out the drop_p when no alarm