+ if (action.get_state() != kernel::resource::Action::State::FINISHED)
+ return;
+
+ auto const* actionWifi = dynamic_cast<const simgrid::kernel::resource::WifiLinkAction*>(&action);
+ if (actionWifi == nullptr)
+ return;
+
+ if (auto* link_src = actionWifi->get_src_link()) {
+ link_src->dec_active_flux();
+ }
+ if (auto* link_dst = actionWifi->get_dst_link()) {
+ link_dst->dec_active_flux();
+ }
+}
+
+double WifiLinkImpl::get_max_ratio() const
+{
+ double new_peak;
+ if (nb_active_flux_ > conc_lim_) {
+ new_peak = (nb_active_flux_-conc_lim_) * co_acc_ + x0_;
+ XBT_DEBUG("Wi-Fi link peak=(%d-%d)*%lf+%lf=%lf", nb_active_flux_, conc_lim_, co_acc_, x0_, new_peak);
+ } else {
+ new_peak = x0_;
+ XBT_DEBUG("Wi-Fi link peak=%lf", x0_);
+ }
+ // should be the new maximum bandwidth ratio (comparison between max throughput without concurrency and with it)
+ double propCap = new_peak / x0_;
+
+ return propCap;
+}
+
+bool WifiLinkImpl::toggle_callback()
+{
+ if (not use_callback_) {
+ XBT_DEBUG("Activate throughput reduction mechanism");
+ use_callback_ = true;
+ this->set_sharing_policy(
+ simgrid::s4u::Link::SharingPolicy::WIFI,
+ std::bind(&wifi_link_dynamic_sharing, std::cref(*this), std::placeholders::_1, std::placeholders::_2));
+ }
+ return use_callback_;