aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-24 13:42:41 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-24 13:42:41 +0000
commit50c90b76002c2e37e36a98ca0b2f01b1d0e8f84d (patch)
treef5d86fdb7fd701d0b45694d91d719eb5a7a94b26 /src/dht/gnunet-service-dht.c
parent1ad2882cb8779c07dc4930dca417c84f6ffeba38 (diff)
downloadgnunet-50c90b76002c2e37e36a98ca0b2f01b1d0e8f84d.tar.gz
gnunet-50c90b76002c2e37e36a98ca0b2f01b1d0e8f84d.zip
allow bucket size, kademlia replication to be set by configuration, increase base replication
Diffstat (limited to 'src/dht/gnunet-service-dht.c')
-rw-r--r--src/dht/gnunet-service-dht.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 823ad0f55..224ac6c46 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -144,7 +144,7 @@
144/** 144/**
145 * How many initial requests to send out (in true Kademlia fashion) 145 * How many initial requests to send out (in true Kademlia fashion)
146 */ 146 */
147#define DHT_KADEMLIA_REPLICATION 3 147#define DEFAULT_KADEMLIA_REPLICATION 3
148 148
149/* 149/*
150 * Default frequency for sending malicious get messages 150 * Default frequency for sending malicious get messages
@@ -309,7 +309,7 @@ struct PeerInfo
309 * be considered a really bad idea. 309 * be considered a really bad idea.
310 * FIXME: remove this value (create struct which holds 310 * FIXME: remove this value (create struct which holds
311 * a single peerinfo and the matching bits, use 311 * a single peerinfo and the matching bits, use
312 * that to pass to comparitor) 312 * that to pass to comparator)
313 */ 313 */
314 unsigned int matching_bits; 314 unsigned int matching_bits;
315 315
@@ -882,6 +882,11 @@ static unsigned long long malicious_get_frequency;
882static unsigned long long malicious_put_frequency; 882static unsigned long long malicious_put_frequency;
883 883
884/** 884/**
885 * Kademlia replication
886 */
887static unsigned long long kademlia_replication;
888
889/**
885 * Reply times for requests, if we are busy, don't send any 890 * Reply times for requests, if we are busy, don't send any
886 * more requests! 891 * more requests!
887 */ 892 */
@@ -2730,6 +2735,11 @@ get_forward_count (unsigned int hop_count, size_t target_replication)
2730 float target_value; 2735 float target_value;
2731 unsigned int diameter; 2736 unsigned int diameter;
2732 2737
2738 diameter = estimate_diameter ();
2739
2740 if (GNUNET_NO == use_max_hops)
2741 max_hops = (diameter + 1) * 2;
2742
2733 /** 2743 /**
2734 * If we are behaving in strict kademlia mode, send multiple initial requests, 2744 * If we are behaving in strict kademlia mode, send multiple initial requests,
2735 * but then only send to 1 or 0 peers based strictly on the number of hops. 2745 * but then only send to 1 or 0 peers based strictly on the number of hops.
@@ -2737,7 +2747,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication)
2737 if (strict_kademlia == GNUNET_YES) 2747 if (strict_kademlia == GNUNET_YES)
2738 { 2748 {
2739 if (hop_count == 0) 2749 if (hop_count == 0)
2740 return DHT_KADEMLIA_REPLICATION; 2750 return kademlia_replication;
2741 else if (hop_count < max_hops) 2751 else if (hop_count < max_hops)
2742 return 1; 2752 return 1;
2743 else 2753 else
@@ -2748,8 +2758,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication)
2748 * routing right? The estimation below only works if we think we have reasonably 2758 * routing right? The estimation below only works if we think we have reasonably
2749 * full routing tables, which for our RR topologies may not be the case! 2759 * full routing tables, which for our RR topologies may not be the case!
2750 */ 2760 */
2751 diameter = estimate_diameter (); 2761 if (hop_count > max_hops)
2752 if ((hop_count > (diameter + 1) * 2) && (MINIMUM_PEER_THRESHOLD < estimate_diameter() * bucket_size) && (use_max_hops == GNUNET_NO))
2753 { 2762 {
2754#if DEBUG_DHT 2763#if DEBUG_DHT
2755 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2758,18 +2767,10 @@ get_forward_count (unsigned int hop_count, size_t target_replication)
2758#endif 2767#endif
2759 return 0; 2768 return 0;
2760 } 2769 }
2761 else if (hop_count > max_hops)
2762 {
2763#if DEBUG_DHT
2764 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2765 "`%s:%s': Hop count too high (greater than max)\n", my_short_id,
2766 "DHT");
2767#endif
2768 return 0;
2769 }
2770 2770
2771 random_value = 0; 2771 random_value = 0;
2772 target_value = target_replication / ((2.0 * (diameter)) + ((float)target_replication * hop_count)); 2772 /* FIXME: we use diameter as the expected number of hops, but with randomized routing we will likely route to more! */
2773 target_value = target_replication / (diameter + ((float)target_replication * hop_count));
2773 if (target_value > 1) 2774 if (target_value > 1)
2774 return (unsigned int)target_value; 2775 return (unsigned int)target_value;
2775 else 2776 else
@@ -4665,6 +4666,16 @@ run (void *cls,
4665 dht_republish_frequency = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, temp_config_num); 4666 dht_republish_frequency = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, temp_config_num);
4666 } 4667 }
4667 4668
4669 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number(cfg, "DHT", "bucket_size", &temp_config_num))
4670 {
4671 bucket_size = (unsigned int)temp_config_num;
4672 }
4673
4674 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(cfg, "DHT", "kad_alpha", &kademlia_replication))
4675 {
4676 kademlia_replication = DEFAULT_KADEMLIA_REPLICATION;
4677 }
4678
4668 if (GNUNET_YES == 4679 if (GNUNET_YES ==
4669 GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht", 4680 GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht",
4670 "malicious_dropper")) 4681 "malicious_dropper"))