fix crash on unexpected client disconnect on incoming message, remove bogus assertion
[oweals/gnunet.git] / src / rps / test_rps.c
index 127b973acc3c55015fe425733bb221f5c1f1e068..542919425da19ca90984fe8603233794f3157e12 100644 (file)
@@ -257,7 +257,12 @@ struct RPSPeer
   /**
    * @brief File name of the file the stats are finally written to
    */
-  char *file_name_stats;
+  const char *file_name_stats;
+
+  /**
+   * @brief File name of the file the stats are finally written to
+   */
+  const char *file_name_probs;
 
   /**
    * @brief The current view
@@ -268,6 +273,31 @@ struct RPSPeer
    * @brief Number of peers in the #cur_view.
    */
   uint32_t cur_view_count;
+
+  /**
+   * @brief Number of occurrences in other peer's view
+   */
+  uint32_t count_in_views;
+
+  /**
+   * @brief statistics values
+   */
+  uint64_t num_rounds;
+  uint64_t num_blocks;
+  uint64_t num_blocks_many_push;
+  uint64_t num_blocks_no_push;
+  uint64_t num_blocks_no_pull;
+  uint64_t num_blocks_many_push_no_pull;
+  uint64_t num_blocks_no_push_no_pull;
+  uint64_t num_issued_push;
+  uint64_t num_issued_pull_req;
+  uint64_t num_issued_pull_rep;
+  uint64_t num_sent_push;
+  uint64_t num_sent_pull_req;
+  uint64_t num_sent_pull_rep;
+  uint64_t num_recv_push;
+  uint64_t num_recv_pull_req;
+  uint64_t num_recv_pull_rep;
 };
 
 enum STAT_TYPE
@@ -328,6 +358,11 @@ static struct RPSPeer *eval_peer;
  */
 static unsigned int num_peers_online;
 
+/**
+ * @brief The added sizes of the peer's views
+ */
+static unsigned int view_sizes;
+
 /**
  * Return value from 'main'.
  */
@@ -1774,51 +1809,270 @@ profiler_eval (void)
   return evaluate ();
 }
 
+static uint32_t fac (uint32_t x)
+{
+  if (1 >= x)
+  {
+    return x;
+  }
+  return x * fac (x - 1);
+}
+
+static uint32_t binom (uint32_t n, uint32_t k)
+{
+  //GNUNET_assert (n >= k);
+  if (k > n) return 0;
+  if (0 > n) return 0;
+  if (0 > k) return 0;
+  if (0 == k) return 1;
+  return fac (n)
+    /
+    fac(k) * fac(n - k);
+}
+
 /**
- * @brief Try to ensure that `/tmp/rps` exists.
+ * @brief is b in view of a?
+ *
+ * @param a
+ * @param b
  *
- * @return #GNUNET_YES on success
- *         #GNUNET_SYSERR on failure
+ * @return
  */
-static int ensure_folder_exist (void)
+static int is_in_view (uint32_t a, uint32_t b)
 {
-  if (GNUNET_NO == GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
+  uint32_t i;
+  for (i = 0; i < rps_peers[a].cur_view_count; i++)
   {
-    GNUNET_DISK_directory_create ("/tmp/rps");
+    if (0 == memcmp (rps_peers[b].peer_id,
+          &rps_peers[a].cur_view[i],
+          sizeof (struct GNUNET_PeerIdentity)))
+    {
+      return GNUNET_YES;
+    }
   }
-  if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
+  return GNUNET_NO;
+}
+
+static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
+{
+  uint32_t i;
+
+  for (i = 0; i < num_peers; i++)
   {
-    return GNUNET_SYSERR;
+    if (0 == memcmp (pid,
+          rps_peers[i].peer_id,
+          sizeof (struct GNUNET_PeerIdentity)))
+    {
+      return i;
+    }
   }
-  return GNUNET_YES;
+  //return 0; /* Should not happen - make compiler happy */
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+             "No known _PeerIdentity %s!\n",
+             GNUNET_i2s_full (pid));
+  GNUNET_assert (0);
 }
 
-static void
-store_stats_file_name (struct RPSPeer *rps_peer)
+/**
+ * @brief Counts number of peers in view of a that have b in their view
+ *
+ * @param a
+ * @param uint32_tb
+ *
+ * @return
+ */
+static uint32_t count_containing_views (uint32_t a, uint32_t b)
 {
-  unsigned int len_file_name;
-  unsigned int out_size;
-  char *file_name;
+  uint32_t i;
+  uint32_t peer_idx;
+  uint32_t count = 0;
 
-  if (GNUNET_SYSERR == ensure_folder_exist()) return;
-  len_file_name = (14 + strlen (GNUNET_i2s_full (rps_peer->peer_id)) + 1) * sizeof (char);
-  file_name = GNUNET_malloc (len_file_name);
-  out_size = GNUNET_snprintf (file_name,
-                              len_file_name,
-                              "/tmp/rps/stat-%s",
-                              GNUNET_i2s_full (rps_peer->peer_id));
-  if (len_file_name < out_size ||
-      0 > out_size)
+  for (i = 0; i < rps_peers[a].cur_view_count; i++)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-               "Failed to write string to buffer (size: %i, out_size: %i)\n",
-               len_file_name,
-               out_size);
+    peer_idx = get_idx_of_pid (&rps_peers[a].cur_view[i]);
+    if (GNUNET_YES == is_in_view (peer_idx, b))
+    {
+      count++;
+    }
+  }
+  return count;
+}
+
+/**
+ * @brief Computes the probability for each other peer to be selected by the
+ * sampling process based on the views of all peers
+ *
+ * @param peer_idx index of the peer that is about to sample
+ */
+static void compute_probabilities (uint32_t peer_idx)
+{
+  //double probs[num_peers] = { 0 };
+  double probs[num_peers];
+  size_t probs_as_str_size = (num_peers * 10 + 1) * sizeof (char);
+  char *probs_as_str = GNUNET_malloc (probs_as_str_size);
+  char *probs_as_str_cpy;
+  uint32_t i;
+  double prob_push;
+  double prob_pull;
+  uint32_t view_size;
+  uint32_t cont_views;
+  uint32_t number_of_being_in_pull_events;
+  int tmp;
+  uint32_t count_non_zero_prob = 0;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      "Computing probabilities for peer %" PRIu32 "\n", peer_idx);
+  /* Firstly without knowledge of old views */
+  for (i = 0; i < num_peers; i++)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+        "\tfor peer %" PRIu32 ":\n", i);
+    view_size = rps_peers[i].cur_view_count;
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+        "\t\tview_size: %" PRIu32 "\n", view_size);
+    /* For peer i the probability of being sampled is
+     * evenly distributed among all possibly observed peers. */
+    /* We could have observed a peer in three cases:
+     *   1. peer sent a push
+     *   2. peer was contained in a pull reply
+     *   3. peer was in history (sampler) - ignored for now */
+    /* 1. Probability of having received a push from peer i */
+    if ((GNUNET_YES == is_in_view (i, peer_idx)) &&
+        (1 <= (0.45 * view_size)))
+    {
+      prob_push = 1.0 * binom (0.45 * view_size, 1)
+        /
+        binom (view_size, 0.45 * view_size);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n",
+                 peer_idx,
+                 i,
+                 prob_push);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "\t\tposs choices from view: %" PRIu32 ", containing i: %" PRIu32 "\n",
+                 binom (view_size, 0.45 * view_size),
+                 binom (0.45 * view_size, 1));
+    } else {
+      prob_push = 0;
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "\t\t%" PRIu32 " is not in %" PRIu32 "'s view, prob: 0\n",
+                 peer_idx,
+                 i);
+    }
+    /* 2. Probability of peer i being contained in pulls */
+    view_size = rps_peers[peer_idx].cur_view_count;
+    cont_views = count_containing_views (peer_idx, i);
+    number_of_being_in_pull_events =
+      (binom (view_size, 0.45 * view_size) -
+       binom (view_size - cont_views, 0.45 * view_size));
+    if (0 != number_of_being_in_pull_events)
+    {
+      prob_pull = number_of_being_in_pull_events
+        /
+        (1.0 * binom (view_size, 0.45 * view_size));
+    } else
+    {
+      prob_pull = 0;
+    }
+    probs[i] = prob_push + prob_pull - (prob_push * prob_pull);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "\t\t%" PRIu32 " has %" PRIu32 " of %" PRIu32
+               " peers in its view who know %" PRIu32 " prob: %f\n",
+               peer_idx,
+               cont_views,
+               view_size,
+               i,
+               prob_pull);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "\t\tnumber of possible pull combinations: %" PRIu32 "\n",
+               binom (view_size, 0.45 * view_size));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "\t\tnumber of possible pull combinations without %" PRIu32
+               ": %" PRIu32 "\n",
+               i,
+               binom (view_size - cont_views, 0.45 * view_size));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "\t\tnumber of possible pull combinations with %" PRIu32
+               ": %" PRIu32 "\n",
+               i,
+               number_of_being_in_pull_events);
+
+    if (0 != probs[i]) count_non_zero_prob++;
+  }
+  /* normalize */
+  if (0 != count_non_zero_prob)
+  {
+    for (i = 0; i < num_peers; i++)
+    {
+      probs[i] = probs[i] * (1.0 / count_non_zero_prob);
+    }
+  } else {
+    for (i = 0; i < num_peers; i++)
+    {
+      probs[i] = 0;
+    }
+  }
+  /* str repr */
+  for (i = 0; i < num_peers; i++)
+  {
+    probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
+    tmp = GNUNET_snprintf (probs_as_str,
+                           probs_as_str_size,
+                           "%s %7.6f", probs_as_str_cpy, probs[i]);
+    GNUNET_free (probs_as_str_cpy);
+    GNUNET_assert (0 <= tmp);
+  }
+
+  to_file_w_len (rps_peers[peer_idx].file_name_probs,
+                 probs_as_str_size,
+                 probs_as_str);
+  GNUNET_free (probs_as_str);
+}
+
+/**
+ * @brief This counts the number of peers in which views a given peer occurs.
+ *
+ * It also stores this value in the rps peer.
+ *
+ * @param peer_idx the index of the peer to count the representation
+ *
+ * @return the number of occurrences
+ */
+static uint32_t count_peer_in_views_2 (uint32_t peer_idx)
+{
+  uint32_t i, j;
+  uint32_t count = 0;
+
+  for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
+  {
+    for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
+    {
+      if (0 == memcmp (rps_peers[peer_idx].peer_id,
+            &rps_peers[i].cur_view[j],
+            sizeof (struct GNUNET_PeerIdentity)))
+      {
+        count++;
+        break;
+      }
+    }
+  }
+  rps_peers[peer_idx].count_in_views = count;
+  return count;
+}
+
+static uint32_t cumulated_view_sizes ()
+{
+  uint32_t i;
+
+  view_sizes = 0;
+  for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
+  {
+    view_sizes += rps_peers[i].cur_view_count;
   }
-  rps_peer->file_name_stats = file_name;
+  return view_sizes;
 }
 
-void count_peer_in_views (uint32_t *count_peers)
+static void count_peer_in_views (uint32_t *count_peers)
 {
   uint32_t i, j;
 
@@ -1878,39 +2132,119 @@ void compute_diversity ()
   GNUNET_free (deviation);
 }
 
-void all_views_updated_cb ()
+void print_view_sizes()
 {
-  compute_diversity ();
+  uint32_t i;
+
+  for (i = 0; i < num_peers; i++) /* Peer to count */
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
+               i,
+               GNUNET_i2s (rps_peers[i].peer_id),
+               rps_peers[i].cur_view_count);
+  }
+}
+
+void all_views_updated_cb()
+{
+  compute_diversity();
+  print_view_sizes();
 }
 
 void view_update_cb (void *cls,
-                     uint64_t num_peers,
+                     uint64_t view_size,
                      const struct GNUNET_PeerIdentity *peers)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "View was updated (%" PRIu64 ")\n", num_peers);
+              "View was updated (%" PRIu64 ")\n", view_size);
   struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
-  for (int i = 0; i < num_peers; i++)
+  to_file ("/tmp/rps/view_sizes.txt",
+         "%" PRIu64 " %" PRIu32 "",
+         rps_peer->index,
+         view_size);
+  for (int i = 0; i < view_size; i++)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "\t%s\n", GNUNET_i2s (&peers[i]));
   }
   GNUNET_array_grow (rps_peer->cur_view,
                      rps_peer->cur_view_count,
-                     num_peers);
+                     view_size);
   //*rps_peer->cur_view = *peers;
-  memcpy (rps_peer->cur_view,
-          peers,
-          num_peers * sizeof (struct GNUNET_PeerIdentity));
+  GNUNET_memcpy (rps_peer->cur_view,
+                 peers,
+                 view_size * sizeof (struct GNUNET_PeerIdentity));
+  to_file ("/tmp/rps/count_in_views.txt",
+         "%" PRIu64 " %" PRIu32 "",
+         rps_peer->index,
+         count_peer_in_views_2 (rps_peer->index));
+  cumulated_view_sizes();
+  if (0 != view_size)
+  {
+    to_file ("/tmp/rps/repr.txt",
+           "%" PRIu64 /* index */
+           " %" PRIu32 /* occurrence in views */
+           " %" PRIu32 /* view sizes */
+           " %f" /* fraction of repr in views */
+           " %f" /* average view size */
+           " %f" /* prob of occurrence in view slot */
+           " %f" "", /* exp frac of repr in views */
+           rps_peer->index,
+           count_peer_in_views_2 (rps_peer->index),
+           view_sizes,
+           count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */
+           view_sizes / (view_size * 1.0), /* average view size */
+           1.0 /view_size, /* prob of occurrence in view slot */
+           (1.0/view_size) * (view_sizes/view_size) /* expected fraction of repr in views */
+           );
+  }
+  compute_probabilities (rps_peer->index);
   all_views_updated_cb();
 }
 
 static void
 pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
 {
+  rps_peer->file_name_probs =
+    store_prefix_file_name (rps_peer->peer_id, "probs");
   GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
 }
 
+void write_final_stats (void){
+  uint32_t i;
+
+  for (i = 0; i < num_peers; i++)
+  {
+    to_file ("/tmp/rps/final_stats.dat",
+             "%" PRIu32 " " /* index */
+             "%s %" /* id */
+             PRIu64 " %" /* rounds */
+             PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */
+             PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */
+             PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */
+             PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
+             i,
+             GNUNET_i2s (rps_peers[i].peer_id),
+             rps_peers[i].num_rounds,
+             rps_peers[i].num_blocks,
+             rps_peers[i].num_blocks_many_push,
+             rps_peers[i].num_blocks_no_push,
+             rps_peers[i].num_blocks_no_pull,
+             rps_peers[i].num_blocks_many_push_no_pull,
+             rps_peers[i].num_blocks_no_push_no_pull,
+             rps_peers[i].num_issued_push,
+             rps_peers[i].num_issued_pull_req,
+             rps_peers[i].num_issued_pull_rep,
+             rps_peers[i].num_sent_push,
+             rps_peers[i].num_sent_pull_req,
+             rps_peers[i].num_sent_pull_rep,
+             rps_peers[i].num_recv_push,
+             rps_peers[i].num_recv_pull_req,
+             rps_peers[i].num_recv_pull_rep);
+  }
+}
+
 /**
  * Continuation called by #GNUNET_STATISTICS_get() functions.
  *
@@ -1946,8 +2280,10 @@ post_test_shutdown_ready_cb (void *cls,
     GNUNET_TESTBED_operation_done (rps_peer->stat_op);
   }
 
+  write_final_stats ();
   if (GNUNET_YES == check_statistics_collect_completed())
   {
+    //write_final_stats ();
     GNUNET_free (stat_cls);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
         "Shutting down\n");
@@ -1957,6 +2293,83 @@ post_test_shutdown_ready_cb (void *cls,
   }
 }
 
+/**
+ * @brief Converts string representation to the corresponding #STAT_TYPE enum.
+ *
+ * @param stat_str string representation of statistics specifier
+ *
+ * @return corresponding enum
+ */
+enum STAT_TYPE stat_str_2_type (const char *stat_str)
+{
+  if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ("# rounds blocked - no pull replies")))
+  {
+    return STAT_TYPE_BLOCKS_NO_PULL;
+  }
+  else if (0 == strncmp ("# rounds blocked - too many pushes, no pull replies", stat_str, strlen ("# rounds blocked - too many pushes, no pull replies")))
+  {
+    return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL;
+  }
+  else if (0 == strncmp ("# rounds blocked - too many pushes", stat_str, strlen ("# rounds blocked - too many pushes")))
+  {
+    return STAT_TYPE_BLOCKS_MANY_PUSH;
+  }
+  else if (0 == strncmp ("# rounds blocked - no pushes, no pull replies", stat_str, strlen ("# rounds blocked - no pushes, no pull replies")))
+  {
+    return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL;
+  }
+  else if (0 == strncmp ("# rounds blocked - no pushes", stat_str, strlen ("# rounds blocked - no pushes")))
+  {
+    return STAT_TYPE_BLOCKS_NO_PUSH;
+  }
+  else if (0 == strncmp ("# rounds blocked", stat_str, strlen ("# rounds blocked")))
+  {
+    return STAT_TYPE_BLOCKS;
+  }
+  else if (0 == strncmp ("# rounds", stat_str, strlen ("# rounds")))
+  {
+    return STAT_TYPE_ROUNDS;
+  }
+  else if (0 == strncmp ("# push send issued", stat_str, strlen ("# push send issued")))
+  {
+    return STAT_TYPE_ISSUED_PUSH_SEND;
+  }
+  else if (0 == strncmp ("# pull request send issued", stat_str, strlen ("# pull request send issued")))
+  {
+    return STAT_TYPE_ISSUED_PULL_REQ;
+  }
+  else if (0 == strncmp ("# pull reply send issued", stat_str, strlen ("# pull reply send issued")))
+  {
+    return STAT_TYPE_ISSUED_PULL_REP;
+  }
+  else if (0 == strncmp ("# pushes sent", stat_str, strlen ("# pushes sent")))
+  {
+    return STAT_TYPE_SENT_PUSH_SEND;
+  }
+  else if (0 == strncmp ("# pull requests sent", stat_str, strlen ("# pull requests sent")))
+  {
+    return STAT_TYPE_SENT_PULL_REQ;
+  }
+  else if (0 == strncmp ("# pull replys sent", stat_str, strlen ("# pull replys sent")))
+  {
+    return STAT_TYPE_SENT_PULL_REP;
+  }
+  else if (0 == strncmp ("# push message received", stat_str, strlen ("# push message received")))
+  {
+    return STAT_TYPE_RECV_PUSH_SEND;
+  }
+  else if (0 == strncmp ("# pull request message received", stat_str, strlen ("# pull request message received")))
+  {
+    return STAT_TYPE_RECV_PULL_REQ;
+  }
+  else if (0 == strncmp ("# pull reply messages received", stat_str, strlen ("# pull reply messages received")))
+  {
+    return STAT_TYPE_RECV_PULL_REP;
+  }
+  return STAT_TYPE_MAX;
+}
+
+
 /**
  * @brief Converts #STAT_TYPE enum to the equivalent string representation that
  * is stored with the statistics service.
@@ -2026,7 +2439,7 @@ stat_iterator (void *cls,
                int is_persistent)
 {
   const struct STATcls *stat_cls = (const struct STATcls *) cls;
-  const struct RPSPeer *rps_peer = (const struct RPSPeer *) stat_cls->rps_peer;
+  struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
       //stat_type_2_str (stat_cls->stat_type),
       name,
@@ -2035,6 +2448,63 @@ stat_iterator (void *cls,
           "%s: %" PRIu64 "\n",
           name,
           value);
+  switch (stat_str_2_type (name))
+  {
+    case STAT_TYPE_ROUNDS:
+      rps_peer->num_rounds = value;
+      break;
+    case STAT_TYPE_BLOCKS:
+      rps_peer->num_blocks = value;
+      break;
+    case STAT_TYPE_BLOCKS_MANY_PUSH:
+      rps_peer->num_blocks_many_push = value;
+      break;
+    case STAT_TYPE_BLOCKS_NO_PUSH:
+      rps_peer->num_blocks_no_push = value;
+      break;
+    case STAT_TYPE_BLOCKS_NO_PULL:
+      rps_peer->num_blocks_no_pull = value;
+      break;
+    case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
+      rps_peer->num_blocks_many_push_no_pull = value;
+      break;
+    case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
+      rps_peer->num_blocks_no_push_no_pull = value;
+      break;
+    case STAT_TYPE_ISSUED_PUSH_SEND:
+      rps_peer->num_issued_push = value;
+      break;
+    case STAT_TYPE_ISSUED_PULL_REQ:
+      rps_peer->num_issued_pull_req = value;
+      break;
+    case STAT_TYPE_ISSUED_PULL_REP:
+      rps_peer->num_issued_pull_rep = value;
+      break;
+    case STAT_TYPE_SENT_PUSH_SEND:
+      rps_peer->num_sent_push = value;
+      break;
+    case STAT_TYPE_SENT_PULL_REQ:
+      rps_peer->num_sent_pull_req = value;
+      break;
+    case STAT_TYPE_SENT_PULL_REP:
+      rps_peer->num_sent_pull_rep = value;
+      break;
+    case STAT_TYPE_RECV_PUSH_SEND:
+      rps_peer->num_recv_push = value;
+      break;
+    case STAT_TYPE_RECV_PULL_REQ:
+      rps_peer->num_recv_pull_req = value;
+      break;
+    case STAT_TYPE_RECV_PULL_REP:
+      rps_peer->num_recv_pull_rep = value;
+      break;
+    case STAT_TYPE_MAX:
+    default:
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                 "Unknown statistics string: %s\n",
+                 name);
+      break;
+  }
   return GNUNET_OK;
 }
 
@@ -2060,7 +2530,8 @@ void post_profiler (struct RPSPeer *rps_peer)
       stat_cls = GNUNET_malloc (sizeof (struct STATcls));
       stat_cls->rps_peer = rps_peer;
       stat_cls->stat_type = stat_type;
-      store_stats_file_name (rps_peer);
+      rps_peer->file_name_stats =
+        store_prefix_file_name (rps_peer->peer_id, "stats");
       GNUNET_STATISTICS_get (rps_peer->stats_h,
                              "rps",
                              stat_type_2_str (stat_type),
@@ -2103,7 +2574,6 @@ run (void *cls,
 {
   unsigned int i;
   struct OpListEntry *entry;
-  uint32_t num_mal_peers;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
 
@@ -2144,24 +2614,19 @@ run (void *cls,
   }
 
   /* Bring peers up */
-  num_mal_peers = round (portion * num_peers);
   GNUNET_assert (num_peers == n_peers);
   for (i = 0; i < n_peers; i++)
   {
     rps_peers[i].index = i;
-    if ( (rps_peers[i].num_recv_ids < rps_peers[i].num_ids_to_request) ||
-         (i < num_mal_peers) )
-    {
-      rps_peers[i].op =
-        GNUNET_TESTBED_service_connect (&rps_peers[i],
-                                        peers[i],
-                                        "rps",
-                                        &rps_connect_complete_cb,
-                                        &rps_peers[i],
-                                        &rps_connect_adapter,
-                                        &rps_disconnect_adapter,
-                                        &rps_peers[i]);
-    }
+    rps_peers[i].op =
+      GNUNET_TESTBED_service_connect (&rps_peers[i],
+                                      peers[i],
+                                      "rps",
+                                      &rps_connect_complete_cb,
+                                      &rps_peers[i],
+                                      &rps_connect_adapter,
+                                      &rps_disconnect_adapter,
+                                      &rps_peers[i]);
     /* Connect all peers to statistics service */
     if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics)
     {
@@ -2308,7 +2773,7 @@ main (int argc, char *argv[])
     cur_test_run.main_test = churn_test_cb;
     cur_test_run.reply_handle = default_reply_handle;
     cur_test_run.eval_cb = default_eval_cb;
-    cur_test_run.have_churn = HAVE_CHURN;
+    cur_test_run.have_churn = HAVE_NO_CHURN;
     cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
     timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
   }
@@ -2328,7 +2793,8 @@ main (int argc, char *argv[])
     cur_test_run.post_test = post_profiler;
     cur_test_run.request_interval = 2;
     cur_test_run.num_requests = 5;
-    cur_test_run.have_churn = HAVE_CHURN;
+    //cur_test_run.have_churn = HAVE_CHURN;
+    cur_test_run.have_churn = HAVE_NO_CHURN;
     cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
     cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
     cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS |