gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r13083 - gnunet/src/dht
Date: Tue, 28 Sep 2010 13:46:38 +0200

Author: nevans
Date: 2010-09-28 13:46:38 +0200 (Tue, 28 Sep 2010)
New Revision: 13083

Modified:
   gnunet/src/dht/gnunet-service-dht.c
Log:
backup previous changes before altering routing algorithm yet again

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-09-26 14:11:23 UTC (rev 13082)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-09-28 11:46:38 UTC (rev 13083)
@@ -2754,7 +2754,67 @@
     }
 }
 
+
 /**
+ * Return this peers adjusted value based on the convergence
+ * function chosen.  This is the key function for randomized
+ * routing decisions.
+ *
+ * @param target the key of the request
+ * @param peer the peer we would like the value of
+ * @param hops number of hops this message has already traveled
+ *
+ * @return GNUNET_YES if we should try to route to a closer peer
+ *         than ourselves (and one exists), GNUNET_NO if we should
+ *         choose from the set of all known peers
+ *
+ */
+unsigned long long
+route_value (const GNUNET_HashCode *target,
+             struct PeerInfo *peer,
+             unsigned int hops)
+{
+  unsigned int other_matching_bits;
+  double calc_value;
+  int curr_max_hops;
+
+  if (GNUNET_YES == use_max_hops)
+    curr_max_hops = max_hops;
+  else
+    curr_max_hops = max_hops;
+  other_matching_bits = GNUNET_CRYPTO_hash_matching_bits(target, 
&peer->id.hashPubKey);
+
+  switch (converge_option)
+    {
+      case DHT_CONVERGE_RANDOM:
+        return 1; /* Always return 1, choose equally among all peers */
+//      case DHT_CONVERGE_SIMPLE:
+//        return (unsigned long long)other_matching_bits * 
other_matching_bits; /* Always return the bit distance squared */
+      case DHT_CONVERGE_LINEAR:
+        return (unsigned long long)pow(other_matching_bits, hops * 
converge_modifier);
+      case DHT_CONVERGE_SQUARE:
+        /**
+         * Simple square based curve.
+         */
+        calc_value = (sqrt(hops) / sqrt(curr_max_hops)) * converge_modifier;
+        return (unsigned long long)pow(other_matching_bits, calc_value);
+      case DHT_CONVERGE_EXPONENTIAL:
+        /**
+         * Simple exponential curve.
+         */
+        if (converge_modifier > 0)
+          calc_value = ((converge_modifier * (hops * hops)) / (curr_max_hops * 
curr_max_hops)) / curr_max_hops;
+        else
+          calc_value = ((hops * hops) / (curr_max_hops * curr_max_hops)) / 
curr_max_hops;
+
+        return (unsigned long long)pow(other_matching_bits, calc_value);
+      default:
+        return 1;
+
+    }
+}
+
+/**
  * Select a peer from the routing table that would be a good routing
  * destination for sending a message for "target".  The resulting peer
  * must not be in the set of blocked peers.<p>
@@ -3821,7 +3881,8 @@
 
   if (get_max_send_delay().value > MAX_REQUEST_TIME.value)
   {
-    fprintf(stderr, "Sending of previous replies took far too long, backing 
off!\n");
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending of previous replies took 
too long, backing off!\n");
+    increment_stats("# route requests dropped due to high load");
     decrease_max_send_delay(get_max_send_delay());
     return GNUNET_YES;
   }




reply via email to

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