From: Martin Quinson Date: Thu, 8 Feb 2018 21:55:46 +0000 (+0100) Subject: more C++ around ns3 X-Git-Tag: v3.19~242 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e5fac81b878c12bafe94ab9407bad0080a3d1581 more C++ around ns3 --- diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index 8cd88b5d3b..0ff044cd94 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -372,31 +372,32 @@ void ns3_create_flow(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, } // initialize the NS3 interface and environment -void ns3_initialize(const char* TcpProtocol){ -// tcpModel are: -// "ns3::TcpNewReno" -// "ns3::TcpReno" -// "ns3::TcpTahoe" +void ns3_initialize(std::string TcpProtocol) +{ + // tcpModel are: + // "ns3::TcpNewReno" + // "ns3::TcpReno" + // "ns3::TcpTahoe" ns3::Config::SetDefault ("ns3::TcpSocket::SegmentSize", ns3::UintegerValue (1000)); ns3::Config::SetDefault ("ns3::TcpSocket::DelAckCount", ns3::UintegerValue (1)); ns3::Config::SetDefault ("ns3::TcpSocketBase::Timestamp", ns3::BooleanValue (false)); - if (not strcmp(TcpProtocol, "default")) + if (TcpProtocol == "default") return; - if (not strcmp(TcpProtocol, "Reno")) { - XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol); + if (TcpProtocol == "Reno") { + XBT_INFO("Switching Tcp protocol to '%s'", TcpProtocol.c_str()); ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpReno")); return; } - if (not strcmp(TcpProtocol, "NewReno")) { - XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol); + if (TcpProtocol == "NewReno") { + XBT_INFO("Switching Tcp protocol to '%s'", TcpProtocol.c_str()); ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpNewReno")); return; } - if (not strcmp(TcpProtocol, "Tahoe")) { - XBT_INFO("Switching Tcp protocol to '%s'",TcpProtocol); + if (TcpProtocol == "Tahoe") { + XBT_INFO("Switching Tcp protocol to '%s'", TcpProtocol.c_str()); ns3::Config::SetDefault ("ns3::TcpL4Protocol::SocketType", ns3::StringValue("ns3::TcpTahoe")); return; } diff --git a/src/surf/ns3/ns3_interface.hpp b/src/surf/ns3/ns3_interface.hpp index dfee129862..a1c523f3d7 100644 --- a/src/surf/ns3/ns3_interface.hpp +++ b/src/surf/ns3/ns3_interface.hpp @@ -27,9 +27,8 @@ public: ns3::Ptr ns3Node_; }; +XBT_PUBLIC(void) ns3_initialize(std::string TcpProtocol); extern "C" { - -XBT_PUBLIC(void) ns3_initialize(const char* TcpProtocol); XBT_PUBLIC(void) ns3_create_flow(sg_host_t src, sg_host_t dst, u_int32_t TotalBytes, simgrid::surf::NetworkNS3Action* action); XBT_PUBLIC(void) ns3_simulator(double maxSeconds);