Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/mwapl/simgrid
[simgrid.git] / src / kernel / resource / WifiLinkImpl.hpp
index 234eb09..969eeeb 100644 (file)
@@ -1,44 +1,43 @@
-/* Copyright (c) 2019-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SURF_NETWORK_WIFI_HPP_
-#define SURF_NETWORK_WIFI_HPP_
+#ifndef SIMGRID_KERNEL_NETWORK_WIFI_HPP_
+#define SIMGRID_KERNEL_NETWORK_WIFI_HPP_
 
-#include <xbt/base.h>
-
-#include "src/surf/network_cm02.hpp"
-#include "xbt/string.hpp"
+#include "src/kernel/resource/models/network_cm02.hpp"
+#include "xbt/ex.h"
 
 /***********
  * Classes *
  ***********/
 
-namespace simgrid {
-namespace kernel {
-namespace resource {
+namespace simgrid::kernel::resource {
 
 class XBT_PRIVATE WifiLinkAction;
 
 class WifiLinkImpl : public StandardLinkImpl {
   /** @brief Hold every rates association between host and links (host name, rates id) */
-  std::map<xbt::string, int> host_rates_;
+  std::map<std::string, int, std::less<>> host_rates_;
 
   /** @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:
@@ -52,9 +51,14 @@ 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();
-  int get_host_count() const;
+  bool toggle_callback();
+
+  static void update_bw_comm_end(const NetworkAction& action, Action::State state);
+  void inc_active_flux();
+  void dec_active_flux();
+  static double wifi_link_dynamic_sharing(const WifiLinkImpl& link, double capacity, int n);
+  double get_max_ratio() const;
+  size_t get_host_count() const;
 };
 
 class WifiLinkAction : public NetworkCm02Action {
@@ -73,7 +77,5 @@ public:
   WifiLinkImpl* get_dst_link() const { return dst_wifi_link_; }
 };
 
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+} // namespace simgrid::kernel::resource
 #endif