gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32157 - in gnunet/src/ats-tests: . experiments


From: gnunet
Subject: [GNUnet-SVN] r32157 - in gnunet/src/ats-tests: . experiments
Date: Mon, 3 Feb 2014 10:44:09 +0100

Author: wachs
Date: 2014-02-03 10:44:09 +0100 (Mon, 03 Feb 2014)
New Revision: 32157

Modified:
   gnunet/src/ats-tests/ats-testing-experiment.c
   gnunet/src/ats-tests/ats-testing.h
   gnunet/src/ats-tests/experiments/test.exp
Log:
experiment parsing + test.exp containing different examples


Modified: gnunet/src/ats-tests/ats-testing-experiment.c
===================================================================
--- gnunet/src/ats-tests/ats-testing-experiment.c       2014-02-03 09:10:13 UTC 
(rev 32156)
+++ gnunet/src/ats-tests/ats-testing-experiment.c       2014-02-03 09:44:09 UTC 
(rev 32157)
@@ -94,14 +94,15 @@
   char *sec_name;
   char *op_name;
   char *op;
-  int ep_counter = 0;
+  char *type;
+  int op_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);
+    /* Load operation */
+    GNUNET_asprintf(&op_name, "op-%u-operation", op_counter);
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
         sec_name, op_name, &op))
     {
@@ -128,72 +129,140 @@
     else
     {
       fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
-          ep_counter, op, cur->id);
+          op_counter, op, cur->id);
       GNUNET_free (op);
+      GNUNET_free (op_name);
       return GNUNET_SYSERR;
     }
+    GNUNET_free (op_name);
 
-    GNUNET_free (op_name);
-    GNUNET_asprintf(&op_name, "op-%u-src", ep_counter);
+    /* Get source */
+    GNUNET_asprintf(&op_name, "op-%u-src", op_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);
+          op_counter, op, cur->id);
       GNUNET_free (op);
+      GNUNET_free (op_name);
       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);
+          o->src_id, op_counter, op, cur->id);
       GNUNET_free (op);
+      GNUNET_free (op_name);
       return GNUNET_SYSERR;
     }
+    GNUNET_free (op_name);
 
-    GNUNET_free (op_name);
-    GNUNET_asprintf(&op_name, "op-%u-dest", ep_counter);
+    /* Get destination */
+    GNUNET_asprintf(&op_name, "op-%u-dest", op_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);
+          op_counter, op, cur->id);
       GNUNET_free (op);
+      GNUNET_free (op_name);
       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);
+          o->dest_id, op_counter, op, cur->id);
       GNUNET_free (op);
+      GNUNET_free (op_name);
       return GNUNET_SYSERR;
     }
+    GNUNET_free (op_name);
 
-
-    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))
+    GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
+    if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
+        sec_name, op_name, &type))
     {
-      fprintf (stderr, "Missing value in operation %u `%s' in episode %u\n",
-          ep_counter, op, cur->id);
-      GNUNET_free (op);
-      return GNUNET_SYSERR;
+      break;
     }
-    if (o->dest_id > e->num_slaves)
+
+    if (STOP_SEND != o->type)
     {
-      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;
+      /* Load arguments for set_rate, start_send, set_preference */
+      if (0 == strcmp (type, "constant"))
+      {
+        o->tg_type = GNUNET_ATS_TEST_TG_CONSTANT;
+      }
+      else if (0 == strcmp (type, "linear"))
+      {
+        o->tg_type = GNUNET_ATS_TEST_TG_LINEAR;
+      }
+      else if (0 == strcmp (type, "sinus"))
+      {
+        o->tg_type = GNUNET_ATS_TEST_TG_SINUS;
+      }
+      else if (0 == strcmp (type, "random"))
+      {
+        o->tg_type = GNUNET_ATS_TEST_TG_RANDOM;
+      }
+      else
+      {
+        fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
+            op_counter, op, cur->id);
+        GNUNET_free (op);
+        GNUNET_free (op_name);
+        return GNUNET_SYSERR;
+      }
+      GNUNET_free (op_name);
+
+      /* Get base rate */
+      GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
+      if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+          sec_name, op_name, &o->base_rate))
+      {
+        fprintf (stderr, "Missing base rate in operation %u `%s' in episode 
%u\n",
+            op_counter, op, cur->id);
+        GNUNET_free (op);
+        GNUNET_free (op_name);
+        return GNUNET_SYSERR;
+      }
+      GNUNET_free (op_name);
+
+      /* Get max rate */
+      GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
+      if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+          sec_name, op_name, &o->max_rate))
+      {
+        if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) ||
+            (GNUNET_ATS_TEST_TG_RANDOM == o->tg_type) ||
+            (GNUNET_ATS_TEST_TG_SINUS == o->tg_type))
+        {
+          fprintf (stderr, "Missing max rate in operation %u `%s' in episode 
%u\n",
+              op_counter, op, cur->id);
+          GNUNET_free (op);
+          return GNUNET_SYSERR;
+        }
+      }
+      GNUNET_free (op_name);
+
+      {
+        /* Get period */
+        GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
+        if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
+            sec_name, op_name, &o->period))
+        {
+          o->period = cur->duration;
+        }
+        GNUNET_free (op_name);
+      }
     }
 
-    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);
+    fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == 
%s, %llu -> %llu in %s\n",
+        op_counter, cur->id, print_op (o->type), o->src_id,
+        o->dest_id, type, o->base_rate, o->max_rate,
+        GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
 
     GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
-    GNUNET_free (op_name);
-    ep_counter++;
+    op_counter++;
   }
   GNUNET_free (sec_name);
 
@@ -300,7 +369,7 @@
   {
 
     fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n",
-        print_op (cur->type), cur->src_id, cur->dest_id, cur->value);
+        print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate);
     switch (cur->type) {
       case START_SEND:
         enforce_start_send (cur);

Modified: gnunet/src/ats-tests/ats-testing.h
===================================================================
--- gnunet/src/ats-tests/ats-testing.h  2014-02-03 09:10:13 UTC (rev 32156)
+++ gnunet/src/ats-tests/ats-testing.h  2014-02-03 09:44:09 UTC (rev 32157)
@@ -453,14 +453,23 @@
 typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment 
*e,
     struct GNUNET_TIME_Relative duration,int success);
 
+/**
+ * An operation in an experiment
+ */
 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;
+
+  long long unsigned int base_rate;
+  long long unsigned int max_rate;
+  struct GNUNET_TIME_Relative period;
+
   enum OperationType type;
+  enum TrafficGeneratorType tg_type;
 };
 
 struct Episode

Modified: gnunet/src/ats-tests/experiments/test.exp
===================================================================
--- gnunet/src/ats-tests/experiments/test.exp   2014-02-03 09:10:13 UTC (rev 
32156)
+++ gnunet/src/ats-tests/experiments/test.exp   2014-02-03 09:44:09 UTC (rev 
32157)
@@ -1,7 +1,7 @@
 [experiment]
  name = test
  masters = 1
- slaves = 3
+ slaves = 4
  max_duration = 10 s
  cfg_file = gnunet_ats_sim_default.conf
  
@@ -9,24 +9,32 @@
 # operations = set_rate, start_send, stop_send, set_preference
 duration = 2 s
 op-0-operation = set_rate
-op-0-value = 10000
 op-0-src = 0
 op-0-dest = 1
+op-0-type = constant
+op-0-base-rate= 10000
+op-0-max-rate = 10000
 
 op-1-operation = set_rate
-op-1-value = 1000
 op-1-src = 0
 op-1-dest = 2
+op-1-type = sinus
+op-1-period = 1 s
+op-1-base-rate= 10000
+op-1-max-rate = 20000
 
+op-2-operation = set_rate
+op-2-src = 0
+op-2-dest = 3
+op-2-type = random
+op-2-period = 1 s
+op-2-base-rate= 10000
+op-2-max-rate = 20000
 
-[episode-1]
-duration = 2 s
-op-0-operation = set_preference
-op-0-value = 10000
-op-0-src = 0
-op-0-dest = 1
-
-op-1-operation = set_preference
-op-1-value = 10000
-op-1-src = 0
-op-1-dest = 2
+op-3-operation = set_rate
+op-3-src = 0
+op-3-dest = 2
+op-3-type = linear
+op-3-period = 1 s
+op-3-base-rate= 10000
+op-3-max-rate = 20000
\ No newline at end of file




reply via email to

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