diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-09-13 10:29:11 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-09-13 10:29:11 +0000 |
commit | d97e42d24a1e12455e5f9f25b7aeb521fd920502 (patch) | |
tree | d70dcd5ac4c6470b6ea6dd12a31b0e309b0c4ebf /src/dht/gnunet-service-dht.c | |
parent | d569c10ccf978e32bfe7363d14086afeaf0c17ce (diff) | |
download | gnunet-d97e42d24a1e12455e5f9f25b7aeb521fd920502.tar.gz gnunet-d97e42d24a1e12455e5f9f25b7aeb521fd920502.zip |
NSE also replaces max_hops
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r-- | src/dht/gnunet-service-dht.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 3ce49fda2..57ac618a0 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -23,6 +23,10 @@ | |||
23 | * @brief GNUnet DHT service | 23 | * @brief GNUnet DHT service |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | * @author Nathan Evans | 25 | * @author Nathan Evans |
26 | * | ||
27 | * TODO: | ||
28 | * - decide which 'benchmark'/test functions to keep | ||
29 | * - estiamte_diameter? | ||
26 | */ | 30 | */ |
27 | 31 | ||
28 | #include "platform.h" | 32 | #include "platform.h" |
@@ -161,12 +165,6 @@ | |||
161 | #define DHT_DEFAULT_PING_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1) | 165 | #define DHT_DEFAULT_PING_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1) |
162 | 166 | ||
163 | /** | 167 | /** |
164 | * Real maximum number of hops, at which point we refuse | ||
165 | * to forward the message. | ||
166 | */ | ||
167 | #define DEFAULT_MAX_HOPS 10 | ||
168 | |||
169 | /** | ||
170 | * How many time differences between requesting a core send and | 168 | * How many time differences between requesting a core send and |
171 | * the actual callback to remember. | 169 | * the actual callback to remember. |
172 | */ | 170 | */ |
@@ -781,21 +779,11 @@ static GNUNET_SCHEDULER_TaskIdentifier cleanup_task; | |||
781 | static unsigned int lowest_bucket; /* Initially equal to MAX_BUCKETS - 1 */ | 779 | static unsigned int lowest_bucket; /* Initially equal to MAX_BUCKETS - 1 */ |
782 | 780 | ||
783 | /** | 781 | /** |
784 | * The maximum number of hops before we stop routing messages. | ||
785 | */ | ||
786 | static unsigned long long max_hops; | ||
787 | |||
788 | /** | ||
789 | * How often to republish content we have previously stored. | 782 | * How often to republish content we have previously stored. |
790 | */ | 783 | */ |
791 | static struct GNUNET_TIME_Relative dht_republish_frequency; | 784 | static struct GNUNET_TIME_Relative dht_republish_frequency; |
792 | 785 | ||
793 | /** | 786 | /** |
794 | * GNUNET_YES to stop at max_hops, GNUNET_NO to heuristically decide when to stop forwarding. | ||
795 | */ | ||
796 | static int use_max_hops; | ||
797 | |||
798 | /** | ||
799 | * The buckets (Kademlia routing table, complete with growth). | 787 | * The buckets (Kademlia routing table, complete with growth). |
800 | * Array of size MAX_BUCKET_SIZE. | 788 | * Array of size MAX_BUCKET_SIZE. |
801 | */ | 789 | */ |
@@ -3051,9 +3039,6 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3051 | 3039 | ||
3052 | diameter = estimate_diameter (); | 3040 | diameter = estimate_diameter (); |
3053 | 3041 | ||
3054 | if (GNUNET_NO == use_max_hops) | ||
3055 | max_hops = (diameter + 1) * 2; | ||
3056 | |||
3057 | /** | 3042 | /** |
3058 | * If we are behaving in strict kademlia mode, send multiple initial requests, | 3043 | * If we are behaving in strict kademlia mode, send multiple initial requests, |
3059 | * but then only send to 1 or 0 peers based strictly on the number of hops. | 3044 | * but then only send to 1 or 0 peers based strictly on the number of hops. |
@@ -3062,7 +3047,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3062 | { | 3047 | { |
3063 | if (hop_count == 0) | 3048 | if (hop_count == 0) |
3064 | return kademlia_replication; | 3049 | return kademlia_replication; |
3065 | if (hop_count < max_hops) | 3050 | if (hop_count < log_of_network_size_estimate * 2.0) |
3066 | return 1; | 3051 | return 1; |
3067 | return 0; | 3052 | return 0; |
3068 | } | 3053 | } |
@@ -3071,7 +3056,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3071 | * routing right? The estimation below only works if we think we have reasonably | 3056 | * routing right? The estimation below only works if we think we have reasonably |
3072 | * full routing tables, which for our RR topologies may not be the case! | 3057 | * full routing tables, which for our RR topologies may not be the case! |
3073 | */ | 3058 | */ |
3074 | if (hop_count > max_hops) | 3059 | if (hop_count > log_of_network_size_estimate * 2.0) |
3075 | { | 3060 | { |
3076 | #if DEBUG_DHT | 3061 | #if DEBUG_DHT |
3077 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3062 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -5008,18 +4993,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
5008 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; | 4993 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; |
5009 | } | 4994 | } |
5010 | 4995 | ||
5011 | if (GNUNET_YES != | ||
5012 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", "MAX_HOPS", &max_hops)) | ||
5013 | { | ||
5014 | max_hops = DEFAULT_MAX_HOPS; | ||
5015 | } | ||
5016 | |||
5017 | if (GNUNET_YES == | ||
5018 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "USE_MAX_HOPS")) | ||
5019 | { | ||
5020 | use_max_hops = GNUNET_YES; | ||
5021 | } | ||
5022 | |||
5023 | if (GNUNET_YES == | 4996 | if (GNUNET_YES == |
5024 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_putter")) | 4997 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_putter")) |
5025 | { | 4998 | { |