X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f00f8da2fe2073d48fc817d7d0272997837200fd..346c06db41ebb088e88351d8381d0c232d2ddbb5:/src/surf/network_ns3.c diff --git a/src/surf/network_ns3.c b/src/surf/network_ns3.c index 6e047c783c..5083d948ba 100644 --- a/src/surf/network_ns3.c +++ b/src/surf/network_ns3.c @@ -18,7 +18,7 @@ extern xbt_lib_t as_router_lib; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_ns3, surf, "Logging specific to the SURF network NS3 module"); -extern routing_global_t global_routing; +extern routing_platf_t routing_platf; extern xbt_dict_t dict_socket; static double time_to_next_flow_completion = -1; @@ -26,8 +26,9 @@ static double time_to_next_flow_completion = -1; static double ns3_share_resources(double min); static void ns3_update_actions_state(double now, double delta); static void finalize(void); -static surf_action_t ns3_communicate(const char *src_name, - const char *dst_name, double size, double rate); +static surf_action_t ns3_communicate(sg_routing_edge_t src_elm, + sg_routing_edge_t dst_elm, + double size, double rate); static void action_suspend(surf_action_t action); static void action_resume(surf_action_t action); static int action_is_suspended(surf_action_t action); @@ -232,10 +233,10 @@ static double ns3_get_link_bandwidth (const void *link) return bdw; } -static xbt_dynar_t ns3_get_route(const char *src, const char *dst) +static xbt_dynar_t ns3_get_route(void *src_card, void *dst_card) { xbt_dynar_t route = NULL; - routing_get_route_and_latency(src, dst, &route, NULL); + routing_get_route_and_latency(src_card, dst_card, &route, NULL); return route; } @@ -252,7 +253,7 @@ static void create_ns3_topology(void) xbt_dynar_shrink(IPV4addr,0); //get the onelinks from the parsed platform - xbt_dynar_t onelink_routes = global_routing->get_onelink_routes(); + xbt_dynar_t onelink_routes = routing_platf->get_onelink_routes(); if (!onelink_routes) xbt_die("There is no routes!"); XBT_DEBUG("Have get_onelink_routes, found %ld routes",onelink_routes->used); @@ -260,10 +261,9 @@ static void create_ns3_topology(void) onelink_t onelink; unsigned int iter; xbt_dynar_foreach(onelink_routes, iter, onelink) { - char *src = onelink->src; - char *dst = onelink->dst; + char *src = onelink->src->name; + char *dst = onelink->dst->name; void *link = onelink->link_ptr; - if( strcmp(src,dst) && ((surf_ns3_link_t)link)->created){ XBT_DEBUG("Route from '%s' to '%s' with link '%s'",src,dst,((surf_ns3_link_t)link)->data->id); char * link_bdw = xbt_strdup(((surf_ns3_link_t)link)->data->bdw); @@ -444,7 +444,8 @@ static void ns3_update_actions_state(double now, double delta) double data_delta_sent = data_sent - action->last_sent; xbt_dynar_t route = NULL; - routing_get_route_and_latency (action->src_name, action->dst_name, &route, NULL); + + routing_get_route_and_latency (action->src_elm, action->dst_elm, &route, NULL); unsigned int i; for (i = 0; i < xbt_dynar_length (route); i++){ surf_ns3_link_t *link = ((surf_ns3_link_t*)xbt_dynar_get_ptr (route, i)); @@ -478,20 +479,21 @@ static void ns3_update_actions_state(double now, double delta) } /* Max durations are not supported */ -static surf_action_t ns3_communicate(const char *src_name, - const char *dst_name, double size, double rate) +static surf_action_t ns3_communicate(sg_routing_edge_t src_elm, + sg_routing_edge_t dst_elm, + double size, double rate) { surf_action_network_ns3_t action = NULL; - XBT_DEBUG("Communicate from %s to %s",src_name,dst_name); + XBT_DEBUG("Communicate from %s to %s", src_elm->name, dst_elm->name); action = surf_action_new(sizeof(s_surf_action_network_ns3_t), size, surf_network_model, 0); - ns3_create_flow(src_name, dst_name, surf_get_clock(), size, action); + ns3_create_flow(src_elm->name, dst_elm->name, surf_get_clock(), size, action); #ifdef HAVE_TRACING action->last_sent = 0; - action->src_name = xbt_strdup (src_name); - action->dst_name = xbt_strdup (dst_name); + action->src_elm = src_elm; + action->dst_elm = dst_elm; #endif return (surf_action_t) action; @@ -522,8 +524,6 @@ static int action_unref(surf_action_t action) xbt_swag_remove(action, action->state_set); #ifdef HAVE_TRACING - xbt_free(((surf_action_network_ns3_t)action)->src_name); - xbt_free(((surf_action_network_ns3_t)action)->dst_name); xbt_free(action->category); #endif XBT_DEBUG ("Removing action %p", action);