From: Loic Guegan Date: Thu, 4 Jul 2019 12:06:32 +0000 (+0200) Subject: Extend Link interface in order to handle links with multiple bandwidths. X-Git-Tag: v3.23.2~17 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1ebb8e111d904fea559e48ec193c1f7c5dee2245?hp=8245021ec5b4a8b2d82ffc4c8100e3bc2c7f3884 Extend Link interface in order to handle links with multiple bandwidths. 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). --- diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 883578bf6b..68bba7058f 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -267,6 +267,16 @@ NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& nam simgrid::s4u::Link::on_creation(this->piface_); } +NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const std::string& name, std::vector 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 */ diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index cd576d6e94..8cfa9ff60c 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -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); + NetworkCm02Link(NetworkCm02Model* model, const std::string& name, std::vector 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; diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 79103fdc16..e0cb0807ed 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -160,6 +160,8 @@ public: 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 bandwidths_; }; /**********