gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31999 - gnunet/src/ats-tests


From: gnunet
Subject: [GNUnet-SVN] r31999 - gnunet/src/ats-tests
Date: Wed, 22 Jan 2014 11:40:04 +0100

Author: wachs
Date: 2014-01-22 11:40:04 +0100 (Wed, 22 Jan 2014)
New Revision: 31999

Modified:
   gnunet/src/ats-tests/Makefile.am
   gnunet/src/ats-tests/ats-testing.c
   gnunet/src/ats-tests/ats-testing.h
   gnunet/src/ats-tests/gnunet-ats-sim.c
   gnunet/src/ats-tests/perf_ats.c
   gnunet/src/ats-tests/perf_ats.h
Log:
improvements


Modified: gnunet/src/ats-tests/Makefile.am
===================================================================
--- gnunet/src/ats-tests/Makefile.am    2014-01-22 08:48:22 UTC (rev 31998)
+++ gnunet/src/ats-tests/Makefile.am    2014-01-22 10:40:04 UTC (rev 31999)
@@ -52,7 +52,7 @@
  gnunet-ats-sim
  
 libgnunetatstesting_la_SOURCES = \
-  ats-testing.c ats-testing.h
+  ats-testing.c ats-testing-log.c ats-testing.h
 libgnunetatstesting_la_LIBADD = \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/hello/libgnunethello.la \
@@ -65,7 +65,7 @@
  $(GN_LIB_LDFLAGS)
  
 gnunet_ats_sim_SOURCES = \
- gnunet-ats-sim.c
+ gnunet-ats-sim.c 
 gnunet_ats_sim_LDADD = \
  $(top_builddir)/src/util/libgnunetutil.la \
  $(top_builddir)/src/ats-tests/libgnunetatstesting.la \
@@ -79,7 +79,7 @@
 
 
 perf_ats_proportional_core_none_SOURCES = \
-  perf_ats.c perf_ats_logging.c perf_ats.h
+  perf_ats.c
 perf_ats_proportional_core_none_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/ats-tests/libgnunetatstesting.la \
@@ -92,7 +92,7 @@
  $(top_builddir)/src/util/libgnunetutil.la  
 
 perf_ats_proportional_transport_none_SOURCES = \
-  perf_ats.c perf_ats_logging.c
+  perf_ats.c
 perf_ats_proportional_transport_none_LDADD = \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/ats-tests/libgnunetatstesting.la \
@@ -100,9 +100,9 @@
   $(top_builddir)/src/ats/libgnunetats.la \
   $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/transport/libgnunettransport.la
-perf_ats_proportional_transport_DEPENDENCIES = \
+perf_ats_proportional_transport_none_DEPENDENCIES = \
  $(top_builddir)/src/ats-tests/libgnunetatstesting.la \
- $(top_builddir)/src/util/libgnunetutil.la  
+ $(top_builddir)/src/util/libgnunetutil.la    
 
 perf_ats_proportional_core_bandwidth_SOURCES = \
   perf_ats.c perf_ats_logging.c

Modified: gnunet/src/ats-tests/ats-testing.c
===================================================================
--- gnunet/src/ats-tests/ats-testing.c  2014-01-22 08:48:22 UTC (rev 31998)
+++ gnunet/src/ats-tests/ats-testing.c  2014-01-22 10:40:04 UTC (rev 31999)
@@ -18,21 +18,14 @@
  Boston, MA 02111-1307, USA.
  */
 /**
- * @file ats/perf_ats.c
- * @brief ats benchmark: start peers and modify preferences, monitor change 
over time
+ * @file ats-tests/ats-testing.c
+ * @brief ats testing library: setup topology and provide logging to test ats
+ * solvers
  * @author Christian Grothoff
  * @author Matthias Wachs
  */
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_testbed_service.h"
-#include "gnunet_ats_service.h"
-#include "gnunet_core_service.h"
 #include "ats-testing.h"
 
-
-
-
 static struct GNUNET_ATS_TEST_Topology *top;
 
 /**
@@ -48,20 +41,11 @@
   int c_s;
   int c_op;
   struct BenchmarkPeer *p;
-/*
-  if (GNUNET_YES == logging)
-    perf_logging_stop();
-*/
+
+  if (GNUNET_YES == top->logging)
+    GNUNET_ATS_TEST_logging_stop ();
+
   top->shutdown_task = GNUNET_SCHEDULER_NO_TASK;
-/*
-  if (GNUNET_SCHEDULER_NO_TASK != progress_task)
-  {
-    fprintf (stderr, "0\n");
-    GNUNET_SCHEDULER_cancel (progress_task);
-  }
-  progress_task = GNUNET_SCHEDULER_NO_TASK;
-*/
-  //evaluate ();
 
   top->state.benchmarking = GNUNET_NO;
   GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
@@ -604,10 +588,9 @@
   GNUNET_assert(NULL != peers_);
 
   top->shutdown_task = GNUNET_SCHEDULER_add_delayed (
-      GNUNET_TIME_relative_multiply (TEST_TIMEOUT, top->num_masters + 
top->num_slaves),
-      &do_shutdown, top );
+      GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, top);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u masters and %u slaves\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting up %u masters and %u slaves\n",
       top->num_masters, top->num_slaves);
 
   /* Setup master peers */
@@ -618,7 +601,7 @@
     top->mps[c_m].no = c_m;
     top->mps[c_m].master = GNUNET_YES;
     top->mps[c_m].pref_partner = &top->sps[c_m];
-    top->mps[c_m].pref_value = TEST_ATS_PREFRENCE_START;
+    top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT;
     top->mps[c_m].partners =
         GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner));
     top->mps[c_m].num_partners = top->num_slaves;
@@ -720,4 +703,4 @@
   GNUNET_SCHEDULER_shutdown();
 }
 
-/* end of file perf_ats.c */
+/* end of file ats-testing.c */

Modified: gnunet/src/ats-tests/ats-testing.h
===================================================================
--- gnunet/src/ats-tests/ats-testing.h  2014-01-22 08:48:22 UTC (rev 31998)
+++ gnunet/src/ats-tests/ats-testing.h  2014-01-22 10:40:04 UTC (rev 31999)
@@ -18,8 +18,8 @@
  Boston, MA 02111-1307, USA.
  */
 /**
- * @file ats/perf_ats.c
- * @brief ats benchmark: start peers and modify preferences, monitor change 
over time
+ * @file ats-tests/ats-testing.h
+ * @brief ats testing library: setup topology and provide logging to test ats
  * @author Christian Grothoff
  * @author Matthias Wachs
  */
@@ -29,22 +29,8 @@
 #include "gnunet_ats_service.h"
 #include "gnunet_core_service.h"
 
-#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 
120)
-#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 10)
-#define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MILLISECONDS, 500)
-#define TESTNAME_PREFIX "perf_ats_"
-#define DEFAULT_SLAVES_NUM 2
-#define DEFAULT_MASTERS_NUM 1
+#define TEST_ATS_PREFERENCE_DEFAULT 1.0
 
-#define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 1)
-#define TEST_ATS_PREFRENCE_START 1.0
-#define TEST_ATS_PREFRENCE_DELTA 1.0
-
-#define TEST_MESSAGE_TYPE_PING 12345
-#define TEST_MESSAGE_TYPE_PONG 12346
-#define TEST_MESSAGE_SIZE 1000
-#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 1)
-
 /**
  * Overall state of the performance benchmark
  */
@@ -394,6 +380,16 @@
 };
 
 void
+GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
+    char * testname, struct BenchmarkPeer *masters, int num_masters);
+
+void
+GNUNET_ATS_TEST_logging_now (void);
+
+void
+GNUNET_ATS_TEST_logging_stop (void);
+
+void
 GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
     unsigned int num_slaves,
     unsigned int num_masters,
@@ -407,4 +403,4 @@
 void
 GNUNET_ATS_TEST_shutdown_topology (void);
 
-/* end of file perf_ats.c */
+/* end of file ats-testing.h */

Modified: gnunet/src/ats-tests/gnunet-ats-sim.c
===================================================================
--- gnunet/src/ats-tests/gnunet-ats-sim.c       2014-01-22 08:48:22 UTC (rev 
31998)
+++ gnunet/src/ats-tests/gnunet-ats-sim.c       2014-01-22 10:40:04 UTC (rev 
31999)
@@ -18,8 +18,10 @@
  Boston, MA 02111-1307, USA.
  */
 /**
- * @file ats/perf_ats.c
- * @brief ats benchmark: start peers and modify preferences, monitor change 
over time
+ * @file ats-test/gnunet-ats-sim.c
+ * @brief ats traffic simulator: this tool uses the ats-test library to setup a
+ * topology and generate traffic between these peers. The traffic description
+ * is loaded from a experiment description file
  * @author Christian Grothoff
  * @author Matthias Wachs
  */
@@ -36,8 +38,14 @@
 #define TEST_MESSAGE_TYPE_PING 12345
 #define TEST_MESSAGE_TYPE_PONG 12346
 
+/**
+ * Number of master peers to use
+ */
 static int c_masters;
 
+/**
+ * Number of slave peers to use
+ */
 static int c_slaves;
 
 static int
@@ -76,6 +84,9 @@
     struct BenchmarkPeer *slaves)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Topology setup complete!\n");
+
+
+  /* Shutdown a topology with */
   GNUNET_ATS_TEST_shutdown_topology ();
 }
 
@@ -90,6 +101,7 @@
   c_slaves = DEFAULT_NUM_SLAVES;
   c_masters = DEFAULT_NUM_MASTERS;
 
+  /* Setup a topology with */
   GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", 
"perf_ats_proportional_none.conf",
       c_slaves,
       c_masters,
@@ -101,4 +113,4 @@
       &ats_performance_info_cb);
   return 0;
 }
-/* end of file perf_ats_topogy.c */
+/* end of file gnunet-ats-sim.c */

Modified: gnunet/src/ats-tests/perf_ats.c
===================================================================
--- gnunet/src/ats-tests/perf_ats.c     2014-01-22 08:48:22 UTC (rev 31998)
+++ gnunet/src/ats-tests/perf_ats.c     2014-01-22 10:40:04 UTC (rev 31999)
@@ -40,7 +40,12 @@
 #define TEST_MESSAGE_SIZE 1000
 #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 1)
 
-
+#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 
120)
+#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 10)
+#define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_MILLISECONDS, 500)
+#define TESTNAME_PREFIX "perf_ats_"
+#define DEFAULT_SLAVES_NUM 2
+#define DEFAULT_MASTERS_NUM 1
 /**
  * Shutdown task
  */
@@ -124,6 +129,12 @@
   struct BenchmarkPeer *mp;
   struct BenchmarkPartner *p;
 
+  unsigned int kb_sent_sec;
+  double kb_sent_percent;
+  unsigned int kb_recv_sec;
+  double kb_recv_percent;
+  unsigned int rtt;
+
   duration = (perf_duration.rel_value_us / (1000 * 1000));
   for (c_m = 0; c_m < num_masters; c_m++)
   {
@@ -138,19 +149,35 @@
     for (c_s = 0; c_s < num_slaves; c_s++)
     {
       p = &mp->partners[c_s];
+
+      kb_sent_sec = 0;
+      kb_recv_sec = 0;
+      kb_sent_percent = 0.0;
+      kb_recv_percent = 0.0;
+      rtt = 0;
+
+      if (duration > 0)
+      {
+         kb_sent_percent = (p->bytes_sent / 1024) / duration;
+         kb_recv_percent = (p->bytes_received / 1024) / duration;
+      }
+      if (mp->total_bytes_sent > 0)
+         kb_sent_percent = ((double) p->bytes_sent * 100) / 
mp->total_bytes_sent;
+      if (mp->total_bytes_received > 0)
+         kb_recv_percent = ((double) p->bytes_received * 100) / 
mp->total_bytes_received;
+      if (1000 * p->messages_sent > 0)
+         rtt = p->total_app_rtt / (1000 * p->messages_sent);
       fprintf (stderr,
           "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u 
KiB/s (%.2f %%)\n",
           (mp->pref_partner == p->dest) ? '*' : ' ',
           mp->no, p->dest->no,
-          (p->bytes_sent / 1024) / duration,
-          ((double) p->bytes_sent * 100) / mp->total_bytes_sent,
-          (p->bytes_received / 1024) / duration,
-          ((double) p->bytes_received * 100) / mp->total_bytes_received );
+          kb_sent_sec, kb_sent_percent,
+                 kb_recv_sec, kb_recv_percent);
+
       fprintf (stderr,
           "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u 
ms\n",
           (mp->pref_partner == p->dest) ? '*' : ' ',
-          mp->no, p->dest->no,
-          p->total_app_rtt / (1000 * p->messages_sent));
+          mp->no, p->dest->no, rtt);
     }
   }
 }
@@ -164,10 +191,10 @@
 static void
 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  /*
+
   if (GNUNET_YES == logging)
-    perf_logging_stop();
-*/
+    GNUNET_ATS_TEST_logging_stop();
+
   shutdown_task = GNUNET_SCHEDULER_NO_TASK;
   if (GNUNET_SCHEDULER_NO_TASK != progress_task)
   {
@@ -300,10 +327,8 @@
       masters[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, 
&masters[c_m]);
   }
 
-  /*
   if (GNUNET_YES == logging)
-    perf_logging_start (log_frequency, testname, mps, num_masters);
-*/
+    GNUNET_ATS_TEST_logging_start (log_frequency, testname, mps, num_masters);
 }
 
 
@@ -349,7 +374,6 @@
       return &me->partners[c_m];
     }
   }
-
   return NULL;
 }
 
@@ -422,11 +446,10 @@
 }
 
 
-
 static void
-transport_recv_cb (void *cls,
-                   const struct GNUNET_PeerIdentity * peer,
-                   const struct GNUNET_MessageHeader * message)
+test_recv_cb (void *cls,
+                     const struct GNUNET_PeerIdentity * peer,
+                     const struct GNUNET_MessageHeader * message)
 {
   if (TEST_MESSAGE_SIZE != ntohs (message->size) ||
       (TEST_MESSAGE_TYPE_PING != ntohs (message->type) &&
@@ -442,9 +465,6 @@
 }
 
 
-
-
-
 static void
 ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address,
     int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
@@ -532,17 +552,17 @@
         break;
     }
   }
-  /*
+
   if ((GNUNET_YES == logging) && (GNUNET_YES == log))
-    collect_log_now();
-    */
+    GNUNET_ATS_TEST_logging_now();
+
   GNUNET_free(peer_id);
 }
 
 
-
-
-
+/*
+ * Start the performance test case
+ */
 int
 main (int argc, char *argv[])
 {
@@ -720,14 +740,23 @@
     return GNUNET_SYSERR;
   }
 
+  /**
+   * Core message handler to use for PING/PONG messages
+   */
   static struct GNUNET_CORE_MessageHandler handlers[] = {
       {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 },
       {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 },
       { NULL, 0, 0 } };
 
+  /**
+   * Setup the topology
+   */
   GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name,
-      num_slaves, num_masters, test_core,
-      &do_benchmark, NULL, handlers, &transport_recv_cb,
+      num_slaves, num_masters,
+      test_core,
+      &do_benchmark,
+      NULL, handlers,
+      &test_recv_cb,
       &ats_performance_info_cb);
 
   return result;

Modified: gnunet/src/ats-tests/perf_ats.h
===================================================================
--- gnunet/src/ats-tests/perf_ats.h     2014-01-22 08:48:22 UTC (rev 31998)
+++ gnunet/src/ats-tests/perf_ats.h     2014-01-22 10:40:04 UTC (rev 31999)
@@ -248,13 +248,13 @@
 
 
 void
-collect_log_now (void);
+GNUNET_ATS_TEST_logging_now (void);
 
 void
-perf_logging_stop ();
+GNUNET_ATS_TEST_logging_stop ();
 
 void
-perf_logging_start (struct GNUNET_TIME_Relative log_frequency,
+GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
     char * testname, struct BenchmarkPeer *masters, int num_masters);
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]