gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (6db3d3269 -> 5378a0bf6)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (6db3d3269 -> 5378a0bf6)
Date: Sat, 20 Oct 2018 14:48:14 +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 6db3d3269 move aux before canonical checks
     new 061e86b15 RPS: Try to fix building error
     new d2bdef77c RPS: Fix writing internals to disk
     new 5378a0bf6 RPS service: Write push frequency and pull delays to disk

The 3 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/Makefile.am          |  7 ++--
 src/rps/gnunet-service-rps.c | 83 ++++++++++++++++++++++++++++++++++++++++++++
 src/rps/rps-test_util.c      | 73 ++------------------------------------
 src/rps/rps-test_util.h      | 21 +++++++----
 4 files changed, 105 insertions(+), 79 deletions(-)

diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index 8d2ddf7d7..3b5b1ef3e 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -20,8 +20,6 @@ pkgcfg_DATA = \
 bin_PROGRAMS = gnunet-rps
 
 gnunet_rps_SOURCES = \
-  gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
-  rps-sampler_common.h rps-sampler_common.c \
   gnunet-rps.c
 
 gnunet_rps_LDADD = \
@@ -32,6 +30,9 @@ gnunet_rps_LDADD = \
 lib_LTLIBRARIES = libgnunetrps.la
 
 libgnunetrps_la_SOURCES = \
+ gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
+  rps-test_util.h rps-test_util.c \
+  rps-sampler_common.h rps-sampler_common.c \
   rps-sampler_client.h rps-sampler_client.c \
   rps_api.c rps.h
 libgnunetrps_la_LIBADD = \
@@ -40,6 +41,8 @@ libgnunetrps_la_LIBADD = \
 libgnunetrps_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS)  $(WINFLAGS) \
   -version-info 0:0:0
+# Fix 'created both with libtool and without' error:
+libgnunetrps_la_CFLAGS = $(AM_CFLAGS)
 
 
 libexec_PROGRAMS = \
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 4c8914627..288a79e7a 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -215,6 +215,7 @@ struct PeerContext
    * it, how did we get its ID, how many pushes (in a timeinterval),
    * ...)
    */
+  uint32_t round_pull_req;
 };
 
 /**
@@ -353,6 +354,16 @@ struct Sub
   uint32_t num_observed_peers;
 
   /**
+   * @brief File name to log number of pushes per round to
+   */
+  char *file_name_push_recv;
+
+  /**
+   * @brief File name to log number of pushes per round to
+   */
+  char *file_name_pull_delays;
+
+  /**
    * @brief Multipeermap (ab-) used to count unique peer_ids
    */
   struct GNUNET_CONTAINER_MultiPeerMap *observed_unique_peers;
@@ -391,6 +402,28 @@ struct Sub
    * Identifier for the main task that runs periodically.
    */
   struct GNUNET_SCHEDULER_Task *do_round_task;
+
+  /* === stats === */
+
+  /**
+   * @brief Counts the executed rounds.
+   */
+  uint32_t num_rounds;
+
+  /**
+   * @brief This array accumulates the number of received pushes per round.
+   *
+   * Number at index i represents the number of rounds with i observed pushes.
+   */
+  uint32_t push_recv[256];
+
+  /**
+   * @brief Number of pull replies with this delay measured in rounds.
+   *
+   * Number at index i represents the number of pull replies with a delay of i
+   * rounds.
+   */
+  uint32_t pull_delays[256];
 };
 
 
@@ -2803,6 +2836,10 @@ new_sub (const struct GNUNET_HashCode *hash,
   #ifdef TO_FILE
   sub->file_name_observed_log = store_prefix_file_name (&own_identity,
                                                        "observed");
+  sub->file_name_push_recv = store_prefix_file_name (&own_identity,
+                                                     "push_recv");
+  sub->file_name_pull_delays = store_prefix_file_name (&own_identity,
+                                                       "pull_delays");
   sub->num_observed_peers = 0;
   sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1,
                                                                     GNUNET_NO);
@@ -2836,6 +2873,10 @@ new_sub (const struct GNUNET_HashCode *hash,
 static void
 destroy_sub (struct Sub *sub)
 {
+#ifdef TO_FILE
+  char push_recv_str[1536] = ""; /* 256 * 6 (1 whitespace, 1 comma, up to 4 
chars) */
+  char pull_delays_str[1536] = ""; /* 256 * 6 (1 whitespace, 1 comma, up to 4 
chars) */
+#endif /* TO_FILE */
   GNUNET_assert (NULL != sub);
   GNUNET_assert (NULL != sub->do_round_task);
   GNUNET_SCHEDULER_cancel (sub->do_round_task);
@@ -2861,6 +2902,43 @@ destroy_sub (struct Sub *sub)
 #ifdef TO_FILE
   GNUNET_free (sub->file_name_observed_log);
   sub->file_name_observed_log = NULL;
+
+  /* Write push frequencies to disk */
+  for (uint32_t i = 0; i < 256; i++)
+  {
+    char push_recv_str_tmp[8];
+    (void) snprintf (push_recv_str_tmp, 8, "%" PRIu32 ", ", sub->push_recv[i]);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Adding str `%s' to `%s'\n",
+         push_recv_str_tmp,
+         push_recv_str);
+    (void) strncat (push_recv_str,
+                    push_recv_str_tmp,
+                    1535 - strnlen (push_recv_str, 1536));
+  }
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing push stats to disk\n");
+  to_file_w_len (sub->file_name_push_recv, 1535, push_recv_str);
+  GNUNET_free (sub->file_name_push_recv);
+  sub->file_name_push_recv = NULL;
+
+  /* Write pull delays to disk */
+  for (uint32_t i = 0; i < 256; i++)
+  {
+    char pull_delays_str_tmp[8];
+    (void) snprintf (pull_delays_str_tmp, 8, "%" PRIu32 ", ", 
sub->pull_delays[i]);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Adding str `%s' to `%s'\n",
+         pull_delays_str_tmp,
+         pull_delays_str);
+    (void) strncat (pull_delays_str,
+                    pull_delays_str_tmp,
+                    1535 - strnlen (pull_delays_str, 1536));
+  }
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing pull delays to disk\n");
+  to_file_w_len (sub->file_name_pull_delays, 1535, pull_delays_str);
+  GNUNET_free (sub->file_name_pull_delays);
+  sub->file_name_pull_delays = NULL;
+
   GNUNET_CONTAINER_multipeermap_destroy (sub->observed_unique_peers);
   sub->observed_unique_peers = NULL;
 #endif /* TO_FILE */
@@ -3411,11 +3489,13 @@ handle_peer_pull_reply (void *cls,
   const struct ChannelCtx *channel_ctx = cls;
   const struct GNUNET_PeerIdentity *sender = &channel_ctx->peer_ctx->peer_id;
   const struct GNUNET_PeerIdentity *peers;
+  struct Sub *sub = channel_ctx->peer_ctx->sub;
   uint32_t i;
 #ifdef ENABLE_MALICIOUS
   struct AttackedPeer *tmp_att_peer;
 #endif /* ENABLE_MALICIOUS */
 
+  sub->pull_delays[sub->num_rounds - channel_ctx->peer_ctx->round_pull_req]++;
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REPLY (%s)\n", GNUNET_i2s 
(sender));
   if (channel_ctx->peer_ctx->sub == msub)
   {
@@ -3556,6 +3636,7 @@ send_pull_request (struct PeerContext *peer_ctx)
                                                &peer_ctx->peer_id,
                                                Peers_PULL_REPLY_PENDING));
   SET_PEER_FLAG (peer_ctx, Peers_PULL_REPLY_PENDING);
+  peer_ctx->round_pull_req = peer_ctx->sub->num_rounds;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Going to send PULL REQUEST to peer %s.\n",
@@ -3905,6 +3986,7 @@ do_round (void *cls)
   struct GNUNET_PeerIdentity *update_peer;
   struct Sub *sub = cls;
 
+  sub->num_rounds++;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Going to execute next round.\n");
   if (sub == msub)
@@ -4106,6 +4188,7 @@ do_round (void *cls)
     }
   }
   // TODO independent of that also get some peers from CADET_get_peers()?
+  sub->push_recv[CustomPeerMap_size (sub->push_map)]++;
   if (sub == msub)
   {
     GNUNET_STATISTICS_set (stats,
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 271c96648..f3367e01b 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -26,6 +26,7 @@
 
 #include "platform.h"
 #include "gnunet_util_lib.h"
+#include "rps-test_util.h"
 
 #include <inttypes.h>
 
@@ -56,76 +57,6 @@ static char buf_unaligned;
  */
 static unsigned num_bits_buf_unaligned;
 
-void
-to_file_ (const char *file_name, char *line)
-{
-  struct GNUNET_DISK_FileHandle *f;
-  char output_buffer[512];
-  size_t output_buffer_size = 512;
-  char *output_buffer_p;
-  //size_t size;
-  int size;
-  int size2;
-
-
-  if (NULL == (f = GNUNET_DISK_file_open (file_name,
-                                          GNUNET_DISK_OPEN_APPEND |
-                                          GNUNET_DISK_OPEN_WRITE |
-                                          GNUNET_DISK_OPEN_CREATE,
-                                          GNUNET_DISK_PERM_USER_READ |
-                                          GNUNET_DISK_PERM_USER_WRITE |
-                                          GNUNET_DISK_PERM_GROUP_READ |
-                                          GNUNET_DISK_PERM_OTHER_READ)))
-  {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-         "Not able to open file %s\n",
-         file_name);
-    return;
-  }
-  output_buffer_size = strlen (line) + 18;
-  if (512 < output_buffer_size)
-  {
-    output_buffer_p = GNUNET_malloc ((output_buffer_size) * sizeof (char));
-  } else {
-    output_buffer_p = &output_buffer[0];
-  }
-  size = GNUNET_snprintf (output_buffer_p,
-                          output_buffer_size,
-                          "%llu %s\n",
-                          (GNUNET_TIME_absolute_get ().abs_value_us) / 
1000000, // microsec -> sec
-                          line);
-  if (0 > size)
-  {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-         "Failed to write string to buffer (size: %i)\n",
-         size);
-    return;
-  }
-
-  size2 = GNUNET_DISK_file_write (f, output_buffer_p, size);
-  if (size != size2)
-  {
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-         "Unable to write to file! (Size: %u, size2: %u)\n",
-         size,
-         size2);
-
-    if (GNUNET_YES != GNUNET_DISK_file_close (f))
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-           "Unable to close file\n");
-
-    return;
-  }
-
-  if (512 < output_buffer_size)
-  {
-    GNUNET_free (output_buffer_p);
-  }
-
-  if (GNUNET_YES != GNUNET_DISK_file_close (f))
-    LOG (GNUNET_ERROR_TYPE_WARNING,
-         "Unable to close file\n");
-}
 
 void
 to_file_raw (const char *file_name, const char *buf, size_t size_buf)
@@ -456,7 +387,7 @@ static int ensure_folder_exist (void)
   return GNUNET_YES;
 }
 
-const char *
+char *
 store_prefix_file_name (const struct GNUNET_PeerIdentity *peer,
     const char *prefix)
 {
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index 02b4bb400..11093420e 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -26,9 +26,8 @@
 #ifndef RPS_TEST_UTIL_H
 #define RPS_TEST_UTIL_H
 
+#define TO_FILE 1
 
-void
-to_file_ (const char *file_name, char *line);
 
 char *
 auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key);
@@ -43,23 +42,33 @@ create_file (const char *name);
  * This function is used to facilitate writing important information to disk
  */
 #ifdef TO_FILE
-#  define to_file(file_name, ...) do {char tmp_buf[512];\
+#  define to_file(file_name, ...) do {char tmp_buf[512] = "";\
     int size;\
     size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
     if (0 > size)\
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
            "Failed to create tmp_buf\n");\
     else\
-      to_file_(file_name,tmp_buf);\
+      GNUNET_DISK_fn_write(file_name,tmp_buf, sizeof(tmp_buf),\
+                            GNUNET_DISK_PERM_USER_READ |\
+                            GNUNET_DISK_PERM_USER_WRITE |\
+                            GNUNET_DISK_PERM_GROUP_READ |\
+                            GNUNET_DISK_PERM_OTHER_READ);\
   } while (0);
-#  define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\
+
+#define to_file_w_len(file_name, len, ...) do {char tmp_buf[len];\
     int size;\
+    memset (tmp_buf, 0, len);\
     size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
     if (0 > size)\
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
            "Failed to create tmp_buf\n");\
     else\
-      to_file_(file_name,tmp_buf);\
+      GNUNET_DISK_fn_write(file_name,tmp_buf, len, \
+                            GNUNET_DISK_PERM_USER_READ |\
+                            GNUNET_DISK_PERM_USER_WRITE |\
+                            GNUNET_DISK_PERM_GROUP_READ |\
+                            GNUNET_DISK_PERM_OTHER_READ);\
   } while (0);
 #else /* TO_FILE */
 #  define to_file(file_name, ...)

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



reply via email to

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