Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Single get_bandwidth_constraint function.
[simgrid.git] / src / surf / network_interface.cpp
index 26bad90..d4e4eb0 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef NETWORK_INTERFACE_CPP_
 #define NETWORK_INTERFACE_CPP_
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_network, ker_resource, "Network resources, that fuels communications");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_network, ker_resource, "Network resources, that fuel communications");
 
 /*********
  * Model *
@@ -52,6 +52,11 @@ double NetworkModel::next_occurring_event_full(double now)
   return minRes;
 }
 
+double NetworkModel::get_bandwidth_constraint(double rate, double bound, double size)
+{
+  return rate < 0 ? bound : std::min(bound, rate);
+}
+
 /************
  * Resource *
  ************/
@@ -61,9 +66,6 @@ LinkImpl::LinkImpl(const std::string& name) : Resource_T(name), piface_(this)
   if (name != "__loopback__")
     xbt_assert(not s4u::Link::by_name_or_null(name), "Link '%s' declared several times in the platform.", name.c_str());
 
-  latency_.scale   = 1;
-  bandwidth_.scale = 1;
-
   s4u::Engine::get_instance()->link_register(name, &piface_);
   XBT_DEBUG("Create link '%s'", name.c_str());
 }
@@ -132,6 +134,9 @@ void LinkImpl::turn_off()
 
 void LinkImpl::seal()
 {
+  if (is_sealed())
+    return;
+
   xbt_assert(this->get_model(), "Cannot seal Link(%s) without setting the Network model first", this->get_cname());
   Resource::seal();
   s4u::Link::on_creation(piface_);