gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13790 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r13790 - gnunet/src/dht
Date: Wed, 24 Nov 2010 14:42:41 +0100

Author: nevans
Date: 2010-11-24 14:42:41 +0100 (Wed, 24 Nov 2010)
New Revision: 13790

Modified:
   gnunet/src/dht/gnunet-service-dht.c
Log:
allow bucket size, kademlia replication to be set by configuration, increase 
base replication

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-11-24 12:01:52 UTC (rev 13789)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-11-24 13:42:41 UTC (rev 13790)
@@ -144,7 +144,7 @@
 /**
  * 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
@@ -309,7 +309,7 @@
    * 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;
 
@@ -882,6 +882,11 @@
 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!
  */
@@ -2730,6 +2735,11 @@
   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.
@@ -2737,7 +2747,7 @@
   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
@@ -2748,8 +2758,7 @@
    * 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,
@@ -2758,18 +2767,10 @@
 #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
@@ -4665,6 +4666,16 @@
       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"))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]