- XBT_DEBUG("Starting topology generation");
-
- xbt_dynar_shrink(IPV4addr,0);
-
- //get the onelinks from the parsed platform
- xbt_dynar_t onelink_routes = routing_platf->getOneLinkRoutes();
- if (!onelink_routes)
- xbt_die("There is no routes!");
- XBT_DEBUG("Have get_onelink_routes, found %ld routes",onelink_routes->used);
- //save them in trace file
- simgrid::surf::Onelink *onelink;
- unsigned int iter;
- xbt_dynar_foreach(onelink_routes, iter, onelink) {
- char *src = onelink->src_->name();
- char *dst = onelink->dst_->name();
- simgrid::surf::NetworkNS3Link *link =
- static_cast<simgrid::surf::NetworkNS3Link *>(onelink->link_);
-
- if (strcmp(src,dst) && link->m_created){
- XBT_DEBUG("Route from '%s' to '%s' with link '%s'", src, dst, link->getName());
- char * link_bdw = bprintf("%fBps", link->getBandwidth());
- char * link_lat = bprintf("%fs", link->getLatency());
- link->m_created = 0;
-
- // 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", link->getName(), link_bdw, link_lat);
-
- //create link ns3
- ns3_nodes_t host_src = ns3_find_host(src);
- if (!host_src)
- host_src = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(as_router_lib,src,NS3_ASR_LEVEL));
- ns3_nodes_t host_dst = ns3_find_host(dst);
- if(!host_dst)
- host_dst = static_cast<ns3_nodes_t>(xbt_lib_get_or_null(as_router_lib,dst,NS3_ASR_LEVEL));
-
- if (!host_src || !host_dst)
- xbt_die("\tns3_add_link from %d to %d",host_src->node_num,host_dst->node_num);
-
- ns3_add_link(host_src->node_num,host_src->type,host_dst->node_num,host_dst->type,link_bdw,link_lat);
-
- xbt_free(link_bdw);
- xbt_free(link_lat);
- }
+ if (link_list.size() == 1) {
+ simgrid::kernel::resource::LinkNS3* link = static_cast<simgrid::kernel::resource::LinkNS3*>(link_list[0]);
+
+ XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->get_cname(), dst->get_cname(), link->get_cname(),
+ (symmetrical ? "(symmetrical)" : "(not symmetrical)"));
+
+ // XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id);
+ XBT_DEBUG("\tLink (%s) bw:%fbps lat:%fs", link->get_cname(), link->get_bandwidth(), link->get_latency());
+
+ // create link ns3
+ NetPointNs3* host_src = src->extension<NetPointNs3>();
+ NetPointNs3* host_dst = dst->extension<NetPointNs3>();
+
+ xbt_assert(host_src != nullptr, "Network element %s does not seem to be NS3-ready", src->get_cname());
+ xbt_assert(host_dst != nullptr, "Network element %s does not seem to be NS3-ready", dst->get_cname());
+
+ ns3_add_link(host_src, host_dst, link->get_bandwidth(), link->get_latency());
+ } else {
+ static bool warned_about_long_routes = false;
+
+ if (not warned_about_long_routes)
+ XBT_WARN("Ignoring a route between %s and %s of length %zu: Only routes of length 1 are considered with NS3.\n"
+ "WARNING: You can ignore this warning if your hosts can still communicate when only considering routes "
+ "of length 1.\n"
+ "WARNING: Remove long routes to avoid this harmless message; subsequent long routes will be silently "
+ "ignored.",
+ src->get_cname(), dst->get_cname(), link_list.size());
+ warned_about_long_routes = true;