X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e5b9aba8d360583bd56a42dfa5d49f85f1917616..6ea02583071600052a8d20356d211df93a6eec4b:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index d3ec49e1c9..f11bd97a56 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -629,7 +629,9 @@ void routing_model_create(size_t size_of_links, void* loopback) { surfxml_add_callback(ETag_surfxml_AS_cb_list, &parse_E_AS); /* DEBUG ONLY */ - surfxml_add_callback(ETag_surfxml_platform_cb_list, &DEBUG_exit); + //surfxml_add_callback(ETag_surfxml_platform_cb_list, &DEBUG_exit); + + // TODO checked if ANY AS are duplicated } /* ************************************************************************** */ @@ -748,8 +750,8 @@ static void model_full_end(void) { /* Put the routes in position */ xbt_dict_foreach(routing->parse_routes, cursor, key, data) { keys = xbt_str_split_str(key, sep); - src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16); - dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16); + src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10); + dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10); TO_ROUTE_FULL(src_id,dst_id) = generic_new_extended_route(current_routing->hierarchy,data,1); xbt_dynar_free(&keys); } @@ -851,17 +853,22 @@ static route_extended_t floyd_get_route(routing_component_t rc, const char* src, if(first) first_gw = gw_dst; if(rc->hierarchy == SURF_ROUTING_RECURSIVE && !first && strcmp(gw_dst,prev_gw_src)) { - routing_component_t src_as = xbt_dict_get_or_null(global_routing->where_network_elements,gw_dst); - routing_component_t dst_as = xbt_dict_get_or_null(global_routing->where_network_elements,prev_gw_src); - xbt_assert4(src_as==dst_as,"bad routing, differents AS gateways in route \"%s\" to \"%s\" (\"%s\"-\"%s\")",src,dst,gw_dst,prev_gw_src); - route_extended_t e_route_as_to_as = (*(src_as->get_route))(src_as,gw_dst,prev_gw_src); + //routing_component_t src_as = xbt_dict_get_or_null(global_routing->where_network_elements,gw_dst); + //routing_component_t dst_as = xbt_dict_get_or_null(global_routing->where_network_elements,prev_gw_src); + //xbt_assert4(src_as==dst_as,"bad routing, differents AS gateways in route \"%s\" to \"%s\" (\"%s\"-\"%s\")",src,dst,gw_dst,prev_gw_src); + //route_extended_t e_route_as_to_as = (*(src_as->get_route))(src_as,gw_dst,prev_gw_src); + // TODO: - check for error - is possible to generate a route like = as----as----as + xbt_dynar_t e_route_as_to_as = (*(global_routing->get_route))(gw_dst,prev_gw_src); xbt_assert2(e_route_as_to_as,"no route between \"%s\" and \"%s\"",gw_dst,prev_gw_src); - links = e_route_as_to_as->generic_route.link_list; + //links = e_route_as_to_as->generic_route.link_list; + links = e_route_as_to_as; int pos = 0; xbt_dynar_foreach(links, cpt, link) { xbt_dynar_insert_at(new_e_route->generic_route.link_list,pos,&link); pos++; } +// xbt_dynar_free(&(e_route_as_to_as->generic_route.link_list)); +// xbt_free(e_route_as_to_as); } links = e_route->generic_route.link_list; @@ -950,18 +957,18 @@ static void model_floyd_end(void) { for(j = 0; jparse_routes, cursor, key, data) { keys = xbt_str_split_str(key, sep); - src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16); - dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16); + src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10); + dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10); TO_FLOYD_LINK(src_id,dst_id) = generic_new_extended_route(current_routing->hierarchy,data,0); TO_FLOYD_PRED(src_id,dst_id) = src_id; //link cost - TO_FLOYD_COST(src_id,dst_id) = 1; // assume 1 for now // TODO DAVID REDO + TO_FLOYD_COST(src_id,dst_id) = ((TO_FLOYD_LINK(src_id,dst_id))->generic_route.link_list)->used; // assume 1 for now // TODO DAVID REDO xbt_dynar_free(&keys); } @@ -1206,11 +1213,10 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, const char* s xbt_assert2(edge != NULL, "no route between host %d and %d", *src_id, *dst_id); e_route = (route_extended_t)xbt_graph_edge_get_data(edge); - - // TODO: correct the order + links = e_route->generic_route.link_list; xbt_dynar_foreach(links, cpt, link) { - xbt_dynar_push(new_e_route->generic_route.link_list,&link); + xbt_dynar_unshift(new_e_route->generic_route.link_list,&link); } return new_e_route; @@ -1262,7 +1268,8 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, const char* s xbt_node_t u_node = xbt_graph_edge_get_target(edge); graph_node_data_t data = xbt_graph_node_get_data(u_node); int u_id = data->graph_id; - int cost_v_u = 1; //fixed link cost for now // TODO DAVID REDO + route_extended_t tmp_e_route = (route_extended_t)xbt_graph_edge_get_data(edge); // added TODO DAVID REDO + int cost_v_u = (tmp_e_route->generic_route.link_list)->used; //fixed link cost for now // TODO DAVID REDO if(cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) { pred_arr[u_id] = *v_id; @@ -1279,7 +1286,6 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, const char* s xbt_free(cost_arr); xbt_heap_free(pqueue); - } //compose route path with links @@ -1302,19 +1308,22 @@ static route_extended_t dijkstra_get_route(routing_component_t rc, const char* s if(v==dst_node_id) first_gw = gw_dst; if(rc->hierarchy == SURF_ROUTING_RECURSIVE && v!=dst_node_id && strcmp(gw_dst,prev_gw_src)) { - routing_component_t src_as = xbt_dict_get_or_null(global_routing->where_network_elements,gw_dst); - routing_component_t dst_as = xbt_dict_get_or_null(global_routing->where_network_elements,prev_gw_src); - xbt_assert4(src_as==dst_as,"bad routing, differents AS gateways in route \"%s\" to \"%s\" (\"%s\"-\"%s\")",src,dst,gw_dst,prev_gw_src); - route_extended_t e_route_as_to_as = (*(src_as->get_route))(src_as,gw_dst,prev_gw_src); + //routing_component_t src_as = xbt_dict_get_or_null(global_routing->where_network_elements,gw_dst); + //routing_component_t dst_as = xbt_dict_get_or_null(global_routing->where_network_elements,prev_gw_src); + //xbt_assert4(src_as==dst_as,"bad routing, differents AS gateways in route \"%s\" to \"%s\" (\"%s\"-\"%s\")",src,dst,gw_dst,prev_gw_src); + //route_extended_t e_route_as_to_as = (*(src_as->get_route))(src_as,gw_dst,prev_gw_src); + // TODO: - check for error - is possible to generate a route like = as----as----as + xbt_dynar_t e_route_as_to_as = (*(global_routing->get_route))(gw_dst,prev_gw_src); xbt_assert2(e_route_as_to_as,"no route between \"%s\" and \"%s\"",gw_dst,prev_gw_src); - links = e_route_as_to_as->generic_route.link_list; + //links = e_route_as_to_as->generic_route.link_list; + links = e_route_as_to_as; int pos = 0; xbt_dynar_foreach(links, cpt, link) { xbt_dynar_insert_at(new_e_route->generic_route.link_list,pos,&link); pos++; } - xbt_dynar_free(&(e_route_as_to_as->generic_route.link_list)); - xbt_free(e_route_as_to_as); +// xbt_dynar_free(&(e_route_as_to_as->generic_route.link_list)); +// xbt_free(e_route_as_to_as); } links = e_route->generic_route.link_list; @@ -1417,8 +1426,8 @@ static void model_dijkstra_both_end(void) { /* Put the routes in position */ xbt_dict_foreach(routing->parse_routes, cursor, key, data) { keys = xbt_str_split_str(key, sep); - src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16); - dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16); + src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 10); + dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 10); route_extended_t e_route = generic_new_extended_route(current_routing->hierarchy,data,0); route_new_dijkstra(routing,src_id,dst_id,e_route); xbt_dynar_free(&keys); @@ -2013,45 +2022,6 @@ static void DEBUG_exit(void) { printf("\n"); } } - for(i=0;i>>\n ",names[i],names[j]); - links = (*(global_routing->get_route))(names[i],names[j]); - printf(">>>"); - unsigned int cpt=0; - xbt_dynar_foreach(links, cpt, link) { - s_surf_resource_t* generic_resource = link; - printf(" %s",generic_resource->name); - } - printf("\n"); - } - } - for(i=0;i>>\n ",names[i],names[j]); - links = (*(global_routing->get_route))(names[i],names[j]); - printf(">>>"); - unsigned int cpt=0; - xbt_dynar_foreach(links, cpt, link) { - s_surf_resource_t* generic_resource = link; - printf(" %s",generic_resource->name); - } - printf("\n"); - } - } - for(i=0;i>>\n ",names[i],names[j]); - links = (*(global_routing->get_route))(names[i],names[j]); - printf(">>>"); - unsigned int cpt=0; - xbt_dynar_foreach(links, cpt, link) { - s_surf_resource_t* generic_resource = link; - printf(" %s",generic_resource->name); - } - printf("\n"); - } - } printf("----------------------------------\n\n"); printf("---------- call finalize ---------\n");