X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dbb6a5398ebdb917f1de3acc0d16cd83cd23de71..2f2ce19fcb66a634c19de8dda2dc4b4896203537:/src/surf/network_ns3.c diff --git a/src/surf/network_ns3.c b/src/surf/network_ns3.c index e5684d7bed..dc56b4db58 100644 --- a/src/surf/network_ns3.c +++ b/src/surf/network_ns3.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2008, 2009, 2010, 2011. The SimGrid Team. +/* Copyright (c) 2007-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -18,16 +18,17 @@ 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; -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(void *src_elm, void *dst_elm, - double size, double rate); +static double ns3_share_resources(surf_model_t network_model, double min); +static void ns3_update_actions_state(surf_model_t network_model, double now, double delta); +static void finalize(surf_model_t network_model); +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); @@ -108,13 +109,13 @@ static void parse_ns3_add_router(sg_platf_router_cbarg_t router) ); } -static void parse_ns3_add_AS(const char*id, const char*routing) +static void parse_ns3_add_AS(sg_platf_AS_cbarg_t AS) { - XBT_DEBUG("NS3_ADD_AS '%s'",id); + XBT_DEBUG("NS3_ADD_AS '%s'",AS->id); xbt_lib_set(as_router_lib, - id, + AS->id, NS3_ASR_LEVEL, - ns3_add_AS(id) + ns3_add_AS(AS->id) ); } @@ -214,7 +215,7 @@ static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster) replace_bdw_ns3(&bw); ns3_add_cluster(bw,lat,cluster->id); xbt_free(lat); - xbt_free(bw); + xbt_free(bw); } static double ns3_get_link_latency (const void *link) @@ -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,8 +261,8 @@ static void create_ns3_topology(void) onelink_t onelink; unsigned int iter; xbt_dynar_foreach(onelink_routes, iter, onelink) { - char *src = ((network_element_t)onelink->src)->name; - char *dst = ((network_element_t)onelink->dst)->name; + 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); @@ -271,7 +272,7 @@ static void create_ns3_topology(void) replace_bdw_ns3(&link_bdw); ((surf_ns3_link_t)link)->created = 0; - // XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id); + // XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id); XBT_DEBUG("\tLink (%s) bdw:%s lat:%s",((surf_ns3_link_t)link)->data->id, link_bdw, link_lat @@ -316,8 +317,8 @@ static void free_ns3_link(void * elmts) static void free_ns3_host(void * elmts) { - ns3_nodes_t host = elmts; - free(host); + ns3_nodes_t host = elmts; + free(host); } #ifdef HAVE_LATENCY_BOUND_TRACKING @@ -341,6 +342,7 @@ void surf_network_model_init_NS3() surf_network_model = surf_model_init(); surf_network_model->name = "network NS3"; + surf_network_model->type = SURF_MODEL_TYPE_NETWORK; surf_network_model->extension.network.get_link_latency = ns3_get_link_latency; surf_network_model->extension.network.get_link_bandwidth = ns3_get_link_bandwidth; surf_network_model->extension.network.get_route = ns3_get_route; @@ -361,11 +363,11 @@ void surf_network_model_init_NS3() /* Added the initialization for NS3 interface */ - if (ns3_initialize(xbt_cfg_get_string(_surf_cfg_set,"ns3/TcpModel"))) { + if (ns3_initialize(xbt_cfg_get_string(_sg_cfg_set, "ns3/TcpModel"))) { xbt_die("Impossible to initialize NS3 interface"); } - routing_model_create(sizeof(s_surf_ns3_link_t), NULL); + routing_model_create(NULL); define_callbacks_ns3(); NS3_HOST_LEVEL = xbt_lib_add_level(host_lib,(void_f_pvoid_t)free_ns3_host); @@ -379,19 +381,19 @@ void surf_network_model_init_NS3() #endif } -static void finalize(void) +static void finalize(surf_model_t network_model) { ns3_finalize(); xbt_dynar_free_container(&IPV4addr); xbt_dict_free(&dict_socket); } -static double ns3_share_resources(double min) +static double ns3_share_resources(surf_model_t network_model, double min) { XBT_DEBUG("ns3_share_resources"); xbt_swag_t running_actions = - surf_network_model->states.running_action_set; + network_model->states.running_action_set; //get the first relevant value from the running_actions list if (!xbt_swag_size(running_actions) || min == 0.0) @@ -410,7 +412,7 @@ static double ns3_share_resources(double min) return time_to_next_flow_completion; } -static void ns3_update_actions_state(double now, double delta) +static void ns3_update_actions_state(surf_model_t network_model, double now, double delta) { xbt_dict_cursor_t cursor = NULL; char *key; @@ -421,7 +423,7 @@ static void ns3_update_actions_state(double now, double delta) surf_action_network_ns3_t action = NULL; xbt_swag_t running_actions = - surf_network_model->states.running_action_set; + network_model->states.running_action_set; /* If there are no running flows, just return */ if (!xbt_swag_size(running_actions)) { @@ -478,15 +480,16 @@ static void ns3_update_actions_state(double now, double delta) } /* Max durations are not supported */ -static surf_action_t ns3_communicate(void *src_elm, - void *dst_elm, 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",((network_element_t)src_elm)->name,((network_element_t)dst_elm)->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(((network_element_t)src_elm)->name, ((network_element_t)dst_elm)->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;