void WifiLinkImpl::refresh_decay_bandwidths()
{
// Compute number of STAtion on the Access Point
- size_t nSTA = get_host_count();
+ const auto nSTA_minus_1 = static_cast<double>(get_host_count() - 1);
std::vector<Metric> new_bandwidths;
for (auto const& bandwidth : bandwidths_) {
double N0 = max_bw - min_bw;
double lambda = (-log(model_rate - min_bw) + log(N0)) / model_n_;
// Since decay model start at 0 we should use (nSTA-1)
- double new_peak = N0 * exp(-lambda * (nSTA - 1)) + min_bw;
+ double new_peak = N0 * exp(-lambda * nSTA_minus_1) + min_bw;
new_bandwidths.push_back({new_peak, 1.0, nullptr});
}
decay_bandwidths_ = new_bandwidths;
dur_idle_ += duration;
// add IDLE energy usage, as well as beacons consumption since previous update
- eDyn_ += duration * control_duration_ * wifi_link->get_host_count() * pRx_;
- eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (wifi_link->get_host_count() + 1);
+ const auto host_count = static_cast<double>(wifi_link->get_host_count());
+ eDyn_ += duration * control_duration_ * host_count * pRx_;
+ eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (host_count + 1);
- XBT_DEBUG("finish eStat_ += %f * %f * (%zu+1) | eStat = %f", duration, pIdle_, wifi_link->get_host_count(), eStat_);
+ XBT_DEBUG("finish eStat_ += %f * %f * (%f+1) | eStat = %f", duration, pIdle_, host_count, eStat_);
}
void LinkEnergyWifi::update()
XBT_DEBUG("durUsage: %f", durUsage);
// beacons cost
- eDyn_ += duration * control_duration_ * wifi_link->get_host_count() * pRx_;
+ const auto host_count = static_cast<double>(wifi_link->get_host_count());
+ eDyn_ += duration * control_duration_ * host_count * pRx_;
/**
* Same principle as ns3:
* P_{tot} = P_{dyn}+P_{stat}
*/
if (link_->get_usage() != 0.0) {
- eDyn_ += /*duration * */ durUsage * ((wifi_link->get_host_count() * pRx_) + pTx_);
- eStat_ += (duration - durUsage) * pIdle_ * (wifi_link->get_host_count() + 1);
- XBT_DEBUG("eDyn += %f * ((%zu * %f) + %f) | eDyn = %f (durusage =%f)", durUsage, wifi_link->get_host_count(), pRx_,
- pTx_, eDyn_, durUsage);
+ eDyn_ += /*duration * */ durUsage * ((host_count * pRx_) + pTx_);
+ eStat_ += (duration - durUsage) * pIdle_ * (host_count + 1);
+ XBT_DEBUG("eDyn += %f * ((%f * %f) + %f) | eDyn = %f (durusage =%f)", durUsage, host_count, pRx_, pTx_, eDyn_,
+ durUsage);
dur_TxRx_ += duration;
} else {
dur_idle_ += duration;
- eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (wifi_link->get_host_count() + 1);
+ eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (host_count + 1);
}
- XBT_DEBUG("eStat_ += %f * %f * (%zu+1) | eStat = %f", duration, pIdle_, wifi_link->get_host_count(), eStat_);
+ XBT_DEBUG("eStat_ += %f * %f * (%f+1) | eStat = %f", duration, pIdle_, host_count, eStat_);
}
void LinkEnergyWifi::init_watts_range_list()