From b37e8c1c0eda90b626076167387e2bd7cbe2d559 Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Tue, 23 Nov 2010 11:48:54 +0000 Subject: [PATCH] specify total connections desired after find peer requests for dht testing, use float for better precision in replication --- src/dht/gnunet-dht-driver.c | 23 +++++++++++++++++++---- src/dht/gnunet-service-dht.c | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index 47493c256..0d7c5b092 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -505,6 +505,12 @@ static unsigned int get_from_same; */ static unsigned long long total_rounds; +/** + * Target number of connections (will stop sending find peer + * messages when this number is exceeded) + */ +static unsigned long long target_total_connections; + /** * Number of rounds already run */ @@ -1965,16 +1971,17 @@ count_peers_cb (void *cls, } else { - GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (double %u)\n", + GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (target %u)\n", find_peer_context->current_peers, find_peer_context->current_peers - find_peer_context->previous_peers, connection_estimate(num_peers, DEFAULT_BUCKET_SIZE), - 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)); + target_total_connections); if ((find_peer_context->last_sent < 8) || ((find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) && (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && - (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0))) + (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && + (find_peer_context->current_peers < target_total_connections))) { GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); } @@ -2018,7 +2025,7 @@ schedule_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContex find_peer_ctx->total = num_peers; find_peer_ctx->last_sent = find_peer_ctx->total; - GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending %u find peer messages (goal at least %u connections)\n", find_peer_ctx->total, connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)); + GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending %u find peer messages (goal at least %u connections)\n", find_peer_ctx->total, target_total_connections); find_peer_offset = GNUNET_TIME_relative_divide(find_peer_delay, find_peer_ctx->total); for (i = 0; i < find_peer_ctx->total; i++) @@ -2959,6 +2966,14 @@ run (void *cls, total_rounds = 1; } + if ((GNUNET_SYSERR == + GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "target_total_connections", + &target_total_connections)) || + (target_total_connections == 0)) + { + target_total_connections = connection_estimate(num_peers, DEFAULT_BUCKET_SIZE); + } + topology_str = NULL; if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 00fa62398..823ad0f55 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c @@ -2727,7 +2727,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication) { uint32_t random_value; unsigned int forward_count; - unsigned int target_value; + float target_value; unsigned int diameter; /** -- 2.25.1