Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more C++ around ns3
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 8 Feb 2018 21:55:46 +0000 (22:55 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 8 Feb 2018 21:55:46 +0000 (22:55 +0100)
src/surf/network_ns3.cpp
src/surf/ns3/ns3_interface.hpp

index 8cd88b5..0ff044c 100644 (file)
@@ -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;
   }
index dfee129..a1c523f 100644 (file)
@@ -27,9 +27,8 @@ public:
   ns3::Ptr<ns3::Node> 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);