gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r32013 - gnunet/src/ats-tests
Date: Thu, 23 Jan 2014 13:28:33 +0100

Author: wachs
Date: 2014-01-23 13:28:32 +0100 (Thu, 23 Jan 2014)
New Revision: 32013

Added:
   gnunet/src/ats-tests/ats-testing-experiment.c
Modified:
   gnunet/src/ats-tests/Makefile.am
   gnunet/src/ats-tests/ats-testing-traffic.c
   gnunet/src/ats-tests/ats-testing.h
   gnunet/src/ats-tests/gnunet-ats-sim.c
Log:
experimentation basics


Modified: gnunet/src/ats-tests/Makefile.am
===================================================================
--- gnunet/src/ats-tests/Makefile.am    2014-01-23 10:36:32 UTC (rev 32012)
+++ gnunet/src/ats-tests/Makefile.am    2014-01-23 12:28:32 UTC (rev 32013)
@@ -52,7 +52,8 @@
  gnunet-ats-sim
  
 libgnunetatstesting_la_SOURCES = \
-  ats-testing.c ats-testing-log.c ats-testing-traffic.c ats-testing.h
+  ats-testing.c ats-testing-log.c ats-testing-traffic.c \
+  ats-testing-experiment.c
 libgnunetatstesting_la_LIBADD = \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/hello/libgnunethello.la \

Added: gnunet/src/ats-tests/ats-testing-experiment.c
===================================================================
--- gnunet/src/ats-tests/ats-testing-experiment.c                               
(rev 0)
+++ gnunet/src/ats-tests/ats-testing-experiment.c       2014-01-23 12:28:32 UTC 
(rev 32013)
@@ -0,0 +1,130 @@
+/*
+ This file is part of GNUnet.
+ (C) 2010-2013 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING.  If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+/**
+ * @file ats-tests/ats-testing-experiment.c
+ * @brief ats benchmark: controlled experiment execution
+ * @author Christian Grothoff
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "ats-testing.h"
+
+static struct Experiment *
+create_experiment ()
+{
+  struct Experiment *e;
+  e = GNUNET_new (struct Experiment);
+  e->name = NULL;
+  e->num_masters = 0;
+  e->num_slaves = 0;
+
+  return e;
+}
+
+static void
+free_experiment (struct Experiment *e)
+{
+  GNUNET_free_non_null (e->name);
+  GNUNET_free_non_null (e->cfg_file);
+  GNUNET_free (e);
+}
+
+struct Experiment *
+GNUNET_ATS_TEST_experimentation_start (char *filename)
+{
+  struct Experiment *e;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+  e = NULL;
+
+  cfg = GNUNET_CONFIGURATION_create();
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to load `%s'\n", filename);
+    GNUNET_CONFIGURATION_destroy (cfg);
+    return NULL;
+  }
+
+  e = create_experiment ();
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
+      "name", &e->name))
+  {
+    fprintf (stderr, "Invalid %s", "name");
+    free_experiment (e);
+    return NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", e->name);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, 
"experiment",
+      "cfg_file", &e->cfg_file))
+  {
+    fprintf (stderr, "Invalid %s", "cfg_file");
+    free_experiment (e);
+    return NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment name: `%s'\n", 
e->cfg_file);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
+      "masters", &e->num_masters))
+  {
+    fprintf (stderr, "Invalid %s", "masters");
+    free_experiment (e);
+    return NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment masters: `%llu'\n",
+        e->num_masters);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
+      "slaves", &e->num_slaves))
+  {
+    fprintf (stderr, "Invalid %s", "slaves");
+    free_experiment (e);
+    return NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment slaves: `%llu'\n",
+        e->num_slaves);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
+      "max_duration", &e->max_duration))
+  {
+    fprintf (stderr, "Invalid %s", "max_duration");
+    free_experiment (e);
+    return NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
+        GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES));
+
+  return e;
+}
+
+void
+GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e)
+{
+  free_experiment (e);
+}
+
+/* end of file ats-testing-experiment.c*/
+

Modified: gnunet/src/ats-tests/ats-testing-traffic.c
===================================================================
--- gnunet/src/ats-tests/ats-testing-traffic.c  2014-01-23 10:36:32 UTC (rev 
32012)
+++ gnunet/src/ats-tests/ats-testing-traffic.c  2014-01-23 12:28:32 UTC (rev 
32013)
@@ -50,7 +50,7 @@
     return 0;
   }
 
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Master [%u]: Sending PING to [%u]\n",
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n",
       p->me->no, p->dest->no);
 
   if (top->test_core)
@@ -146,7 +146,7 @@
 void
 GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p)
 {
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
       "Slave [%u]: Received PING from [%u], sending PONG\n", p->me->no,
       p->dest->no);
 
@@ -176,7 +176,7 @@
 GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
 {
   struct GNUNET_TIME_Relative left;
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
       "Master [%u]: Received PONG from [%u], next message\n", p->me->no,
       p->dest->no);
 
@@ -204,6 +204,12 @@
   }
 }
 
+/**
+ * Generate between the source master and the partner and send traffic with a
+ * maximum rate.
+ *
+ */
+
 struct TrafficGenerator *
 GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
     struct BenchmarkPartner *dest,
@@ -233,7 +239,7 @@
   tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS;
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-      "Setting up traffic generator between master[%u] `%s' and slave [%u] 
`%s' sending with max %u Bips\n",
+      "Setting up traffic generator master[%u] `%s' and slave [%u] `%s' max %u 
Bips\n",
       dest->me->no, GNUNET_i2s (&dest->me->id),
       dest->dest->no, GNUNET_i2s (&dest->dest->id),
       rate);
@@ -299,5 +305,5 @@
   }
 }
 
-/* end of file perf_ats_logging.c */
+/* end of file ats-testing-traffic.c */
 

Modified: gnunet/src/ats-tests/ats-testing.h
===================================================================
--- gnunet/src/ats-tests/ats-testing.h  2014-01-23 10:36:32 UTC (rev 32012)
+++ gnunet/src/ats-tests/ats-testing.h  2014-01-23 12:28:32 UTC (rev 32013)
@@ -382,7 +382,22 @@
   void *done_cb_cls;
 };
 
+struct Experiment
+{
+  char *name;
+  char *cfg_file;
+  unsigned long long int num_masters;
+  unsigned long long int num_slaves;
+  struct GNUNET_TIME_Relative max_duration;
+};
 
+struct Experiment *
+GNUNET_ATS_TEST_experimentation_start (char *filename);
+
+void
+GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e);
+
+
 struct TrafficGenerator *
 GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
     struct BenchmarkPartner *dest, unsigned int rate,

Modified: gnunet/src/ats-tests/gnunet-ats-sim.c
===================================================================
--- gnunet/src/ats-tests/gnunet-ats-sim.c       2014-01-23 10:36:32 UTC (rev 
32012)
+++ gnunet/src/ats-tests/gnunet-ats-sim.c       2014-01-23 12:28:32 UTC (rev 
32013)
@@ -32,23 +32,13 @@
 #include "gnunet_core_service.h"
 #include "ats-testing.h"
 
-#define DEFAULT_NUM_SLAVES 5
-#define DEFAULT_NUM_MASTERS 1
-
 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 
10)
 
 static struct BenchmarkPeer *masters_p;
 static struct BenchmarkPeer *slaves_p;
 
-/**
- * Number of master peers to use
- */
-static int c_masters;
+struct Experiment *e;
 
-/**
- * Number of slave peers to use
- */
-static int c_slaves;
 
 static void
 evaluate ()
@@ -66,7 +56,7 @@
   unsigned int rtt;
 
   duration = (TEST_TIMEOUT.rel_value_us / (1000 * 1000));
-  for (c_m = 0; c_m < c_masters; c_m++)
+  for (c_m = 0; c_m < e->num_masters; c_m++)
   {
     mp = &masters_p[c_m];
     fprintf (stderr,
@@ -76,7 +66,7 @@
         mp->total_bytes_received / 1024, duration,
         (mp->total_bytes_received / 1024) / duration);
 
-    for (c_s = 0; c_s < c_slaves; c_s++)
+    for (c_s = 0; c_s < e->num_slaves; c_s++)
     {
       p = &mp->partners[c_s];
 
@@ -148,11 +138,12 @@
   masters_p = masters;
   slaves_p = slaves;
 
-  for (c_m = 0; c_m < c_masters; c_m++)
+  for (c_m = 0; c_m < e->num_masters; c_m++)
   {
-      for (c_s = 0; c_s < c_slaves; c_s++)
+      for (c_s = 0; c_s < e->num_slaves; c_s++)
       {
         /* Generate maximum traffic to all peers */
+        fprintf (stderr, "c_m %u c_s %u\n", c_m, c_s);
         GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
             &masters[c_m].partners[c_s],
             10000,
@@ -166,13 +157,26 @@
 int
 main (int argc, char *argv[])
 {
-  c_slaves = DEFAULT_NUM_SLAVES;
-  c_masters = DEFAULT_NUM_MASTERS;
+  if (argc < 2)
+  {
+    fprintf (stderr, "No experiment given...\n");
+    return 1;
+  }
 
+  fprintf (stderr, "Loading experiment `%s' \n", argv[1]);
+  e = GNUNET_ATS_TEST_experimentation_start (argv[1]);
+  if (NULL == e)
+  {
+    fprintf (stderr, "Invalid experiment\n");
+    return 1;
+  }
+
+  fprintf (stderr, "%llu %llu\n", e->num_masters, e->num_slaves);
+
   /* Setup a topology with */
-  GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", 
"gnunet_ats_sim_default.conf",
-      c_slaves,
-      c_masters,
+  GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", e->cfg_file,
+      e->num_slaves,
+      e->num_masters,
       GNUNET_NO,
       &topology_setup_done,
       NULL,




reply via email to

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