aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-06-05 23:03:08 +0000
committerJulius Bünger <buenger@mytum.de>2015-06-05 23:03:08 +0000
commitf7de514efc0292b993fe2935d7b0cb9499833ed0 (patch)
tree3f214a3d929658ed14e1e456c4a0342aec27212f /src
parenteb654238188f2224a1cf54d2d1fa4288cb57d3b4 (diff)
downloadgnunet-f7de514efc0292b993fe2935d7b0cb9499833ed0.tar.gz
gnunet-f7de514efc0292b993fe2935d7b0cb9499833ed0.zip
-writing the gossip list (view) to file
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index c77e8eddf..bc0468fd9 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -28,6 +28,7 @@
28#include "gnunet_cadet_service.h" 28#include "gnunet_cadet_service.h"
29#include "gnunet_nse_service.h" 29#include "gnunet_nse_service.h"
30#include "rps.h" 30#include "rps.h"
31#include "rps-test_util.h"
31 32
32#include "gnunet-service-rps_sampler.h" 33#include "gnunet-service-rps_sampler.h"
33 34
@@ -218,6 +219,11 @@ static struct GNUNET_PeerIdentity *gossip_list;
218//static unsigned int gossip_list_size; 219//static unsigned int gossip_list_size;
219static uint32_t gossip_list_size; 220static uint32_t gossip_list_size;
220 221
222/**
223 * Name to log view (gossip_list) to
224 */
225static char *file_name_view_log;
226
221 227
222/** 228/**
223 * The size of sampler we need to be able to satisfy the client's need of 229 * The size of sampler we need to be able to satisfy the client's need of
@@ -673,7 +679,12 @@ hist_update (void *cls, struct GNUNET_PeerIdentity *ids, uint32_t num_peers)
673 GNUNET_assert (1 == num_peers); 679 GNUNET_assert (1 == num_peers);
674 680
675 if (gossip_list_size < sampler_size_est_need) 681 if (gossip_list_size < sampler_size_est_need)
682 {
676 GNUNET_array_append (gossip_list, gossip_list_size, *ids); 683 GNUNET_array_append (gossip_list, gossip_list_size, *ids);
684 to_file (file_name_view_log,
685 "+%s\t(hist)",
686 GNUNET_i2s_full (ids));
687 }
677 688
678 if (0 < num_hist_update_tasks) 689 if (0 < num_hist_update_tasks)
679 num_hist_update_tasks--; 690 num_hist_update_tasks--;
@@ -913,7 +924,12 @@ insert_in_pull_list_scheduled (const struct PeerContext *peer_ctx)
913insert_in_gossip_list (void *cls, const struct GNUNET_PeerIdentity *peer) 924insert_in_gossip_list (void *cls, const struct GNUNET_PeerIdentity *peer)
914{ 925{
915 if (GNUNET_NO == in_arr (gossip_list, gossip_list_size, peer)) 926 if (GNUNET_NO == in_arr (gossip_list, gossip_list_size, peer))
927 {
916 GNUNET_array_append (gossip_list, gossip_list_size, *peer); 928 GNUNET_array_append (gossip_list, gossip_list_size, *peer);
929 to_file (file_name_view_log,
930 "+%s\t(ins in gossip list)",
931 GNUNET_i2s_full (peer));
932 }
917 933
918 (void) get_channel (peer_map, peer); 934 (void) get_channel (peer_map, peer);
919} 935}
@@ -1968,8 +1984,13 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1968 LOG (GNUNET_ERROR_TYPE_DEBUG, 1984 LOG (GNUNET_ERROR_TYPE_DEBUG,
1969 "Printing gossip list:\n"); 1985 "Printing gossip list:\n");
1970 for (i = 0 ; i < gossip_list_size ; i++) 1986 for (i = 0 ; i < gossip_list_size ; i++)
1987 {
1971 LOG (GNUNET_ERROR_TYPE_DEBUG, 1988 LOG (GNUNET_ERROR_TYPE_DEBUG,
1972 "\t%s\n", GNUNET_i2s (&gossip_list[i])); 1989 "\t%s\n", GNUNET_i2s (&gossip_list[i]));
1990 to_file (file_name_view_log,
1991 "=%s\t(do round)",
1992 GNUNET_i2s_full (&gossip_list[i]));
1993 }
1973 // TODO log lists, ... 1994 // TODO log lists, ...
1974 1995
1975 /* Would it make sense to have one shuffeled gossip list and then 1996 /* Would it make sense to have one shuffeled gossip list and then
@@ -2022,6 +2043,7 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2022 2043
2023 2044
2024 /* Update gossip list */ 2045 /* Update gossip list */
2046 /* TODO see how many peers are in push-/pull- list! */
2025 2047
2026 if (push_list_size <= alpha * gossip_list_size 2048 if (push_list_size <= alpha * gossip_list_size
2027 && push_list_size > 0 2049 && push_list_size > 0
@@ -2047,11 +2069,17 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2047 2069
2048 GNUNET_array_grow (gossip_list, gossip_list_size, second_border); 2070 GNUNET_array_grow (gossip_list, gossip_list_size, second_border);
2049 2071
2072 to_file (file_name_view_log,
2073 "--- emptied ---");
2074
2050 for (i = 0 ; i < first_border ; i++) 2075 for (i = 0 ; i < first_border ; i++)
2051 {/* Update gossip list with peers received through PUSHes */ 2076 {/* Update gossip list with peers received through PUSHes */
2052 r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, 2077 r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
2053 push_list_size); 2078 push_list_size);
2054 gossip_list[i] = push_list[r_index]; 2079 gossip_list[i] = push_list[r_index];
2080 to_file (file_name_view_log,
2081 "+%s't(push list)",
2082 GNUNET_i2s_full (&gossip_list[i]));
2055 // TODO change the peer_flags accordingly 2083 // TODO change the peer_flags accordingly
2056 } 2084 }
2057 2085
@@ -2060,6 +2088,9 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2060 r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, 2088 r_index = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG,
2061 pull_list_size); 2089 pull_list_size);
2062 gossip_list[i] = pull_list[r_index]; 2090 gossip_list[i] = pull_list[r_index];
2091 to_file (file_name_view_log,
2092 "+%s\t(pull list)",
2093 GNUNET_i2s_full (&gossip_list[i]));
2063 // TODO change the peer_flags accordingly 2094 // TODO change the peer_flags accordingly
2064 } 2095 }
2065 2096
@@ -2077,7 +2108,12 @@ do_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2077 rem_from_list (&peers_to_clean, &peers_to_clean_size, &gossip_list[i]); 2108 rem_from_list (&peers_to_clean, &peers_to_clean_size, &gossip_list[i]);
2078 2109
2079 for (i = 0 ; i < peers_to_clean_size ; i++) 2110 for (i = 0 ; i < peers_to_clean_size ; i++)
2111 {
2080 peer_clean (&peers_to_clean[i]); 2112 peer_clean (&peers_to_clean[i]);
2113 /* to_file (file_name_view_log,
2114 "-%s",
2115 GNUNET_i2s_full (&peers_to_clean[i])); */
2116 }
2081 2117
2082 GNUNET_free (peers_to_clean); 2118 GNUNET_free (peers_to_clean);
2083 } 2119 }
@@ -2470,6 +2506,9 @@ run (void *cls,
2470 struct GNUNET_SERVER_Handle *server, 2506 struct GNUNET_SERVER_Handle *server,
2471 const struct GNUNET_CONFIGURATION_Handle *c) 2507 const struct GNUNET_CONFIGURATION_Handle *c)
2472{ 2508{
2509 int size;
2510 int out_size;
2511
2473 // TODO check what this does -- copied from gnunet-boss 2512 // TODO check what this does -- copied from gnunet-boss
2474 // - seems to work as expected 2513 // - seems to work as expected
2475 GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL); 2514 GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL);
@@ -2511,7 +2550,26 @@ run (void *cls,
2511 2550
2512 2551
2513 gossip_list = NULL; 2552 gossip_list = NULL;
2514 2553 gossip_list_size = 0;
2554
2555 /* file_name_view_log */
2556 GNUNET_DISK_directory_create ("/tmp/rps/");
2557
2558 size = (14 + strlen (GNUNET_i2s_full (&own_identity)) + 1) * sizeof (char);
2559 file_name_view_log = GNUNET_malloc (size);
2560 out_size = GNUNET_snprintf (file_name_view_log,
2561 size,
2562 "/tmp/rps/view-%s",
2563 GNUNET_i2s_full (&own_identity));
2564 if (size < out_size ||
2565 0 > out_size)
2566 {
2567 LOG (GNUNET_ERROR_TYPE_WARNING,
2568 "Failed to write string to buffer (size: %i, out_size: %i)\n",
2569 size,
2570 out_size);
2571 }
2572
2515 2573
2516 /* connect to NSE */ 2574 /* connect to NSE */
2517 nse = GNUNET_NSE_connect (cfg, nse_callback, NULL); 2575 nse = GNUNET_NSE_connect (cfg, nse_callback, NULL);