Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix another typo
[simgrid.git] / src / surf / gtnets / gtnets_interface.cc
index f62dbdb..b278ed7 100644 (file)
@@ -1,14 +1,13 @@
-/*     $Id$     */
-/* Copyright (c) 2007 Kayo Fujiwara. All rights reserved.                  */
+/* Copyright (c) 2007-2011, 2014. 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 "gtnets_simulator.h"
 #include "gtnets_interface.h"
-#ifdef DEBUG0
-       #undef DEBUG0
+#ifdef XBT_DEBUG
+       #undef XBT_DEBUG
 #endif
 #include "xbt/log.h"
 #include "xbt/asserts.h"
@@ -22,13 +21,17 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets_interface, surf_network_gtne
 
 
 // initialize the GTNetS interface and environment
-int gtnets_initialize(){
-
-  DEBUG0("Using logging.");
-
-  xbt_assert0(!gtnets_sim, "gtnets already initialized");
+int gtnets_initialize(int wsize){
+  XBT_DEBUG("Using logging.");
+  xbt_assert(!gtnets_sim, "gtnets already initialized");
+
+  if(wsize > 0){
+       XBT_INFO("TCP window maximum size : %d", wsize);
+       gtnets_sim = new GTSim(wsize);
+  }else{
+       gtnets_sim = new GTSim(wsize);
+  }
 
-  gtnets_sim = new GTSim();
   return 0;
 }
 
@@ -74,9 +77,9 @@ double gtnets_get_time_to_next_flow_completion(){
          file.open ("/dev/null");
          sbuf = cout.rdbuf();
          cout.rdbuf(file.rdbuf());
-         DEBUG0("Enable GTNetS library quite mode");
+         XBT_DEBUG("Enable GTNetS library quite mode");
   }else {
-         DEBUG0("Disable GTNetS library quite mode");
+         XBT_DEBUG("Disable GTNetS library quite mode");
   }
 
   value = gtnets_sim->get_time_to_next_flow_completion();
@@ -89,7 +92,7 @@ double gtnets_get_time_to_next_flow_completion(){
 }
 
 // run until a flow completes (returns that flow's metadata)
-int gtnets_run_until_next_flow_completion(void ***metadata, int *number_of_flows){
+double gtnets_run_until_next_flow_completion(void ***metadata, int *number_of_flows){
   ofstream file;
   streambuf* sbuf;
   double value;
@@ -98,9 +101,9 @@ int gtnets_run_until_next_flow_completion(void ***metadata, int *number_of_flows
          file.open ("/dev/null");
          sbuf = cout.rdbuf();
          cout.rdbuf(file.rdbuf());
-         DEBUG0("Enable GTNetS library quite mode");
+         XBT_DEBUG("Enable GTNetS library quite mode");
   }else {
-         DEBUG0("Disable GTNetS library quite mode");
+         XBT_DEBUG("Disable GTNetS library quite mode");
   }
 
   value = gtnets_sim->run_until_next_flow_completion(metadata, number_of_flows);
@@ -109,7 +112,7 @@ int gtnets_run_until_next_flow_completion(void ***metadata, int *number_of_flows
          cout.rdbuf(sbuf);
          file.close();
   }
-  return value;
+  return (double) value;
 }
 
 // get the total received in bytes using the TCPServer object totRx field
@@ -120,7 +123,26 @@ double gtnets_get_flow_rx(void *metadata){
 
 // run for a given time (double)
 int gtnets_run(Time_t deltat){
+  ofstream file;
+  streambuf* sbuf;
+  double value;
+
+  if (!XBT_LOG_ISENABLED(surf_network_gtnets_interface, xbt_log_priority_debug)) {
+          file.open ("/dev/null");
+          sbuf = cout.rdbuf();
+          cout.rdbuf(file.rdbuf());
+          XBT_DEBUG("Enable GTNetS library quite mode");
+  }else {
+          XBT_DEBUG("Disable GTNetS library quite mode");
+  }
+
   gtnets_sim->run(deltat);
+
+
+  if (!XBT_LOG_ISENABLED(surf_network_gtnets_interface, xbt_log_priority_debug)) {
+          cout.rdbuf(sbuf);
+          file.close();
+  }
   return 0;
 }
 
@@ -137,3 +159,14 @@ void gtnets_print_topology(void){
   gtnets_sim->print_topology();
 }
 
+// set jitter
+void gtnets_set_jitter(double d){
+  gtnets_sim->set_jitter(d);
+}
+
+// set jitter seed
+void gtnets_set_jitter_seed(int seed){
+  gtnets_sim->set_jitter_seed(seed);
+}
+
+