Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix NS3 and lua builds
[simgrid.git] / src / surf / network_ns3.cpp
index 4de446c..e27db35 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include "ns3/core-module.h"
 #include "ns3/node.h"
 
-#include "ns3/ns3_interface.h"
 #include "ns3/ns3_simulator.h"
 #include "network_ns3.hpp"
 
-#include "simgrid/sg_config.h"
 #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
 #include "src/kernel/routing/NetPoint.hpp"
-#include "src/surf/HostImpl.hpp"
-#include "src/surf/surf_private.h"
 
+#include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/NetZone.hpp"
-#include "simgrid/s4u/engine.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ns3, surf, "Logging specific to the SURF network NS3 module");
 
@@ -91,18 +87,19 @@ static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster)
 
 static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoint* src,
                              simgrid::kernel::routing::NetPoint* dst, simgrid::kernel::routing::NetPoint* gw_src,
-                             simgrid::kernel::routing::NetPoint* gw_dst, std::vector<Link*>* link_list)
+                             simgrid::kernel::routing::NetPoint* gw_dst,
+                             std::vector<simgrid::surf::LinkImpl*>* link_list)
 {
   if (link_list->size() == 1) {
     simgrid::surf::LinkNS3* link = static_cast<simgrid::surf::LinkNS3*>(link_list->at(0));
 
-    XBT_DEBUG("Route from '%s' to '%s' with link '%s' %s", src->cname(), dst->cname(), link->getName(),
+    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_lat = bprintf("%fs", link->latency());
 
     //   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);
+    XBT_DEBUG("\tLink (%s) bdw:%s lat:%s", link->cname(), link_bdw, link_lat);
 
     // create link ns3
     NetPointNs3* host_src = src->extension<NetPointNs3>();
@@ -172,8 +169,8 @@ NetworkNS3Model::~NetworkNS3Model() {
   xbt_dict_free(&flowFromSock);
 }
 
-Link* NetworkNS3Model::createLink(const char* name, double bandwidth, double latency,
-                                  e_surf_link_sharing_policy_t policy)
+LinkImpl* NetworkNS3Model::createLink(const char* name, double bandwidth, double latency,
+                                      e_surf_link_sharing_policy_t policy)
 {
   return new LinkNS3(this, name, bandwidth, latency);
 }
@@ -230,11 +227,12 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
         action->getState() == Action::State::running){
       double data_delta_sent = sgFlow->sentBytes_ - action->lastSent_;
 
-      std::vector<Link*> route = std::vector<Link*>();
+      std::vector<LinkImpl*> route = std::vector<LinkImpl*>();
 
       action->src_->routeTo(action->dst_, &route, nullptr);
       for (auto link : route)
-        TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, now-delta, delta);
+        TRACE_surf_link_set_utilization(link->cname(), action->getCategory(), (data_delta_sent) / delta, now - delta,
+                                        delta);
 
       action->lastSent_ = sgFlow->sentBytes_;
     }
@@ -263,12 +261,12 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
  ************/
 
 LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, double bandwidth, double latency)
-    : Link(model, name, nullptr)
+    : LinkImpl(model, name, nullptr)
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
 
-  Link::onCreation(this);
+  s4u::Link::onCreation(this->piface_);
 }
 
 LinkNS3::~LinkNS3() = default;
@@ -297,7 +295,7 @@ NetworkNS3Action::NetworkNS3Action(Model* model, double size, s4u::Host* src, s4
   dst_ = dst;
   ns3_create_flow(src, dst, surf_get_clock(), size, this);
 
-  Link::onCommunicate(this, src, dst);
+  s4u::Link::onCommunicate(this, src, dst);
 }
 
 void NetworkNS3Action::suspend() {