kernel::resource::LinkImpl* const pimpl_;
public:
- enum class SharingPolicy { SPLITDUPLEX = 2, SHARED = 1, FATPIPE = 0 };
+ enum class SharingPolicy { WIFI = 3, SPLITDUPLEX = 2, SHARED = 1, FATPIPE = 0 };
kernel::resource::LinkImpl* get_impl() const { return pimpl_; }
type = lua_gettable(L, -2);
lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
"Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
- link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1), "bandwidth of backbone", link.id.c_str());
+ link.bandwidths.push_back(surf_parse_get_bandwidth(lua_tostring(L, -1), "bandwidth of backbone", link.id.c_str()));
lua_pop(L, 1);
lua_pushstring(L, "lat");
lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
"Attribute 'bandwidth' must be specified for any link and must either be either a string (in the right format; see docs) or a number.");
if (type == LUA_TNUMBER)
- link.bandwidth = lua_tonumber(L, -1);
+ link.bandwidths.push_back(lua_tonumber(L, -1));
else // LUA_TSTRING
- link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1), "bandwidth of link", link.id.c_str());
+ link.bandwidths.push_back(surf_parse_get_bandwidth(lua_tostring(L, -1), "bandwidth of link", link.id.c_str()));
lua_pop(L, 1);
//get latency value
LinkCreationArgs link;
link.id = link_id;
- link.bandwidth = cluster->bw;
+ link.bandwidths.push_back(cluster->bw);
link.latency = cluster->lat;
link.policy = cluster->sharing_policy;
sg_platf_new_link(&link);
*linkup = nullptr;
*linkdown = nullptr;
LinkCreationArgs linkTemplate;
- linkTemplate.bandwidth = this->bw_ * numlinks;
+ linkTemplate.bandwidths.push_back(this->bw_ * numlinks);
linkTemplate.latency = this->lat_;
linkTemplate.policy = this->sharing_policy_;
linkTemplate.id = std::move(id);
{
LinkCreationArgs linkTemplate;
if (cluster->limiter_link) {
- linkTemplate.bandwidth = cluster->limiter_link;
+ linkTemplate.bandwidths.push_back(cluster->limiter_link);
linkTemplate.latency = 0;
linkTemplate.policy = s4u::Link::SharingPolicy::SHARED;
linkTemplate.id = "limiter_"+std::to_string(id);
this->limiter_link_ = s4u::Link::by_name(linkTemplate.id)->get_impl();
}
if (cluster->loopback_bw || cluster->loopback_lat) {
- linkTemplate.bandwidth = cluster->loopback_bw;
+ linkTemplate.bandwidths.push_back(cluster->loopback_bw);
linkTemplate.latency = cluster->loopback_lat;
linkTemplate.policy = s4u::Link::SharingPolicy::FATPIPE;
linkTemplate.id = "loopback_"+ std::to_string(id);
{
static int uniqueId = 0;
LinkCreationArgs linkTemplate;
- linkTemplate.bandwidth = cluster->bw;
+ linkTemplate.bandwidths.push_back(cluster->bw);
linkTemplate.latency = cluster->lat;
linkTemplate.policy = cluster->sharing_policy; // sthg to do with that ?
linkTemplate.id =
std::string link_id =
std::string(cluster->id) + "_link_from_" + std::to_string(id) + "_to_" + std::to_string(neighbor_rank_id);
link.id = link_id;
- link.bandwidth = cluster->bw;
+ link.bandwidths.push_back(cluster->bw);
link.latency = cluster->lat;
link.policy = cluster->sharing_policy;
sg_platf_new_link(&link);
std::string link_up = "link_" + netpoint->get_name() + "_UP";
std::string link_down = "link_" + netpoint->get_name() + "_DOWN";
- resource::LinkImpl* linkUp = network_model_->create_link(link_up, bw_out, 0, s4u::Link::SharingPolicy::SHARED);
- resource::LinkImpl* linkDown = network_model_->create_link(link_down, bw_in, 0, s4u::Link::SharingPolicy::SHARED);
+ resource::LinkImpl* linkUp =
+ network_model_->create_link(link_up, std::vector<double>(1, bw_out), 0, s4u::Link::SharingPolicy::SHARED);
+ resource::LinkImpl* linkDown =
+ network_model_->create_link(link_down, std::vector<double>(1, bw_in), 0, s4u::Link::SharingPolicy::SHARED);
private_links_.insert({netpoint->id(), {linkUp, linkDown}});
}
+++ /dev/null
-/* Copyright (c) 2013-2019. 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. */
-
-#include "src/surf/link_wifi.hpp"
-
-namespace simgrid {
-namespace kernel {
-namespace resource {
-
-NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
- s4u::Link::SharingPolicy policy, lmm::System* system)
- : NetworkCm02Link(model, name, 0, 0, policy, system)
-{
- for (auto bandwith : bandwidths) {
- bandwidths_.push_back({bandwith, 1.0, nullptr});
- }
-}
-
-void NetworkWifiLink::set_host_rate(sg_host_t host, int rate_level)
-{
- host_rates_.insert(std::make_pair(host->get_name(), rate_level));
-}
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
+++ /dev/null
-/* Copyright (c) 2013-2019. 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_LINK_WIFI_HPP_
-#define SURF_LINK_WIFI_HPP_
-
-#include "network_cm02.hpp"
-#include "network_interface.hpp"
-#include "src/surf/HostImpl.hpp"
-#include "xbt/string.hpp"
-
-namespace simgrid {
-namespace kernel {
-namespace resource {
-
-class NetworkWifiLink : public NetworkCm02Link {
- /** @brief Hold every rates association between host and links (host name, rates id) */
- std::map<xbt::string, int> host_rates_;
-
- /** @brief Hold every rates available for this Access Point */
- // double* rates; FIXME: unused
-
- /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
- std::vector<Metric> bandwidths_;
-
-public:
- NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
- s4u::Link::SharingPolicy policy, lmm::System* system);
-
- void set_host_rate(sg_host_t host, int rate_level);
-};
-
-} // namespace resource
-} // namespace kernel
-} // namespace simgrid
-
-#endif
}
set_maxmin_system(make_new_lmm_system(select));
- loopback_ = NetworkCm02Model::create_link("__loopback__", 498000000, 0.000015, s4u::Link::SharingPolicy::FATPIPE);
+ loopback_ = NetworkCm02Model::create_link("__loopback__", std::vector<double>(1, 498000000), 0.000015,
+ s4u::Link::SharingPolicy::FATPIPE);
}
-LinkImpl* NetworkCm02Model::create_link(const std::string& name, double bandwidth, double latency,
+LinkImpl* NetworkCm02Model::create_link(const std::string& name, std::vector<double> bandwidths, double latency,
s4u::Link::SharingPolicy policy)
{
- return new NetworkCm02Link(this, name, bandwidth, latency, policy, get_maxmin_system());
+ if (policy == s4u::Link::SharingPolicy::WIFI) {
+ return (new NetworkWifiLink(this, name, bandwidths, policy, get_maxmin_system()));
+ }
+ xbt_assert(bandwidths.size() == 1, "Non WIFI links must use only 1 bandwidth.");
+ return new NetworkCm02Link(this, name, bandwidths[0], latency, policy, get_maxmin_system());
}
void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
}
}
+NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
+ s4u::Link::SharingPolicy policy, lmm::System* system)
+ : NetworkCm02Link(model, name, 0, 0, policy, system)
+{
+ for (auto bandwith : bandwidths) {
+ bandwidths_.push_back({bandwith, 1.0, nullptr});
+ }
+}
+
+void NetworkWifiLink::set_host_rate(sg_host_t host, int rate_level)
+{
+ host_rates_.insert(std::make_pair(host->get_name(), rate_level));
+}
+
/**********
* Action *
**********/
#include "network_interface.hpp"
#include "xbt/graph.h"
-
+#include "xbt/string.hpp"
/***********
* Classes *
public:
explicit NetworkCm02Model(lmm::System* (*make_new_sys)(bool) = &lmm::make_new_maxmin_system);
virtual ~NetworkCm02Model() = default;
- LinkImpl* create_link(const std::string& name, double bandwidth, double latency,
+ LinkImpl* create_link(const std::string& name, std::vector<double> bandwidths, double latency,
s4u::Link::SharingPolicy policy) override;
void update_actions_state_lazy(double now, double delta) override;
void update_actions_state_full(double now, double delta) override;
void set_latency(double value) override;
};
+class NetworkWifiLink : public NetworkCm02Link {
+ /** @brief Hold every rates association between host and links (host name, rates id) */
+ std::map<xbt::string, int> host_rates_;
+
+ /** @brief Hold every rates available for this Access Point */
+ // double* rates; FIXME: unused
+
+ /** @brief A link can have several bandwith attach to it (mostly use by wifi model) */
+ std::vector<Metric> bandwidths_;
+
+public:
+ NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
+ s4u::Link::SharingPolicy policy, lmm::System* system);
+
+ void set_host_rate(sg_host_t host, int rate_level);
+};
+
/**********
* Action *
**********/
all_existing_models.push_back(this);
}
-LinkImpl* NetworkConstantModel::create_link(const std::string& name, double /*bandwidth*/, double /*latency*/,
- s4u::Link::SharingPolicy)
+LinkImpl* NetworkConstantModel::create_link(const std::string& name, std::vector<double> /*bandwidth*/,
+ double /*latency*/, s4u::Link::SharingPolicy)
{
xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
double next_occuring_event(double now) override;
void update_actions_state(double now, double delta) override;
- LinkImpl* create_link(const std::string& name, double bw, double lat, s4u::Link::SharingPolicy policy) override;
+ LinkImpl* create_link(const std::string& name, std::vector<double> bws, double lat,
+ s4u::Link::SharingPolicy policy) override;
};
class NetworkConstantAction : public NetworkAction {
* @param latency The initial latency of the Link in seconds
* @param policy The sharing policy of the Link
*/
- virtual LinkImpl* create_link(const std::string& name, double bandwidth, double latency,
+ virtual LinkImpl* create_link(const std::string& name, std::vector<double> bandwidths, double latency,
s4u::Link::SharingPolicy policy) = 0;
/**
IPV4addr.clear();
}
-LinkImpl* NetworkNS3Model::create_link(const std::string& name, double bandwidth, double latency,
+LinkImpl* NetworkNS3Model::create_link(const std::string& name, std::vector<double> bandwidths, double latency,
s4u::Link::SharingPolicy policy)
{
- return new LinkNS3(this, name, bandwidth, latency);
+ xbt_assert(bandwidths.size() == 1, "Non WIFI links must use only 1 bandwidth.");
+ return new LinkNS3(this, name, bandwidths[0], latency);
}
Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
: NetworkModel(Model::UpdateAlgo::FULL), hostModel_(hmodel)
{
set_maxmin_system(sys);
- loopback_ = NetworkL07Model::create_link("__loopback__", 498000000, 0.000015, s4u::Link::SharingPolicy::FATPIPE);
+ loopback_ = NetworkL07Model::create_link("__loopback__", std::vector<double>(1, 498000000), 0.000015,
+ s4u::Link::SharingPolicy::FATPIPE);
}
NetworkL07Model::~NetworkL07Model()
return new CpuL07(this, host, speed_per_pstate, core);
}
-kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name, double bandwidth, double latency,
- s4u::Link::SharingPolicy policy)
+kernel::resource::LinkImpl* NetworkL07Model::create_link(const std::string& name, std::vector<double> bandwidths,
+ double latency, s4u::Link::SharingPolicy policy)
{
- return new LinkL07(this, name, bandwidth, latency, policy);
+ xbt_assert(bandwidths.size() == 1, "Non WIFI link must have only 1 bandwidth.");
+ return new LinkL07(this, name, bandwidths[0], latency, policy);
}
/************
NetworkL07Model(const NetworkL07Model&) = delete;
NetworkL07Model& operator=(const NetworkL07Model&) = delete;
~NetworkL07Model();
- kernel::resource::LinkImpl* create_link(const std::string& name, double bandwidth, double latency,
+ kernel::resource::LinkImpl* create_link(const std::string& name, std::vector<double> bandwidths, double latency,
s4u::Link::SharingPolicy policy) override;
kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
{
simgrid::kernel::resource::LinkImpl* l =
- surf_network_model->create_link(link_name, link->bandwidth, link->latency, link->policy);
+ surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy);
if (link->properties) {
l->set_properties(*link->properties);
simgrid::kernel::routing::LinkCreationArgs link;
link.id = tmp_link;
- link.bandwidth = cluster->loopback_bw;
+ link.bandwidths.push_back(cluster->loopback_bw);
link.latency = cluster->loopback_lat;
link.policy = simgrid::s4u::Link::SharingPolicy::FATPIPE;
sg_platf_new_link(&link);
simgrid::kernel::routing::LinkCreationArgs link;
link.id = tmp_link;
- link.bandwidth = cluster->limiter_link;
+ link.bandwidths.push_back(cluster->limiter_link);
link.latency = 0;
link.policy = simgrid::s4u::Link::SharingPolicy::SHARED;
sg_platf_new_link(&link);
simgrid::kernel::routing::LinkCreationArgs link;
link.id = std::string(cluster->id)+ "_backbone";
- link.bandwidth = cluster->bb_bw;
+ link.bandwidths.push_back(cluster->bb_bw);
link.latency = cluster->bb_lat;
link.policy = cluster->bb_sharing_policy;
simgrid::kernel::routing::LinkCreationArgs link;
link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
link.latency = cabinet->lat;
- link.bandwidth = cabinet->bw;
+ link.bandwidths.push_back(cabinet->bw);
link.id = "link_" + hostname;
sg_platf_new_link(&link);
XBT_PUBLIC double surf_parse_get_time(const char* string, const char* entity_kind, const std::string& name);
XBT_PUBLIC double surf_parse_get_size(const char* string, const char* entity_kind, const std::string& name);
XBT_PUBLIC double surf_parse_get_bandwidth(const char* string, const char* entity_kind, const std::string& name);
+XBT_PUBLIC std::vector<double> surf_parse_get_bandwidths(const char* string, const char* entity_kind,
+ const std::string& name);
XBT_PUBLIC double surf_parse_get_speed(const char* string, const char* entity_kind, const std::string& name);
XBT_PUBLIC int surf_parse(); /* Entry-point to the parser */
class LinkCreationArgs {
public:
std::string id;
- double bandwidth = 0;
+ std::vector<double> bandwidths;
profile::Profile* bandwidth_trace = nullptr;
double latency = 0;
profile::Profile* latency_trace = nullptr;
"Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps");
}
+std::vector<double> surf_parse_get_bandwidths(const char* string, const char* entity_kind, const std::string& name)
+{
+ static const unit_scale units{std::make_tuple("bps", 0.125, 2, true), std::make_tuple("bps", 0.125, 10, true),
+ std::make_tuple("Bps", 1.0, 2, true), std::make_tuple("Bps", 1.0, 10, true)};
+
+ std::vector<double> bandwidths;
+ std::vector<std::string> tokens;
+ boost::split(tokens, string, boost::is_any_of(";"));
+ for (auto token : tokens) {
+ bandwidths.push_back(surf_parse_get_value_with_unit(
+ token.c_str(), units, entity_kind, name,
+ "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps"));
+ }
+
+ return (bandwidths);
+}
+
double surf_parse_get_speed(const char* string, const char* entity_kind, const std::string& name)
{
static const unit_scale units{std::make_tuple("f", 1.0, 10, true), std::make_tuple("flops", 1.0, 10, false)};
current_property_set = nullptr;
link.id = std::string(A_surfxml_link_id);
- link.bandwidth = surf_parse_get_bandwidth(A_surfxml_link_bandwidth, "bandwidth of link", link.id.c_str());
+ link.bandwidths = surf_parse_get_bandwidths(A_surfxml_link_bandwidth, "bandwidth of link", link.id.c_str());
link.bandwidth_trace = A_surfxml_link_bandwidth___file[0]
? simgrid::kernel::profile::Profile::from_file(A_surfxml_link_bandwidth___file)
: nullptr;
case A_surfxml_link_sharing___policy_SPLITDUPLEX:
link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
break;
+ case A_surfxml_link_sharing___policy_WIFI:
+ link.policy = simgrid::s4u::Link::SharingPolicy::WIFI;
+ break;
default:
surf_parse_error(std::string("Invalid sharing policy in link ") + link.id);
}
link.properties = nullptr;
link.id = std::string(A_surfxml_backbone_id);
- link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id.c_str());
+ link.bandwidths.push_back(
+ surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id.c_str()));
link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id.c_str());
link.policy = simgrid::s4u::Link::SharingPolicy::SHARED;
src/surf/cpu_interface.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp
- src/surf/link_wifi.cpp
- src/surf/link_wifi.hpp
src/surf/network_constant.cpp
src/surf/network_interface.cpp
src/surf/PropertyHolder.cpp