Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use new tag host_link for peer. No need for router now.
[simgrid.git] / src / surf / surf_routing.c
index b9ae258..f024565 100644 (file)
@@ -27,6 +27,8 @@ int SD_HOST_LEVEL;              //Simdag level
 int COORD_HOST_LEVEL=0;         //Coordinates level
 int NS3_HOST_LEVEL;             //host node for ns3
 
+xbt_dict_t watched_hosts_lib;
+
 /**
  * @ingroup SURF_build_api
  * @brief A library containing all known links
@@ -43,8 +45,18 @@ int NS3_ASR_LEVEL;              //host node for ns3
 
 static xbt_dict_t random_value = NULL;
 
+/** @brief Retrieve a routing edge from its name
+ *
+ * Routing edges are either CPU/workstation and routers, whatever
+ */
+sg_routing_edge_t sg_routing_edge_by_name_or_null(const char *name) {
+    sg_routing_edge_t net_elm = xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL);
+    if(!net_elm) net_elm = xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
+  return net_elm;
+}
+
 /* Global vars */
-routing_global_t global_routing = NULL;
+routing_platf_t routing_platf = NULL;
 AS_t current_routing = NULL;
 
 /* global parse functions */
@@ -99,6 +111,37 @@ struct s_model_type routing_models[] = {
   {NULL, NULL, NULL, NULL}
 };
 
+/**
+ * \brief Add a "host_link" to the network element list
+ */
+static void parse_S_host_link(sg_platf_host_link_cbarg_t host)
+{
+  sg_routing_edge_t info = NULL;
+  info = xbt_lib_get_or_null(host_lib, host->id, ROUTING_HOST_LEVEL);
+  xbt_assert(info, "Host '%s' not found!",host->id);
+  xbt_assert(current_routing->model_desc == &routing_models[SURF_MODEL_CLUSTER] ||
+      current_routing->model_desc == &routing_models[SURF_MODEL_VIVALDI],
+      "You have to be in model Cluster to use tag host_link!");
+
+  s_surf_parsing_link_up_down_t link_up_down;
+  link_up_down.link_up = xbt_lib_get_or_null(link_lib, host->link_up, SURF_LINK_LEVEL);
+  link_up_down.link_down = xbt_lib_get_or_null(link_lib, host->link_down, SURF_LINK_LEVEL);
+
+  xbt_assert(link_up_down.link_up, "Link '%s' not found!",host->link_up);
+  xbt_assert(link_up_down.link_down, "Link '%s' not found!",host->link_down);
+
+  if(!current_routing->link_up_down_list)
+    current_routing->link_up_down_list = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
+
+  // If dynar is is greater than edge id and if the host_link is already defined
+  if(xbt_dynar_length(current_routing->link_up_down_list) > info->id &&
+      xbt_dynar_get_as(current_routing->link_up_down_list,info->id,void*))
+    xbt_die("Host_link for '%s' is already defined!",host->id);
+
+  XBT_DEBUG("Push Host_link for host '%s' to position %d",info->name,info->id);
+  xbt_dynar_set_as(current_routing->link_up_down_list,info->id,s_surf_parsing_link_up_down_t,link_up_down);
+}
+
 /**
  * \brief Add a "host" to the network element list
  */
@@ -189,13 +232,10 @@ static void parse_S_router(sg_platf_router_cbarg_t router)
  */
 static void routing_parse_S_route(void)
 {
-  if (src != NULL && dst != NULL && parsed_link_list != NULL)
-    THROWF(arg_error, 0, "Route between %s to %s can not be defined",
-           A_surfxml_route_src, A_surfxml_route_dst);
   src = A_surfxml_route_src;
   dst = A_surfxml_route_dst;
   xbt_assert(strlen(src) > 0 || strlen(dst) > 0,
-             "Some limits are null in the route between \"%s\" and \"%s\"",
+             "Missing end-points while defining route \"%s\"->\"%s\"",
              src, dst);
   parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
@@ -205,17 +245,13 @@ static void routing_parse_S_route(void)
  */
 static void routing_parse_S_ASroute(void)
 {
-  if (src != NULL && dst != NULL && parsed_link_list != NULL)
-    THROWF(arg_error, 0, "Route between %s to %s can not be defined",
-           A_surfxml_ASroute_src, A_surfxml_ASroute_dst);
   src = A_surfxml_ASroute_src;
   dst = A_surfxml_ASroute_dst;
   gw_src = A_surfxml_ASroute_gw_src;
   gw_dst = A_surfxml_ASroute_gw_dst;
-  xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0
-             || strlen(gw_dst) > 0,
-             "Some limits are null in the route between \"%s\" and \"%s\"",
-             src, dst);
+  xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 || strlen(gw_dst) > 0,
+             "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
+             src, dst,gw_src,gw_dst);
   parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
@@ -224,18 +260,13 @@ static void routing_parse_S_ASroute(void)
  */
 static void routing_parse_S_bypassRoute(void)
 {
-  if (src != NULL && dst != NULL && parsed_link_list != NULL)
-    THROWF(arg_error, 0,
-           "Bypass Route between %s to %s can not be defined",
-           A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
   src = A_surfxml_bypassRoute_src;
   dst = A_surfxml_bypassRoute_dst;
   gw_src = NULL;
   gw_dst = NULL;
-  xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0
-             || strlen(gw_dst) > 0,
-             "Some limits are null in the route between \"%s\" and \"%s\"",
-             src, dst);
+  xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 || strlen(gw_dst) > 0,
+             "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
+             src, dst,gw_src,gw_dst);
   parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
@@ -244,18 +275,13 @@ static void routing_parse_S_bypassRoute(void)
  */
 static void routing_parse_S_bypassASroute(void)
 {
-  if (src != NULL && dst != NULL && parsed_link_list != NULL)
-    THROWF(arg_error, 0,
-           "Bypass AS Route between %s to %s can not be defined",
-           A_surfxml_bypassASroute_src, A_surfxml_bypassASroute_dst);
   src = A_surfxml_bypassASroute_src;
   dst = A_surfxml_bypassASroute_dst;
   gw_src = A_surfxml_bypassASroute_gw_src;
   gw_dst = A_surfxml_bypassASroute_gw_dst;
-  xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0
-             || strlen(gw_dst) > 0,
-             "Some limits are null in the route between \"%s\" and \"%s\"",
-             src, dst);
+  xbt_assert(strlen(src) > 0 || strlen(dst) > 0 || strlen(gw_src) > 0 || strlen(gw_dst) > 0,
+             "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
+             src, dst,gw_src,gw_dst);
   parsed_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 /**
@@ -306,19 +332,15 @@ static void routing_parse_E_ASroute(void)
   e_route->link_list = parsed_link_list;
 
   if (!strcmp(current_routing->model_desc->name,"RuleBased")) {
-    e_route->src_gateway = (sg_routing_edge_t) gw_src; // DIRTY HACK possible only
-    e_route->dst_gateway = (sg_routing_edge_t) gw_dst; // because of what is in routing_parse_E_ASroute
+    // DIRTY PERL HACK AHEAD: with the rulebased routing, the {src,dst}_gateway fields
+    // store the provided name instead of the entity directly (model_rulebased_parse_ASroute knows)
+    //
+    // This is because the user will provide something like "^AS_(.*)$" instead of the proper name of a given entity
+    e_route->src_gateway = (sg_routing_edge_t) gw_src;
+    e_route->dst_gateway = (sg_routing_edge_t) gw_dst;
   } else {
-    e_route->src_gateway =  xbt_lib_get_or_null(as_router_lib, gw_src,
-                                                ROUTING_ASR_LEVEL);
-    if (!e_route->src_gateway)
-      e_route->src_gateway = xbt_lib_get_or_null(host_lib, gw_src,
-                                                 ROUTING_HOST_LEVEL);
-    e_route->dst_gateway =  xbt_lib_get_or_null(as_router_lib, gw_dst,
-                                                ROUTING_ASR_LEVEL);
-    if (!e_route->dst_gateway)
-      e_route->dst_gateway = xbt_lib_get_or_null(host_lib, gw_dst,
-                                                 ROUTING_HOST_LEVEL);
+    e_route->src_gateway = sg_routing_edge_by_name_or_null(gw_src);
+    e_route->dst_gateway = sg_routing_edge_by_name_or_null(gw_dst);
   }
   xbt_assert(current_routing->parse_ASroute,
              "no defined method \"set_ASroute\" in \"%s\"",
@@ -358,16 +380,8 @@ static void routing_parse_E_bypassASroute(void)
 {
   route_t e_route = xbt_new0(s_route_t, 1);
   e_route->link_list = parsed_link_list;
-  e_route->src_gateway = xbt_lib_get_or_null(as_router_lib, gw_src,
-                                             ROUTING_ASR_LEVEL);
-  if (!e_route->src_gateway)
-    e_route->src_gateway = xbt_lib_get_or_null(host_lib, gw_src,
-                                               ROUTING_HOST_LEVEL);
-  e_route->dst_gateway = xbt_lib_get_or_null(as_router_lib, gw_dst,
-                                             ROUTING_ASR_LEVEL);
-  if (!e_route->dst_gateway)
-    e_route->dst_gateway = xbt_lib_get_or_null(host_lib, gw_dst,
-                                               ROUTING_HOST_LEVEL);
+  e_route->src_gateway = sg_routing_edge_by_name_or_null(gw_src);
+  e_route->dst_gateway = sg_routing_edge_by_name_or_null(gw_dst);
   xbt_assert(current_routing->parse_bypassroute,
              "Bypassing mechanism not implemented by routing '%s'",
              current_routing->name);
@@ -392,28 +406,25 @@ static void routing_parse_E_bypassASroute(void)
  * @param AS_id name of this autonomous system. Must be unique in the platform
  * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c
  */
-void routing_AS_begin(const char *AS_id, const char *wanted_routing_type)
+void routing_AS_begin(const char *AS_id, int wanted_routing_type)
 {
   AS_t new_as;
   routing_model_description_t model = NULL;
-  int cpt;
 
   xbt_assert(!xbt_lib_get_or_null
              (as_router_lib, AS_id, ROUTING_ASR_LEVEL),
              "The AS \"%s\" already exists", AS_id);
 
   /* search the routing model */
-  for (cpt = 0; routing_models[cpt].name; cpt++)
-    if (!strcmp(wanted_routing_type, routing_models[cpt].name))
-      model = &routing_models[cpt];
-  /* if its not exist, error */
-  if (model == NULL) {
-    fprintf(stderr, "Routing model %s not found. Existing models:\n",
-            wanted_routing_type);
-    for (cpt = 0; routing_models[cpt].name; cpt++)
-      fprintf(stderr, "   %s: %s\n", routing_models[cpt].name,
-              routing_models[cpt].desc);
-    xbt_die("dying");
+  switch(wanted_routing_type){
+    case A_surfxml_AS_routing_Cluster:       model = &routing_models[SURF_MODEL_CLUSTER];break;
+    case A_surfxml_AS_routing_Dijkstra:      model = &routing_models[SURF_MODEL_DIJKSTRA];break;
+    case A_surfxml_AS_routing_DijkstraCache: model = &routing_models[SURF_MODEL_DIJKSTRACACHE];break;
+    case A_surfxml_AS_routing_Floyd:         model = &routing_models[SURF_MODEL_FLOYD];break;
+    case A_surfxml_AS_routing_Full:          model = &routing_models[SURF_MODEL_FULL];break;
+    case A_surfxml_AS_routing_None:          model = &routing_models[SURF_MODEL_NONE];break;
+    case A_surfxml_AS_routing_RuleBased:     model = &routing_models[SURF_MODEL_RULEBASED];break;
+    case A_surfxml_AS_routing_Vivaldi:       model = &routing_models[SURF_MODEL_VIVALDI];break;
   }
 
   /* make a new routing component */
@@ -425,13 +436,13 @@ void routing_AS_begin(const char *AS_id, const char *wanted_routing_type)
   sg_routing_edge_t info = NULL;
   info = xbt_new0(s_network_element_t, 1);
 
-  if (current_routing == NULL && global_routing->root == NULL) {
+  if (current_routing == NULL && routing_platf->root == NULL) {
 
     /* it is the first one */
     new_as->routing_father = NULL;
-    global_routing->root = new_as;
+    routing_platf->root = new_as;
     info->id = -1;
-  } else if (current_routing != NULL && global_routing->root != NULL) {
+  } else if (current_routing != NULL && routing_platf->root != NULL) {
 
     xbt_assert(!xbt_dict_get_or_null
                (current_routing->routing_sons, AS_id),
@@ -595,17 +606,16 @@ static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
 
   /* Common ancestor is kind enough to declare a bypass route from src to dst -- use it and bail out */
   if (e_route_bypass) {
-    xbt_dynar_merge(links,&(e_route_bypass->link_list));
+    xbt_dynar_merge(links, &e_route_bypass->link_list);
     generic_free_route(e_route_bypass);
     return;
   }
 
   /* If src and dst are in the same AS, life is good */
   if (src_father == dst_father) {       /* SURF_ROUTING_BASE */
-
     route.link_list = *links;
-
     common_father->get_route_and_latency(common_father, src, dst, &route,latency);
+    // if vivaldi latency+=vivaldi(src,dst)
     return;
   }
 
@@ -616,7 +626,9 @@ static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
   sg_routing_edge_t src_father_net_elm = src_father->net_elem;
   sg_routing_edge_t dst_father_net_elm = dst_father->net_elem;
 
-  common_father->get_route_and_latency(common_father, src_father_net_elm, dst_father_net_elm, &route,latency);
+  common_father->get_route_and_latency(common_father,
+                                       src_father_net_elm, dst_father_net_elm,
+                                       &route, latency);
 
   xbt_assert((route.src_gateway != NULL) && (route.dst_gateway != NULL),
       "bad gateways for route from \"%s\" to \"%s\"", src->name, dst->name);
@@ -627,15 +639,13 @@ static void _get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst,
   /* If source gateway is not our source, we have to recursively find our way up to this point */
   if (src != src_gateway_net_elm)
     _get_route_and_latency(src, src_gateway_net_elm, links, latency);
-
-  xbt_dynar_merge(links,&(route.link_list));
+  xbt_dynar_merge(links, &route.link_list);
 
   /* If dest gateway is not our destination, we have to recursively find our way from this point */
-  // FIXME why can't I factorize it the same way than [src;src_gw] without breaking the examples??
-  if (dst_gateway_net_elm != dst) {
+  if (dst_gateway_net_elm != dst)
     _get_route_and_latency(dst_gateway_net_elm, dst, links, latency);
-  }
-  xbt_dynar_free(&route.link_list);
+
+  // if vivaldi latency+=vivaldi(src_gateway,dst_gateway)
 }
 
 /**
@@ -658,8 +668,8 @@ void routing_get_route_and_latency(sg_routing_edge_t src,
 {
   XBT_DEBUG("routing_get_route_and_latency from %s to %s",src->name,dst->name);
   if (!*route) {
-    xbt_dynar_reset(global_routing->last_route);
-    *route = global_routing->last_route;
+    xbt_dynar_reset(routing_platf->last_route);
+    *route = routing_platf->last_route;
   }
 
   _get_route_and_latency(src, dst, route, latency);
@@ -691,18 +701,12 @@ static xbt_dynar_t recursive_get_onelink_routes(AS_t rc)
 
 static xbt_dynar_t get_onelink_routes(void)
 {
-  return recursive_get_onelink_routes(global_routing->root);
+  return recursive_get_onelink_routes(routing_platf->root);
 }
 
 e_surf_network_element_type_t routing_get_network_element_type(const char *name)
 {
-  sg_routing_edge_t rc = NULL;
-
-  rc = xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL);
-  if (rc)
-    return rc->rc_type;
-
-  rc = xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
+  sg_routing_edge_t rc = sg_routing_edge_by_name_or_null(name);
   if (rc)
     return rc->rc_type;
 
@@ -717,11 +721,11 @@ e_surf_network_element_type_t routing_get_network_element_type(const char *name)
 void routing_model_create( void *loopback)
 {
   /* config the uniq global routing */
-  global_routing = xbt_new0(s_routing_global_t, 1);
-  global_routing->root = NULL;
-  global_routing->get_onelink_routes = get_onelink_routes;
-  global_routing->loopback = loopback;
-  global_routing->last_route = xbt_dynar_new(sizeof(sg_routing_link_t),NULL);
+  routing_platf = xbt_new0(s_routing_platf_t, 1);
+  routing_platf->root = NULL;
+  routing_platf->get_onelink_routes = get_onelink_routes;
+  routing_platf->loopback = loopback;
+  routing_platf->last_route = xbt_dynar_new(sizeof(sg_routing_link_t),NULL);
   /* no current routing at moment */
   current_routing = NULL;
 }
@@ -773,6 +777,14 @@ void routing_model_create( void *loopback)
 /* ************************************************************************** */
 /* ************************* GENERIC PARSE FUNCTIONS ************************ */
 
+void routing_cluster_add_backbone(void* bb) {
+  xbt_assert(current_routing->model_desc == &routing_models[SURF_MODEL_CLUSTER],
+        "You have to be in model Cluster to use tag backbone!");
+  xbt_assert(!((as_cluster_t)current_routing)->backbone,"The backbone link is already defined!");
+  ((as_cluster_t)current_routing)->backbone = bb;
+  XBT_DEBUG("Add a backbone to AS '%s'",current_routing->name);
+}
+
 static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
 {
   char *host_id, *groups, *link_id = NULL;
@@ -795,7 +807,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
   }
 
   XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", cluster->id);
-  sg_platf_new_AS_begin(cluster->id, "Cluster");
+  sg_platf_new_AS_begin(cluster->id, A_surfxml_AS_routing_Cluster);
 
   current_routing->link_up_down_list
             = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL);
@@ -831,7 +843,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
         xbt_dict_set(patterns, "radical", bprintf("%d", i), NULL);
         char *avail_file = xbt_str_varsubst(cluster->availability_trace, patterns);
         XBT_DEBUG("\tavailability_file=\"%s\"", avail_file);
-        host.power_trace = tmgr_trace_new(avail_file);
+        host.power_trace = tmgr_trace_new_from_file(avail_file);
         xbt_free(avail_file);
       } else {
         XBT_DEBUG("\tavailability_file=\"\"");
@@ -840,7 +852,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
       if (strcmp(cluster->state_trace, "")) {
         char *avail_file = xbt_str_varsubst(cluster->state_trace, patterns);
         XBT_DEBUG("\tstate_file=\"%s\"", avail_file);
-        host.state_trace = tmgr_trace_new(avail_file);
+        host.state_trace = tmgr_trace_new_from_file(avail_file);
         xbt_free(avail_file);
       } else {
         XBT_DEBUG("\tstate_file=\"\"");
@@ -920,7 +932,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
 
     sg_platf_new_link(&link);
 
-    surf_routing_cluster_add_backbone(current_routing, xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL));
+    routing_cluster_add_backbone(xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL));
 
     free(link_backbone);
   }
@@ -939,7 +951,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer)
 {
   static int AX_ptr = 0;
   char *host_id = NULL;
-  char *router_id, *link_router, *link_backbone, *link_id_up, *link_id_down;
+  char *link_id;
 
   static unsigned int surfxml_buffer_stack_stack_ptr = 1;
   static unsigned int surfxml_buffer_stack_stack[1024];
@@ -948,17 +960,9 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer)
 
   surfxml_bufferstack_push(1);
 
-  XBT_DEBUG("<AS id=\"%s\"\trouting=\"Full\">", peer->id);
-  sg_platf_new_AS_begin(peer->id, "Full");
-
   XBT_DEBUG(" ");
   host_id = HOST_PEER(peer->id);
-  router_id = ROUTER_PEER(peer->id);
-  link_id_up = LINK_UP_PEER(peer->id);
-  link_id_down = LINK_DOWN_PEER(peer->id);
-
-  link_router = bprintf("%s_link_router", peer->id);
-  link_backbone = bprintf("%s_backbone", peer->id);
+  link_id = LINK_PEER(peer->id);
 
   XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->power);
   s_sg_platf_host_cbarg_t host;
@@ -973,79 +977,33 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer)
   host.coord = peer->coord;
   sg_platf_new_host(&host);
 
-
-  XBT_DEBUG("<router id=\"%s\"\tcoordinates=\"%s\"/>", router_id, peer->coord);
-  s_sg_platf_router_cbarg_t router;
-  memset(&router, 0, sizeof(router));
-  router.id = router_id;
-  router.coord = peer->coord;
-  sg_platf_new_router(&router);
-
-  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id_up,
+  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id,
             peer->bw_in, peer->lat);
   s_sg_platf_link_cbarg_t link;
   memset(&link, 0, sizeof(link));
   link.state = SURF_RESOURCE_ON;
-  link.policy = SURF_LINK_SHARED;
-  link.id = link_id_up;
+  link.policy = SURF_LINK_FULLDUPLEX;
+  link.id = link_id;
   link.bandwidth = peer->bw_in;
   link.latency = peer->lat;
   sg_platf_new_link(&link);
 
-  // FIXME: dealing with full duplex is not the role of this piece of code, I'd say [Mt]
-  // Instead, it should be created fullduplex, and the models will do what's needed in this case
-  XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id_down,
-            peer->bw_out, peer->lat);
-  link.id = link_id_down;
-  sg_platf_new_link(&link);
+  char* link_up = bprintf("%s_UP",link_id);
+  char* link_down = bprintf("%s_DOWN",link_id);
+  XBT_DEBUG("<host_link\tid=\"%s\"\tup=\"%s\"\tdown=\"%s\" />", host_id,link_up,link_down);
+  SURFXML_BUFFER_SET(host_link_id, host_id);
+  SURFXML_BUFFER_SET(host_link_up,   link_up);
+  SURFXML_BUFFER_SET(host_link_down, link_down);
+  SURFXML_START_TAG(host_link);
+  SURFXML_END_TAG(host_link);
+  free(link_up);
+  free(link_down);
 
   XBT_DEBUG(" ");
 
-  // begin here
-  XBT_DEBUG("<route\tsrc=\"%s\"\tdst=\"%s\"", host_id, router_id);
-  XBT_DEBUG("symmetrical=\"NO\">");
-  SURFXML_BUFFER_SET(route_src, host_id);
-  SURFXML_BUFFER_SET(route_dst, router_id);
-  A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_NO;
-  SURFXML_START_TAG(route);
-
-  XBT_DEBUG("<link_ctn\tid=\"%s\"/>", link_id_up);
-  SURFXML_BUFFER_SET(link_ctn_id, link_id_up);
-  A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
-  SURFXML_START_TAG(link_ctn);
-  SURFXML_END_TAG(link_ctn);
-
-  XBT_DEBUG("</route>");
-  SURFXML_END_TAG(route);
-
-  //Opposite Route
-  XBT_DEBUG("<route\tsrc=\"%s\"\tdst=\"%s\"", router_id, host_id);
-  XBT_DEBUG("symmetrical=\"NO\">");
-  SURFXML_BUFFER_SET(route_src, router_id);
-  SURFXML_BUFFER_SET(route_dst, host_id);
-  A_surfxml_route_symmetrical = A_surfxml_route_symmetrical_NO;
-  SURFXML_START_TAG(route);
-
-  XBT_DEBUG("<link_ctn\tid=\"%s\"/>", link_id_down);
-  SURFXML_BUFFER_SET(link_ctn_id, link_id_down);
-  A_surfxml_link_ctn_direction = A_surfxml_link_ctn_direction_NONE;
-  SURFXML_START_TAG(link_ctn);
-  SURFXML_END_TAG(link_ctn);
-
-  XBT_DEBUG("</route>");
-  SURFXML_END_TAG(route);
-
-  XBT_DEBUG("</AS>");
-  sg_platf_new_AS_end();
-  XBT_DEBUG(" ");
-
   //xbt_dynar_free(&tab_elements_num);
   free(host_id);
-  free(router_id);
-  free(link_router);
-  free(link_backbone);
-  free(link_id_up);
-  free(link_id_down);
+  free(link_id);
   surfxml_bufferstack_pop(1);
 }
 
@@ -1173,6 +1131,7 @@ void routing_register_callbacks()
 {
   sg_platf_host_add_cb(parse_S_host);
   sg_platf_router_add_cb(parse_S_router);
+  sg_platf_host_link_add_cb(parse_S_host_link);
 
   surfxml_add_callback(STag_surfxml_random_cb_list, &routing_parse_Srandom);
 
@@ -1228,9 +1187,9 @@ static void finalize_rec(AS_t as) {
 
 /** \brief Frees all memory allocated by the routing module */
 void routing_exit(void) {
-  if (!global_routing)
+  if (!routing_platf)
     return;
-  xbt_dynar_free(&global_routing->last_route);
-  finalize_rec(global_routing->root);
-  xbt_free(global_routing);
+  xbt_dynar_free(&routing_platf->last_route);
+  finalize_rec(routing_platf->root);
+  xbt_free(routing_platf);
 }