ns-allinone-2.35/ns-2.35/diffserv/ew.cc
void EWdetectorB::detect() {
  // When ALARM:
  //  detect if it is the time to release the alarm
  // When NO ALARM:
  //  detect if it is the time to trigger the alarm
  if (alarm) {
    // Determine if an alarm should be released
    if (cur_rate > avg_rate * (1 + EW_RELEASE_RANGE)) {
      // reset alarm
      resetAlarm();
    } 
  } else {
    // Determine if an alarm should be triggered
    //   need to be conservative!
    if (cur_rate < avg_rate * (1 - EW_DETECT_RANGE)) {
      setAlarm();
      
      // Initial drop_p to the MAX value whenever alarm triggered
      if (drop_p < EW_MAX_DROP_P)
	drop_p = EW_MAX_DROP_P;
    } else {
    }
  }
  
  // Determine the dropping probability
  //computeDropP();
}
// detect the traffic change by 
// comparing the current measurement with the long-term average
//   trigger alarm if necessary.
detect the traffic change by
comparing the current measurement with the long-term average
trigger alarm if necessary.
detect the traffic change by comparing the current measurement with the long - term average trigger alarm if necessary .
void EWdetectorB::detect() {
  if (alarm) {
    if (cur_rate > avg_rate * (1 + EW_RELEASE_RANGE)) {
      resetAlarm();
    } 
  } else {
    if (cur_rate < avg_rate * (1 - EW_DETECT_RANGE)) {
      setAlarm();
      if (drop_p < EW_MAX_DROP_P)
	drop_p = EW_MAX_DROP_P;
    } else {
    }
  }
}
void EWdetectorB :: detect ( ) { if ( alarm ) { if ( cur_rate > avg_rate * ( 1 + EW_RELEASE_RANGE ) ) { resetAlarm ( ) ; } } else { if ( cur_rate < avg_rate * ( 1 - EW_DETECT_RANGE ) ) { setAlarm ( ) ; if ( drop_p < EW_MAX_DROP_P ) drop_p = EW_MAX_DROP_P ; } else { } } }
detect the traffic change by
comparing the current measurement with the long-term average
trigger alarm if necessary.
detect the traffic change by comparing the current measurement with the long - term average trigger alarm if necessary .
// When ALARM: //  detect if it is the time to release the alarm // When NO ALARM: //  detect if it is the time to trigger the alarm // Determine if an alarm should be released // reset alarm // Determine if an alarm should be triggered //   need to be conservative! // Initial drop_p to the MAX value whenever alarm triggered // Determine the dropping probability //computeDropP();