gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated (0950b1df7 -> 91e8c2ff2)


From: gnunet
Subject: [gnunet] branch master updated (0950b1df7 -> 91e8c2ff2)
Date: Mon, 16 Nov 2020 23:59:05 +0100

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a change to branch master
in repository gnunet.

    from 0950b1df7 rps: properly initialise memory
     new d30ec0f1f rps: comment ill-defined code
     new 91e8c2ff2 rps: deal with currently unused code

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/rps/gnunet-rps-profiler.c | 209 +++++++++++++++---------------------------
 src/rps/gnunet-service-rps.c  | 115 ++++++++++++-----------
 src/rps/rps-sampler_client.c  |  66 ++++++-------
 3 files changed, 170 insertions(+), 220 deletions(-)

diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 7d6bf407f..0ec2fec71 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -59,10 +59,10 @@ static struct GNUNET_TIME_Relative duration;
 static struct GNUNET_TIME_Relative timeout;
 
 
-/**
- * Portion of malicious peers
- */
-static double portion = .1;
+// /**
+//  * Portion of malicious peers
+//  */
+// static double portion = .1;
 
 /**
  * Type of malicious peer to test
@@ -1228,29 +1228,6 @@ post_test_op (void *cls)
 }
 
 
-/**
- * Seed peers.
- */
-static void
-seed_peers (void *cls)
-{
-  struct RPSPeer *peer = cls;
-  unsigned int amount;
-  unsigned int i;
-
-  // TODO if malicious don't seed mal peers
-  amount = round (.5 * num_peers);
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n");
-  for (i = 0; i < amount; i++)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
-                i,
-                GNUNET_i2s (&rps_peer_ids[i]));
-
-  GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
-}
-
-
 /**
  * Get the id of peer i.
  */
@@ -1635,76 +1612,76 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
 * MALICIOUS
 ***********************************/
 
-/**
- * Initialise only non-mal RPSPeers
- */
-static void
-mal_init_peer (struct RPSPeer *rps_peer)
-{
-  if (rps_peer->index >= round (portion * num_peers))
-    rps_peer->num_ids_to_request = 1;
-}
-
-
-/**
- * @brief Set peers to (non-)malicious before execution
- *
- * Of signature #PreTest
- *
- * @param rps_peer the peer to set (non-) malicious
- * @param h the handle to the service
- */
-static void
-mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
-{
-  #if ENABLE_MALICIOUS
-  uint32_t num_mal_peers;
-
-  GNUNET_assert ((1 >= portion) &&
-                 (0 < portion));
-  num_mal_peers = round (portion * num_peers);
-
-  if (rps_peer->index < num_mal_peers)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "%u. peer [%s] of %" PRIu32
-                " malicious peers turning malicious\n",
-                rps_peer->index,
-                GNUNET_i2s (rps_peer->peer_id),
-                num_mal_peers);
-
-    GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
-                              rps_peer_ids, target_peer);
-  }
-  #endif /* ENABLE_MALICIOUS */
-}
-
-
-static void
-mal_cb (struct RPSPeer *rps_peer)
-{
-  if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
-  {
-    return;
-  }
-
-  #if ENABLE_MALICIOUS
-  uint32_t num_mal_peers;
-
-  GNUNET_assert ((1 >= portion) &&
-                 (0 < portion));
-  num_mal_peers = round (portion * num_peers);
-
-  if (rps_peer->index >= num_mal_peers)
-  {   /* It's useless to ask a malicious peer about a random sample -
-         it's not sampling */
-    GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
-                                    GNUNET_TIME_UNIT_SECONDS, 2),
-                                  seed_peers, rps_peer);
-    schedule_missing_requests (rps_peer);
-  }
-  #endif /* ENABLE_MALICIOUS */
-}
+///**
+// * Initialise only non-mal RPSPeers
+// */
+//static void
+//mal_init_peer (struct RPSPeer *rps_peer)
+//{
+//  if (rps_peer->index >= round (portion * num_peers))
+//    rps_peer->num_ids_to_request = 1;
+//}
+
+
+///**
+// * @brief Set peers to (non-)malicious before execution
+// *
+// * Of signature #PreTest
+// *
+// * @param rps_peer the peer to set (non-) malicious
+// * @param h the handle to the service
+// */
+//static void
+//mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
+//{
+//  #if ENABLE_MALICIOUS
+//  uint32_t num_mal_peers;
+//
+//  GNUNET_assert ((1 >= portion) &&
+//                 (0 < portion));
+//  num_mal_peers = round (portion * num_peers);
+//
+//  if (rps_peer->index < num_mal_peers)
+//  {
+//    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+//                "%u. peer [%s] of %" PRIu32
+//                " malicious peers turning malicious\n",
+//                rps_peer->index,
+//                GNUNET_i2s (rps_peer->peer_id),
+//                num_mal_peers);
+//
+//    GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
+//                              rps_peer_ids, target_peer);
+//  }
+//  #endif /* ENABLE_MALICIOUS */
+//}
+
+
+// static void
+// mal_cb (struct RPSPeer *rps_peer)
+// {
+//   if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
+//   {
+//     return;
+//   }
+// 
+//   #if ENABLE_MALICIOUS
+//   uint32_t num_mal_peers;
+// 
+//   GNUNET_assert ((1 >= portion) &&
+//                  (0 < portion));
+//   num_mal_peers = round (portion * num_peers);
+// 
+//   if (rps_peer->index >= num_mal_peers)
+//   {   /* It's useless to ask a malicious peer about a random sample -
+//          it's not sampling */
+//     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
+//                                     GNUNET_TIME_UNIT_SECONDS, 2),
+//                                   seed_peers, rps_peer);
+//     schedule_missing_requests (rps_peer);
+//   }
+//   #endif /* ENABLE_MALICIOUS */
+// }
 
 
 /***********************************
@@ -1714,44 +1691,6 @@ mal_cb (struct RPSPeer *rps_peer)
 static void
 churn (void *cls);
 
-/**
- * @brief Starts churn
- *
- * Has signature of #MainTest
- *
- * This is not implemented too nicely as this is called for each peer, but we
- * only need to call it once. (Yes we check that we only schedule the task
- * once.)
- *
- * @param rps_peer The peer it's called for
- */
-static void
-churn_test_cb (struct RPSPeer *rps_peer)
-{
-  if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
-  {
-    return;
-  }
-
-  /* Start churn */
-  if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Starting churn task\n");
-    churn_task = GNUNET_SCHEDULER_add_delayed (
-      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
-      churn,
-      NULL);
-  }
-  else
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Not starting churn task\n");
-  }
-
-  schedule_missing_requests (rps_peer);
-}
-
 
 /***********************************
 * PROFILER
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 0e3759c4c..dc4c5dab7 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2466,6 +2466,7 @@ resize_wrapper (struct RPS_Sampler *sampler, uint32_t 
new_size)
 }
 
 
+#if ENABLE_MALICIOUS
 /**
  * Add all peers in @a peer_array to @a peer_map used as set.
  *
@@ -2502,6 +2503,7 @@ add_peer_array_to_set (const struct GNUNET_PeerIdentity 
*peer_array,
     }
   }
 }
+#endif /* ENABLE_MALICIOUS */
 
 
 /**
@@ -2950,12 +2952,16 @@ new_sub (const struct GNUNET_HashCode *hash,
 
   /* Logging of internals */
 #ifdef TO_FILE_FULL
-  sub->file_name_view_log = store_prefix_file_name (&own_identity, "view");
+  // FIXME: The service cannot know the index, which is required by this
+  // function:
+  // sub->file_name_view_log = store_prefix_file_name (&own_identity, "view");
 #endif /* TO_FILE_FULL */
 #ifdef TO_FILE
 #ifdef TO_FILE_FULL
-  sub->file_name_observed_log = store_prefix_file_name (&own_identity,
-                                                        "observed");
+  // FIXME: The service cannot know the index, which is required by this
+  // function:
+  // sub->file_name_observed_log = store_prefix_file_name (&own_identity,
+  //                                                       "observed");
 #endif /* TO_FILE_FULL */
   sub->num_observed_peers = 0;
   sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1,
@@ -2983,46 +2989,50 @@ new_sub (const struct GNUNET_HashCode *hash,
 
 
 #ifdef TO_FILE
-/**
- * @brief Write all numbers in the given array into the given file
- *
- * Single numbers devided by a newline
- *
- * @param hist_array[] the array to dump
- * @param file_name file to dump into
- */
-static void
-write_histogram_to_file (const uint32_t hist_array[],
-                         const char *file_name)
-{
-  char collect_str[SIZE_DUMP_FILE + 1] = "";
-  char *recv_str_iter;
-  char *file_name_full;
-
-  recv_str_iter = collect_str;
-  file_name_full = store_prefix_file_name (&own_identity,
-                                           file_name);
-  for (uint32_t i = 0; i < HISTOGRAM_FILE_SLOTS; i++)
-  {
-    char collect_str_tmp[8];
-
-    GNUNET_snprintf (collect_str_tmp,
-                     sizeof(collect_str_tmp),
-                     "%" PRIu32 "\n",
-                     hist_array[i]);
-    recv_str_iter = stpncpy (recv_str_iter,
-                             collect_str_tmp,
-                             6);
-  }
-  (void) stpcpy (recv_str_iter,
-                 "\n");
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Writing push stats to disk\n");
-  to_file_w_len (file_name_full,
-                 SIZE_DUMP_FILE, "%s",
-                 collect_str);
-  GNUNET_free (file_name_full);
-}
+// /**
+//  * @brief Write all numbers in the given array into the given file
+//  *
+//  * Single numbers devided by a newline
+//  *
+//  * FIXME: The call to store_prefix_file_name expects the index of the peer,
+//  * which cannot be known to the service.
+//  * Write a dedicated function that uses the peer id.
+//  *
+//  * @param hist_array[] the array to dump
+//  * @param file_name file to dump into
+//  */
+// static void
+// write_histogram_to_file (const uint32_t hist_array[],
+//                          const char *file_name)
+// {
+//   char collect_str[SIZE_DUMP_FILE + 1] = "";
+//   char *recv_str_iter;
+//   char *file_name_full;
+// 
+//   recv_str_iter = collect_str;
+//   file_name_full = store_prefix_file_name (&own_identity,
+//                                            file_name);
+//   for (uint32_t i = 0; i < HISTOGRAM_FILE_SLOTS; i++)
+//   {
+//     char collect_str_tmp[8];
+// 
+//     GNUNET_snprintf (collect_str_tmp,
+//                      sizeof(collect_str_tmp),
+//                      "%" PRIu32 "\n",
+//                      hist_array[i]);
+//     recv_str_iter = stpncpy (recv_str_iter,
+//                              collect_str_tmp,
+//                              6);
+//   }
+//   (void) stpcpy (recv_str_iter,
+//                  "\n");
+//   LOG (GNUNET_ERROR_TYPE_DEBUG,
+//        "Writing push stats to disk\n");
+//   to_file_w_len (file_name_full,
+//                  SIZE_DUMP_FILE, "%s",
+//                  collect_str);
+//   GNUNET_free (file_name_full);
+// }
 
 
 #endif /* TO_FILE */
@@ -3067,17 +3077,18 @@ destroy_sub (struct Sub *sub)
   sub->file_name_observed_log = NULL;
 #endif /* TO_FILE_FULL */
 
-  /* Write push frequencies to disk */
-  write_histogram_to_file (sub->push_recv,
-                           "push_recv");
+  // FIXME: Currently this calls malfunctionning code
+  // /* Write push frequencies to disk */
+  // write_histogram_to_file (sub->push_recv,
+  //                          "push_recv");
 
-  /* Write push deltas to disk */
-  write_histogram_to_file (sub->push_delta,
-                           "push_delta");
+  // /* Write push deltas to disk */
+  // write_histogram_to_file (sub->push_delta,
+  //                          "push_delta");
 
-  /* Write pull delays to disk */
-  write_histogram_to_file (sub->pull_delays,
-                           "pull_delays");
+  // /* Write pull delays to disk */
+  // write_histogram_to_file (sub->pull_delays,
+  //                          "pull_delays");
 
   GNUNET_CONTAINER_multipeermap_destroy (sub->observed_unique_peers);
   sub->observed_unique_peers = NULL;
diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c
index 714943b51..f6e98ce29 100644
--- a/src/rps/rps-sampler_client.c
+++ b/src/rps/rps-sampler_client.c
@@ -258,39 +258,39 @@ RPS_sampler_mod_init (size_t init_size,
 }
 
 
-/**
- * @brief Compute the probability that we already observed all peers from a
- * biased stream of peer ids.
- *
- * Deficiency factor:
- * As introduced by Brahms: Factor between the number of unique ids in a
- * truly random stream and number of unique ids in the gossip stream.
- *
- * @param num_peers_estim The estimated number of peers in the network
- * @param num_peers_observed The number of peers the given element has observed
- * @param deficiency_factor A factor that catches the 'bias' of a random stream
- * of peer ids
- *
- * @return The estimated probability
- */
-static double
-prob_observed_n_peers (uint32_t num_peers_estim,
-                       uint32_t num_peers_observed,
-                       double deficiency_factor)
-{
-  uint32_t num_peers = num_peers_estim * (1 / deficiency_factor);
-  uint64_t sum = 0;
-
-  for (uint32_t i = 0; i < num_peers; i++)
-  {
-    uint64_t a = pow (-1, num_peers - i);
-    uint64_t b = binom (num_peers, i);
-    uint64_t c = pow (i, num_peers_observed);
-    sum += a * b * c;
-  }
-
-  return sum / (double) pow (num_peers, num_peers_observed);
-}
+// /**
+//  * @brief Compute the probability that we already observed all peers from a
+//  * biased stream of peer ids.
+//  *
+//  * Deficiency factor:
+//  * As introduced by Brahms: Factor between the number of unique ids in a
+//  * truly random stream and number of unique ids in the gossip stream.
+//  *
+//  * @param num_peers_estim The estimated number of peers in the network
+//  * @param num_peers_observed The number of peers the given element has 
observed
+//  * @param deficiency_factor A factor that catches the 'bias' of a random 
stream
+//  * of peer ids
+//  *
+//  * @return The estimated probability
+//  */
+// static double
+// prob_observed_n_peers (uint32_t num_peers_estim,
+//                        uint32_t num_peers_observed,
+//                        double deficiency_factor)
+// {
+//   uint32_t num_peers = num_peers_estim * (1 / deficiency_factor);
+//   uint64_t sum = 0;
+// 
+//   for (uint32_t i = 0; i < num_peers; i++)
+//   {
+//     uint64_t a = pow (-1, num_peers - i);
+//     uint64_t b = binom (num_peers, i);
+//     uint64_t c = pow (i, num_peers_observed);
+//     sum += a * b * c;
+//   }
+// 
+//   return sum / (double) pow (num_peers, num_peers_observed);
+// }
 
 
 /**

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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