Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SplitDuplexLinkImpl always have SharingPolicy::SPLITDUPLEX. Use a sdingle assert...
[simgrid.git] / src / surf / network_ns3.cpp
index 6e4a467..81839ef 100644 (file)
@@ -185,7 +185,10 @@ static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs con
 {
   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();
@@ -229,6 +232,10 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin
                              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]);
 
@@ -270,7 +277,7 @@ 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) {
@@ -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<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)
@@ -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)
 {
   sharing_policy_ = policy;
-  return this;
 }
 /**********
  * Action *