gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (dc86c377a -> f7cc48d3e)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (dc86c377a -> f7cc48d3e)
Date: Sun, 26 Aug 2018 23:04:48 +0200

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

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

    from dc86c377a Reinitialise the (client) sampler element after querying
     new b1edf308b Change cosmetics of sampler element implementation
     new f7cc48d3e Request samples from multiple peers (rps profiler)

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             | 47 ++++++++---------
 src/rps/gnunet-service-rps_sampler_elem.c | 88 +++++++++++++++----------------
 src/rps/gnunet-service-rps_sampler_elem.h | 18 +++----
 3 files changed, 74 insertions(+), 79 deletions(-)

diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 79f0fbe2f..073d26ffd 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -476,11 +476,6 @@ static struct GNUNET_PeerIdentity *rps_peer_ids;
 static struct GNUNET_PeerIdentity *target_peer;
 
 /**
- * ID of the peer that requests for the evaluation.
- */
-static struct RPSPeer *eval_peer;
-
-/**
  * Number of online peers.
  */
 static unsigned int num_peers_online;
@@ -1762,12 +1757,7 @@ churn (void *cls)
  */
 static void profiler_init_peer (struct RPSPeer *rps_peer)
 {
-  if (num_peers - 1 == rps_peer->index)
-  {
-    rps_peer->num_ids_to_request = cur_test_run.num_requests;
-  } else {
-    rps_peer->num_ids_to_request = 0;
-  }
+  rps_peer->num_ids_to_request = cur_test_run.num_requests;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n",
               rps_peer->num_ids_to_request);
 }
@@ -1787,19 +1777,32 @@ profiler_reply_handle (void *cls,
 {
   struct RPSPeer *rps_peer;
   struct RPSPeer *rcv_rps_peer;
-  char *file_name;
-  char *file_name_dh;
-  char *file_name_dhr;
-  char *file_name_dhru;
+  char file_name_buf[128];
+  char file_name_dh_buf[128];
+  char file_name_dhr_buf[128];
+  char file_name_dhru_buf[128];
+  char *file_name = file_name_buf;
+  char *file_name_dh = file_name_dh_buf;
+  char *file_name_dhr = file_name_dhr_buf;
+  char *file_name_dhru = file_name_dhru_buf;
   unsigned int i;
   struct PendingReply *pending_rep = (struct PendingReply *) cls;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n");
   rps_peer = pending_rep->rps_peer;
-  file_name = "/tmp/rps/received_ids";
-  file_name_dh = "/tmp/rps/diehard_input";
-  file_name_dhr = "/tmp/rps/diehard_input_raw";
-  file_name_dhru = "/tmp/rps/diehard_input_raw_aligned";
+  (void) GNUNET_asprintf (&file_name,
+                                       "/tmp/rps/received_ids-%u",
+                                       rps_peer->index);
+
+  (void) GNUNET_asprintf (&file_name_dh,
+                                       "/tmp/rps/diehard_input-%u",
+                                       rps_peer->index);
+  (void) GNUNET_asprintf (&file_name_dhr,
+                                       "/tmp/rps/diehard_input_raw-%u",
+                                       rps_peer->index);
+  (void) GNUNET_asprintf (&file_name_dhru,
+                                       "/tmp/rps/diehard_input_raw_aligned-%u",
+                                       rps_peer->index);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "[%s] got %" PRIu64 " peers:\n",
               GNUNET_i2s (rps_peer->peer_id),
@@ -1855,7 +1858,7 @@ profiler_cb (struct RPSPeer *rps_peer)
   /* Only request peer ids at one peer.
    * (It's the before-last because last one is target of the focussed attack.)
    */
-  if (eval_peer == rps_peer)
+  if (0 < rps_peer->num_ids_to_request)
     schedule_missing_requests (rps_peer);
 }
 
@@ -2727,10 +2730,6 @@ run (void *cls,
   if ( (2 == mal_type) ||
        (3 == mal_type))
     target_peer = &rps_peer_ids[num_peers - 2];
-  if (profiler_eval == cur_test_run.eval_cb)
-    eval_peer = &rps_peers[num_peers - 1];    /* FIXME: eval_peer could be a
-                                                 malicious peer if not careful
-                                                 with the malicious portion */
 
   ok = 1;
   GNUNET_TESTBED_run (NULL,
diff --git a/src/rps/gnunet-service-rps_sampler_elem.c 
b/src/rps/gnunet-service-rps_sampler_elem.c
index 7569801a6..a1a46b2d7 100644
--- a/src/rps/gnunet-service-rps_sampler_elem.c
+++ b/src/rps/gnunet-service-rps_sampler_elem.c
@@ -33,45 +33,41 @@
 #define LOG(kind, ...) GNUNET_log_from(kind,"rps-sampler_elem",__VA_ARGS__)
 
 
-// TODO check for overflows
-
 /***********************************************************************
  * WARNING: This section needs to be reviewed regarding the use of
  * functions providing (pseudo)randomness!
 ***********************************************************************/
 
-// TODO care about invalid input of the caller (size 0 or less...)
-
 
 /**
  * Reinitialise a previously initialised sampler element.
  *
- * @param sampler pointer to the memory that keeps the value.
+ * @param sampler_el The sampler element to (re-) initialise
  */
 void
-RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_el)
+RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_elem)
 {
-  sampler_el->is_empty = EMPTY;
+  sampler_elem->is_empty = EMPTY;
 
   // I guess I don't need to call GNUNET_CRYPTO_hmac_derive_key()...
   GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_STRONG,
-                             &(sampler_el->auth_key.key),
+                             &(sampler_elem->auth_key.key),
                              GNUNET_CRYPTO_HASH_LENGTH);
 
   #ifdef TO_FILE
   /* Create a file(-name) to store internals to */
   char *name_buf;
-  name_buf = auth_key_to_string (sampler_el->auth_key);
+  name_buf = auth_key_to_string (sampler_elem->auth_key);
 
-  sampler_el->file_name = create_file (name_buf);
+  sampler_elem->file_name = create_file (name_buf);
   GNUNET_free (name_buf);
   #endif /* TO_FILE */
 
-  sampler_el->last_client_request = GNUNET_TIME_UNIT_FOREVER_ABS;
+  sampler_elem->last_client_request = GNUNET_TIME_UNIT_FOREVER_ABS;
 
-  sampler_el->birth = GNUNET_TIME_absolute_get ();
-  sampler_el->num_peers = 0;
-  sampler_el->num_change = 0;
+  sampler_elem->birth = GNUNET_TIME_absolute_get ();
+  sampler_elem->num_peers = 0;
+  sampler_elem->num_change = 0;
 }
 
 
@@ -115,89 +111,89 @@ RPS_sampler_elem_destroy (struct RPS_SamplerElement 
*sampler_elem)
 
 
 /**
- * Input an PeerID into the given sampler element.
+ * Update a sampler element with a PeerID
  *
- * @param sampler the sampler the @a s_elem belongs to.
- *                Needed to know the
+ * @param sampler_elem The sampler element to update
+ * @param new_ID The PeerID to update with
  */
 void
-RPS_sampler_elem_next (struct RPS_SamplerElement *s_elem,
-                       const struct GNUNET_PeerIdentity *other)
+RPS_sampler_elem_next (struct RPS_SamplerElement *sampler_elem,
+                       const struct GNUNET_PeerIdentity *new_ID)
 {
   struct GNUNET_HashCode other_hash;
 
-  s_elem->num_peers++;
+  sampler_elem->num_peers++;
 
   #ifdef TO_FILE
-  to_file (s_elem->file_name,
+  to_file (sampler_elem->file_name,
            "Got id %s",
-           GNUNET_i2s_full (other));
+           GNUNET_i2s_full (new_ID));
   #endif /* TO_FILE */
 
-  if (0 == GNUNET_CRYPTO_cmp_peer_identity (other, &(s_elem->peer_id)))
+  if (0 == GNUNET_CRYPTO_cmp_peer_identity (new_ID, &(sampler_elem->peer_id)))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "Have already PeerID %s\n",
-        GNUNET_i2s (&(s_elem->peer_id)));
+        GNUNET_i2s (&(sampler_elem->peer_id)));
   }
   else
   {
-    GNUNET_CRYPTO_hmac(&s_elem->auth_key,
-        other,
+    GNUNET_CRYPTO_hmac(&sampler_elem->auth_key,
+        new_ID,
         sizeof(struct GNUNET_PeerIdentity),
         &other_hash);
 
-    if (EMPTY == s_elem->is_empty)
+    if (EMPTY == sampler_elem->is_empty)
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Got PeerID %s; Simply accepting (was empty previously).\n",
-           GNUNET_i2s(other));
-      s_elem->peer_id = *other;
-      s_elem->peer_id_hash = other_hash;
+           GNUNET_i2s(new_ID));
+      sampler_elem->peer_id = *new_ID;
+      sampler_elem->peer_id_hash = other_hash;
 
-      s_elem->num_change++;
+      sampler_elem->num_change++;
     }
-    else if (0 > GNUNET_CRYPTO_hash_cmp (&other_hash, &s_elem->peer_id_hash))
+    else if (0 > GNUNET_CRYPTO_hash_cmp (&other_hash, 
&sampler_elem->peer_id_hash))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Discarding old PeerID %s\n",
-          GNUNET_i2s (&s_elem->peer_id));
-      s_elem->peer_id = *other;
-      s_elem->peer_id_hash = other_hash;
+          GNUNET_i2s (&sampler_elem->peer_id));
+      sampler_elem->peer_id = *new_ID;
+      sampler_elem->peer_id_hash = other_hash;
 
-      s_elem->num_change++;
+      sampler_elem->num_change++;
     }
     else
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG, "Keeping old PeerID %s\n",
-          GNUNET_i2s (&s_elem->peer_id));
+          GNUNET_i2s (&sampler_elem->peer_id));
     }
   }
-  s_elem->is_empty = NOT_EMPTY;
+  sampler_elem->is_empty = NOT_EMPTY;
 
   #ifdef TO_FILE
-  to_file (s_elem->file_name,
+  to_file (sampler_elem->file_name,
            "Now holding %s",
-           GNUNET_i2s_full (&s_elem->peer_id));
+           GNUNET_i2s_full (&sampler_elem->peer_id));
   #endif /* TO_FILE */
 }
 
 /**
- * Initialise the min-wise independent function of the given sampler element.
+ * Set the min-wise independent function of the given sampler element.
  *
- * @param s_elem the sampler element
+ * @param sampler_elem the sampler element
  * @param auth_key the key to use
  */
 void
-RPS_sampler_elem_set (struct RPS_SamplerElement *s_elem,
+RPS_sampler_elem_set (struct RPS_SamplerElement *sampler_elem,
                       struct GNUNET_CRYPTO_AuthKey auth_key)
 {
-  s_elem->auth_key = auth_key;
+  sampler_elem->auth_key = auth_key;
 
   #ifdef TO_FILE
   /* Create a file(-name) to store internals to */
   char *name_buf;
-  name_buf = auth_key_to_string (s_elem->auth_key);
+  name_buf = auth_key_to_string (sampler_elem->auth_key);
 
-  s_elem->file_name = create_file (name_buf);
+  sampler_elem->file_name = create_file (name_buf);
   GNUNET_free (name_buf);
   #endif /* TO_FILE */
 }
diff --git a/src/rps/gnunet-service-rps_sampler_elem.h 
b/src/rps/gnunet-service-rps_sampler_elem.h
index 1dbdcbadd..7598a627b 100644
--- a/src/rps/gnunet-service-rps_sampler_elem.h
+++ b/src/rps/gnunet-service-rps_sampler_elem.h
@@ -99,10 +99,10 @@ struct RPS_SamplerElement
 /**
  * Reinitialise a previously initialised sampler element.
  *
- * @param sampler pointer to the memory that keeps the value.
+ * @param sampler_el The sampler element to (re-) initialise
  */
 void
-RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_el);
+RPS_sampler_elem_reinit (struct RPS_SamplerElement *sampler_elem);
 
 
 /**
@@ -127,23 +127,23 @@ RPS_sampler_elem_destroy (struct RPS_SamplerElement 
*sampler_elem);
 
 
 /**
- * Input an PeerID into the given sampler element.
+ * Update a sampler element with a PeerID
  *
- * @param sampler the sampler the @a s_elem belongs to.
- *                Needed to know the
+ * @param sampler_elem The sampler element to update
+ * @param new_ID The PeerID to update with
  */
 void
-RPS_sampler_elem_next (struct RPS_SamplerElement *s_elem,
+RPS_sampler_elem_next (struct RPS_SamplerElement *sampler_elem,
                        const struct GNUNET_PeerIdentity *new_ID);
 
 /**
- * Initialise the min-wise independent function of the given sampler element.
+ * Set the min-wise independent function of the given sampler element.
  *
- * @param s_elem the sampler element
+ * @param sampler_elem the sampler element
  * @param auth_key the key to use
  */
 void
-RPS_sampler_elem_set (struct RPS_SamplerElement *s_elem,
+RPS_sampler_elem_set (struct RPS_SamplerElement *sampler_elem,
                       struct GNUNET_CRYPTO_AuthKey auth_key);
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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