gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r32019 - gnunet/src/ats-tests
Date: Thu, 23 Jan 2014 17:03:53 +0100

Author: wachs
Date: 2014-01-23 17:03:53 +0100 (Thu, 23 Jan 2014)
New Revision: 32019

Modified:
   gnunet/src/ats-tests/ats-testing-experiment.c
   gnunet/src/ats-tests/ats-testing.h
   gnunet/src/ats-tests/gnunet-ats-sim.c
Log:
implementing operations, episodes...


Modified: gnunet/src/ats-tests/ats-testing-experiment.c
===================================================================
--- gnunet/src/ats-tests/ats-testing-experiment.c       2014-01-23 15:10:08 UTC 
(rev 32018)
+++ gnunet/src/ats-tests/ats-testing-experiment.c       2014-01-23 16:03:53 UTC 
(rev 32019)
@@ -27,6 +27,25 @@
 #include "gnunet_util_lib.h"
 #include "ats-testing.h"
 
+const char *
+print_op (enum OperationType op)
+{
+  switch (op) {
+    case START_SEND:
+      return "START_SEND";
+    case STOP_SEND:
+      return "STOP_SEND";
+    case SET_RATE:
+      return "SET_RATE";
+    case SET_PREFERENCE:
+      return "SET_PREFERENCE";
+    default:
+      break;
+  }
+  return "";
+}
+
+
 static struct Experiment *
 create_experiment ()
 {
@@ -59,6 +78,120 @@
 }
 
 static int
+load_episode (struct Experiment *e, struct Episode *cur,
+    struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct Operation *o;
+  char *sec_name;
+  char *op_name;
+  char *op;
+  int ep_counter = 0;
+  fprintf (stderr, "Parsing episode %u\n",cur->id);
+  GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
+
+  while (1)
+  {
+
+    GNUNET_asprintf(&op_name, "op-%u-operation", ep_counter);
+    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
+        sec_name, op_name, &op))
+    {
+      break;
+    }
+    o = GNUNET_new (struct Operation);
+    /* operations = set_rate, start_send, stop_send, set_preference */
+    if (0 == strcmp (op, "start_send"))
+    {
+      o->type = START_SEND;
+    }
+    else if (0 == strcmp (op, "stop_send"))
+    {
+      o->type = STOP_SEND;
+    }
+    else if (0 == strcmp (op, "set_rate"))
+    {
+      o->type = SET_RATE;
+    }
+    else if (0 == strcmp (op, "set_preference "))
+    {
+      o->type = SET_PREFERENCE;
+    }
+    else
+    {
+      fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
+          ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+
+    GNUNET_free (op_name);
+    GNUNET_asprintf(&op_name, "op-%u-src", ep_counter);
+    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+        sec_name, op_name, &o->src_id))
+    {
+      fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
+          ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+    if (o->src_id > e->num_masters)
+    {
+      fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
+          o->src_id, ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+
+    GNUNET_free (op_name);
+    GNUNET_asprintf(&op_name, "op-%u-dest", ep_counter);
+    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+        sec_name, op_name, &o->dest_id))
+    {
+      fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
+          ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+    if (o->dest_id > e->num_slaves)
+    {
+      fprintf (stderr, "Invalid destination %llu in operation %u `%s' in 
episode %u\n",
+          o->dest_id, ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+
+
+    GNUNET_free (op_name);
+    GNUNET_asprintf(&op_name, "op-%u-value", ep_counter);
+    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+        sec_name, op_name, &o->value))
+    {
+      fprintf (stderr, "Missing value in operation %u `%s' in episode %u\n",
+          ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+    if (o->dest_id > e->num_slaves)
+    {
+      fprintf (stderr, "Invalid destination %llu in operation %u `%s' in 
episode %u\n",
+          o->dest_id, ep_counter, op, cur->id);
+      GNUNET_free (op);
+      return GNUNET_SYSERR;
+    }
+
+    fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == 
%llu\n",
+        ep_counter, cur->id, print_op (o->type), o->src_id, o->dest_id, 
o->value);
+
+    GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
+    GNUNET_free (op_name);
+    ep_counter++;
+  }
+  GNUNET_free (sec_name);
+
+  return GNUNET_OK;
+}
+
+static int
 load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   int e_counter = 0;
@@ -83,6 +216,13 @@
     cur->duration = e_duration;
     cur->id = e_counter;
 
+    if (GNUNET_OK != load_episode (e, cur, cfg))
+    {
+      GNUNET_free (sec_name);
+      GNUNET_free (cur);
+      return GNUNET_SYSERR;
+    }
+
     fprintf (stderr, "Found episode %u with duration %s \n",
         e_counter,
         GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
@@ -110,7 +250,8 @@
   e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK;
   fprintf (stderr, "Experiment timeout!\n");
 
-  e->e_done_cb (e, GNUNET_SYSERR);
+  e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time),
+      GNUNET_SYSERR);
 }
 
 static void
@@ -131,7 +272,7 @@
       GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
       e->experiment_timeout_task = GNUNET_SCHEDULER_NO_TASK;
     }
-    e->e_done_cb (e, GNUNET_OK);
+    e->e_done_cb (e, GNUNET_TIME_absolute_get_duration(e->start_time), 
GNUNET_OK);
     return;
   }
 
@@ -152,6 +293,7 @@
       GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES));
   e->e_done_cb = e_done_cb;
   e->ep_done_cb = ep_done_cb;
+  e->start_time = GNUNET_TIME_absolute_get();
 
   /* Start total time out */
   e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration,
@@ -168,6 +310,7 @@
 
 }
 
+
 struct Experiment *
 GNUNET_ATS_TEST_experimentation_load (char *filename)
 {

Modified: gnunet/src/ats-tests/ats-testing.h
===================================================================
--- gnunet/src/ats-tests/ats-testing.h  2014-01-23 15:10:08 UTC (rev 32018)
+++ gnunet/src/ats-tests/ats-testing.h  2014-01-23 16:03:53 UTC (rev 32019)
@@ -385,17 +385,45 @@
   void *done_cb_cls;
 };
 
-struct Experiment;
+enum OperationType
+{
+  START_SEND,
+  STOP_SEND,
+  SET_RATE,
+  SET_PREFERENCE
+};
 
 struct Episode;
 
+struct Experiment;
+
 typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) (
     struct Episode *e);
 
-typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (
-    struct Experiment *e, int success);
+typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment 
*e,
+    struct GNUNET_TIME_Relative duration,int success);
 
+struct Operation
+{
+  struct Operation *next;
+  struct Operation *prev;
+  long long unsigned int src_id;
+  long long unsigned int dest_id;
+  long long unsigned int value;
+  enum OperationType type;
+};
 
+struct Episode
+{
+  int id;
+  struct Episode *next;
+  struct GNUNET_TIME_Relative duration;
+
+  struct Operation *head;
+  struct Operation *tail;
+};
+
+
 struct Experiment
 {
   char *name;
@@ -416,13 +444,6 @@
   GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
 };
 
-struct Episode
-{
-  int id;
-  struct Episode *next;
-  struct GNUNET_TIME_Relative duration;
-};
-
 void
 GNUNET_ATS_TEST_experimentation_run (struct Experiment *e,
     GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,

Modified: gnunet/src/ats-tests/gnunet-ats-sim.c
===================================================================
--- gnunet/src/ats-tests/gnunet-ats-sim.c       2014-01-23 15:10:08 UTC (rev 
32018)
+++ gnunet/src/ats-tests/gnunet-ats-sim.c       2014-01-23 16:03:53 UTC (rev 
32019)
@@ -43,7 +43,7 @@
 struct LoggingHandle *l;
 
 static void
-evaluate ()
+evaluate (struct GNUNET_TIME_Relative duration_total)
 {
   int c_m;
   int c_s;
@@ -57,7 +57,8 @@
   double kb_recv_percent;
   unsigned int rtt;
 
-  duration = (TEST_TIMEOUT.rel_value_us / (1000 * 1000));
+
+  duration = (duration_total.rel_value_us / (1000 * 1000));
   for (c_m = 0; c_m < e->num_masters; c_m++)
   {
     mp = &masters_p[c_m];
@@ -135,12 +136,13 @@
 }
 
 static void
-experiment_done_cb (struct Experiment *e, int success)
+experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative 
duration,int success)
 {
   if (GNUNET_OK == success)
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment `%s' done successful\n", 
e->name);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment done successful in %s\n",
+        GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
   else
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment `%s' failed \n", e->name);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
   if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
   {
     GNUNET_SCHEDULER_cancel (timeout_task);
@@ -148,7 +150,7 @@
   }
   /* Stop logging */
   GNUNET_ATS_TEST_logging_stop (l);
-  evaluate ();
+  evaluate (duration);
 
   /* Stop traffic generation */
   GNUNET_ATS_TEST_generate_traffic_stop_all();




reply via email to

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