aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-10-26 10:33:01 +0000
committerNathan S. Evans <evans@in.tum.de>2010-10-26 10:33:01 +0000
commit7be0d997e770cb7005e5fbb4e56ee7fa7495bde4 (patch)
tree5246b2eea1b432f312a5fe26f088218f512fb623 /src
parent31d3d15c36a696dea9d7589fb0a57f1225c109ba (diff)
downloadgnunet-7be0d997e770cb7005e5fbb4e56ee7fa7495bde4.tar.gz
gnunet-7be0d997e770cb7005e5fbb4e56ee7fa7495bde4.zip
binary converge option in dht, make find peer requests more likely to be sent early in testing
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-dht-driver.c3
-rw-r--r--src/dht/gnunet-service-dht.c26
2 files changed, 26 insertions, 3 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 6ebb4da8a..4424a45f3 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -1906,7 +1906,8 @@ count_peers_cb (void *cls,
1906 connection_estimate(num_peers, DEFAULT_BUCKET_SIZE), 1906 connection_estimate(num_peers, DEFAULT_BUCKET_SIZE),
1907 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)); 1907 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE));
1908 1908
1909 if ((find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) && 1909 if ((find_peer_context->last_sent > 8) &&
1910 (find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) &&
1910 (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && 1911 (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) &&
1911 (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0)) 1912 (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0))
1912 { 1913 {
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 5df8c33e3..02cf9ae90 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -198,7 +198,13 @@ enum ConvergenceOptions
198 * the algorithm to hopefully route to closer 198 * the algorithm to hopefully route to closer
199 * peers more often. 199 * peers more often.
200 */ 200 */
201 DHT_CONVERGE_RANDOM 201 DHT_CONVERGE_RANDOM,
202
203 /**
204 * Binary convergence, start routing to closest
205 * only after set number of hops.
206 */
207 DHT_CONVERGE_BINARY
202}; 208};
203 209
204/** 210/**
@@ -2886,7 +2892,7 @@ converge_distance (const GNUNET_HashCode *target,
2886{ 2892{
2887 unsigned long long ret; 2893 unsigned long long ret;
2888 unsigned int other_matching_bits; 2894 unsigned int other_matching_bits;
2889 double base_converge_modifier = .1; 2895 double base_converge_modifier = .1; /* Value that "looks" good (when plotted), have to start somewhere */
2890 double temp_modifier; 2896 double temp_modifier;
2891 double calc_value; 2897 double calc_value;
2892 double exponent; 2898 double exponent;
@@ -2931,6 +2937,16 @@ converge_distance (const GNUNET_HashCode *target,
2931 else 2937 else
2932 calc_value = (hops * hops) / curr_max_hops; 2938 calc_value = (hops * hops) / curr_max_hops;
2933 break; 2939 break;
2940 case DHT_CONVERGE_BINARY:
2941 /**
2942 * If below the cutoff, route randomly (return 1),
2943 * If above the cutoff, return the maximum possible
2944 * value first (always route to closest, because
2945 * they are sorted.)
2946 */
2947 if (hops > converge_modifier) /* Past cutoff */
2948 return ULLONG_MAX;
2949 /* Fall through */
2934 default: 2950 default:
2935 return 1; 2951 return 1;
2936 } 2952 }
@@ -4728,6 +4744,12 @@ run (void *cls,
4728 { 4744 {
4729 converge_option = DHT_CONVERGE_RANDOM; 4745 converge_option = DHT_CONVERGE_RANDOM;
4730 } 4746 }
4747 else if (GNUNET_YES ==
4748 GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht",
4749 "converge_binary"))
4750 {
4751 converge_option = DHT_CONVERGE_BINARY;
4752 }
4731 4753
4732 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "dht_testing", "converge_modifier", &converge_modifier_buf)) 4754 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "dht_testing", "converge_modifier", &converge_modifier_buf))
4733 { 4755 {