Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Extend Link interface in order to handle links with multiple bandwidths.
authorLoic Guegan <manzerberdes@gmx.com>
Thu, 4 Jul 2019 12:06:32 +0000 (14:06 +0200)
committerLoic Guegan <manzerberdes@gmx.com>
Thu, 4 Jul 2019 12:06:32 +0000 (14:06 +0200)
It will be used by wifi access points (each station connected to an access point
will communicate using one of the rate available on the access point).

src/surf/network_cm02.cpp
src/surf/network_cm02.hpp
src/surf/network_interface.hpp

index 883578b..68bba70 100644 (file)
@@ -267,6 +267,16 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& nam
   simgrid::s4u::Link::on_creation(this->piface_);
 }
 
   simgrid::s4u::Link::on_creation(this->piface_);
 }
 
+NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
+                                 s4u::Link::SharingPolicy policy, lmm::System* system)
+    : NetworkCm02Link(model, name, 0, 0, policy, system)
+{
+  /* Setup Metrics for bandwidths_ */
+  for (auto bandwith : bandwidths) {
+    bandwidths_.push_back({bandwith, 1.0, nullptr});
+  }
+}
+
 void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
 {
   /* Find out which of my iterators was triggered, and react accordingly */
 void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
 {
   /* Find out which of my iterators was triggered, and react accordingly */
index cd576d6..8cfa9ff 100644 (file)
@@ -47,6 +47,8 @@ class NetworkCm02Link : public LinkImpl {
 public:
   NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
                   s4u::Link::SharingPolicy policy, lmm::System* system);
 public:
   NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency,
                   s4u::Link::SharingPolicy policy, lmm::System* system);
+  NetworkCm02Link(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
+                  s4u::Link::SharingPolicy policy, lmm::System* system);
   virtual ~NetworkCm02Link() = default;
   void apply_event(kernel::profile::Event* event, double value) override;
   void set_bandwidth(double value) override;
   virtual ~NetworkCm02Link() = default;
   void apply_event(kernel::profile::Event* event, double value) override;
   void set_bandwidth(double value) override;
index 79103fd..e0cb080 100644 (file)
@@ -160,6 +160,8 @@ public:
   Metric latency_                   = {1.0, 0, nullptr};
   Metric bandwidth_                 = {1.0, 0, nullptr};
 
   Metric latency_                   = {1.0, 0, nullptr};
   Metric bandwidth_                 = {1.0, 0, nullptr};
 
+  /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
+  std::vector<Metric> bandwidths_;
 };
 
 /**********
 };
 
 /**********