aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c83
1 files changed, 83 insertions, 0 deletions
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
215 * it, how did we get its ID, how many pushes (in a timeinterval), 215 * it, how did we get its ID, how many pushes (in a timeinterval),
216 * ...) 216 * ...)
217 */ 217 */
218 uint32_t round_pull_req;
218}; 219};
219 220
220/** 221/**
@@ -353,6 +354,16 @@ struct Sub
353 uint32_t num_observed_peers; 354 uint32_t num_observed_peers;
354 355
355 /** 356 /**
357 * @brief File name to log number of pushes per round to
358 */
359 char *file_name_push_recv;
360
361 /**
362 * @brief File name to log number of pushes per round to
363 */
364 char *file_name_pull_delays;
365
366 /**
356 * @brief Multipeermap (ab-) used to count unique peer_ids 367 * @brief Multipeermap (ab-) used to count unique peer_ids
357 */ 368 */
358 struct GNUNET_CONTAINER_MultiPeerMap *observed_unique_peers; 369 struct GNUNET_CONTAINER_MultiPeerMap *observed_unique_peers;
@@ -391,6 +402,28 @@ struct Sub
391 * Identifier for the main task that runs periodically. 402 * Identifier for the main task that runs periodically.
392 */ 403 */
393 struct GNUNET_SCHEDULER_Task *do_round_task; 404 struct GNUNET_SCHEDULER_Task *do_round_task;
405
406 /* === stats === */
407
408 /**
409 * @brief Counts the executed rounds.
410 */
411 uint32_t num_rounds;
412
413 /**
414 * @brief This array accumulates the number of received pushes per round.
415 *
416 * Number at index i represents the number of rounds with i observed pushes.
417 */
418 uint32_t push_recv[256];
419
420 /**
421 * @brief Number of pull replies with this delay measured in rounds.
422 *
423 * Number at index i represents the number of pull replies with a delay of i
424 * rounds.
425 */
426 uint32_t pull_delays[256];
394}; 427};
395 428
396 429
@@ -2803,6 +2836,10 @@ new_sub (const struct GNUNET_HashCode *hash,
2803 #ifdef TO_FILE 2836 #ifdef TO_FILE
2804 sub->file_name_observed_log = store_prefix_file_name (&own_identity, 2837 sub->file_name_observed_log = store_prefix_file_name (&own_identity,
2805 "observed"); 2838 "observed");
2839 sub->file_name_push_recv = store_prefix_file_name (&own_identity,
2840 "push_recv");
2841 sub->file_name_pull_delays = store_prefix_file_name (&own_identity,
2842 "pull_delays");
2806 sub->num_observed_peers = 0; 2843 sub->num_observed_peers = 0;
2807 sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1, 2844 sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1,
2808 GNUNET_NO); 2845 GNUNET_NO);
@@ -2836,6 +2873,10 @@ new_sub (const struct GNUNET_HashCode *hash,
2836static void 2873static void
2837destroy_sub (struct Sub *sub) 2874destroy_sub (struct Sub *sub)
2838{ 2875{
2876#ifdef TO_FILE
2877 char push_recv_str[1536] = ""; /* 256 * 6 (1 whitespace, 1 comma, up to 4 chars) */
2878 char pull_delays_str[1536] = ""; /* 256 * 6 (1 whitespace, 1 comma, up to 4 chars) */
2879#endif /* TO_FILE */
2839 GNUNET_assert (NULL != sub); 2880 GNUNET_assert (NULL != sub);
2840 GNUNET_assert (NULL != sub->do_round_task); 2881 GNUNET_assert (NULL != sub->do_round_task);
2841 GNUNET_SCHEDULER_cancel (sub->do_round_task); 2882 GNUNET_SCHEDULER_cancel (sub->do_round_task);
@@ -2861,6 +2902,43 @@ destroy_sub (struct Sub *sub)
2861#ifdef TO_FILE 2902#ifdef TO_FILE
2862 GNUNET_free (sub->file_name_observed_log); 2903 GNUNET_free (sub->file_name_observed_log);
2863 sub->file_name_observed_log = NULL; 2904 sub->file_name_observed_log = NULL;
2905
2906 /* Write push frequencies to disk */
2907 for (uint32_t i = 0; i < 256; i++)
2908 {
2909 char push_recv_str_tmp[8];
2910 (void) snprintf (push_recv_str_tmp, 8, "%" PRIu32 ", ", sub->push_recv[i]);
2911 LOG (GNUNET_ERROR_TYPE_DEBUG,
2912 "Adding str `%s' to `%s'\n",
2913 push_recv_str_tmp,
2914 push_recv_str);
2915 (void) strncat (push_recv_str,
2916 push_recv_str_tmp,
2917 1535 - strnlen (push_recv_str, 1536));
2918 }
2919 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing push stats to disk\n");
2920 to_file_w_len (sub->file_name_push_recv, 1535, push_recv_str);
2921 GNUNET_free (sub->file_name_push_recv);
2922 sub->file_name_push_recv = NULL;
2923
2924 /* Write pull delays to disk */
2925 for (uint32_t i = 0; i < 256; i++)
2926 {
2927 char pull_delays_str_tmp[8];
2928 (void) snprintf (pull_delays_str_tmp, 8, "%" PRIu32 ", ", sub->pull_delays[i]);
2929 LOG (GNUNET_ERROR_TYPE_DEBUG,
2930 "Adding str `%s' to `%s'\n",
2931 pull_delays_str_tmp,
2932 pull_delays_str);
2933 (void) strncat (pull_delays_str,
2934 pull_delays_str_tmp,
2935 1535 - strnlen (pull_delays_str, 1536));
2936 }
2937 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing pull delays to disk\n");
2938 to_file_w_len (sub->file_name_pull_delays, 1535, pull_delays_str);
2939 GNUNET_free (sub->file_name_pull_delays);
2940 sub->file_name_pull_delays = NULL;
2941
2864 GNUNET_CONTAINER_multipeermap_destroy (sub->observed_unique_peers); 2942 GNUNET_CONTAINER_multipeermap_destroy (sub->observed_unique_peers);
2865 sub->observed_unique_peers = NULL; 2943 sub->observed_unique_peers = NULL;
2866#endif /* TO_FILE */ 2944#endif /* TO_FILE */
@@ -3411,11 +3489,13 @@ handle_peer_pull_reply (void *cls,
3411 const struct ChannelCtx *channel_ctx = cls; 3489 const struct ChannelCtx *channel_ctx = cls;
3412 const struct GNUNET_PeerIdentity *sender = &channel_ctx->peer_ctx->peer_id; 3490 const struct GNUNET_PeerIdentity *sender = &channel_ctx->peer_ctx->peer_id;
3413 const struct GNUNET_PeerIdentity *peers; 3491 const struct GNUNET_PeerIdentity *peers;
3492 struct Sub *sub = channel_ctx->peer_ctx->sub;
3414 uint32_t i; 3493 uint32_t i;
3415#ifdef ENABLE_MALICIOUS 3494#ifdef ENABLE_MALICIOUS
3416 struct AttackedPeer *tmp_att_peer; 3495 struct AttackedPeer *tmp_att_peer;
3417#endif /* ENABLE_MALICIOUS */ 3496#endif /* ENABLE_MALICIOUS */
3418 3497
3498 sub->pull_delays[sub->num_rounds - channel_ctx->peer_ctx->round_pull_req]++;
3419 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REPLY (%s)\n", GNUNET_i2s (sender)); 3499 LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REPLY (%s)\n", GNUNET_i2s (sender));
3420 if (channel_ctx->peer_ctx->sub == msub) 3500 if (channel_ctx->peer_ctx->sub == msub)
3421 { 3501 {
@@ -3556,6 +3636,7 @@ send_pull_request (struct PeerContext *peer_ctx)
3556 &peer_ctx->peer_id, 3636 &peer_ctx->peer_id,
3557 Peers_PULL_REPLY_PENDING)); 3637 Peers_PULL_REPLY_PENDING));
3558 SET_PEER_FLAG (peer_ctx, Peers_PULL_REPLY_PENDING); 3638 SET_PEER_FLAG (peer_ctx, Peers_PULL_REPLY_PENDING);
3639 peer_ctx->round_pull_req = peer_ctx->sub->num_rounds;
3559 3640
3560 LOG (GNUNET_ERROR_TYPE_DEBUG, 3641 LOG (GNUNET_ERROR_TYPE_DEBUG,
3561 "Going to send PULL REQUEST to peer %s.\n", 3642 "Going to send PULL REQUEST to peer %s.\n",
@@ -3905,6 +3986,7 @@ do_round (void *cls)
3905 struct GNUNET_PeerIdentity *update_peer; 3986 struct GNUNET_PeerIdentity *update_peer;
3906 struct Sub *sub = cls; 3987 struct Sub *sub = cls;
3907 3988
3989 sub->num_rounds++;
3908 LOG (GNUNET_ERROR_TYPE_DEBUG, 3990 LOG (GNUNET_ERROR_TYPE_DEBUG,
3909 "Going to execute next round.\n"); 3991 "Going to execute next round.\n");
3910 if (sub == msub) 3992 if (sub == msub)
@@ -4106,6 +4188,7 @@ do_round (void *cls)
4106 } 4188 }
4107 } 4189 }
4108 // TODO independent of that also get some peers from CADET_get_peers()? 4190 // TODO independent of that also get some peers from CADET_get_peers()?
4191 sub->push_recv[CustomPeerMap_size (sub->push_map)]++;
4109 if (sub == msub) 4192 if (sub == msub)
4110 { 4193 {
4111 GNUNET_STATISTICS_set (stats, 4194 GNUNET_STATISTICS_set (stats,