diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-23 11:48:54 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-23 11:48:54 +0000 |
commit | b37e8c1c0eda90b626076167387e2bd7cbe2d559 (patch) | |
tree | fecc3f003041902c522e61603f1c5a3b783317b9 /src/dht/gnunet-dht-driver.c | |
parent | 11489754ee4b080b31dc68471e3dc3c7ae2885ce (diff) | |
download | gnunet-b37e8c1c0eda90b626076167387e2bd7cbe2d559.tar.gz gnunet-b37e8c1c0eda90b626076167387e2bd7cbe2d559.zip |
specify total connections desired after find peer requests for dht testing, use float for better precision in replication
Diffstat (limited to 'src/dht/gnunet-dht-driver.c')
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 23 |
1 files changed, 19 insertions, 4 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 | |||
@@ -506,6 +506,12 @@ static unsigned int get_from_same; | |||
506 | static unsigned long long total_rounds; | 506 | static unsigned long long total_rounds; |
507 | 507 | ||
508 | /** | 508 | /** |
509 | * Target number of connections (will stop sending find peer | ||
510 | * messages when this number is exceeded) | ||
511 | */ | ||
512 | static unsigned long long target_total_connections; | ||
513 | |||
514 | /** | ||
509 | * Number of rounds already run | 515 | * Number of rounds already run |
510 | */ | 516 | */ |
511 | static unsigned int rounds_finished; | 517 | static unsigned int rounds_finished; |
@@ -1965,16 +1971,17 @@ count_peers_cb (void *cls, | |||
1965 | } | 1971 | } |
1966 | else | 1972 | else |
1967 | { | 1973 | { |
1968 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (double %u)\n", | 1974 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (target %u)\n", |
1969 | find_peer_context->current_peers, | 1975 | find_peer_context->current_peers, |
1970 | find_peer_context->current_peers - find_peer_context->previous_peers, | 1976 | find_peer_context->current_peers - find_peer_context->previous_peers, |
1971 | connection_estimate(num_peers, DEFAULT_BUCKET_SIZE), | 1977 | connection_estimate(num_peers, DEFAULT_BUCKET_SIZE), |
1972 | 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)); | 1978 | target_total_connections); |
1973 | 1979 | ||
1974 | if ((find_peer_context->last_sent < 8) || | 1980 | if ((find_peer_context->last_sent < 8) || |
1975 | ((find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) && | 1981 | ((find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) && |
1976 | (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && | 1982 | (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && |
1977 | (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0))) | 1983 | (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) && |
1984 | (find_peer_context->current_peers < target_total_connections))) | ||
1978 | { | 1985 | { |
1979 | GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); | 1986 | GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context); |
1980 | } | 1987 | } |
@@ -2018,7 +2025,7 @@ schedule_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContex | |||
2018 | find_peer_ctx->total = num_peers; | 2025 | find_peer_ctx->total = num_peers; |
2019 | 2026 | ||
2020 | find_peer_ctx->last_sent = find_peer_ctx->total; | 2027 | find_peer_ctx->last_sent = find_peer_ctx->total; |
2021 | 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)); | 2028 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending %u find peer messages (goal at least %u connections)\n", find_peer_ctx->total, target_total_connections); |
2022 | 2029 | ||
2023 | find_peer_offset = GNUNET_TIME_relative_divide(find_peer_delay, find_peer_ctx->total); | 2030 | find_peer_offset = GNUNET_TIME_relative_divide(find_peer_delay, find_peer_ctx->total); |
2024 | for (i = 0; i < find_peer_ctx->total; i++) | 2031 | for (i = 0; i < find_peer_ctx->total; i++) |
@@ -2959,6 +2966,14 @@ run (void *cls, | |||
2959 | total_rounds = 1; | 2966 | total_rounds = 1; |
2960 | } | 2967 | } |
2961 | 2968 | ||
2969 | if ((GNUNET_SYSERR == | ||
2970 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "target_total_connections", | ||
2971 | &target_total_connections)) || | ||
2972 | (target_total_connections == 0)) | ||
2973 | { | ||
2974 | target_total_connections = connection_estimate(num_peers, DEFAULT_BUCKET_SIZE); | ||
2975 | } | ||
2976 | |||
2962 | topology_str = NULL; | 2977 | topology_str = NULL; |
2963 | if ((GNUNET_YES == | 2978 | if ((GNUNET_YES == |
2964 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", | 2979 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", |