extern std::map<std::string, SgFlow*, std::less<>> flow_from_sock;
extern std::map<std::string, ns3::ApplicationContainer, std::less<>> sink_from_sock;
-static ns3::InternetStackHelper stack;
-
static int number_of_links = 1;
static int number_of_networks = 1;
NetPointNs3::NetPointNs3()
{
+ static ns3::InternetStackHelper stack;
stack.Install(ns3_node_);
}
/*********
* Model *
*********/
-void surf_network_model_init_NS3()
+// We can't use SIMGRID_REGISTER_NETWORK_MODEL here because ns-3 has a dash in its name
+static void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_ns3_network_model_register()
{
- auto net_model = std::make_shared<simgrid::kernel::resource::NetworkNS3Model>("NS3 network model");
- auto* engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model(net_model);
- engine->get_netzone_root()->set_network_model(net_model);
+ simgrid_network_models().add(
+ "ns-3", "Network pseudo-model using the real ns-3 simulator instead of an analytic model", []() {
+ auto net_model = std::make_shared<simgrid::kernel::resource::NetworkNS3Model>("NS3 network 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>
// NS-3 stops as soon as a flow ends,
// but it does not process the other flows that may finish at the same (simulated) time.
// If another flow ends at the same time, time_to_next_flow_completion = 0
- if (double_equals(time_to_next_flow_completion, 0, sg_surf_precision))
+ if (double_equals(time_to_next_flow_completion, 0, sg_precision_timing))
time_to_next_flow_completion = 0.0;
XBT_DEBUG("min : %f", now);
// If there is no other started actions, we need to move NS-3 forward to be sync with SimGrid
if (model->get_started_action_set()->size() == 1) {
- while (double_positive(EngineImpl::get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)) {
+ while (double_positive(EngineImpl::get_clock() - ns3::Simulator::Now().GetSeconds(), sg_precision_timing)) {
XBT_DEBUG("Synchronizing NS-3 (time %f) with SimGrid (time %f)", ns3::Simulator::Now().GetSeconds(),
EngineImpl::get_clock());
ns3_simulator(EngineImpl::get_clock() - ns3::Simulator::Now().GetSeconds());