X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d516b0cdfe63107f0ad16e152445c716d4ef0156..090f69e16fc2256292aa7ca819b9d80a2a51d8d4:/src/surf/network_ns3.cpp diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 71f8614352..e8f73008fc 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -185,6 +185,9 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs con { ns3::NodeContainer Nodes; + 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; @@ -229,6 +232,10 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin simgrid::kernel::routing::NetPoint* /*gw_dst*/, std::vector 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(link_list[0]); @@ -270,7 +277,7 @@ static simgrid::config::Flag static simgrid::config::Flag 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) { @@ -323,19 +330,23 @@ NetworkNS3Model::NetworkNS3Model(const std::string& name) : NetworkModel(name) 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& 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& 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) @@ -448,28 +459,24 @@ void LinkNS3::apply_event(profile::Event*, double) 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 *