#include "src/instr/instr_private.hpp" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
#include "src/kernel/EngineImpl.hpp"
#include "src/surf/surf_interface.hpp"
-#include "src/surf/xml/platf_private.hpp"
+#include "src/surf/xml/platf_private.hpp" // ClusterCreationArgs
#include "surf/surf.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_ns3, res_network, "Network model based on ns-3");
wifiPhy.Set("Antennas", ns3::UintegerValue(nss_value));
wifiPhy.Set("MaxSupportedTxSpatialStreams", ns3::UintegerValue(nss_value));
wifiPhy.Set("MaxSupportedRxSpatialStreams", ns3::UintegerValue(nss_value));
+#if NS3_MINOR_VERSION > 33
+ wifiPhy.Set("ChannelWidth", ns3::UintegerValue(40));
+#endif
wifiMac.SetType("ns3::ApWifiMac", "Ssid", ns3::SsidValue(ssid));
mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
ns3::Simulator::Schedule(ns3::Seconds(start_time_value), &resumeWifiDevice, device);
}
+#if NS3_MINOR_VERSION < 33
+ // This fails with "The channel width does not uniquely identify an operating channel" on v3.34,
+ // so we specified the ChannelWidth of wifiPhy to 40, above, when creating wifiPhy with v3.34 and higher
ns3::Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", ns3::UintegerValue(40));
+#endif
mobility.SetPositionAllocator(positionAllocS);
mobility.Install(nodes);
{
ns3::NodeContainer Nodes;
- for (int const& i : *cluster.radicals) {
+ xbt_assert(cluster.topology == simgrid::kernel::routing::ClusterTopology::FLAT,
+ "NS-3 is supported only by flat clusters. Do not use with other topologies");
+
+ for (int const& i : cluster.radicals) {
// Create private link
std::string host_id = cluster.prefix + std::to_string(i) + cluster.suffix;
auto* src = simgrid::s4u::Host::by_name(host_id)->get_netpoint();
simgrid::kernel::routing::NetPoint* /*gw_dst*/,
std::vector<simgrid::kernel::resource::LinkImpl*> const& link_list)
{
+ /* ignoring routes from StarZone, not supported */
+ if (not src || not dst)
+ return;
+
if (link_list.size() == 1) {
auto const* link = static_cast<simgrid::kernel::resource::LinkNS3*>(link_list[0]);
void surf_network_model_init_NS3()
{
auto net_model = std::make_shared<simgrid::kernel::resource::NetworkNS3Model>("NS3 network model");
- simgrid::kernel::EngineImpl::get_instance()->add_model(net_model);
- simgrid::s4u::Engine::get_instance()->get_netzone_root()->get_impl()->set_network_model(net_model);
+ auto* engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(net_model);
+ engine->get_netzone_root()->set_network_model(net_model);
}
static simgrid::config::Flag<std::string>
static simgrid::config::Flag<std::string> ns3_seed(
"ns3/seed",
"The random seed provided to ns-3. Either 'time' to seed with time(), blank to not set (default), or a number.", "",
- [](std::string val) {
+ [](const std::string& val) {
if (val.length() == 0)
return;
if (strcasecmp(val.c_str(), "time") == 0) {
ns3::GlobalRouteManager::InitializeRoutes();
});
routing::on_cluster_creation.connect(&clusterCreation_cb);
- s4u::NetZone::on_route_creation.connect(&routeCreation_cb);
+ routing::NetZoneImpl::on_route_creation.connect(&routeCreation_cb);
s4u::NetZone::on_seal.connect(&zoneCreation_cb);
}
LinkImpl* NetworkNS3Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(bandwidths.size() == 1, "ns-3 links must use only 1 bandwidth.");
- return (new LinkNS3(name, bandwidths[0]))->set_model(this);
+ auto* link = new LinkNS3(name, bandwidths[0]);
+ link->set_model(this);
+ return link;
}
LinkImpl* NetworkNS3Model::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
{
- return create_link(name, bandwidths)->set_sharing_policy(s4u::Link::SharingPolicy::WIFI);
+ auto* link = create_link(name, bandwidths);
+ link->set_sharing_policy(s4u::Link::SharingPolicy::WIFI, {});
+ return link;
}
Action* NetworkNS3Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
THROW_UNIMPLEMENTED;
}
-LinkImpl* LinkNS3::set_bandwidth_profile(profile::Profile* profile)
+void LinkNS3::set_bandwidth_profile(profile::Profile* profile)
{
xbt_assert(profile == nullptr, "The ns-3 network model doesn't support bandwidth profiles");
- return this;
}
-LinkImpl* LinkNS3::set_latency_profile(profile::Profile* profile)
+void LinkNS3::set_latency_profile(profile::Profile* profile)
{
xbt_assert(profile == nullptr, "The ns-3 network model doesn't support latency profiles");
- return this;
}
-LinkImpl* LinkNS3::set_latency(double latency)
+void LinkNS3::set_latency(double latency)
{
latency_.peak = latency;
- return this;
}
-LinkImpl* LinkNS3::set_sharing_policy(s4u::Link::SharingPolicy policy)
+void LinkNS3::set_sharing_policy(s4u::Link::SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
{
sharing_policy_ = policy;
- return this;
}
/**********
* Action *