header
[oweals/gnunet.git] / src / ats / gnunet-ats-solver-eval.c
index b5c57bb94810538a7a37191c797ef39fd0a05f5f..9636709b7b4f634591cb002cbc45b7c39af3946c 100644 (file)
 #include "gnunet_util_lib.h"
 #include "gnunet-ats-solver-eval.h"
 
-
 #define BIG_M_STRING "unlimited"
 
 static struct Experiment *e;
 
-static struct GNUNET_ATS_TESTING_SolverHandle *sh;
+static struct LoggingHandle *l;
+
+static struct SolverHandle *sh;
+
+static struct TestPeer *peer_head;
+static struct TestPeer *peer_tail;
+
+static double default_properties[GNUNET_ATS_PropertyCount];
+static double default_preferences[GNUNET_ATS_PreferenceCount];
 
 /**
  * cmd option -e: experiment file
@@ -49,18 +56,29 @@ static int opt_log;
 /**
  * cmd option -p: enable plots
  */
-static int opt_plot;
+static int opt_save;
 
 /**
  * cmd option -v: verbose logs
  */
 static int opt_verbose;
 
+/**
+ * cmd option -p: print logs
+ */
+static int opt_print;
+
+/**
+ * cmd option -d: disable normalization
+ */
+static int opt_disable_normalization;
+
 static int res;
 
 static void
 end_now ();
 
+
 static char *
 print_generator_type (enum GeneratorType g)
 {
@@ -79,6 +97,455 @@ print_generator_type (enum GeneratorType g)
   }
 }
 
+struct AddressLookupCtx
+{
+  struct ATS_Address *res;
+  char *plugin;
+  char *addr;
+};
+
+
+int find_address_it (void *cls,
+                     const struct GNUNET_PeerIdentity *key,
+                     void *value)
+{
+  struct AddressLookupCtx *ctx = cls;
+  struct ATS_Address *addr = value;
+
+  if ( (0 == strcmp (ctx->plugin, addr->plugin)) &&
+       (0 == strcmp (ctx->addr, addr->addr)) )
+  {
+       ctx->res = addr;
+       return GNUNET_NO;
+  }
+  return GNUNET_YES;
+}
+
+static struct TestPeer *
+find_peer_by_id (int id)
+{
+  struct TestPeer *cur;
+  for (cur = peer_head; NULL != cur; cur = cur->next)
+    if (cur->id == id)
+      return cur;
+  return NULL;
+}
+
+static struct TestPeer *
+find_peer_by_pid (const struct GNUNET_PeerIdentity *pid)
+{
+  struct TestPeer *cur;
+  for (cur = peer_head; NULL != cur; cur = cur->next)
+    if (0 == memcmp (&cur->peer_id, pid, sizeof (struct GNUNET_PeerIdentity)))
+      return cur;
+  return NULL;
+}
+
+static struct TestAddress *
+find_address_by_id (struct TestPeer *peer, int aid)
+{
+  struct TestAddress *cur;
+  for (cur = peer->addr_head; NULL != cur; cur = cur->next)
+    if (cur->aid == aid)
+      return cur;
+  return NULL;
+}
+
+
+static struct TestAddress *
+find_address_by_ats_address (struct TestPeer *p, const struct ATS_Address *addr)
+{
+  struct TestAddress *cur;
+  for (cur = p->addr_head; NULL != cur; cur = cur->next)
+    if ((0 == strcmp(cur->ats_addr->plugin, addr->plugin)) &&
+         (cur->ats_addr->addr_len == addr->addr_len) &&
+        (0 == memcmp (cur->ats_addr->addr, addr->addr, addr->addr_len)))
+      return cur;
+  return NULL;
+}
+
+
+/**
+ * Logging
+ */
+
+void
+GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
+{
+  struct LoggingTimeStep *lts;
+  struct TestPeer *cur;
+  struct TestAddress *cur_addr;
+  struct LoggingPeer *log_p;
+  struct LoggingAddress *log_a;
+  int c;
+
+  lts = GNUNET_new (struct LoggingTimeStep);
+  GNUNET_CONTAINER_DLL_insert_tail(l->head, l->tail, lts);
+  lts->timestamp = GNUNET_TIME_absolute_get();
+  if (NULL == lts->prev)
+    lts->delta = GNUNET_TIME_UNIT_ZERO;
+  else
+    lts->delta = GNUNET_TIME_absolute_get_duration(lts->prev->timestamp);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging %llu, delta %llu\n",
+      lts->timestamp.abs_value_us, lts->delta.rel_value_us);
+
+
+  /* Store logging data here */
+  for (cur = peer_head; NULL != cur; cur = cur->next)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging peer id %llu\n", cur->id);
+
+    log_p = GNUNET_new (struct LoggingPeer);
+    log_p->id = cur->id;
+    log_p->peer_id = cur->peer_id;
+    for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+    {
+      log_p->pref_abs[c] = cur->pref_abs[c];
+      log_p->pref_norm[c] = cur->pref_norm[c];
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t %s = %.2f %.2f [abs/rel]\n",
+          GNUNET_ATS_print_preference_type(c),
+          log_p->pref_abs[c], log_p->pref_norm[c]);
+    }
+    GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
+
+    for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging peer id %llu address %llu \n",
+          cur->id, cur_addr->aid);
+      log_a = GNUNET_new (struct LoggingAddress);
+      log_a->aid = cur_addr->aid;
+      log_a->active = cur_addr->ats_addr->active;
+      log_a->network = cur_addr->network;
+      log_a->used = cur_addr->ats_addr->used;
+      log_a->assigned_bw_in = cur_addr->ats_addr->assigned_bw_in;
+      log_a->assigned_bw_out = cur_addr->ats_addr->assigned_bw_out;
+      for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
+      {
+        log_a->prop_abs[c] = cur_addr->prop_abs[c];
+        log_a->prop_norm[c] = cur_addr->prop_norm[c];
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t %s = %.2f %.2f [abs/rel]\n",
+            GNUNET_ATS_print_property_type(c),
+            log_a->prop_abs[c], log_a->prop_norm[c]);
+      }
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", ntohl(log_a->assigned_bw_in.value__));
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\t BW out = %llu\n", ntohl(log_a->assigned_bw_out.value__));
+
+      GNUNET_CONTAINER_DLL_insert_tail (log_p->addr_head, log_p->addr_tail, log_a);
+    }
+  }
+}
+
+static void
+logging_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct LoggingHandle *l = cls;
+  l->logging_task = GNUNET_SCHEDULER_NO_TASK;
+
+  GNUNET_ATS_solver_logging_now (l);
+
+  l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq, &logging_task, l);
+
+}
+
+struct LoggingHandle *
+GNUNET_ATS_solver_logging_start (struct GNUNET_TIME_Relative freq)
+{
+  struct LoggingHandle *l;
+  l = GNUNET_new (struct LoggingHandle);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start logging every  %s\n",
+      GNUNET_STRINGS_relative_time_to_string(freq, GNUNET_NO));
+  l->log_freq = freq;
+  l->logging_task = GNUNET_SCHEDULER_add_now (&logging_task, l);
+  return l;
+}
+
+void
+GNUNET_ATS_solver_logging_stop (struct LoggingHandle *l)
+{
+  if (GNUNET_SCHEDULER_NO_TASK != l->logging_task)
+    GNUNET_SCHEDULER_cancel (l->logging_task);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop logging\n");
+
+  l->logging_task = GNUNET_SCHEDULER_NO_TASK;
+}
+
+static struct LoggingFileHandle *
+find_logging_file_handle (struct LoggingFileHandle *lf_head,
+    struct LoggingFileHandle *lf_tail,
+    int peer_id, int address_id)
+{
+  struct LoggingFileHandle *res;
+
+  for (res = lf_head; NULL != res; res = res->next)
+    if ((res->pid == peer_id) && (res->aid == address_id))
+      return res;
+  return NULL;
+
+}
+
+void
+GNUNET_ATS_solver_logging_write_to_disk (struct LoggingHandle *l, int add_time_stamp,
+    char *output_dir)
+{
+  struct LoggingTimeStep *lts;
+  struct LoggingPeer *log_p;
+  struct LoggingAddress *log_a;
+  struct LoggingFileHandle *lf_head;
+  struct LoggingFileHandle *lf_tail;
+  struct LoggingFileHandle *cur;
+  struct LoggingFileHandle *next;
+  char * filename;
+  char * datastring;
+  char * propstring;
+  char * propstring_tmp;
+  char * prefstring;
+  char * prefstring_tmp;
+  int c;
+  int use_dir;
+
+  use_dir = GNUNET_NO;
+  if (NULL != output_dir)
+  {
+    if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (output_dir))
+    {
+      fprintf (stderr, "Failed to create directory `%s'\n", output_dir);
+      return;
+    }
+    else
+    {
+      fprintf (stderr, "Created directory `%s'\n", output_dir);
+      use_dir = GNUNET_YES;
+    }
+  }
+
+  lf_head = NULL;
+  lf_tail = NULL;
+
+  for (lts = l->head; NULL != lts; lts = lts->next)
+  {
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Writing log step %llu\n",
+        (long long unsigned int) lts->timestamp.abs_value_us);
+
+    for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
+    {
+      for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
+      {
+
+        cur = find_logging_file_handle (lf_head, lf_tail, log_p->id,
+            log_a->aid);
+        if (NULL == cur)
+        {
+          cur = GNUNET_new (struct LoggingFileHandle);
+          cur->aid = log_a->aid;
+          cur->pid = log_p->id;
+
+          if (GNUNET_YES == add_time_stamp)
+            GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u_%llu.log",
+                (GNUNET_YES == use_dir) ? output_dir : "",
+                (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
+                e->log_prefix,
+                opt_solver,
+                cur->pid,
+                cur->aid,
+                l->head->timestamp.abs_value_us);
+          else
+            GNUNET_asprintf (&filename, "%s%s%s_%s_p%u_a%u.log",
+                (GNUNET_YES == use_dir) ? output_dir : "",
+                (GNUNET_YES == use_dir) ? DIR_SEPARATOR_STR : "",
+                e->log_prefix,
+                opt_solver,
+                cur->pid,
+                cur->aid);
+
+          fprintf (stderr, "Add writing log data for peer %llu address %llu to file `%s'\n",
+              cur->pid, cur->aid, filename);
+
+
+          cur->f_hd = GNUNET_DISK_file_open (filename,
+              GNUNET_DISK_OPEN_READWRITE |
+              GNUNET_DISK_OPEN_CREATE |
+              GNUNET_DISK_OPEN_TRUNCATE,
+              GNUNET_DISK_PERM_USER_READ |
+              GNUNET_DISK_PERM_USER_WRITE |
+              GNUNET_DISK_PERM_GROUP_READ |
+              GNUNET_DISK_PERM_OTHER_READ);
+          if (NULL == cur->f_hd)
+          {
+            fprintf (stderr, "Cannot open `%s' to write log data!\n", filename);
+            GNUNET_free (filename);
+            goto cleanup;
+          }
+          GNUNET_free (filename);
+          GNUNET_CONTAINER_DLL_insert (lf_head, lf_tail, cur);
+
+          GNUNET_asprintf(&datastring,"#time delta;log duration; addr net; addr_active; bw in; bw out; " \
+              "UTILIZATION_UP [abs/rel]; UTILIZATION_UP; UTILIZATION_DOWN; UTILIZATION_DOWN; " \
+              "UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_UP; UTILIZATION_PAYLOAD_DOWN; UTILIZATION_PAYLOAD_DOWN;"\
+              "DELAY; DELAY; " \
+              "DISTANCE ;DISTANCE ; COST_WAN; COST_WAN; COST_LAN; COST_LAN; " \
+              "COST_WLAN; COST_WLAN; PREF BW abs; PREF BW rel; PREF LATENCY abs; PREF LATENCY rel;\n");
+          GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
+          GNUNET_free (datastring);
+
+        }
+
+        prefstring = GNUNET_strdup("");
+        for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
+        {
+          /*
+          fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
+              GNUNET_ATS_print_preference_type(c),
+              log_p->pref_abs[c], log_p->pref_norm[c]);
+           */
+          GNUNET_asprintf(&prefstring_tmp,"%s;%.3f;%.3f",
+              prefstring, log_p->pref_abs[c], log_p->pref_norm[c]);
+
+
+          GNUNET_free (prefstring);
+          prefstring = GNUNET_strdup(prefstring_tmp);
+          GNUNET_free (prefstring_tmp);
+        }
+
+
+        propstring = GNUNET_strdup("");
+        for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
+        {
+          if (GNUNET_ATS_NETWORK_TYPE == c)
+            continue;
+          /*
+          fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
+              GNUNET_ATS_print_property_type(c),
+              log_a->prop_abs[c], log_a->prop_norm[c]);*/
+          GNUNET_asprintf(&propstring_tmp,"%s%.3f;%.3f;",
+              propstring, log_a->prop_abs[c], log_a->prop_norm[c]);
+          GNUNET_free (propstring);
+          propstring = GNUNET_strdup(propstring_tmp);
+          GNUNET_free (propstring_tmp);
+        }
+
+        GNUNET_asprintf(&datastring,"%llu;%llu;%u;%i;%u;%u;%s;%s\n",
+            GNUNET_TIME_absolute_get_difference(l->head->timestamp, lts->timestamp).rel_value_us / 1000,
+            lts->delta,
+            log_a->network,
+            log_a->active,
+            ntohl (log_a->assigned_bw_in.value__),
+            ntohl (log_a->assigned_bw_out.value__),
+            propstring, prefstring);
+
+        GNUNET_DISK_file_write (cur->f_hd, datastring, strlen(datastring));
+        GNUNET_free (datastring);
+        GNUNET_free (prefstring);
+        GNUNET_free (propstring);
+      }
+    }
+  }
+
+cleanup:
+  next = lf_head;
+  for (cur = next; NULL != cur; cur = next)
+  {
+    next = cur->next;
+    GNUNET_CONTAINER_DLL_remove (lf_head, lf_tail, cur);
+    if (NULL != cur->f_hd)
+      GNUNET_DISK_file_close (cur->f_hd);
+    GNUNET_free (cur);
+  }
+
+}
+
+void
+GNUNET_ATS_solver_logging_eval (struct LoggingHandle *l)
+{
+  struct LoggingTimeStep *lts;
+  struct LoggingPeer *log_p;
+  struct LoggingAddress *log_a;
+  int c;
+
+  for (lts = l->head; NULL != lts; lts = lts->next)
+  {
+    fprintf (stderr, "Log step %llu %llu: \n",
+        (long long unsigned int) lts->timestamp.abs_value_us,
+        (long long unsigned int) lts->delta.rel_value_us);
+
+    for (log_p = lts->head; NULL != log_p; log_p = log_p->next)
+    {
+      fprintf (stderr,"\tLogging peer pid %llu\n", log_p->id);
+      for (c = 1; c < GNUNET_ATS_PreferenceCount; c++)
+      {
+        fprintf(stderr,"\t %s = %.2f %.2f [abs/rel]\n",
+            GNUNET_ATS_print_preference_type(c),
+            log_p->pref_abs[c], log_p->pref_norm[c]);
+      }
+
+      for (log_a = log_p->addr_head; NULL != log_a; log_a = log_a->next)
+      {
+        fprintf (stderr, "\tPeer pid %llu address %llu: %u %u %u\n",
+            log_p->id, log_a->aid, log_a->active,
+            ntohl(log_a->assigned_bw_in.value__),
+            ntohl(log_a->assigned_bw_out.value__));
+
+        for (c = 1; c < GNUNET_ATS_PropertyCount; c++)
+        {
+          if (GNUNET_ATS_NETWORK_TYPE == c)
+            continue;
+          fprintf(stderr, "\t %s = %.2f %.2f [abs/rel]\n",
+              GNUNET_ATS_print_property_type(c),
+              log_a->prop_abs[c], log_a->prop_norm[c]);
+        }
+      }
+    }
+  }
+}
+
+void
+GNUNET_ATS_solver_logging_free (struct LoggingHandle *l)
+{
+  struct LoggingTimeStep *lts_cur;
+  struct LoggingTimeStep *lts_next;
+  struct LoggingPeer *log_p_cur;
+  struct LoggingPeer *log_p_next;
+  struct LoggingAddress *log_a_cur;
+  struct LoggingAddress *log_a_next;
+
+  if (GNUNET_SCHEDULER_NO_TASK != l->logging_task)
+    GNUNET_SCHEDULER_cancel (l->logging_task);
+  l->logging_task = GNUNET_SCHEDULER_NO_TASK;
+
+  lts_next = l->head;
+  while (NULL != (lts_cur = lts_next))
+  {
+    lts_next = lts_cur->next;
+
+    log_p_next = lts_cur->head;
+    while (NULL != (log_p_cur = log_p_next))
+    {
+      log_p_next = log_p_cur->next;
+
+      log_a_next = log_p_cur->addr_head;
+      while (NULL != (log_a_cur = log_a_next))
+      {
+        log_a_next = log_a_cur->next;
+
+        GNUNET_CONTAINER_DLL_remove (log_p_cur->addr_head, log_p_cur->addr_tail, log_a_cur);
+        GNUNET_free (log_a_cur);
+      }
+
+      GNUNET_CONTAINER_DLL_remove (lts_cur->head, lts_cur->tail, log_p_cur);
+      GNUNET_free (log_p_cur);
+    }
+
+    GNUNET_CONTAINER_DLL_remove (l->head, l->tail, lts_cur);
+    GNUNET_free (lts_cur);
+  }
+
+  GNUNET_free (l);
+}
+
 /**
  * Property Generators
  */
@@ -145,50 +612,83 @@ get_property (struct PropertyGenerator *pg)
 
 
 static void
-set_prop_task (void *cls,
-                    const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct PropertyGenerator *pg = cls;
-  double pref_value;
+  struct TestPeer *p;
+  struct TestAddress *a;
+  double prop_value;
+  struct GNUNET_ATS_Information atsi;
+
   pg->set_task = GNUNET_SCHEDULER_NO_TASK;
 
-  pref_value = get_property (pg);
+  if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains_value (sh->addresses,
+      &pg->test_peer->peer_id, pg->test_address->ats_addr))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting property generation for unknown address [%u:%u]\n",
+        pg->peer, pg->address_id);
+    return;
+  }
+  if (NULL == (p = find_peer_by_id (pg->peer)))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting property generation for unknown peer %u\n",
+        pg->peer);
+  }
+  if (NULL == (a = find_address_by_id (p, pg->address_id)))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting property generation for unknown peer %u\n",
+        pg->peer);
+  }
+
+  prop_value = get_property (pg);
+  a->prop_abs[pg->ats_property] = prop_value;
 
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
       "Setting property for peer [%u] address [%u] for %s to %f\n",
       pg->peer, pg->address_id,
-      GNUNET_ATS_print_property_type (pg->ats_property), pref_value);
+      GNUNET_ATS_print_property_type (pg->ats_property), prop_value);
 
-  /* set performance here!
-  GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle,
-      &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END);
-*/
+  atsi.type = htonl (pg->ats_property);
+  atsi.value = htonl ((uint32_t) prop_value);
 
-  switch (pg->ats_property) {
-    case GNUNET_ATS_PREFERENCE_BANDWIDTH:
-      //p->pref_bandwidth = pref_value;
-      break;
-    case GNUNET_ATS_PREFERENCE_LATENCY:
-      //p->pref_delay = pref_value;
-      break;
-    default:
-      break;
+  /* set performance here! */
+  sh->env.sf.s_bulk_start (sh->solver);
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    a->prop_abs[pg->ats_property] = prop_value;
+    a->prop_norm[pg->ats_property] = prop_value;
+    sh->env.sf.s_address_update_property (sh->solver, a->ats_addr,
+        pg->ats_property, prop_value, prop_value);
   }
+  else
+    GAS_normalization_normalize_property (sh->addresses,
+      pg->test_address->ats_addr, &atsi, 1);
+  sh->env.sf.s_bulk_stop (sh->solver);
 
   pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
       &set_prop_task, pg);
 
 }
 
+/**
+ * Set ats_property to 0 to find all pgs
+ */
+
 static struct PropertyGenerator *
 find_prop_gen (unsigned int peer, unsigned int address,
     uint32_t ats_property)
 {
   struct PropertyGenerator *cur;
   for (cur = prop_gen_head; NULL != cur; cur = cur->next)
-    if ((cur->peer == peer) && (cur->address_id == address) &&
-        (cur->ats_property == ats_property))
-      return cur;
+    if ((cur->peer == peer) && (cur->address_id == address))
+    {
+      if ((cur->ats_property == ats_property) || (0 == ats_property))
+        return cur;
+    }
   return NULL;
 }
 
@@ -212,21 +712,26 @@ GNUNET_ATS_solver_generate_property_stop (struct PropertyGenerator *pg)
 
 
 /**
- * Generate between the source master and the partner and set preferences with a
+ * Generate between the source master and the partner and set property with a
  * value depending on the generator.
  *
- * @param src source
- * @param dest partner
- * @param type type of preferences to generate
- * @param base_rate traffic base rate to send data with
- * @param max_rate  traffic maximum rate to send data with
- * @param period duration of a period of traffic generation (~ 1/frequency)
- * @param duration how long to generate traffic
- * @return the traffic generator
+ * @param peer source
+ * @param address_id partner
+ * @param test_peer the peer
+ * @param test_address the address
+ * @param type type of generator
+ * @param base_value base value
+ * @param value_rate maximum value
+ * @param period duration of a period of generation (~ 1/frequency)
+ * @param frequency how long to generate property
+ * @param ats_property ATS property to generate
+ * @return the property generator
  */
 struct PropertyGenerator *
 GNUNET_ATS_solver_generate_property_start (unsigned int peer,
     unsigned int address_id,
+    struct TestPeer *test_peer,
+    struct TestAddress *test_address,
     enum GeneratorType type,
     long int base_value,
     long int value_rate,
@@ -240,6 +745,8 @@ GNUNET_ATS_solver_generate_property_start (unsigned int peer,
   GNUNET_CONTAINER_DLL_insert (prop_gen_head, prop_gen_tail, pg);
   pg->type = type;
   pg->peer = peer;
+  pg->test_address = test_address;
+  pg->test_peer = test_peer;
   pg->address_id = address_id;
   pg->ats_property = ats_property;
   pg->base_value = base_value;
@@ -251,27 +758,34 @@ GNUNET_ATS_solver_generate_property_start (unsigned int peer,
   switch (type) {
     case GNUNET_ATS_TEST_TG_CONSTANT:
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-          "Setting up constant property generator peer [%u] address [%u] `%s' max %u Bips\n",
-          pg->peer, pg->address_id,  GNUNET_ATS_print_property_type (ats_property),
+          "Setting up %s property generator peer [%u] address [%u] `%s'"\
+          "max %u Bips\n",
+          print_generator_type(type), pg->peer, pg->address_id,
+          GNUNET_ATS_print_property_type (ats_property),
           base_value);
       break;
     case GNUNET_ATS_TEST_TG_LINEAR:
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-          "Setting up linear property generator peer [%u] address [%u] `%s' min %u Bips max %u Bips\n",
-          pg->peer, pg->address_id, GNUNET_ATS_print_property_type(ats_property),
+          "Setting up %s property generator peer [%u] address [%u] `%s' " \
+          "min %u Bips max %u Bips\n",
+          print_generator_type(type), pg->peer, pg->address_id,
+          GNUNET_ATS_print_property_type(ats_property),
           base_value, value_rate);
       break;
     case GNUNET_ATS_TEST_TG_SINUS:
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-          "Setting up sinus property generator peer [%u] address [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
-          pg->peer, pg->address_id, GNUNET_ATS_print_property_type(ats_property),
+          "Setting up %s property generator peer [%u] address [%u] `%s' "\
+          "baserate %u Bips, amplitude %u Bps\n",
+          print_generator_type(type), pg->peer, pg->address_id,
+          GNUNET_ATS_print_property_type(ats_property),
           base_value, value_rate);
-
       break;
     case GNUNET_ATS_TEST_TG_RANDOM:
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-          "Setting up random property generator peer [%u] address [%u] `%s' min %u Bips max %u Bps\n",
-          pg->peer, pg->address_id, GNUNET_ATS_print_property_type(ats_property),
+          "Setting up %s property generator peer [%u] address [%u] `%s' "\
+          "min %u Bips max %u Bps\n",
+          print_generator_type(type), pg->peer, pg->address_id,
+          GNUNET_ATS_print_property_type(ats_property),
           base_value, value_rate);
       break;
     default:
@@ -371,20 +885,37 @@ set_pref_task (void *cls,
                     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct PreferenceGenerator *pg = cls;
+  struct TestPeer *p;
   double pref_value;
   pg->set_task = GNUNET_SCHEDULER_NO_TASK;
 
+  if (NULL == (p = find_peer_by_id (pg->peer)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting preference for unknown peer %u\n", pg->peer);
+    return;
+  }
+
   pref_value = get_preference (pg);
+  p->pref_abs[pg->kind] = pref_value;
 
   GNUNET_log(GNUNET_ERROR_TYPE_INFO,
-      "Setting preference for peer [%u] address [%u] for %s to %f\n",
-      pg->peer, pg->address_id,
+      "Setting preference for peer [%u] for client %p pref %s to %f\n",
+      pg->peer, NULL + (pg->client_id),
       GNUNET_ATS_print_preference_type (pg->kind), pref_value);
 
-  /* set performance here!
-  GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle,
-      &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END);
-*/
+  sh->env.sf.s_bulk_start (sh->solver);
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    p->pref_abs[pg->kind] = pref_value;
+    p->pref_norm[pg->kind] = pref_value;
+    sh->env.sf.s_pref (sh->solver, &p->peer_id, pg->kind, pref_value);
+  }
+  else
+    GAS_normalization_normalize_preference (NULL + (pg->client_id),
+        &p->peer_id, pg->kind, pref_value);
+  sh->env.sf.s_bulk_stop (sh->solver);
 
   switch (pg->kind) {
     case GNUNET_ATS_PREFERENCE_BANDWIDTH:
@@ -403,13 +934,15 @@ set_pref_task (void *cls,
 }
 
 static struct PreferenceGenerator *
-find_pref_gen (unsigned int peer, unsigned int address,
-    enum GNUNET_ATS_PreferenceKind kind)
+find_pref_gen (unsigned int peer, enum GNUNET_ATS_PreferenceKind kind)
 {
   struct PreferenceGenerator *cur;
   for (cur = pref_gen_head; NULL != cur; cur = cur->next)
-    if ((cur->peer == peer) && (cur->address_id == address) && (cur->kind == kind))
-      return cur;
+    if (cur->peer == peer)
+    {
+      if ((cur->kind == kind) || (GNUNET_ATS_PREFERENCE_END == kind))
+        return cur;
+    }
   return NULL;
 }
 
@@ -424,29 +957,32 @@ GNUNET_ATS_solver_generate_preferences_stop (struct PreferenceGenerator *pg)
     pg->set_task = GNUNET_SCHEDULER_NO_TASK;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-      "Removing old up preference generator peer [%u] address [%u] `%s'\n",
-      pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(pg->kind));
+      "Removing old up preference generator peer [%u] `%s'\n",
+      pg->peer, GNUNET_ATS_print_preference_type(pg->kind));
 
   GNUNET_free (pg);
 }
 
 
 /**
- * Generate between the source master and the partner and set preferences with a
+ * Generate between the source master and the partner and set property with a
  * value depending on the generator.
  *
- * @param src source
- * @param dest partner
- * @param type type of preferences to generate
- * @param base_rate traffic base rate to send data with
- * @param max_rate  traffic maximum rate to send data with
- * @param period duration of a period of traffic generation (~ 1/frequency)
- * @param duration how long to generate traffic
- * @return the traffic generator
+ * @param peer source
+ * @param address_id partner
+ * @param client_id the client
+ * @param type type of generator
+ * @param base_value base value
+ * @param value_rate maximum value
+ * @param period duration of a period of generation (~ 1/frequency)
+ * @param frequency how long to generate property
+ * @param kind ATS preference to generate
+ * @return the preference generator
  */
 struct PreferenceGenerator *
 GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
     unsigned int address_id,
+    unsigned int client_id,
     enum GeneratorType type,
     long int base_value,
     long int value_rate,
@@ -460,7 +996,7 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
   GNUNET_CONTAINER_DLL_insert (pref_gen_head, pref_gen_tail, pg);
   pg->type = type;
   pg->peer = peer;
-  pg->address_id = address_id;
+  pg->client_id = client_id;
   pg->kind = kind;
   pg->base_value = base_value;
   pg->max_value = value_rate;
@@ -471,27 +1007,27 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
   switch (type) {
     case GNUNET_ATS_TEST_TG_CONSTANT:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' max %u Bips\n",
-          print_generator_type (type), pg->peer, pg->address_id,
+          "Setting up %s preference generator peer [%u] `%s' max %u Bips\n",
+          print_generator_type (type), pg->peer,
           GNUNET_ATS_print_preference_type(kind),
           base_value);
       break;
     case GNUNET_ATS_TEST_TG_LINEAR:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bips\n",
-          print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+          "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bips\n",
+          print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind),
           base_value, value_rate);
       break;
     case GNUNET_ATS_TEST_TG_SINUS:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
-          print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+          "Setting up %s preference generator peer [%u] `%s' baserate %u Bips, amplitude %u Bps\n",
+          print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind),
           base_value, value_rate);
       break;
     case GNUNET_ATS_TEST_TG_RANDOM:
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-          "Setting up %s preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bps\n",
-          print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind),
+          "Setting up %s preference generator peer [%u] `%s' min %u Bips max %u Bps\n",
+          print_generator_type (type), pg->peer, GNUNET_ATS_print_preference_type(kind),
           base_value, value_rate);
       break;
     default:
@@ -539,9 +1075,13 @@ print_op (enum OperationType op)
     case SOLVER_OP_STOP_SET_PREFERENCE:
       return "STOP_STOP_PREFERENCE";
     case SOLVER_OP_START_SET_PROPERTY:
-          return "START_SET_PROPERTY";
+      return "START_SET_PROPERTY";
     case SOLVER_OP_STOP_SET_PROPERTY:
       return "STOP_SET_PROPERTY";
+    case SOLVER_OP_START_REQUEST:
+      return "START_REQUEST";
+    case SOLVER_OP_STOP_REQUEST:
+      return "STOP_REQUEST";
     default:
       break;
   }
@@ -554,8 +1094,6 @@ create_experiment ()
   struct Experiment *e;
   e = GNUNET_new (struct Experiment);
   e->name = NULL;
-  e->num_masters = 0;
-  e->num_slaves = 0;
   e->start = NULL;
   e->total_duration = GNUNET_TIME_UNIT_ZERO;
   return e;
@@ -586,6 +1124,8 @@ free_experiment (struct Experiment *e)
   }
 
   GNUNET_free_non_null (e->name);
+  GNUNET_free_non_null (e->log_prefix);
+  GNUNET_free_non_null (e->log_output_dir);
   GNUNET_free_non_null (e->cfg_file);
   GNUNET_free (e);
 }
@@ -599,8 +1139,9 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *op_name;
+  char *op_network;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -612,7 +1153,7 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -662,17 +1203,54 @@ load_op_add_address (struct GNUNET_ATS_TEST_Operation *o,
 
   /* network */
   GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
-      sec_name, op_name, &o->address_network))
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
+      sec_name, op_name, &op_network))
   {
     fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
         op_counter, "ADD_ADDRESS", op_name);
     GNUNET_free (op_name);
     return GNUNET_SYSERR;
   }
+  else
+  {
+    GNUNET_STRINGS_utf8_toupper (op_network,op_network);
+    if (0 == strcmp(op_network, "UNSPECIFIED"))
+    {
+      o->address_network = GNUNET_ATS_NET_UNSPECIFIED;
+    }
+    else if (0 == strcmp(op_network, "LOOPBACK"))
+    {
+      o->address_network = GNUNET_ATS_NET_LOOPBACK;
+    }
+    else if (0 == strcmp(op_network, "LAN"))
+    {
+      o->address_network = GNUNET_ATS_NET_LAN;
+    }
+    else if (0 == strcmp(op_network, "WAN"))
+    {
+      o->address_network = GNUNET_ATS_NET_WAN;
+    }
+    else if (0 == strcmp(op_network, "WLAN"))
+    {
+      o->address_network = GNUNET_ATS_NET_WLAN;
+    }
+    else if (0 == strcmp(op_network, "BT"))
+    {
+      o->address_network = GNUNET_ATS_NET_BT;
+    }
+    else
+    {
+      fprintf (stderr, "Invalid address-network in operation %u `%s' in episode `%s': `%s'\n",
+          op_counter, "ADD_ADDRESS", op_name, op_network);
+      GNUNET_free (op_network);
+      GNUNET_free (op_name);
+      return GNUNET_SYSERR;
+    }
+  }
+  GNUNET_free (op_network);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
       "ADD_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
 
@@ -687,8 +1265,9 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *op_name;
+  //char *op_network;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -700,7 +1279,7 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -712,6 +1291,7 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
+#if 0
   /* plugin */
   GNUNET_asprintf(&op_name, "op-%u-plugin", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -747,20 +1327,9 @@ load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
     return GNUNET_SYSERR;
   }
   GNUNET_free (op_name);
+#endif
 
-  /* network */
-  GNUNET_asprintf(&op_name, "op-%u-address-network", op_counter);
-  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
-      sec_name, op_name, &o->address_network))
-  {
-    fprintf (stderr, "Missing address-network in operation %u `%s' in episode `%s'\n",
-        op_counter, "DEL_ADDRESS", op_name);
-    GNUNET_free (op_name);
-    return GNUNET_SYSERR;
-  }
-  GNUNET_free (op_name);
-
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] address `%s' plugin `%s' \n",
       "DEL_ADDRESS", o->peer_id, o->address_id, o->address, o->plugin);
 
@@ -790,7 +1359,7 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   char *type;
   char *pref;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -802,12 +1371,12 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
-  GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
+  /* address pid */
+  GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
-      sec_name, op_name, &o->address_id))
+      sec_name, op_name, &o->client_id))
   {
-    fprintf (stderr, "Missing address-id in operation %u `%s' in episode `%s'\n",
+    fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
         op_counter, "START_SET_PREFERENCE", op_name);
     GNUNET_free (op_name);
     return GNUNET_SYSERR;
@@ -927,7 +1496,7 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (pref);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu]: %s = %llu\n",
       "START_SET_PREFERENCE", o->peer_id, o->address_id,
       GNUNET_ATS_print_preference_type(o->pref_type), o->base_rate);
@@ -945,7 +1514,7 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   char *op_name;
   char *pref;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -957,7 +1526,7 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -991,7 +1560,7 @@ load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (pref);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu]: %s\n",
       "STOP_SET_PREFERENCE", o->peer_id, o->address_id,
       GNUNET_ATS_print_preference_type(o->pref_type));
@@ -1021,7 +1590,7 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   char *type;
   char *prop;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1033,7 +1602,7 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -1060,22 +1629,18 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   if (0 == strcmp (type, "constant"))
   {
     o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
-    GNUNET_break (0);
   }
   else if (0 == strcmp (type, "linear"))
   {
     o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
-    GNUNET_break (0);
   }
   else if (0 == strcmp (type, "sinus"))
   {
     o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
-    GNUNET_break (0);
   }
   else if (0 == strcmp (type, "random"))
   {
     o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
-    GNUNET_break (0);
   }
   else
   {
@@ -1164,7 +1729,7 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (prop);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] %s = %llu\n",
       "START_SET_PROPERTY", o->peer_id, o->address_id,
       GNUNET_ATS_print_property_type (o->prop_type), o->base_rate);
@@ -1182,7 +1747,7 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   char *op_name;
   char *pref;
 
-  /* peer id */
+  /* peer pid */
   GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->peer_id))
@@ -1194,7 +1759,7 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   }
   GNUNET_free (op_name);
 
-  /* address id */
+  /* address pid */
   GNUNET_asprintf(&op_name, "op-%u-address-id", op_counter);
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
       sec_name, op_name, &o->address_id))
@@ -1223,7 +1788,6 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
       fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
           op_counter, op_name, e->id);
       GNUNET_free (op_name);
-      GNUNET_free (pref);
       GNUNET_free_non_null (pref);
       return GNUNET_SYSERR;
   }
@@ -1231,7 +1795,7 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   GNUNET_free (pref);
   GNUNET_free (op_name);
 
-  fprintf (stderr,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
       "Found operation %s: [%llu:%llu] %s\n",
       "STOP_SET_PROPERTY", o->peer_id, o->address_id,
       GNUNET_ATS_print_property_type (o->prop_type));
@@ -1239,6 +1803,54 @@ load_op_stop_set_property (struct GNUNET_ATS_TEST_Operation *o,
   return GNUNET_OK;
 }
 
+
+static int
+load_op_start_request (struct GNUNET_ATS_TEST_Operation *o,
+    struct Episode *e,
+    int op_counter,
+    char *sec_name,
+    const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  char *op_name;
+
+  /* peer pid */
+  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+      sec_name, op_name, &o->peer_id))
+  {
+    fprintf (stderr, "Missing peer-id in operation %u  `%s' in episode `%s'\n",
+        op_counter, "START_REQUEST", op_name);
+    GNUNET_free (op_name);
+    return GNUNET_SYSERR;
+  }
+  GNUNET_free (op_name);
+  return GNUNET_OK;
+}
+
+static int
+load_op_stop_request (struct GNUNET_ATS_TEST_Operation *o,
+    struct Episode *e,
+    int op_counter,
+    char *sec_name,
+    const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  char *op_name;
+
+  /* peer pid */
+  GNUNET_asprintf(&op_name, "op-%u-peer-id", op_counter);
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+      sec_name, op_name, &o->peer_id))
+  {
+    fprintf (stderr, "Missing peer-id in operation %u  `%s' in episode `%s'\n",
+        op_counter, "STOP_REQUEST", op_name);
+    GNUNET_free (op_name);
+    return GNUNET_SYSERR;
+  }
+  GNUNET_free (op_name);
+  return GNUNET_OK;
+}
+
+
 static int
 load_episode (struct Experiment *e, struct Episode *cur,
     struct GNUNET_CONFIGURATION_Handle *cfg)
@@ -1248,7 +1860,8 @@ load_episode (struct Experiment *e, struct Episode *cur,
   char *op_name;
   char *op;
   int op_counter = 0;
-  fprintf (stderr, "Parsing episode %u\n",cur->id);
+  int res;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Parsing episode %u\n",cur->id);
   GNUNET_asprintf(&sec_name, "episode-%u", cur->id);
 
   while (1)
@@ -1262,298 +1875,79 @@ load_episode (struct Experiment *e, struct Episode *cur,
       break;
     }
     o = GNUNET_new (struct GNUNET_ATS_TEST_Operation);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "==== Parsing operation %u: `%s'\n",
+        cur->id, op_name);
+
     /* operations = set_rate, start_send, stop_send, set_preference */
     if (0 == strcmp (op, "address_add"))
     {
       o->type = SOLVER_OP_ADD_ADDRESS;
-      if (GNUNET_SYSERR == load_op_add_address (o, cur,
-          op_counter, sec_name, cfg))
-      {
-        GNUNET_free (o);
-        GNUNET_free (op);
-        GNUNET_free (op_name);
-        GNUNET_free (sec_name);
-        return GNUNET_SYSERR;
-      }
+      res = load_op_add_address (o, cur,
+          op_counter, sec_name, cfg);
     }
     else if (0 == strcmp (op, "address_del"))
     {
       o->type = SOLVER_OP_DEL_ADDRESS;
-      if (GNUNET_SYSERR == load_op_del_address (o, cur,
-          op_counter, sec_name, cfg))
-      {
-        GNUNET_free (o);
-        GNUNET_free (op);
-        GNUNET_free (op_name);
-        GNUNET_free (sec_name);
-        return GNUNET_SYSERR;
-      }
+      res = load_op_del_address (o, cur,
+          op_counter, sec_name, cfg);
     }
     else if (0 == strcmp (op, "start_set_property"))
     {
       o->type = SOLVER_OP_START_SET_PROPERTY;
-      if (GNUNET_SYSERR == load_op_start_set_property (o, cur,
-          op_counter, sec_name, cfg))
-      {
-        GNUNET_free (o);
-        GNUNET_free (op);
-        GNUNET_free (op_name);
-        GNUNET_free (sec_name);
-        return GNUNET_SYSERR;
-      }
+      res = load_op_start_set_property (o, cur,
+          op_counter, sec_name, cfg);
     }
     else if (0 == strcmp (op, "stop_set_property"))
     {
       o->type = SOLVER_OP_STOP_SET_PROPERTY;
-      if (GNUNET_SYSERR == load_op_stop_set_property (o, cur,
-          op_counter, sec_name, cfg))
-      {
-        GNUNET_free (o);
-        GNUNET_free (op);
-        GNUNET_free (op_name);
-        GNUNET_free (sec_name);
-        return GNUNET_SYSERR;
-      }
+      res = load_op_stop_set_property (o, cur,
+          op_counter, sec_name, cfg);
     }
     else if (0 == strcmp (op, "start_set_preference"))
     {
       o->type = SOLVER_OP_START_SET_PREFERENCE;
-      if (GNUNET_SYSERR == load_op_start_set_preference (o, cur,
-          op_counter, sec_name, cfg))
-      {
-        GNUNET_free (o);
-        GNUNET_free (op);
-        GNUNET_free (op_name);
-        GNUNET_free (sec_name);
-        return GNUNET_SYSERR;
-      }
+      res =  load_op_start_set_preference (o, cur,
+          op_counter, sec_name, cfg);
     }
     else if (0 == strcmp (op, "stop_set_preference"))
     {
       o->type = SOLVER_OP_STOP_SET_PREFERENCE;
-      if (GNUNET_SYSERR == load_op_stop_set_preference (o, cur,
-          op_counter, sec_name, cfg))
-      {
-        GNUNET_free (o);
-        GNUNET_free (op);
-        GNUNET_free (op_name);
-        GNUNET_free (sec_name);
-        return GNUNET_SYSERR;
-      }
+      res =  load_op_stop_set_preference (o, cur,
+          op_counter, sec_name, cfg);
     }
-    else
+    else if (0 == strcmp (op, "start_request"))
     {
-      fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
-          op_counter, op, cur->id);
-      GNUNET_free (o);
-      GNUNET_free (op);
-      GNUNET_free (op_name);
-      GNUNET_free (sec_name);
-      return GNUNET_SYSERR;
+      o->type = SOLVER_OP_START_REQUEST;
+      res = load_op_start_request (o, cur,
+          op_counter, sec_name, cfg);
     }
-    GNUNET_free (op);
-    GNUNET_free (op_name);
-
-    GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o);
-    op_counter++;
-  }
-  GNUNET_free (sec_name);
-
-
-#if 0
-    /* 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))
+    else if (0 == strcmp (op, "stop_request"))
     {
-      fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
-          op_counter, op, cur->id);
-      GNUNET_free (op);
-      GNUNET_free (op_name);
-      return GNUNET_SYSERR;
-    }
-    if (o->src_id > (e->num_masters - 1))
-    {
-      fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
-          o->src_id, op_counter, op, cur->id);
-      GNUNET_free (op);
-      GNUNET_free (op_name);
-      return GNUNET_SYSERR;
+      o->type = SOLVER_OP_STOP_REQUEST;
+      res = load_op_stop_request(o, cur,
+          op_counter, sec_name, cfg);
     }
-    GNUNET_free (op_name);
-
-    /* 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))
+    else
     {
-      fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
+      fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
           op_counter, op, cur->id);
-      GNUNET_free (op);
-      GNUNET_free (op_name);
-      return GNUNET_SYSERR;
-    }
-    if (o->dest_id > (e->num_slaves - 1))
-    {
-      fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
-          o->dest_id, op_counter, op, cur->id);
-      GNUNET_free (op);
-      GNUNET_free (op_name);
-      return GNUNET_SYSERR;
-    }
-    GNUNET_free (op_name);
-
-    GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
-    if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
-            sec_name, op_name, &type)) &&
-        ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type)))
-    {
-      /* Load arguments for set_rate, start_send, set_preference */
-      if (0 == strcmp (type, "constant"))
-      {
-        o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
-      }
-      else if (0 == strcmp (type, "linear"))
-      {
-        o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
-      }
-      else if (0 == strcmp (type, "sinus"))
-      {
-        o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
-      }
-      else if (0 == strcmp (type, "random"))
-      {
-        o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
-      }
-      else
-      {
-        fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
-            op_counter, op, cur->id);
-        GNUNET_free (type);
-        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 (type);
-        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->gen_type) ||
-            (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
-            (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
-        {
-          fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
-              op_counter, op, cur->id);
-          GNUNET_free (type);
-          GNUNET_free (op_name);
-          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);
-
-      if (START_PREFERENCE == o->type)
-      {
-          /* Get frequency */
-          GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
-          if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
-              sec_name, op_name, &o->frequency))
-          {
-              fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
-                  op_counter, op, cur->id);
-              GNUNET_free (type);
-              GNUNET_free (op_name);
-              GNUNET_free (op);
-              return GNUNET_SYSERR;
-          }
-          GNUNET_free (op_name);
-
-          /* Get preference */
-          GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
-          if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
-              sec_name, op_name, &pref))
-          {
-              fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
-                  op_counter, op, cur->id);
-              GNUNET_free (type);
-              GNUNET_free (op_name);
-              GNUNET_free (op);
-              GNUNET_free_non_null (pref);
-              return GNUNET_SYSERR;
-          }
-
-          if (0 == strcmp(pref, "bandwidth"))
-            o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
-          else if (0 == strcmp(pref, "latency"))
-            o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
-          else
-          {
-              fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
-                  op_counter, op, cur->id);
-              GNUNET_free (type);
-              GNUNET_free (op_name);
-              GNUNET_free (op);
-              GNUNET_free (pref);
-              GNUNET_free_non_null (pref);
-              return GNUNET_SYSERR;
-          }
-          GNUNET_free (pref);
-          GNUNET_free (op_name);
-      }
+      res = GNUNET_SYSERR;
     }
 
-    /* Safety checks */
-    if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
-        (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
-    {
-      if ((o->max_rate - o->base_rate) > o->base_rate)
-      {
-        /* This will cause an underflow */
-        GNUNET_break (0);
-      }
-      fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
-    }
-
-    if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
-      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, (NULL != type) ? type : "",
-        o->base_rate, o->max_rate,
-        GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
-    else
-      fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
-        op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
+    GNUNET_free (op);
+    GNUNET_free (op_name);
 
-    GNUNET_free_non_null (type);
-    GNUNET_free (op);
-#endif
+    if (GNUNET_SYSERR == res)
+    {
+      GNUNET_free (o);
+      GNUNET_free (sec_name);
+      return GNUNET_SYSERR;
+    }
 
+    GNUNET_CONTAINER_DLL_insert_tail (cur->head,cur->tail, o);
+    op_counter++;
+  }
+  GNUNET_free (sec_name);
   return GNUNET_OK;
 }
 
@@ -1589,7 +1983,7 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
       return GNUNET_SYSERR;
     }
 
-    fprintf (stderr, "Found episode %u with duration %s \n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Found episode %u with duration %s \n",
         e_counter,
         GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
 
@@ -1600,7 +1994,7 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
     if (NULL == last)
       e->start = cur;
     else
-    last->next = cur;
+      last->next = cur;
 
     GNUNET_free (sec_name);
     e_counter ++;
@@ -1626,79 +2020,170 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
       GNUNET_SYSERR);
 }
 
+struct ATS_Address *
+create_ats_address (const struct GNUNET_PeerIdentity *peer,
+                const char *plugin_name,
+                const void *plugin_addr,
+                size_t plugin_addr_len,
+                uint32_t session_id,
+                uint32_t network)
+{
+  struct ATS_Address *aa = NULL;
+
+  aa = GNUNET_malloc (sizeof (struct ATS_Address) + plugin_addr_len + strlen (plugin_name) + 1);
+  aa->atsi = GNUNET_new (struct GNUNET_ATS_Information);
+  aa->atsi[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
+  aa->atsi[0].value = htonl (network);
+  aa->atsi_count = 1;
+
+  aa->peer = *peer;
+  aa->addr_len = plugin_addr_len;
+  aa->addr = &aa[1];
+  aa->plugin = (char *) &aa[1] + plugin_addr_len;
+  memcpy (&aa[1], plugin_addr, plugin_addr_len);
+  memcpy (aa->plugin, plugin_name, strlen (plugin_name) + 1);
+  aa->session_id = session_id;
+  aa->active = GNUNET_NO;
+  aa->used = GNUNET_NO;
+  aa->solver_information = NULL;
+  aa->assigned_bw_in = GNUNET_BANDWIDTH_value_init(0);
+  aa->assigned_bw_out = GNUNET_BANDWIDTH_value_init(0);
+
+  return aa;
+}
+
+
+
 static void
 enforce_add_address (struct GNUNET_ATS_TEST_Operation *op)
 {
-  /*
-  struct BenchmarkPeer *peer;
-  struct BenchmarkPartner *partner;
+  struct TestPeer *p;
+  struct TestAddress *a;
+  int c;
 
-  peer = GNUNET_ATS_TEST_get_peer (op->src_id);
-  if (NULL == peer)
+  if (NULL == (p = find_peer_by_id (op->peer_id)))
   {
-    GNUNET_break (0);
-    return;
+    p = GNUNET_new (struct TestPeer);
+    p->id = op->peer_id;
+    memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
+    for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+    {
+      p->pref_abs[c] = DEFAULT_ABS_PREFERENCE;
+      p->pref_norm[c] = DEFAULT_REL_PREFERENCE;
+    }
+
+    GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, p);
   }
 
-  partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
-  if (NULL == partner)
+  if (NULL != (find_address_by_id (p, op->address_id)))
   {
-    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
+        op->address_id, op->peer_id);
     return;
   }
 
-  fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+  a = GNUNET_new (struct TestAddress);
+  a->aid = op->address_id;
+  a->network = op->address_network;
+  a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address,
+      strlen (op->address) + 1, op->address_session, op->address_network);
+  memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
+  GNUNET_CONTAINER_DLL_insert_tail (p->addr_head, p->addr_tail, a);
 
-  if (NULL != partner->tg)
-  {
-    fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id);
-    GNUNET_ATS_TEST_generate_traffic_stop(partner->tg);
-    partner->tg = NULL;
-  }
+  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
+    a->prop_norm[c] = DEFAULT_REL_QUALITY;
+
+  GNUNET_CONTAINER_multipeermap_put (sh->addresses, &p->peer_id, a->ats_addr,
+    GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u in network `%s'\n",
+    op->address_id, op->peer_id, GNUNET_ATS_print_network_type(a->network));
+
+  sh->env.sf.s_add (sh->solver, a->ats_addr, op->address_network);
 
-  partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner,
-      op->tg_type, op->base_rate, op->max_rate, op->period,
-      GNUNET_TIME_UNIT_FOREVER_REL);
-   */
 }
 
+
 static void
 enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
 {
-  /*
-  struct BenchmarkPartner *p;
-  p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id);
-  if (NULL == p)
+  struct TestPeer *p;
+  struct TestAddress *a;
+  struct PropertyGenerator *pg;
+
+  if (NULL == (p = find_peer_by_id (op->peer_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Deleting address for unknown peer %u\n", op->peer_id);
+    return;
+  }
+
+  if (NULL == (a =find_address_by_id (p, op->address_id)))
   {
     GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Deleting address for unknown peer %u\n", op->peer_id);
     return;
   }
 
-  fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id);
+  while (NULL != (pg = find_prop_gen (p->id, a->aid, 0)))
+  {
+    GNUNET_ATS_solver_generate_property_stop (pg);
+  }
+
+  GNUNET_CONTAINER_multipeermap_remove (sh->addresses, &p->peer_id, a->ats_addr);
 
-  if (NULL != p->tg)
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Removing address %u for peer %u\n",
+      op->address_id, op->peer_id);
+
+  sh->env.sf.s_del (sh->solver, a->ats_addr, GNUNET_NO);
+
+  if (NULL != l)
   {
-    fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",
-        op->src_id, op->dest_id);
-    GNUNET_ATS_TEST_generate_traffic_stop(p->tg);
-    p->tg = NULL;
+    GNUNET_ATS_solver_logging_now (l);
   }
-  */
+  GNUNET_CONTAINER_DLL_remove(p->addr_head, p->addr_tail, a);
+
+  GNUNET_free_non_null(a->ats_addr->atsi);
+  GNUNET_free (a->ats_addr);
+  GNUNET_free (a);
+
 }
 
 static void
 enforce_start_property (struct GNUNET_ATS_TEST_Operation *op)
 {
   struct PropertyGenerator *pg;
+  struct TestPeer *p;
+  struct TestAddress *a;
+
   if (NULL != (pg = find_prop_gen (op->peer_id, op->address_id, op->prop_type)))
   {
     GNUNET_ATS_solver_generate_property_stop (pg);
     GNUNET_free (pg);
   }
 
+  if (NULL == (p = find_peer_by_id (op->peer_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Starting property generation for unknown peer %u\n", op->peer_id);
+    return;
+  }
+
+  if (NULL == (a = find_address_by_id (p, op->address_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Setting property for unknown address %u\n", op->peer_id);
+    return;
+  }
+
   GNUNET_ATS_solver_generate_property_start (op->peer_id,
     op->address_id,
-    op->type,
+    p, a,
+    op->gen_type,
     op->base_rate,
     op->max_rate,
     op->period,
@@ -1712,24 +2197,42 @@ enforce_stop_property (struct GNUNET_ATS_TEST_Operation *op)
   struct PropertyGenerator *pg = find_prop_gen(op->peer_id, op->address_id,
       op->prop_type);
   if (NULL != pg)
-      GNUNET_ATS_solver_generate_property_stop (pg);
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+        "Stopping preference generation for peer %u address %u\n", op->peer_id,
+        op->address_id);
+    GNUNET_ATS_solver_generate_property_stop (pg);
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Cannot find preference generator for peer %u address %u\n",
+        op->peer_id, op->address_id);
+    GNUNET_break (0);
+  }
 }
 
 static void
 enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
 {
   struct PreferenceGenerator *pg;
-  if (NULL != (pg = find_pref_gen (op->peer_id, op->address_id, op->pref_type)))
+  if (NULL != (pg = find_pref_gen (op->peer_id, op->pref_type)))
   {
     GNUNET_ATS_solver_generate_preferences_stop (pg);
     GNUNET_free (pg);
   }
 
-  fprintf (stderr, "ENFORECE: %s, %u\n", print_generator_type (op->gen_type),
-      op->base_rate);
+  if (NULL == (find_peer_by_id (op->peer_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Starting preference generation for unknown peer %u\n", op->peer_id);
+    return;
+  }
 
   GNUNET_ATS_solver_generate_preferences_start (op->peer_id,
     op->address_id,
+    op->client_id,
     op->gen_type,
     op->base_rate,
     op->max_rate,
@@ -1741,10 +2244,77 @@ enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
 static void
 enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
 {
-  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id, op->address_id,
+  struct PreferenceGenerator *pg = find_pref_gen(op->peer_id,
       op->pref_type);
   if (NULL != pg)
-      GNUNET_ATS_solver_generate_preferences_stop (pg);
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+        "Stopping property generation for peer %u address %u\n", op->peer_id,
+        op->address_id);
+    GNUNET_ATS_solver_generate_preferences_stop (pg);
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Cannot find preference generator for peer %u address %u\n",
+        op->peer_id, op->address_id);
+    GNUNET_break (0);
+  }
+}
+
+
+static void
+enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
+{
+  struct TestPeer *p;
+  const struct ATS_Address *res;
+
+  if (NULL == (p = find_peer_by_id (op->peer_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Requesting address for unknown peer %u\n", op->peer_id);
+    return;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
+      op->peer_id);
+
+  res = sh->env.sf.s_get (sh->solver, &p->peer_id);
+  if (NULL != res)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Suggested address for peer %u: %llu %llu\n",
+        op->peer_id,
+        ntohl(res->assigned_bw_in.value__),
+        ntohl(res->assigned_bw_out.value__));
+    if (NULL != l)
+      GNUNET_ATS_solver_logging_now (l);
+  }
+}
+
+static void
+enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
+{
+  struct TestPeer *p;
+
+  if (NULL == (p = find_peer_by_id (op->peer_id)))
+  {
+    GNUNET_break (0);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+        "Requesting address for unknown peer %u\n", op->peer_id);
+    return;
+  }
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop requesting address for peer %u\n",
+      op->peer_id);
+
+  sh->env.sf.s_get_stop (sh->solver, &p->peer_id);
+
+  if (NULL != l)
+  {
+    GNUNET_ATS_solver_logging_now (l);
+  }
+
 }
 
 static void enforce_episode (struct Episode *ep)
@@ -1783,6 +2353,16 @@ static void enforce_episode (struct Episode *ep)
             print_op (cur->type), cur->peer_id, cur->address_id, cur->base_rate);
         enforce_stop_preference (cur);
         break;
+      case SOLVER_OP_START_REQUEST:
+        fprintf (stderr, "Enforcing operation: %s [%llu]\n",
+            print_op (cur->type), cur->peer_id);
+        enforce_start_request (cur);
+        break;
+      case SOLVER_OP_STOP_REQUEST:
+        fprintf (stderr, "Enforcing operation: %s [%llu]\n",
+            print_op (cur->type), cur->peer_id);
+        enforce_stop_request (cur);
+        break;
       default:
         break;
     }
@@ -1838,13 +2418,13 @@ GNUNET_ATS_solvers_experimentation_run (struct Experiment *e,
   e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration,
       &timeout_experiment, e);
 
-
   /* Start */
   if (NULL == e->start)
   {
     GNUNET_break (0);
     return;
   }
+
   e->cur = e->start;
   fprintf (stderr, "Running episode %u with timeout %s\n",
       e->cur->id,
@@ -1897,64 +2477,70 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
       "name", &e->name))
   {
-    fprintf (stderr, "Invalid %s", "name");
+    fprintf (stderr, "Invalid %s \n", "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_string(cfg, "experiment",
+      "log_prefix", &e->log_prefix))
+  {
+    fprintf (stderr, "Invalid %s \n", "log_prefix");
     free_experiment (e);
     return NULL;
   }
   else
-    fprintf (stderr, "Experiment name: `%s'\n", e->name);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging prefix: `%s'\n",
+        e->log_prefix);
+
+  if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
+      "log_output_dir", &e->log_output_dir))
+  {
+    e->log_output_dir = NULL;
+  }
+  else
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging output directory: `%s'\n",
+        e->log_output_dir);
+
+
+  if (GNUNET_SYSERR == (e->log_append_time_stamp = GNUNET_CONFIGURATION_get_value_yesno(cfg,
+      "experiment", "log_append_time_stamp")))
+    e->log_append_time_stamp = GNUNET_YES;
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging append timestamp: `%s'\n",
+      (GNUNET_YES == e->log_append_time_stamp) ? "yes" : "no");
+
 
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, "experiment",
       "cfg_file", &e->cfg_file))
   {
-    fprintf (stderr, "Invalid %s", "cfg_file");
+    fprintf (stderr, "Invalid %s \n", "cfg_file");
     free_experiment (e);
     return NULL;
   }
   else
   {
-    fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment configuration: `%s'\n", e->cfg_file);
     e->cfg = GNUNET_CONFIGURATION_create();
     if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (e->cfg, e->cfg_file))
     {
-      fprintf (stderr, "Invalid configuration %s", "cfg_file");
+      fprintf (stderr, "Invalid configuration %s \n", "cfg_file");
       free_experiment (e);
       return NULL;
     }
 
   }
 
-  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
-    fprintf (stderr, "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
-    fprintf (stderr, "Experiment slaves: `%llu'\n",
-        e->num_slaves);
-
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
       "log_freq", &e->log_freq))
   {
-    fprintf (stderr, "Invalid %s", "log_freq");
+    fprintf (stderr, "Invalid %s \n", "log_freq");
     free_experiment (e);
     return NULL;
   }
   else
-    fprintf (stderr, "Experiment logging frequency: `%s'\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment logging frequency: `%s'\n",
         GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES));
 
   if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
@@ -1965,7 +2551,7 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
     return NULL;
   }
   else
-    fprintf (stderr, "Experiment duration: `%s'\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment duration: `%s'\n",
         GNUNET_STRINGS_relative_time_to_string (e->max_duration, GNUNET_YES));
 
   if (GNUNET_SYSERR == load_episodes (e, cfg))
@@ -1976,7 +2562,7 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
     fprintf (stderr, "Failed to load experiment\n");
     return NULL;
   }
-  fprintf (stderr, "Loaded %u episodes with total duration %s\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded %u episodes with total duration %s\n",
       e->num_episodes,
       GNUNET_STRINGS_relative_time_to_string (e->total_duration, GNUNET_YES));
 
@@ -1984,38 +2570,35 @@ GNUNET_ATS_solvers_experimentation_load (char *filename)
   return e;
 }
 
-/**
- * Logging
- */
 
 
 /**
  * Solver
  */
 
-struct GNUNET_ATS_TESTING_SolverHandle
-{
-  char * plugin;
-  struct GNUNET_ATS_PluginEnvironment env;
-  void *solver;
-  struct GNUNET_CONTAINER_MultiPeerMap *addresses;
-};
-
-enum GNUNET_ATS_Solvers
+static int
+free_all_it (void *cls,
+    const struct GNUNET_PeerIdentity *key,
+    void *value)
 {
-  GNUNET_ATS_SOLVER_PROPORTIONAL,
-  GNUNET_ATS_SOLVER_MLP,
-  GNUNET_ATS_SOLVER_RIL,
-};
+  struct ATS_Address *address = value;
+  GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses,
+      key, value));
+  GNUNET_free (address);
 
+  return GNUNET_OK;
+}
 
 void
-GNUNET_ATS_solvers_solver_stop (struct GNUNET_ATS_TESTING_SolverHandle *sh)
+GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh)
 {
  GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats,
      GNUNET_NO);
- GNUNET_CONTAINER_multipeermap_destroy(sh->env.addresses);
  GNUNET_PLUGIN_unload (sh->plugin, sh->solver);
+
+ GAS_normalization_stop();
+
+ GNUNET_CONTAINER_multipeermap_iterate (sh->addresses, &free_all_it, NULL);
  GNUNET_CONTAINER_multipeermap_destroy(sh->addresses);
  GNUNET_free (sh->plugin);
  GNUNET_free (sh);
@@ -2118,7 +2701,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
           network_str[c], GNUNET_ATS_DefaultBandwidth);
       out_dest[c] = GNUNET_ATS_DefaultBandwidth;
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]);
     GNUNET_free (entry_out);
     GNUNET_free (entry_in);
   }
@@ -2128,6 +2711,7 @@ GNUNET_ATS_solvers_load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg,
 /**
  * Information callback for the solver
  *
+ * @param cls the closure
  * @param op the solver operation
  * @param stat status of the solver operation
  * @param add additional solver information
@@ -2163,56 +2747,56 @@ solver_info_cb (void *cls,
   switch (op)
   {
     case GAS_OP_SOLVE_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s' `%s'\n", "GAS_OP_SOLVE_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
       return;
     case GAS_OP_SOLVE_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL", add_info);
       return;
 
     case GAS_OP_SOLVE_SETUP_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
 
     case GAS_OP_SOLVE_SETUP_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_SETUP_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
 
     case GAS_OP_SOLVE_MLP_LP_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_MLP_LP_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_LP_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
 
     case GAS_OP_SOLVE_MLP_MLP_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_MLP_MLP_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_MLP_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_UPDATE_NOTIFICATION_START:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
     case GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP:
-      GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
           "Solver notifies `%s' with result `%s'\n", "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
           (GAS_STAT_SUCCESS == stat) ? "SUCCESS" : "FAIL");
       return;
@@ -2226,47 +2810,131 @@ solver_bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 {
   if ( (0 == ntohl (address->assigned_bw_out.value__)) &&
        (0 == ntohl (address->assigned_bw_in.value__)) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Solver notified to disconnect peer `%s'\n",
+                GNUNET_i2s (&address->peer));
     return;
+  }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
               GNUNET_i2s (&address->peer),
               address,
-              (unsigned int) ntohl (address->assigned_bw_out.value__),
+              (unsigned int) ntohl  (address->assigned_bw_out.value__),
               (unsigned int) ntohl (address->assigned_bw_in.value__));
   /*if (GNUNET_YES == ph.bulk_running)
     GNUNET_break (0);*/
+  if (NULL != l)
+    GNUNET_ATS_solver_logging_now (l);
+
   return;
 }
 
 const double *
 get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
 {
-  return GAS_normalization_get_preferences_by_peer (id);
+  struct TestPeer *p;
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    if (NULL == (p = find_peer_by_pid (id)))
+      return NULL;
+    return p->pref_abs;
+  }
+  else
+    return GAS_normalization_get_preferences_by_peer (id);
 }
 
 
 const double *
 get_property_cb (void *cls, const struct ATS_Address *address)
 {
-  return GAS_normalization_get_properties ((struct ATS_Address *) address);
+  struct TestPeer *p;
+  struct TestAddress *a;
+
+  if (GNUNET_YES == opt_disable_normalization)
+  {
+    p = find_peer_by_pid (&address->peer);
+    a = find_address_by_ats_address (p, address);
+    return a->prop_abs;
+  }
+  else
+    return GAS_normalization_get_properties ((struct ATS_Address *) address);
+}
+
+static void
+set_updated_property ( struct ATS_Address *address, uint32_t type, double prop_rel)
+{
+  struct TestPeer *p;
+  struct TestAddress *a;
+
+  if (NULL == (p = find_peer_by_pid (&address->peer)))
+  {
+    GNUNET_break (0);
+    return;
+  }
+
+  if (NULL == (a = find_address_by_ats_address (p, address)))
+  {
+    GNUNET_break (0);
+    return;
+  }
+  a->prop_norm[type] = prop_rel;
+  sh->env.sf.s_address_update_property (sh->solver, address, type, a->prop_abs [type], prop_rel);
 }
 
+
 static void
-normalized_property_changed_cb (void *cls, struct ATS_Address *peer,
+normalized_property_changed_cb (void *cls, struct ATS_Address *address,
     uint32_t type, double prop_rel)
 {
-  /* TODO */
+  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      "Normalized property %s for peer `%s' changed to %.3f \n",
+      GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
+      prop_rel);
+
+  set_updated_property (address, type, prop_rel);
+}
+
+static void
+set_updated_preference (const struct GNUNET_PeerIdentity *peer,
+    enum GNUNET_ATS_PreferenceKind kind,
+    double pref_rel)
+{
+  struct TestPeer *p;
+
+  if (NULL == (p = find_peer_by_pid (peer)))
+  {
+    GNUNET_break (0);
+    return;
+  }
+
+  p->pref_norm[kind] = pref_rel;
+  sh->env.sf.s_pref (sh->solver, peer, kind, pref_rel);
+}
+
+
+static void
+normalized_preference_changed_cb (void *cls,
+    const struct GNUNET_PeerIdentity *peer,
+    enum GNUNET_ATS_PreferenceKind kind,
+    double pref_rel)
+{
+  GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+      "Normalized preference %s for peer `%s' changed to %.3f \n",
+      GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer),
+      pref_rel);
+
+  set_updated_preference(peer, kind, pref_rel);
 }
 
 
-struct GNUNET_ATS_TESTING_SolverHandle *
+struct SolverHandle *
 GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
 {
-  struct GNUNET_ATS_TESTING_SolverHandle *sh;
+  struct SolverHandle *sh;
   char * solver_str;
-  unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
-  unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
+  int c;
 
   switch (type) {
     case GNUNET_ATS_SOLVER_PROPORTIONAL:
@@ -2284,26 +2952,33 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
       break;
   }
 
-  sh = GNUNET_new (struct GNUNET_ATS_TESTING_SolverHandle);
+  sh = GNUNET_new (struct SolverHandle);
   GNUNET_asprintf (&sh->plugin, "libgnunet_plugin_ats_%s", solver_str);
 
+  sh->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
   /* setup environment */
   sh->env.cfg = e->cfg;
   sh->env.stats = GNUNET_STATISTICS_create ("ats", e->cfg);
-  sh->env.addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
+  sh->env.addresses = sh->addresses;
   sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb;
   sh->env.get_preferences = &get_preferences_cb;
   sh->env.get_property = &get_property_cb;
   sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
   sh->env.info_cb = &solver_info_cb;
   sh->env.info_cb_cls = NULL;
+  sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
+  int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
+  for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
+    sh->env.networks[c] = networks[c];
+
 
   /* start normalization */
-  GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL );
+  GAS_normalization_start (&normalized_preference_changed_cb, NULL,
+      &normalized_property_changed_cb, NULL );
 
   /* load quotas */
   if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg,
-      quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount))
+      sh->env.out_quota, sh->env.in_quota, GNUNET_ATS_NetworkTypeCount))
   {
     GNUNET_break(0);
     GNUNET_free (sh->plugin);
@@ -2322,23 +2997,74 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
     end_now ();
     return NULL;
   }
-
-  sh->addresses = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
-
   return sh;
 }
 
 static void
 done ()
 {
-  /* Clean up experiment */
+  struct TestPeer *cur;
+  struct TestPeer *next;
+
+  struct TestAddress *cur_a;
+  struct TestAddress *next_a;
+
+  /* Stop logging */
+  GNUNET_ATS_solver_logging_stop (l);
+
+  /* Stop all preference generation */
   GNUNET_ATS_solver_generate_preferences_stop_all ();
-  GNUNET_ATS_solvers_experimentation_stop (e);
-  e = NULL;
+
+  /* Stop all property generation */
+  GNUNET_ATS_solver_generate_property_stop_all ();
+
+  if (opt_print)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Printing log information \n");
+    GNUNET_ATS_solver_logging_eval (l);
+  }
+  if (opt_save)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "== Saving log information \n");
+    GNUNET_ATS_solver_logging_write_to_disk (l, e->log_append_time_stamp,
+        e->log_output_dir);
+  }
+
+  if (NULL != l)
+  {
+    GNUNET_ATS_solver_logging_free (l);
+    l = NULL;
+  }
+
+  /* Clean up experiment */
+  if (NULL != e)
+  {
+    GNUNET_ATS_solvers_experimentation_stop (e);
+    e = NULL;
+  }
+
+  next = peer_head;
+  while  (NULL != (cur = next))
+  {
+    next = cur->next;
+    GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur);
+    next_a = cur->addr_head;
+    while  (NULL != (cur_a = next_a))
+    {
+      next_a = cur_a->next;
+      GNUNET_CONTAINER_DLL_remove (cur->addr_head, cur->addr_tail, cur_a);
+      GNUNET_free (cur_a);
+    }
+    GNUNET_free (cur);
+  }
+  if (NULL != sh)
+  {
+    GNUNET_ATS_solvers_solver_stop (sh);
+    sh = NULL;
+  }
 
   /* Shutdown */
   end_now();
-
 }
 
 static void
@@ -2350,27 +3076,6 @@ experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,i
   else
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
 
-  /* Stop logging */
-  // GNUNET_ATS_TEST_logging_stop (l);
-
-  /* Stop traffic generation */
-  // GNUNET_ATS_TEST_generate_traffic_stop_all();
-
-  /* Stop all preference generations */
-  GNUNET_ATS_solver_generate_preferences_stop_all ();
-
-  /*
-  evaluate (duration);
-  if (opt_log)
-    GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot);
-
-  if (NULL != l)
-  {
-    GNUNET_ATS_TEST_logging_stop (l);
-    GNUNET_ATS_TEST_logging_clean_up (l);
-    l = NULL;
-  }
-  */
   GNUNET_SCHEDULER_add_now (&done, NULL);
 }
 
@@ -2405,6 +3110,7 @@ run (void *cls, char * const *args, const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   enum GNUNET_ATS_Solvers solver;
+  int c;
 
   if (NULL == opt_exp_file)
   {
@@ -2442,7 +3148,14 @@ run (void *cls, char * const *args, const char *cfgfile,
     return;
   }
 
+  for (c = 0; c < GNUNET_ATS_PropertyCount; c++)
+    default_properties[c] = DEFAULT_REL_QUALITY;
+
+  for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+    default_preferences[c] = DEFAULT_REL_PREFERENCE;
+
   /* load experiment */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading experiment\n");
   e = GNUNET_ATS_solvers_experimentation_load (opt_exp_file);
   if (NULL == e)
   {
@@ -2452,8 +3165,8 @@ run (void *cls, char * const *args, const char *cfgfile,
     return;
   }
 
-
   /* load solver */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Loading solver\n");
   sh = GNUNET_ATS_solvers_solver_start (solver);
   if (NULL == sh)
   {
@@ -2464,9 +3177,11 @@ run (void *cls, char * const *args, const char *cfgfile,
   }
 
   /* start logging */
-
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Start logging \n");
+  l = GNUNET_ATS_solver_logging_start (e->log_freq);
 
   /* run experiment */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "=== Running experiment \n");
   GNUNET_ATS_solvers_experimentation_run (e, episode_done_cb,
       experiment_done_cb);
 
@@ -2486,7 +3201,7 @@ main (int argc, char *argv[])
   opt_exp_file = NULL;
   opt_solver = NULL;
   opt_log = GNUNET_NO;
-  opt_plot = GNUNET_NO;
+  opt_save = GNUNET_NO;
 
   res = 0;
 
@@ -2498,9 +3213,18 @@ main (int argc, char *argv[])
     {  'e', "experiment", NULL,
       gettext_noop ("experiment to use"),
       1, &GNUNET_GETOPT_set_string, &opt_exp_file},
-    {  'e', "experiment", NULL,
-      gettext_noop ("experiment to use"),
-      1, &GNUNET_GETOPT_set_one, &opt_verbose},
+    {  'V', "verbose", NULL,
+      gettext_noop ("be verbose"),
+      0, &GNUNET_GETOPT_set_one, &opt_verbose},
+    {  'p', "print", NULL,
+      gettext_noop ("print logging"),
+      0, &GNUNET_GETOPT_set_one, &opt_print},
+    {  'f', "file", NULL,
+        gettext_noop ("save logging to disk"),
+        0, &GNUNET_GETOPT_set_one, &opt_save},
+    {  'd', "dn", NULL,
+        gettext_noop ("disable normalization"),
+        0, &GNUNET_GETOPT_set_one, &opt_disable_normalization},
     GNUNET_GETOPT_OPTION_END
   };