X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b2d9909db8c479a5d6c6f71ea0504f83a35b55be..919f4502f5e39049ce71245b7fcca16e3781800d:/src/surf/network_ns3.c diff --git a/src/surf/network_ns3.c b/src/surf/network_ns3.c index 16df51312e..86c1aa1388 100644 --- a/src/surf/network_ns3.c +++ b/src/surf/network_ns3.c @@ -349,6 +349,13 @@ static int ns3_get_link_latency_limited(surf_action_t action) } #endif +#ifdef HAVE_TRACING +static void ns3_action_set_category(surf_action_t action, const char *category) +{ + action->category = xbt_strdup (category); +} +#endif + void surf_network_model_init_NS3(const char *filename) { if (surf_network_model) @@ -370,8 +377,13 @@ void surf_network_model_init_NS3(const char *filename) surf_network_model->action_unref = action_unref; surf_network_model->extension.network.communicate = ns3_communicate; +#ifdef HAVE_TRACING + surf_network_model->set_category = ns3_action_set_category; +#endif + /* Added the initialization for NS3 interface */ - if (ns3_initialize()) { + + if (ns3_initialize(xbt_cfg_get_string(_surf_cfg_set,"ns3/TcpModel"))) { xbt_die("Impossible to initialize NS3 interface"); } @@ -405,20 +417,19 @@ static double ns3_share_resources(double min) surf_network_model->states.running_action_set; //get the first relevant value from the running_actions list - if (!xbt_swag_size(running_actions)) - return -1.0; - - ns3_simulator(min); - time_to_next_flow_completion = ns3_time() - surf_get_clock(); - -// XBT_INFO("min : %f",min); -// XBT_INFO("ns3 time : %f",ns3_time()); -// XBT_INFO("surf time : %f",surf_get_clock()); - - xbt_assert(time_to_next_flow_completion, - "Time to next flow completion not initialized!\n"); + if (!xbt_swag_size(running_actions) || min == 0.0) + return -1.0; + else + do { + ns3_simulator(min); + time_to_next_flow_completion = ns3_time() - surf_get_clock(); + } while(time_to_next_flow_completion==0.0); + + XBT_DEBUG("min : %f",min); + XBT_DEBUG("ns3 time : %f",ns3_time()); + XBT_DEBUG("surf time : %f",surf_get_clock()); + XBT_DEBUG("Next completion %f :",time_to_next_flow_completion); - XBT_DEBUG("ns3_share_resources return %f",time_to_next_flow_completion); return time_to_next_flow_completion; } @@ -453,7 +464,7 @@ static void ns3_update_actions_state(double now, double delta) TRACE_surf_link_set_utilization ((*link)->generic_resource.name, action->generic_action.data, (surf_action_t) action, - (data_delta_sent), + (data_delta_sent)/delta, now-delta, delta); }