X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/07c12189c716ea527ddcf8f8b55983213dead2bf..d4ae59be01b5712d91572d5a8503ca56326694c4:/src/surf/network_ns3.cpp diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index c354669848..4de446c397 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -44,9 +44,9 @@ static int number_of_links = 1; static int number_of_networks = 1; static int port_number = 1025; //Port number is limited from 1025 to 65 000 -simgrid::xbt::Extension NetCardNs3::EXTENSION_ID; +simgrid::xbt::Extension NetPointNs3::EXTENSION_ID; -NetCardNs3::NetCardNs3() +NetPointNs3::NetPointNs3() { ns3::Ptr node = ns3::CreateObject(0); stack.Install(node); @@ -58,11 +58,6 @@ NetCardNs3::NetCardNs3() * Callbacks * *************/ -static void netcardCreation_cb(simgrid::kernel::routing::NetPoint* netcard) -{ - netcard->extension_set(new NetCardNs3()); -} - static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster) { char* lat = bprintf("%fs", cluster->lat); @@ -70,12 +65,12 @@ static void clusterCreation_cb(sg_platf_cluster_cbarg_t cluster) for (int i : *cluster->radicals) { // Routers don't create a router on the other end of the private link by themselves. - // We just need this router to be given an ID so we create a temporary NetCardNS3 so that it gets one - NetCardNs3* host_dst = new NetCardNs3(); + // We just need this router to be given an ID so we create a temporary NetPointNS3 so that it gets one + NetPointNs3* host_dst = new NetPointNs3(); // Create private link char* host_id = bprintf("%s%d%s", cluster->prefix, i, cluster->suffix); - NetCardNs3* host_src = sg_host_by_name(host_id)->pimpl_netpoint->extension(); + NetPointNs3* host_src = sg_host_by_name(host_id)->pimpl_netpoint->extension(); xbt_assert(host_src, "Cannot find a NS3 host of name %s", host_id); ns3_add_link(host_src->node_num, host_dst->node_num, bw,lat); @@ -110,8 +105,8 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin XBT_DEBUG("\tLink (%s) bdw:%s lat:%s", link->getName(), link_bdw, link_lat); // create link ns3 - NetCardNs3* host_src = src->extension(); - NetCardNs3* host_dst = dst->extension(); + NetPointNs3* host_src = src->extension(); + NetPointNs3* host_dst = dst->extension(); 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()); @@ -154,13 +149,16 @@ namespace simgrid { namespace surf { NetworkNS3Model::NetworkNS3Model() : NetworkModel() { - NetCardNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create(); + NetPointNs3::EXTENSION_ID = simgrid::kernel::routing::NetPoint::extension_create(); ns3_initialize(ns3_tcp_model.get().c_str()); - simgrid::kernel::routing::NetPoint::onCreation.connect(&netcardCreation_cb); + simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) { + pt->extension_set(new NetPointNs3()); + + }); simgrid::surf::on_cluster.connect(&clusterCreation_cb); - simgrid::surf::on_postparse.connect(&postparse_cb); + simgrid::s4u::onPlatformCreated.connect(&postparse_cb); simgrid::s4u::NetZone::onRouteCreation.connect(&routeCreation_cb); LogComponentEnable("UdpEchoClientApplication", ns3::LOG_LEVEL_INFO); @@ -343,8 +341,8 @@ void ns3_simulator(double maxSeconds) void ns3_create_flow(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double startTime, u_int32_t TotalBytes, simgrid::surf::NetworkNS3Action* action) { - int node1 = src->pimpl_netpoint->extension()->node_num; - int node2 = dst->pimpl_netpoint->extension()->node_num; + int node1 = src->pimpl_netpoint->extension()->node_num; + int node2 = dst->pimpl_netpoint->extension()->node_num; ns3::Ptr src_node = nodes.Get(node1); ns3::Ptr dst_node = nodes.Get(node2);