fix ATS testcase
authorChristian Grothoff <christian@grothoff.org>
Mon, 20 Jun 2016 22:16:25 +0000 (22:16 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 20 Jun 2016 22:16:25 +0000 (22:16 +0000)
src/ats-tests/ats-testing-experiment.c
src/ats-tests/ats-testing-log.c
src/ats-tests/ats-testing.c
src/ats-tests/ats-testing.h
src/ats-tests/perf_ats.c

index b8da23df9ec5e09e39204ab039ff1f7f7bbf8e97..110a480436cae9d190c99bf8e197fcf31632ac2b 100644 (file)
@@ -639,7 +639,7 @@ GNUNET_ATS_TEST_experimentation_run (struct Experiment *e,
 
 
 struct Experiment *
-GNUNET_ATS_TEST_experimentation_load (char *filename)
+GNUNET_ATS_TEST_experimentation_load (const char *filename)
 {
   struct Experiment *e;
   struct GNUNET_CONFIGURATION_Handle *cfg;
index 87af31f5fe439163cc00c6995fcb9d98d549c05d..2442a8249ad5ca59e491d5d2c6d3342603940a75 100644 (file)
@@ -227,7 +227,7 @@ struct LoggingHandle
   /**
    * Logging task
    */
-  struct GNUNET_SCHEDULER_Task * log_task;
+  struct GNUNET_SCHEDULER_Task *log_task;
 
   /**
    * Reference to perf_ats' masters
@@ -236,7 +236,7 @@ struct LoggingHandle
   int num_slaves;
   int running;
   int verbose;
-  char *name;
+  const char *name;
   struct GNUNET_TIME_Relative frequency;
 
   /**
@@ -419,11 +419,12 @@ write_bw_gnuplot_script (char * fn, struct LoggingPeer *lp, char **fs, int slave
 
 void
 GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
-    char *experiment_name, int plots)
+                                       const char *experiment_name,
+                                       int plots)
 {
   struct GNUNET_DISK_FileHandle *f[l->num_slaves];
   struct GNUNET_DISK_FileHandle *f_m;
-  char *tmp_exp_name;
+  const char *tmp_exp_name;
   char *filename_master;
   char *filename_slaves[l->num_slaves];
   char *data;
@@ -878,11 +879,15 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l)
  */
 struct LoggingHandle *
 GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
-    char *testname, struct BenchmarkPeer *masters, int num_masters, int num_slaves,
-    int verbose)
+                              const char *testname,
+                              struct BenchmarkPeer *masters,
+                              int num_masters,
+                              int num_slaves,
+                              int verbose)
 {
   struct LoggingHandle *l;
   int c_m;
+
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
       _("Start logging `%s'\n"), testname);
 
index 24d46442450a7e3d0a8e876f714047db5991d8ec..c894f4445fd3390a9cddd97f5057527f9ddfbe8c 100644 (file)
@@ -66,7 +66,6 @@ do_shutdown (void *cls)
   int c_op;
   struct BenchmarkPeer *p;
 
-  top->shutdown_task = NULL;
   top->state.benchmarking = GNUNET_NO;
 
   GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
@@ -379,7 +378,8 @@ test_recv_cb (void *cls,
 
 
 static void *
-transport_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
+transport_connect_adapter (void *cls,
+                           const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct BenchmarkPeer *me = cls;
 
@@ -390,6 +390,7 @@ transport_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *
   return me->th;
 }
 
+
 static void
 transport_disconnect_adapter (void *cls, void *op_result)
 {
@@ -401,8 +402,9 @@ transport_disconnect_adapter (void *cls, void *op_result)
 
 
 static void
-connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
-    const char *emsg)
+connect_completion_callback (void *cls,
+                             struct GNUNET_TESTBED_Operation *op,
+                             const char *emsg)
 {
   struct TestbedConnectOperation *cop = cls;
   static int ops = 0;
@@ -410,8 +412,9 @@ connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
   if (NULL == emsg)
   {
     GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-        _("Connected master [%u] with slave [%u]\n"), cop->master->no,
-        cop->slave->no);
+               _("Connected master [%u] with slave [%u]\n"),
+               cop->master->no,
+               cop->slave->no);
   }
   else
   {
@@ -419,9 +422,7 @@ connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
         _("Failed to connect master peer [%u] with slave [%u]\n"),
         cop->master->no, cop->slave->no);
     GNUNET_break(0);
-    if (NULL != top->shutdown_task)
-      GNUNET_SCHEDULER_cancel (top->shutdown_task);
-    top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+    GNUNET_SCHEDULER_shutdown ();
   }
   GNUNET_TESTBED_operation_done (op);
   ops++;
@@ -436,6 +437,7 @@ connect_completion_callback (void *cls, struct GNUNET_TESTBED_Operation *op,
   }
 }
 
+
 static void
 do_connect_peers (void *cls)
 {
@@ -470,9 +472,7 @@ do_connect_peers (void *cls)
             _("Could not connect master [%u] and slave [%u]\n"), p->no,
             top->sps[c_s].no);
         GNUNET_break(0);
-        if (NULL != top->shutdown_task)
-          GNUNET_SCHEDULER_cancel (top->shutdown_task);
-        top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+        GNUNET_SCHEDULER_shutdown ();
         return;
       }
     }
@@ -481,17 +481,19 @@ do_connect_peers (void *cls)
 
 
 static void
-comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
-    void *ca_result, const char *emsg)
+comm_connect_completion_cb (void *cls,
+                            struct GNUNET_TESTBED_Operation *op,
+                            void *ca_result,
+                            const char *emsg)
 {
   static int comm_done = 0;
+
   if ((NULL != emsg) || (NULL == ca_result))
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+               "Initialization failed, shutdown\n");
     GNUNET_break(0);
-    if (NULL != top->shutdown_task)
-      GNUNET_SCHEDULER_cancel (top->shutdown_task);
-    top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
   comm_done++;
@@ -505,6 +507,7 @@ comm_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
   }
 }
 
+
 static void
 do_comm_connect (void *cls)
 {
@@ -631,11 +634,10 @@ ats_connect_completion_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
 
   if ((NULL != emsg) || (NULL == ca_result))
   {
-    GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initialization failed, shutdown\n"));
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+               "Initialization failed, shutdown\n");
     GNUNET_break(0);
-    if (NULL != top->shutdown_task)
-      GNUNET_SCHEDULER_cancel (top->shutdown_task);
-    top->shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL );
+    GNUNET_SCHEDULER_shutdown ();
     return;
   }
   op_done++;
@@ -721,15 +723,18 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
 {
   int c_m;
   int c_s;
+
   GNUNET_assert(NULL == cls);
   GNUNET_assert(top->num_masters + top->num_slaves == num_peers);
   GNUNET_assert(NULL != peers_);
 
-  top->shutdown_task = GNUNET_SCHEDULER_add_delayed (
-      GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, top);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                 top);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting up %u masters and %u slaves\n",
-      top->num_masters, top->num_slaves);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Setting up %u masters and %u slaves\n",
+              top->num_masters,
+              top->num_slaves);
 
   /* Setup master peers */
   for (c_m = 0; c_m < top->num_masters; c_m++)
@@ -791,9 +796,8 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h,
  */
 static void
 controller_event_cb (void *cls,
-    const struct GNUNET_TESTBED_EventInformation *event)
+                     const struct GNUNET_TESTBED_EventInformation *event)
 {
-  struct GNUNET_ATS_TEST_Topology *top = cls;
   switch (event->type)
   {
   case GNUNET_TESTBED_ET_CONNECT:
@@ -802,11 +806,11 @@ controller_event_cb (void *cls,
     break;
   default:
     GNUNET_break(0);
-    GNUNET_SCHEDULER_cancel (top->shutdown_task);
-    top->shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL );
+    GNUNET_SCHEDULER_shutdown ();
   }
 }
 
+
 struct BenchmarkPeer *
 GNUNET_ATS_TEST_get_peer (int src)
 {
@@ -815,6 +819,7 @@ GNUNET_ATS_TEST_get_peer (int src)
   return &top->mps[src];
 }
 
+
 struct BenchmarkPartner *
 GNUNET_ATS_TEST_get_partner (int src, int dest)
 {
index 74da0f78cf02be63cd1b5248af4f721652383409..b2a4d13e6ec3d2d739687d212af227664bc992d0 100644 (file)
@@ -376,15 +376,10 @@ struct BenchmarkState
 
 struct GNUNET_ATS_TEST_Topology
 {
-  /**
-   * Shutdown task
-   */
-  struct GNUNET_SCHEDULER_Task * shutdown_task;
-
   /**
    * Progress task
    */
-  struct GNUNET_SCHEDULER_Task * progress_task;
+  struct GNUNET_SCHEDULER_Task *progress_task;
 
   /**
    * Test result
@@ -544,8 +539,9 @@ extern struct GNUNET_CONFIGURATION_Handle *cfg;
  */
 void
 GNUNET_ATS_TEST_experimentation_run (struct Experiment *e,
-    GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,
-    GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb);
+                                     GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb,
+                                     GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb);
+
 
 /**
  * Load an experiment from a file
@@ -554,7 +550,7 @@ GNUNET_ATS_TEST_experimentation_run (struct Experiment *e,
  * @return the Experiment or NULL on failure
  */
 struct Experiment *
-GNUNET_ATS_TEST_experimentation_load (char *filename);
+GNUNET_ATS_TEST_experimentation_load (const char *filename);
 
 
 /**
@@ -606,7 +602,8 @@ GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg);
  * Stop all traffic generators
  */
 void
-GNUNET_ATS_TEST_generate_traffic_stop_all ();
+GNUNET_ATS_TEST_generate_traffic_stop_all (void);
+
 
 /**
  * Generate between the source master and the partner and set preferences with a
@@ -635,8 +632,9 @@ GNUNET_ATS_TEST_generate_preferences_start (struct BenchmarkPeer *src,
 void
 GNUNET_ATS_TEST_generate_preferences_stop (struct PreferenceGenerator *pg);
 
+
 void
-GNUNET_ATS_TEST_generate_preferences_stop_all ();
+GNUNET_ATS_TEST_generate_preferences_stop_all (void);
 
 /*
  * Logging related functions
@@ -655,8 +653,12 @@ GNUNET_ATS_TEST_generate_preferences_stop_all ();
  */
 struct LoggingHandle *
 GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
-    char *testname, struct BenchmarkPeer *masters, int num_masters, int num_slaves,
-    int verbose);
+                              const char *testname,
+                              struct BenchmarkPeer *masters,
+                              int num_masters,
+                              int num_slaves,
+                              int verbose);
+
 
 /**
  * Stop logging
@@ -666,6 +668,7 @@ GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
 void
 GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l);
 
+
 /**
  * Stop logging
  *
@@ -674,6 +677,7 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l);
 void
 GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l);
 
+
 /**
  * Log all data now
  *
@@ -688,22 +692,25 @@ GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l);
  *
  * @param l logging handle to use
  * @param test_name name of the current test
- * @param plots create gnuplots: GNUNET_YES or GNUNET_NO
+ * @param plots create gnuplots: #GNUNET_YES or #GNUNET_NO
  */
 void
 GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
-    char *test_name, int plots);
+                                       const char *test_name,
+                                       int plots);
 
-/*
+
+/**
  * Topology related functions
  */
-
 struct BenchmarkPeer *
 GNUNET_ATS_TEST_get_peer (int src);
 
+
 struct BenchmarkPartner *
 GNUNET_ATS_TEST_get_partner (int src, int dest);
 
+
 /**
  * Create a topology for ats testing
  *
@@ -711,21 +718,23 @@ GNUNET_ATS_TEST_get_partner (int src, int dest);
  * @param cfg_file configuration file to use for the peers
  * @param num_slaves number of slaves
  * @param num_masters number of masters
- * @param test_core connect to CORE service (GNUNET_YES) or transport (GNUNET_NO)
+ * @param test_core connect to CORE service (#GNUNET_YES) or transport (#GNUNET_NO)
  * @param done_cb function to call when topology is setup
  * @param done_cb_cls cls for callback
  * @param transport_recv_cb callback to call when data are received
  * @param log_request_cb callback to call when logging is required
  */
 void
-GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
-    unsigned int num_slaves,
-    unsigned int num_masters,
-    int test_core,
-    GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
-    void *done_cb_cls,
-    GNUNET_TRANSPORT_ReceiveCallback recv_cb,
-    GNUNET_ATS_TEST_LogRequest ats_perf_cb);
+GNUNET_ATS_TEST_create_topology (char *name,
+                                 char *cfg_file,
+                                 unsigned int num_slaves,
+                                 unsigned int num_masters,
+                                 int test_core,
+                                 GNUNET_ATS_TEST_TopologySetupDoneCallback done_cb,
+                                 void *done_cb_cls,
+                                 GNUNET_TRANSPORT_ReceiveCallback recv_cb,
+                                 GNUNET_ATS_TEST_LogRequest ats_perf_cb);
+
 
 /**
  * Shutdown topology
@@ -733,4 +742,5 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file,
 void
 GNUNET_ATS_TEST_shutdown_topology (void);
 
+
 /* end of file ats-testing.h */
index 4c22043e5864ec74b69a4101aabc677a05cc1518..0e4056a6cedc5c793584d8aa85bf6864aa49ec4a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  This file is part of GNUnet.
- Copyright (C) 2010-2013 GNUnet e.V.
+ Copyright (C) 2010-2013, 2016 GNUnet e.V.
 
  GNUnet is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
 #define TESTNAME_PREFIX "perf_ats_"
 #define DEFAULT_SLAVES_NUM 2
 #define DEFAULT_MASTERS_NUM 1
+
 /**
- * Shutdown task
+ * timeout task
  */
-static struct GNUNET_SCHEDULER_Task * shutdown_task;
+static struct GNUNET_SCHEDULER_Task *timeout_task;
 
 /**
  * Progress task
  */
-static struct GNUNET_SCHEDULER_Task * progress_task;
+static struct GNUNET_SCHEDULER_Task *progress_task;
 
 /**
  * Test result
@@ -63,7 +64,8 @@ static int result;
  */
 static int logging;
 
-/**Test core (GNUNET_YES) or transport (GNUNET_NO)
+/**
+ * Test core (#GNUNET_YES) or transport (#GNUNET_NO)
  */
 static int test_core;
 
@@ -119,6 +121,7 @@ static struct BenchmarkPeer *sps;
 
 static struct LoggingHandle *l;
 
+
 static void
 evaluate ()
 {
@@ -138,6 +141,8 @@ evaluate ()
   for (c_m = 0; c_m < num_masters; c_m++)
   {
     mp = &mps[c_m];
+    if (NULL == mp)
+      continue;
     fprintf (stderr,
         _("Master [%u]: sent: %u KiB in %u sec. = %u KiB/s, received: %u KiB in %u sec. = %u KiB/s\n"),
         mp->no, mp->total_bytes_sent / 1024, duration,
@@ -148,7 +153,8 @@ evaluate ()
     for (c_s = 0; c_s < num_slaves; c_s++)
     {
       p = &mp->partners[c_s];
-
+      if (NULL == p)
+        continue;
       kb_sent_sec = 0;
       kb_recv_sec = 0;
       kb_sent_percent = 0.0;
@@ -168,19 +174,20 @@ evaluate ()
       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,
-          kb_sent_sec, kb_sent_percent,
-                 kb_recv_sec, kb_recv_percent);
+               "%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,
+               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, rtt);
+               "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n",
+               (mp->pref_partner == p->dest) ? '*' : ' ',
+               mp->no, p->dest->no, rtt);
     }
   }
 }
 
+
 /**
  * Shutdown nicely
  *
@@ -189,37 +196,55 @@ evaluate ()
 static void
 do_shutdown (void *cls)
 {
-
   if (GNUNET_YES == logging)
     GNUNET_ATS_TEST_logging_clean_up(l);
-
-  shutdown_task = NULL;
+  if (NULL != timeout_task)
+  {
+    GNUNET_SCHEDULER_cancel (timeout_task);
+    timeout_task = NULL;
+  }
   if (NULL != progress_task)
   {
     fprintf (stderr, "0\n");
     GNUNET_SCHEDULER_cancel (progress_task);
+    progress_task = NULL;
   }
-  progress_task = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Benchmarking done\n");
+  GNUNET_ATS_TEST_shutdown_topology ();
+}
 
-  evaluate ();
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n"));
 
-  GNUNET_ATS_TEST_shutdown_topology();
+/**
+ * Shutdown nicely
+ *
+ * @param cls NULL
+ */
+static void
+do_timeout (void *cls)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Terminating with timeout\n");
+  timeout_task = NULL;
+  evaluate ();
+  GNUNET_SCHEDULER_shutdown ();
 }
 
 
 static void
-print_progress ()
+print_progress (void *cls)
 {
   static int calls;
-  progress_task = NULL;
 
-  fprintf (stderr, "%llu..",
-      (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) - calls);
+  progress_task = NULL;
+  fprintf (stderr,
+           "%llu..",
+           (long long unsigned) perf_duration.rel_value_us / (1000 * 1000) - calls);
   calls++;
 
   progress_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-      &print_progress, NULL );
+                                                &print_progress,
+                                                NULL);
 }
 
 
@@ -240,56 +265,65 @@ ats_pref_task (void *cls)
       &ats_pref_task, cls);
 }
 
+
 static void
-start_benchmark()
+start_benchmark (void *cls)
 {
   int c_m;
   int c_s;
 
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking start\n"));
-
-  if (NULL != shutdown_task)
-    GNUNET_SCHEDULER_cancel(shutdown_task);
-  shutdown_task = GNUNET_SCHEDULER_add_delayed(perf_duration, &do_shutdown,
-      NULL );
-
-  progress_task = GNUNET_SCHEDULER_add_now(&print_progress, NULL );
+  progress_task = GNUNET_SCHEDULER_add_now (&print_progress,
+                                            NULL);
 
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-      "Topology connected, start benchmarking...\n");
+             "Topology connected, start benchmarking...\n");
 
   /* Start sending test messages */
   for (c_m = 0; c_m < num_masters; c_m++)
+  {
+    for (c_s = 0; c_s < num_slaves; c_s++)
     {
-      for (c_s = 0; c_s < num_slaves; c_s++)
-      {
-        GNUNET_ATS_TEST_generate_traffic_start (&mps[c_m], &mps[c_m].partners[c_s],
-            GNUNET_ATS_TEST_TG_LINEAR, UINT32_MAX, UINT32_MAX,
-            GNUNET_TIME_UNIT_MINUTES, GNUNET_TIME_UNIT_FOREVER_REL);
-      }
-      if (pref_val != GNUNET_ATS_PREFERENCE_END)
-        mps[c_m].ats_task = GNUNET_SCHEDULER_add_now(&ats_pref_task, &mps[c_m]);
+      GNUNET_ATS_TEST_generate_traffic_start (&mps[c_m],
+                                              &mps[c_m].partners[c_s],
+                                              GNUNET_ATS_TEST_TG_LINEAR,
+                                              UINT32_MAX,
+                                              UINT32_MAX,
+                                              GNUNET_TIME_UNIT_MINUTES,
+                                              GNUNET_TIME_UNIT_FOREVER_REL);
     }
+    if (pref_val != GNUNET_ATS_PREFERENCE_END)
+      mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task,
+                                                    &mps[c_m]);
+  }
 
   if (GNUNET_YES == logging)
-    l = GNUNET_ATS_TEST_logging_start (log_frequency, testname, mps,
-        num_masters, num_slaves, GNUNET_NO);
+    l = GNUNET_ATS_TEST_logging_start (log_frequency,
+                                       testname, mps,
+                                       num_masters, num_slaves,
+                                       GNUNET_NO);
 }
 
+
 static void
-do_benchmark (void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *slaves)
+do_benchmark (void *cls,
+              struct BenchmarkPeer *masters,
+              struct BenchmarkPeer *slaves)
 {
   mps = masters;
   sps = slaves;
-
-  GNUNET_SCHEDULER_add_now(&start_benchmark, NULL);
+  GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+                                 NULL);
+  timeout_task = GNUNET_SCHEDULER_add_delayed (perf_duration,
+                                               &do_timeout,
+                                               NULL);
+  progress_task = GNUNET_SCHEDULER_add_now (&start_benchmark,
+                                            NULL);
 }
 
 
-
-
 static struct BenchmarkPartner *
-find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer)
+find_partner (struct BenchmarkPeer *me,
+              const struct GNUNET_PeerIdentity *peer)
 {
   int c_m;
   GNUNET_assert (NULL != me);
@@ -307,20 +341,23 @@ find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer)
   return NULL;
 }
 
+
 static void
 test_recv_cb (void *cls,
-                     const struct GNUNET_PeerIdentity * peer,
-                     const struct GNUNET_MessageHeader * message)
+              const struct GNUNET_PeerIdentity * peer,
+              const struct GNUNET_MessageHeader * message)
 {
 
 }
 
 
 static void
-log_request_cb (void *cls, const struct GNUNET_HELLO_Address *address,
-    int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-    struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-    const struct GNUNET_ATS_Properties *ats)
+log_request_cb (void *cls,
+                const struct GNUNET_HELLO_Address *address,
+                int address_active,
+                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+                struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                const struct GNUNET_ATS_Properties *ats)
 {
   struct BenchmarkPeer *me = cls;
   struct BenchmarkPartner *p;
@@ -341,12 +378,13 @@ log_request_cb (void *cls, const struct GNUNET_HELLO_Address *address,
   p->bandwidth_in = ntohl (bandwidth_in.value__);
   p->bandwidth_out = ntohl (bandwidth_out.value__);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s [%u] received ATS information for peers `%s'\n",
-      (GNUNET_YES == p->me->master) ? "Master" : "Slave",
-          p->me->no,
-          GNUNET_i2s (&p->dest->id));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "%s [%u] received ATS information for peers `%s'\n",
+              (GNUNET_YES == p->me->master) ? "Master" : "Slave",
+              p->me->no,
+              GNUNET_i2s (&p->dest->id));
 
-  GNUNET_free(peer_id);
+  GNUNET_free (peer_id);
   if (NULL != l)
     GNUNET_ATS_TEST_logging_now (l);
 }
@@ -534,7 +572,8 @@ main (int argc, char *argv[])
 
   if (num_slaves < num_masters)
   {
-    fprintf (stderr, "Number of master peers is lower than slaves! exit...\n");
+    fprintf (stderr,
+             "Number of master peers is lower than slaves! exit...\n");
     GNUNET_free(test_name);
     GNUNET_free(solver);
     GNUNET_free(pref_str);
@@ -545,13 +584,14 @@ main (int argc, char *argv[])
   /**
    * Setup the topology
    */
-  GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name,
-      num_slaves, num_masters,
-      test_core,
-      &do_benchmark,
-      NULL,
-      &test_recv_cb,
-      &log_request_cb);
+  GNUNET_ATS_TEST_create_topology ("perf-ats",
+                                   conf_name,
+                                   num_slaves, num_masters,
+                                   test_core,
+                                   &do_benchmark,
+                                   NULL,
+                                   &test_recv_cb,
+                                   &log_request_cb);
 
   return result;
 }