diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-08-31 11:36:56 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-08-31 11:36:56 +0000 |
commit | 89330e5cc9cefb8d03b822a026aaf7f826ffba88 (patch) | |
tree | b40a6f0019c32d7e5e850dec2fc1befe0e585352 /src/dht | |
parent | 4a9e2610bde0a3f3899ec3b114e712c81978e962 (diff) | |
download | gnunet-89330e5cc9cefb8d03b822a026aaf7f826ffba88.tar.gz gnunet-89330e5cc9cefb8d03b822a026aaf7f826ffba88.zip |
attempt to equalize find peer activity for kademlia and gnunet routing
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index dd2feac45..16f7df42b 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -24,7 +24,7 @@ | |||
24 | * are reported, fine grained results (if requested) are | 24 | * are reported, fine grained results (if requested) are |
25 | * logged to a (mysql) database, or to file. | 25 | * logged to a (mysql) database, or to file. |
26 | * | 26 | * |
27 | * FIXME: Do churn, enable malicious peers! | 27 | * FIXME: Do churn! |
28 | */ | 28 | */ |
29 | #include "platform.h" | 29 | #include "platform.h" |
30 | #include "gnunet_testing_lib.h" | 30 | #include "gnunet_testing_lib.h" |
@@ -65,7 +65,7 @@ | |||
65 | 65 | ||
66 | #define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 10 | 66 | #define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 10 |
67 | 67 | ||
68 | #define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_SECONDS_PER_PEER_START, DEFAULT_MAX_OUTSTANDING_FIND_PEERS) | 68 | #define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_FIND_PEER_DELAY, DEFAULT_MAX_OUTSTANDING_FIND_PEERS) |
69 | 69 | ||
70 | #define DEFAULT_MAX_OUTSTANDING_GETS 10 | 70 | #define DEFAULT_MAX_OUTSTANDING_GETS 10 |
71 | 71 | ||
@@ -269,6 +269,8 @@ static struct GNUNET_TIME_Relative put_delay; | |||
269 | 269 | ||
270 | static struct GNUNET_TIME_Relative find_peer_delay; | 270 | static struct GNUNET_TIME_Relative find_peer_delay; |
271 | 271 | ||
272 | static struct GNUNET_TIME_Relative find_peer_offset; | ||
273 | |||
272 | static struct GNUNET_TIME_Relative seconds_per_peer_start; | 274 | static struct GNUNET_TIME_Relative seconds_per_peer_start; |
273 | 275 | ||
274 | static int do_find_peer; | 276 | static int do_find_peer; |
@@ -1107,7 +1109,6 @@ void count_peers_cb (void *cls, | |||
1107 | (find_peer_context->current_peers < connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && | 1109 | (find_peer_context->current_peers < connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) && |
1108 | (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0)) | 1110 | (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0)) |
1109 | { | 1111 | { |
1110 | fprintf(stderr, "Scheduling another round of find peer requests.\n"); | ||
1111 | GNUNET_SCHEDULER_add_now(sched, schedule_find_peer_requests, find_peer_context); | 1112 | GNUNET_SCHEDULER_add_now(sched, schedule_find_peer_requests, find_peer_context); |
1112 | } | 1113 | } |
1113 | else | 1114 | else |
@@ -1138,7 +1139,6 @@ decrement_find_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
1138 | GNUNET_assert(test_find_peer->find_peer_context->outstanding > 0); | 1139 | GNUNET_assert(test_find_peer->find_peer_context->outstanding > 0); |
1139 | test_find_peer->find_peer_context->outstanding--; | 1140 | test_find_peer->find_peer_context->outstanding--; |
1140 | test_find_peer->find_peer_context->total--; | 1141 | test_find_peer->find_peer_context->total--; |
1141 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%d find_peers remaining\n", test_find_peer->find_peer_context->total); | ||
1142 | if ((0 == test_find_peer->find_peer_context->total) && | 1142 | if ((0 == test_find_peer->find_peer_context->total) && |
1143 | (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).value > 0)) | 1143 | (GNUNET_TIME_absolute_get_remaining(test_find_peer->find_peer_context->endtime).value > 0)) |
1144 | { | 1144 | { |
@@ -1183,7 +1183,6 @@ send_find_peer_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t | |||
1183 | 1183 | ||
1184 | test_find_peer->dht_handle = GNUNET_DHT_connect(sched, test_find_peer->daemon->cfg, 1); | 1184 | test_find_peer->dht_handle = GNUNET_DHT_connect(sched, test_find_peer->daemon->cfg, 1); |
1185 | GNUNET_assert(test_find_peer->dht_handle != NULL); | 1185 | GNUNET_assert(test_find_peer->dht_handle != NULL); |
1186 | fprintf(stderr, "calling GNUNET_DHT_find_peers\n"); | ||
1187 | GNUNET_DHT_find_peers (test_find_peer->dht_handle, | 1186 | GNUNET_DHT_find_peers (test_find_peer->dht_handle, |
1188 | &handle_find_peer_sent, test_find_peer); | 1187 | &handle_find_peer_sent, test_find_peer); |
1189 | } | 1188 | } |
@@ -1897,6 +1896,25 @@ run (void *cls, | |||
1897 | else | 1896 | else |
1898 | do_find_peer = GNUNET_YES; | 1897 | do_find_peer = GNUNET_YES; |
1899 | 1898 | ||
1899 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | ||
1900 | "FIND_PEER_DELAY", | ||
1901 | &temp_config_number)) | ||
1902 | { | ||
1903 | find_peer_delay = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_config_number); | ||
1904 | } | ||
1905 | else | ||
1906 | find_peer_delay = DEFAULT_FIND_PEER_DELAY; | ||
1907 | |||
1908 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | ||
1909 | "OUTSTANDING_FIND_PEERS", | ||
1910 | &max_outstanding_find_peers)) | ||
1911 | max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; | ||
1912 | |||
1913 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht", "strict_kademlia")) | ||
1914 | max_outstanding_find_peers = max_outstanding_find_peers * 3; | ||
1915 | |||
1916 | find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, max_outstanding_find_peers); | ||
1917 | |||
1900 | topology_str = NULL; | 1918 | topology_str = NULL; |
1901 | if ((GNUNET_YES == | 1919 | if ((GNUNET_YES == |
1902 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", | 1920 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", |