Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
create the loopback after the right configuration is set
[simgrid.git] / src / surf / network_ns3.cpp
index aedde29..9404d6b 100644 (file)
@@ -57,7 +57,7 @@ NetPointNs3::NetPointNs3()
 static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster)
 {
   char* lat = bprintf("%fs", cluster->lat);
-  char* bw  = bprintf("%fBps", cluster->bw);
+  char* bw  = bprintf("%fbps", cluster->bw * 8);
 
   for (int i : *cluster->radicals) {
     // Routers don't create a router on the other end of the private link by themselves.
@@ -69,6 +69,7 @@ static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster)
     NetPointNs3* host_src = sg_host_by_name(host_id)->pimpl_netpoint->extension<NetPointNs3>();
     xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id);
 
+    // Any NS3 route is symmetrical
     ns3_add_link(host_src, host_dst, bw, lat);
 
     delete host_dst;
@@ -95,7 +96,7 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin
 
     XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->cname(), dst->cname(), link->cname(),
               (symmetrical ? "(symmetrical)" : "(not symmetrical)"));
-    char* link_bdw = bprintf("%fBps", link->bandwidth());
+    char* link_bdw = bprintf("%fbps", link->bandwidth() * 8);
     char* link_lat = bprintf("%fs", link->latency());
 
     //   XBT_DEBUG("src (%s), dst (%s), src_id = %d, dst_id = %d",src,dst, src_id, dst_id);
@@ -108,9 +109,8 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin
     xbt_assert(host_src != nullptr, "Network element %s does not seem to be NS3-ready", src->cname());
     xbt_assert(host_dst != nullptr, "Network element %s does not seem to be NS3-ready", dst->cname());
 
+    // Any NS3 route is symmetrical
     ns3_add_link(host_src, host_dst, link_bdw, link_lat);
-    if (symmetrical)
-      ns3_add_link(host_dst, host_src, link_bdw, link_lat);
 
     xbt_free(link_bdw);
     xbt_free(link_lat);
@@ -163,7 +163,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
 
   simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) {
     pt->extension_set<NetPointNs3>(new NetPointNs3());
-
+    XBT_VERB("SimGrid's %s is known as node %d within NS3", pt->cname(), pt->extension<NetPointNs3>()->node_num);
   });
   simgrid::surf::on_cluster.connect(&clusterCreation_cb);
   simgrid::s4u::onPlatformCreated.connect(&postparse_cb);
@@ -466,7 +466,6 @@ void ns3_add_link(NetPointNs3* src, NetPointNs3* dst, char* bw, char* lat)
 {
   ns3::PointToPointHelper pointToPoint;
 
-  ns3::NetDeviceContainer netA;
   ns3::Ipv4AddressHelper address;
 
   int srcNum = src->node_num;
@@ -479,6 +478,7 @@ void ns3_add_link(NetPointNs3* src, NetPointNs3* dst, char* bw, char* lat)
   pointToPoint.SetDeviceAttribute ("DataRate", ns3::StringValue (bw));
   pointToPoint.SetChannelAttribute ("Delay", ns3::StringValue (lat));
 
+  ns3::NetDeviceContainer netA;
   netA.Add(pointToPoint.Install (a, b));
 
   char * adr = bprintf("%d.%d.0.0",number_of_networks,number_of_links);