/**
* How many initial requests to send out (in true Kademlia fashion)
*/
-#define DHT_KADEMLIA_REPLICATION 3
+#define DEFAULT_KADEMLIA_REPLICATION 3
/*
* Default frequency for sending malicious get messages
* be considered a really bad idea.
* FIXME: remove this value (create struct which holds
* a single peerinfo and the matching bits, use
- * that to pass to comparitor)
+ * that to pass to comparator)
*/
unsigned int matching_bits;
*/
static unsigned long long malicious_put_frequency;
+/**
+ * Kademlia replication
+ */
+static unsigned long long kademlia_replication;
+
/**
* Reply times for requests, if we are busy, don't send any
* more requests!
float target_value;
unsigned int diameter;
+ diameter = estimate_diameter ();
+
+ if (GNUNET_NO == use_max_hops)
+ max_hops = (diameter + 1) * 2;
+
/**
* If we are behaving in strict kademlia mode, send multiple initial requests,
* but then only send to 1 or 0 peers based strictly on the number of hops.
if (strict_kademlia == GNUNET_YES)
{
if (hop_count == 0)
- return DHT_KADEMLIA_REPLICATION;
+ return kademlia_replication;
else if (hop_count < max_hops)
return 1;
else
* routing right? The estimation below only works if we think we have reasonably
* full routing tables, which for our RR topologies may not be the case!
*/
- diameter = estimate_diameter ();
- if ((hop_count > (diameter + 1) * 2) && (MINIMUM_PEER_THRESHOLD < estimate_diameter() * bucket_size) && (use_max_hops == GNUNET_NO))
+ if (hop_count > max_hops)
{
#if DEBUG_DHT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"`%s:%s': Hop count too high (est %d, lowest %d), NOT Forwarding request\n", my_short_id,
"DHT", estimate_diameter(), lowest_bucket);
-#endif
- return 0;
- }
- else if (hop_count > max_hops)
- {
-#if DEBUG_DHT
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "`%s:%s': Hop count too high (greater than max)\n", my_short_id,
- "DHT");
#endif
return 0;
}
random_value = 0;
- target_value = target_replication / ((2.0 * (diameter)) + ((float)target_replication * hop_count));
+ /* FIXME: we use diameter as the expected number of hops, but with randomized routing we will likely route to more! */
+ target_value = target_replication / (diameter + ((float)target_replication * hop_count));
if (target_value > 1)
return (unsigned int)target_value;
else
dht_republish_frequency = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, temp_config_num);
}
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "DHT", "bucket_size", &temp_config_num))
+ {
+ bucket_size = (unsigned int)temp_config_num;
+ }
+
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(cfg, "DHT", "kad_alpha", &kademlia_replication))
+ {
+ kademlia_replication = DEFAULT_KADEMLIA_REPLICATION;
+ }
+
if (GNUNET_YES ==
GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht",
"malicious_dropper"))