X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/03cb5ca8689347e26d4d3158db3a5340639ce7f1..30f40863fc506c7013dec1902201d4bdffe3a101:/src/surf/network_ns3.cpp diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index a343a7a498..9404d6bc43 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -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(); 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; @@ -90,14 +91,12 @@ static void routeCreation_cb(bool symmetrical, simgrid::kernel::routing::NetPoin simgrid::kernel::routing::NetPoint* gw_dst, std::vector* link_list) { - static bool warned_about_long_routes = false; - if (link_list->size() == 1) { simgrid::surf::LinkNS3* link = static_cast(link_list->at(0)); 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); @@ -110,26 +109,27 @@ 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); } else { + static bool warned_about_long_routes = false; + if (not warned_about_long_routes) - XBT_INFO( - "Ignoring a route between %s and %s of length %zu: Only routes of length 1 are considered with NS3.\n" - "You can ignore this warning if your hosts can still communicate when only considering routes of length 1.\n" - "You may also remove these routes to avoid this harmless message. Other long routes will be silently " - "ignored.", - src->cname(), dst->cname(), link_list->size()); + 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->cname(), dst->cname(), link_list->size()); warned_about_long_routes = true; } } /* Create the ns3 topology based on routing strategy */ -static void postparse_cb(void) +static void postparse_cb() { IPV4addr.shrink_to_fit(); @@ -163,7 +163,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() { simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) { pt->extension_set(new NetPointNs3()); - + XBT_VERB("SimGrid's %s is known as node %d within NS3", pt->cname(), pt->extension()->node_num); }); simgrid::surf::on_cluster.connect(&clusterCreation_cb); simgrid::s4u::onPlatformCreated.connect(&postparse_cb); @@ -197,7 +197,7 @@ double NetworkNS3Model::nextOccuringEvent(double now) XBT_DEBUG("ns3_next_occuring_event"); //get the first relevant value from the running_actions list - if (!getRunningActionSet()->size() || now == 0.0) + if (not getRunningActionSet()->size() || now == 0.0) return -1.0; else do { @@ -256,7 +256,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) } } - while (!xbt_dynar_is_empty(socket_to_destroy)){ + while (not xbt_dynar_is_empty(socket_to_destroy)) { xbt_dynar_pop(socket_to_destroy,&ns3Socket); if (XBT_LOG_ISENABLED(ns3, xbt_log_priority_debug)) { @@ -317,7 +317,12 @@ void NetworkNS3Action::resume() { THROW_UNIMPLEMENTED; } - /* Test whether a flow is suspended */ +std::list NetworkNS3Action::links() +{ + THROW_UNIMPLEMENTED; +} + +/* Test whether a flow is suspended */ bool NetworkNS3Action::isSuspended() { return false; @@ -326,7 +331,7 @@ bool NetworkNS3Action::isSuspended() int NetworkNS3Action::unref() { refcount_--; - if (!refcount_) { + if (not refcount_) { if (action_hook.is_linked()) stateSet_->erase(stateSet_->iterator_to(*this)); XBT_DEBUG ("Removing action %p", this); @@ -391,20 +396,20 @@ void ns3_initialize(const char* TcpProtocol){ ns3::Config::SetDefault ("ns3::TcpSocket::SegmentSize", ns3::UintegerValue (1024)); // 1024-byte packet for easier reading ns3::Config::SetDefault ("ns3::TcpSocket::DelAckCount", ns3::UintegerValue (1)); - if (!strcmp(TcpProtocol,"default")) + if (not strcmp(TcpProtocol, "default")) return; - if (!strcmp(TcpProtocol,"Reno")) { + if (not strcmp(TcpProtocol, "Reno")) { XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol); ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpReno")); return; } - if (!strcmp(TcpProtocol,"NewReno")) { + if (not strcmp(TcpProtocol, "NewReno")) { XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol); ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpNewReno")); return; } - if(!strcmp(TcpProtocol,"Tahoe")){ + if (not strcmp(TcpProtocol, "Tahoe")) { XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol); ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpTahoe")); return; @@ -461,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; @@ -474,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);