Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
callback mechanism
authorClément Courageux-Sudan <clement.courageux-sudan@inria.fr>
Mon, 20 Jun 2022 13:18:44 +0000 (15:18 +0200)
committerClément Courageux-Sudan <clement.courageux-sudan@inria.fr>
Fri, 24 Jun 2022 12:38:56 +0000 (14:38 +0200)
examples/platforms/wifi_large_cell.xml [new file with mode: 0755]
src/kernel/lmm/System.cpp
src/kernel/lmm/System.hpp
src/kernel/lmm/maxmin.cpp
src/kernel/resource/StandardLinkImpl.cpp
src/kernel/resource/WifiLinkImpl.cpp
src/kernel/resource/WifiLinkImpl.hpp
src/surf/network_cm02.cpp
teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp
teshsuite/models/wifi_usage_decay/wifi_usage_decay.tesh

diff --git a/examples/platforms/wifi_large_cell.xml b/examples/platforms/wifi_large_cell.xml
new file mode 100755 (executable)
index 0000000..bd53e78
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version='1.0'?>
+
+<!DOCTYPE platform SYSTEM "https://simgrid.org/simgrid.dtd">
+<platform version="4.1">
+  <zone id="world" routing="Full">
+
+    <zone id="WIFI zone" routing="Wifi">
+        <prop id="access_point" value="WIFI router" />
+
+        <!-- Declare the stations of this wifi zone -->
+        <host id="Station 1" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 2" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 3" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 4" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 5" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 6" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 7" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 8" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 9" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 10" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 11" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 12" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 13" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 14" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 15" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 16" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 17" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 18" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 19" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 20" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 21" speed="100.0Mf,50.0Mf,20.0Mf" />
+        <host id="Station 22" speed="100.0Mf,50.0Mf,20.0Mf" />
+
+        <!-- Declare the wifi media (after hosts because our parser is sometimes annoying) -->
+        <link id="AP1" sharing_policy="WIFI" bandwidth="54Mbps,36Mbps,24Mbps" latency="0ms" />
+
+        <router id="WIFI router"/>
+    </zone>
+
+    <!-- NODE1 AS -->
+    <zone id="Wired zone" routing="Full">
+      <host id="node1" speed="100.0Mf,50.0Mf,20.0Mf" />
+    </zone>
+
+
+    <!-- AS Routing -->
+    <link id="Collector" sharing_policy="SHARED" bandwidth="100Mbps" latency="0ms" />
+    <zoneRoute src="WIFI zone" dst="Wired zone" gw_src="WIFI router" gw_dst="node1">
+      <link_ctn id="Collector" />
+    </zoneRoute>
+
+  </zone>
+</platform>
index 326b404..3f97566 100644 (file)
@@ -29,6 +29,11 @@ Element::Element(Constraint* constraint, Variable* variable, double cweight)
 
 int Element::get_concurrency() const
 {
+  // just to try having the computation of the concurrency
+  if(constraint->get_sharing_policy() == Constraint::SharingPolicy::WIFI) {
+    return 1;
+  }
+
   // Ignore element with weight less than one (e.g. cross-traffic)
   return (consumption_weight >= 1) ? 1 : 0;
   // There are other alternatives, but they will change the behavior of the model..
@@ -754,7 +759,7 @@ double Constraint::get_usage() const
 
 void Constraint::set_sharing_policy(SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
 {
-  xbt_assert(policy == SharingPolicy::NONLINEAR || not cb,
+  xbt_assert(policy == SharingPolicy::NONLINEAR || policy == SharingPolicy::WIFI || not cb,
              "Invalid sharing policy for constraint. Callback should be used with NONLINEAR sharing policy");
   sharing_policy_    = policy;
   dyn_constraint_cb_ = cb;
index 173d044..b2e5c4f 100644 (file)
@@ -205,7 +205,7 @@ public:
  */
 class XBT_PUBLIC Constraint {
 public:
-  enum class SharingPolicy { NONLINEAR = 2, SHARED = 1, FATPIPE = 0 };
+  enum class SharingPolicy { WIFI = 3, NONLINEAR = 2, SHARED = 1, FATPIPE = 0 };
 
   Constraint(resource::Resource* id_value, double bound_value);
 
index d12f588..fb9123f 100644 (file)
@@ -67,7 +67,7 @@ template <class CnstList> void MaxMin::maxmin_solve(CnstList& cnst_list)
     /* INIT: Collect constraints that actually need to be saturated (i.e remaining  and usage are strictly positive)
      * into cnst_light_tab. */
     cnst.dynamic_bound_ = cnst.bound_;
-    if (cnst.get_sharing_policy() == Constraint::SharingPolicy::NONLINEAR && cnst.dyn_constraint_cb_) {
+    if ((cnst.get_sharing_policy() == Constraint::SharingPolicy::NONLINEAR || cnst.get_sharing_policy() == Constraint::SharingPolicy::WIFI) && cnst.dyn_constraint_cb_) {
       cnst.dynamic_bound_ = cnst.dyn_constraint_cb_(cnst.bound_, cnst.concurrency_current_);
     }
     cnst.remaining_ = cnst.dynamic_bound_;
index 6648c23..cec70b7 100644 (file)
@@ -43,6 +43,8 @@ void StandardLinkImpl::destroy()
 constexpr kernel::lmm::Constraint::SharingPolicy to_maxmin_policy(s4u::Link::SharingPolicy policy)
 {
   switch (policy) {
+    case s4u::Link::SharingPolicy::WIFI:
+      return kernel::lmm::Constraint::SharingPolicy::WIFI;
     case s4u::Link::SharingPolicy::NONLINEAR:
       return kernel::lmm::Constraint::SharingPolicy::NONLINEAR;
     case s4u::Link::SharingPolicy::FATPIPE:
index 556a7ff..c4fbc12 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "src/kernel/resource/WifiLinkImpl.hpp"
 #include "src/surf/surf_interface.hpp"
+#include "src/kernel/activity/CommImpl.hpp"
+
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
 
@@ -22,14 +24,18 @@ WifiLinkImpl::WifiLinkImpl(const std::string& name, const std::vector<double>& b
   this->set_constraint(system->constraint_new(this, 1));
   for (auto bandwidth : bandwidths)
     bandwidths_.push_back({bandwidth, 1.0, nullptr});
+
+  kernel::activity::CommImpl::on_start.connect(&update_bw_comm_start);
+  s4u::Link::on_communication_state_change_cb(&update_bw_comm_end);
+
+
 }
 
 void WifiLinkImpl::set_host_rate(const s4u::Host* host, int rate_level)
 {
-  host_rates_[host->get_name()] = rate_level;
-
-  // Each time we add a host, we refresh the decay model
-  refresh_decay_bandwidths();
+  auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level));
+  if (not insert_done.second)
+    insert_done.first->second = rate_level;
 }
 
 double WifiLinkImpl::get_host_rate(const s4u::Host* host) const
@@ -47,7 +53,7 @@ double WifiLinkImpl::get_host_rate(const s4u::Host* host) const
              "Link '%s' only has %zu wifi rate levels, so the provided level %d is invalid for host '%s'.",
              this->get_cname(), bandwidths_.size(), rate_id, host->get_cname());
 
-  Metric rate = use_decay_model_ ? decay_bandwidths_[rate_id] : bandwidths_[rate_id];
+  Metric rate = bandwidths_[rate_id];
   return rate.peak * rate.scale;
 }
 
@@ -61,31 +67,85 @@ size_t WifiLinkImpl::get_host_count() const
   return host_rates_.size();
 }
 
-void WifiLinkImpl::refresh_decay_bandwidths()
+double WifiLinkImpl::wifi_link_dynamic_sharing(WifiLinkImpl* link, double capacity, int n)
+{
+  double ratio = link->get_max_ratio(n);
+  XBT_DEBUG("New ratio value concurrency %d: %lf of link capacity on link %s", n, ratio, link->get_name().c_str());
+  return ratio;
+}
+
+void WifiLinkImpl::inc_active_flux() {
+  xbt_assert(nb_active_flux_>=0, "Negative nb_active_flux should not exist");
+  nb_active_flux_++;
+}
+
+void WifiLinkImpl::dec_active_flux() {
+  xbt_assert(nb_active_flux_>0, "Negative nb_active_flux should not exist");
+  nb_active_flux_--;
+}
+
+void WifiLinkImpl::update_bw_comm_start(const kernel::activity::CommImpl& comm)
+{
+  auto* action = static_cast<kernel::resource::NetworkAction*>(comm.surf_action_);
+
+  auto const* actionWifi = dynamic_cast<const simgrid::kernel::resource::WifiLinkAction*>(action);
+  if (actionWifi == nullptr)
+    return;
+
+  auto* link_src = actionWifi->get_src_link();
+  auto* link_dst = actionWifi->get_dst_link();
+  if(link_src != nullptr) {
+    link_src->inc_active_flux();
+  }
+  if(link_dst != nullptr) {
+    link_dst->inc_active_flux();
+  }
+}
+
+void WifiLinkImpl::update_bw_comm_end(simgrid::kernel::resource::NetworkAction& action, simgrid::kernel::resource::Action::State state)
+{
+  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;
+
+  auto* link_src = actionWifi->get_src_link();
+  auto* link_dst = actionWifi->get_dst_link();
+  if(link_src != nullptr) {
+    link_src->dec_active_flux();
+  }
+  if(link_dst != nullptr) {
+    link_dst->dec_active_flux();
+  }
+}
+
+double WifiLinkImpl::get_max_ratio(int nb_active_flux)
 {
-  // Compute number of STAtion on the Access Point
-  const auto nSTA_minus_1 = static_cast<double>(get_host_count() - 1);
-
-  std::vector<Metric> new_bandwidths;
-  for (auto const& bandwidth : bandwidths_) {
-    // Instantiate decay model relatively to the actual bandwidth
-    double max_bw     = bandwidth.peak;
-    double min_bw     = bandwidth.peak - (wifi_max_rate_ - wifi_min_rate_);
-    double model_rate = bandwidth.peak - (wifi_max_rate_ - model_rate_);
-
-    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_minus_1) + min_bw;
-    new_bandwidths.push_back({new_peak, 1.0, nullptr});
+  double new_peak = -1;
+  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_);
   }
-  decay_bandwidths_ = new_bandwidths;
+  // 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_decay_model()
+bool WifiLinkImpl::toggle_callback()
 {
-  use_decay_model_ = not use_decay_model_;
-  return use_decay_model_;
+  if(! 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, this, std::placeholders::_1, std::placeholders::_2));
+  }
+  return use_callback_;
 }
 
 void WifiLinkImpl::set_latency(double value)
index ea1e30a..5f5fec0 100644 (file)
@@ -26,17 +26,20 @@ class WifiLinkImpl : public StandardLinkImpl {
   /** @brief A link can have several bandwidths attached to it (mostly use by wifi model) */
   std::vector<Metric> bandwidths_;
 
-  /** @brief Should we use the decay model ? */
-  bool use_decay_model_ = false;
-  /** @brief Wifi maximal bit rate according to the ns-3 802.11n standard */
-  const double wifi_max_rate_ = 54 * 1e6 / 8;
-  /** @brief minimum bit rate observed with ns3 during our calibration experiments */
-  const double wifi_min_rate_ = 41.70837 * 1e6 / 8;
-  /** @brief Amount of stations used in the reference point to rescale SimGrid predictions to fit ns-3 ones */
-  const int model_n_ = 5;
-  /** @brief Bit rate observed on ns3 at the reference point used for rescaling */
-  const double model_rate_ = 42.61438 * 1e6 / 8;
-  /** @brief The bandwidth to use for each SNR level, corrected with the decay rescale mechanism */
+  bool use_callback_ = false;
+  /*
+   * Values used for the throughput degradation:
+   * ratio = x0_ + co_acc_ * nb_active_flux_ / x0_
+  **/
+  /** @brief base maximum throughput to compare to when computing the ratio */
+  const double x0_ = 5678270;
+  /** @brief linear regression factor */
+  const double co_acc_ = -5424;
+  /** @brief minimum number of concurrent flows before using the linear regression */
+  const int conc_lim_ = 20;
+  /** @brief current concurrency on the link */
+  int nb_active_flux_ = 0;
+
   std::vector<Metric> decay_bandwidths_;
 
 public:
@@ -50,8 +53,15 @@ public:
   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
   void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
   void set_latency(double) override;
-  void refresh_decay_bandwidths();
-  bool toggle_decay_model();
+  double get_max_ratio();
+  bool toggle_callback();
+
+  static void update_bw_comm_start(const kernel::activity::CommImpl&);
+  static void update_bw_comm_end(simgrid::kernel::resource::NetworkAction& action, simgrid::kernel::resource::Action::State state);
+  void inc_active_flux();
+  void dec_active_flux();
+  static double wifi_link_dynamic_sharing(WifiLinkImpl* link, double capacity, int n);
+  double get_max_ratio(int);
   size_t get_host_count() const;
 };
 
index c7f15ec..049fb15 100644 (file)
@@ -225,19 +225,22 @@ void NetworkCm02Model::comm_action_expand_constraints(const s4u::Host* src, cons
 
   /* WI-FI links needs special treatment, do it here */
   if (src_wifi_link != nullptr) {
-    /* In case of 0Mbps data rate, don't consider it in the LMM */
     if (src_wifi_link->get_host_rate(src) > 0)
       get_maxmin_system()->expand(src_wifi_link->get_constraint(), action->get_variable(),
                                   1.0 / src_wifi_link->get_host_rate(src));
-    else
+    else {
       get_maxmin_system()->update_variable_penalty(action->get_variable(), 0);
+    }
   }
+
   if (dst_wifi_link != nullptr) {
     if (dst_wifi_link->get_host_rate(dst) > 0)
       get_maxmin_system()->expand(dst_wifi_link->get_constraint(), action->get_variable(),
                                   1.0 / dst_wifi_link->get_host_rate(dst));
-    else
+    else {
       get_maxmin_system()->update_variable_penalty(action->get_variable(), 0);
+    }
+
   }
 
   for (auto const* link : route) {
index 0afa31b..48aeeae 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[usage] wifi_usage <platform-file>");
 
-void run_ping_test(const char* src, const char* dest, int data_size);
+void run_ping_test(std::vector<std::pair<std::string,std::string>> mboxes, int data_size);
 
 /* We need a separate actor so that it can sleep after each test */
 static void main_dispatcher()
 {
-  bool crosstraffic = simgrid::kernel::resource::NetworkModel::cfg_crosstraffic;
 
-  XBT_INFO("TEST: Send from a station to a node on the wired network after the AP.");
-  XBT_INFO("----------------------------------------------------------------------");
-  XBT_INFO("Since AP1 is the limiting link, we have the following constraint for AP1:");
-  if (crosstraffic) {
-    XBT_INFO("1.05/r_STA1 * rho_STA1 <= 1   (1.05 instead of 1 because of cross-traffic)");
-    XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487");
-    XBT_INFO("We should thus have:");
-    XBT_INFO("  mu = 1 / [ 1/1 * 1.05/49.00487Mbps ] = 46671305");
-    XBT_INFO("  simulation_time = 1000*8 / mu = 0.0001714115 (rounded to 0.000171s in SimGrid)");
-  } else {
-    XBT_INFO("1/r_STA1 * rho_STA1 <= 1  (there is no cross-traffic)");
-    XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487");
-    XBT_INFO("We should thus have:");
-    XBT_INFO("  mu = 1 / [ 1/1 * 1/49.00487Mbps ] = 49004870");
-    XBT_INFO("  simulation_time = 1000*8 / mu = 0.0001632491s (rounded to 0.000163s in SimGrid)");
-  }
-  run_ping_test("Station 1", "node1", 1000);
+  const std::vector<std::pair<std::string, std::string>> flows = {
+    {"Station 1", "Station 2"},
+    {"Station 3", "Station 4"},
+    {"Station 5", "Station 6"},
+    {"Station 7", "Station 8"},
+    {"Station 9", "Station 10"},
+    {"Station 11", "Station 12"},
+    {"Station 13", "Station 14"},
+    {"Station 15", "Station 16"},
+    {"Station 17", "Station 18"},
+    {"Station 19", "Station 20"},
+    {"Station 21", "Station 22"},
+  };
+
+  XBT_INFO("1/r_STA1 * rho_STA1 <= 1  (there is no cross-traffic)");
+  XBT_INFO("22 concurrent flows, decay model deactivated, we have 54Mbps to share between the flows");
+  XBT_INFO("We should thus have:");
+  XBT_INFO("  mu = 1 / [ 1/22 * (1/54Mbps)*22 ] = 54000000");
+  XBT_INFO("  simulation_time = 100000*8 / (mu/22) = 0.3259259259259259 (rounded to 0.325926s in SimGrid)");
+
+  run_ping_test(flows, 100000);
+
+  XBT_INFO("1/r_STA1 * rho_STA1 <= 1  (there is no cross-traffic)");
+  XBT_INFO("22 concurrent flows, decay model activated, we have 54Mbps to share between the flows, but the number of concurrent flows is above the limit (20)");
+  XBT_INFO("We should thus have:");
+  XBT_INFO("Maximum throughput of the link reduced by:");
+  XBT_INFO("updated link capacity = ( 5678270 + (22-20) * -5424 ) / 5678270 =~ 0.998086");
+  XBT_INFO("  mu = 1 / [ 1/22 * (1/54Mbps*0.998086)*22 ] = 53896644");
+  XBT_INFO("  simulation_time = 100000*8 / (mu/22) = 0.3265509444335718 (rounded to 0.326550 in SimGrid)");
+
+  auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl();
+  l->toggle_callback();
+  run_ping_test(flows, 100000);
 
-  XBT_INFO("TEST: Send from a station to another station on the same AP.");
-  XBT_INFO("------------------------------------------------------------");
-  XBT_INFO("We have the following constraint for AP1:");
-  if (crosstraffic) {
-    XBT_INFO("1.05/r_STA1 * rho_STA1 + 1.05/r_STA2 * rho_2 <= 1     (1.05 instead of 1 because of cross-traffic)");
-    XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487");
-    XBT_INFO("We should thus have:");
-    XBT_INFO("  mu = 1 / [ 1/2 * 1.05/49.00487Mbps + 1.05/49.00487Mbps ] = 46671305");
-    XBT_INFO("  simulation_time = 1000*8 / [ mu / 2 ] = 0.0003428231s (rounded to 0.000343s in SimGrid)");
-  } else {
-    XBT_INFO("1/r_STA1 * rho_STA1 +    1/r_STA2 * rho_2 <= 1   (there is no cross-traffic)");
-    XBT_INFO("However, decay model specify that for 2 stations, we have 54Mbps become 49.00487");
-    XBT_INFO("  mu = 1 / [ 1/2 * 1/49.00487Mbps + 1/49.00487Mbps ] = 49004870");
-    XBT_INFO("  simulation_time = 1000*8 / [ mu / 2 ] =  0.0003264982s (rounded to 0.000326s in SimGrid)");
-  }
-  run_ping_test("Station 1", "Station 2", 1000);
 }
 int main(int argc, char** argv)
 {
@@ -63,25 +62,25 @@ int main(int argc, char** argv)
   return 0;
 }
 
-void run_ping_test(const char* src, const char* dest, int data_size)
+void run_ping_test(std::vector<std::pair<std::string,std::string>> mboxes, int data_size)
 {
   auto* mailbox = simgrid::s4u::Mailbox::by_name("Test");
-
-  simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name(src), [mailbox, dest, data_size]() {
-    double start_time          = simgrid::s4u::Engine::get_clock();
-    static std::string message = "message";
-    mailbox->put(&message, data_size);
-    double end_time = simgrid::s4u::Engine::get_clock();
-    XBT_INFO("Actual result: Sending %d bytes from '%s' to '%s' takes %f seconds.", data_size,
-             simgrid::s4u::this_actor::get_host()->get_cname(), dest, end_time - start_time);
-  });
-  simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(dest),
-                              [mailbox]() { mailbox->get<std::string>(); });
-  auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl();
-  if (not l->toggle_decay_model())
-    l->toggle_decay_model();
-  l->set_host_rate(simgrid::s4u::Host::by_name("Station 1"), 0);
-  l->set_host_rate(simgrid::s4u::Host::by_name("Station 2"), 0);
+  for(auto pair : mboxes) {
+    simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name(pair.first.c_str()), [mailbox, pair, data_size]() {
+      double start_time          = simgrid::s4u::Engine::get_clock();
+      static std::string message = "message";
+      mailbox->put(&message, data_size);
+      double end_time = simgrid::s4u::Engine::get_clock();
+      XBT_INFO("Actual result: Sending %d bytes from '%s' to '%s' takes %f seconds.", data_size,
+              simgrid::s4u::this_actor::get_host()->get_cname(), pair.second.c_str(), end_time - start_time);
+    });
+    simgrid::s4u::Actor::create("receiver", simgrid::s4u::Host::by_name(pair.second.c_str()),
+                                [mailbox]() { mailbox->get<std::string>(); });
+    auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl();
+    for(auto i=1; i<=22; i++) {
+      l->set_host_rate(simgrid::s4u::Host::by_name("Station "+std::to_string(i)), 0);
+    }
+    }
   simgrid::s4u::this_actor::sleep_for(10);
   XBT_INFO("\n");
 }
index b2fa6a9..bf43749 100644 (file)
@@ -1,49 +1,41 @@
 #!/usr/bin/env tesh
 
-p Test WITH crosstraffic
-$ ${bindir:=.}/wifi_usage_decay ${platfdir}/wifi.xml --log=root.fmt=%m%n --cfg=network/model:CM02
-> Configuration change: Set 'network/model' to 'CM02'
-> TEST: Send from a station to a node on the wired network after the AP.
-> ----------------------------------------------------------------------
-> Since AP1 is the limiting link, we have the following constraint for AP1:
-> 1.05/r_STA1 * rho_STA1 <= 1   (1.05 instead of 1 because of cross-traffic)
-> However, decay model specify that for 2 stations, we have 54Mbps become 49.00487
-> We should thus have:
->   mu = 1 / [ 1/1 * 1.05/49.00487Mbps ] = 46671305
->   simulation_time = 1000*8 / mu = 0.0001714115 (rounded to 0.000171s in SimGrid)
-> Actual result: Sending 1000 bytes from 'Station 1' to 'node1' takes 0.000171 seconds.
->
->
-> TEST: Send from a station to another station on the same AP.
-> ------------------------------------------------------------
-> We have the following constraint for AP1:
-> 1.05/r_STA1 * rho_STA1 + 1.05/r_STA2 * rho_2 <= 1     (1.05 instead of 1 because of cross-traffic)
-> However, decay model specify that for 2 stations, we have 54Mbps become 49.00487
-> We should thus have:
->   mu = 1 / [ 1/2 * 1.05/49.00487Mbps + 1.05/49.00487Mbps ] = 46671305
->   simulation_time = 1000*8 / [ mu / 2 ] = 0.0003428231s (rounded to 0.000343s in SimGrid)
-> Actual result: Sending 1000 bytes from 'Station 1' to 'Station 2' takes 0.000343 seconds.
-
-p Test WITHOUT crosstraffic
-$ ${bindir:=.}/wifi_usage_decay ${platfdir}/wifi.xml --log=root.fmt=%m%n --cfg=network/crosstraffic:0 --cfg=network/model:CM02
+$ ${bindir:=.}/wifi_usage_decay ${platfdir}/wifi_large_cell.xml --log=root.fmt=%m%n --cfg=network/crosstraffic:0 --cfg=network/model:CM02
 > Configuration change: Set 'network/crosstraffic' to '0'
 > Configuration change: Set 'network/model' to 'CM02'
-> TEST: Send from a station to a node on the wired network after the AP.
-> ----------------------------------------------------------------------
-> Since AP1 is the limiting link, we have the following constraint for AP1:
 > 1/r_STA1 * rho_STA1 <= 1  (there is no cross-traffic)
-> However, decay model specify that for 2 stations, we have 54Mbps become 49.00487
+> 22 concurrent flows, decay model deactivated, we have 54Mbps to share between the flows
 > We should thus have:
->   mu = 1 / [ 1/1 * 1/49.00487Mbps ] = 49004870
->   simulation_time = 1000*8 / mu = 0.0001632491s (rounded to 0.000163s in SimGrid)
-> Actual result: Sending 1000 bytes from 'Station 1' to 'node1' takes 0.000163 seconds.
+>   mu = 1 / [ 1/22 * (1/54Mbps)*22 ] = 54000000
+>   simulation_time = 100000*8 / (mu/22) = 0.3259259259259259 (rounded to 0.325926s in SimGrid)
+> Actual result: Sending 100000 bytes from 'Station 21' to 'Station 22' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 19' to 'Station 20' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 17' to 'Station 18' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 15' to 'Station 16' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 13' to 'Station 14' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 11' to 'Station 12' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 9' to 'Station 10' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 7' to 'Station 8' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 5' to 'Station 6' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 3' to 'Station 4' takes 0.325926 seconds.
+> Actual result: Sending 100000 bytes from 'Station 1' to 'Station 2' takes 0.325926 seconds.
 >
 >
-> TEST: Send from a station to another station on the same AP.
-> ------------------------------------------------------------
-> We have the following constraint for AP1:
-> 1/r_STA1 * rho_STA1 +    1/r_STA2 * rho_2 <= 1   (there is no cross-traffic)
-> However, decay model specify that for 2 stations, we have 54Mbps become 49.00487
->   mu = 1 / [ 1/2 * 1/49.00487Mbps + 1/49.00487Mbps ] = 49004870
->   simulation_time = 1000*8 / [ mu / 2 ] =  0.0003264982s (rounded to 0.000326s in SimGrid)
-> Actual result: Sending 1000 bytes from 'Station 1' to 'Station 2' takes 0.000326 seconds.
+> 1/r_STA1 * rho_STA1 <= 1  (there is no cross-traffic)
+> 22 concurrent flows, decay model activated, we have 54Mbps to share between the flows, but the number of concurrent flows is above the limit (20)
+> We should thus have:
+> Maximum throughput of the link reduced by:
+> updated link capacity = ( 5678270 + (22-20) * -5424 ) / 5678270 =~ 0.998086
+>   mu = 1 / [ 1/22 * (1/54Mbps*0.998086)*22 ] = 53896644
+>   simulation_time = 100000*8 / (mu/22) = 0.3265509444335718 (rounded to 0.326550 in SimGrid)
+> Actual result: Sending 100000 bytes from 'Station 21' to 'Station 22' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 19' to 'Station 20' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 17' to 'Station 18' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 15' to 'Station 16' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 13' to 'Station 14' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 11' to 'Station 12' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 9' to 'Station 10' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 7' to 'Station 8' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 5' to 'Station 6' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 3' to 'Station 4' takes 0.326550 seconds.
+> Actual result: Sending 100000 bytes from 'Station 1' to 'Station 2' takes 0.326550 seconds.