specify total connections desired after find peer requests for dht testing, use float...
authorNathan S. Evans <evans@in.tum.de>
Tue, 23 Nov 2010 11:48:54 +0000 (11:48 +0000)
committerNathan S. Evans <evans@in.tum.de>
Tue, 23 Nov 2010 11:48:54 +0000 (11:48 +0000)
src/dht/gnunet-dht-driver.c
src/dht/gnunet-service-dht.c

index 47493c256ebb44e0b48f77ee14ff897627508de0..0d7c5b09212204cac6b81454d077a5e6f7ac8392 100644 (file)
@@ -505,6 +505,12 @@ static unsigned int get_from_same;
  */
 static unsigned long long total_rounds;
 
+/**
+ * Target number of connections (will stop sending find peer
+ * messages when this number is exceeded)
+ */
+static unsigned long long target_total_connections;
+
 /**
  * Number of rounds already run
  */
@@ -1965,16 +1971,17 @@ count_peers_cb (void *cls,
     }
   else
     {
-      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (double %u)\n",
+      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Peer count finished (%u connections), %u new peers, connection estimate %u (target %u)\n",
                                             find_peer_context->current_peers,
                                             find_peer_context->current_peers - find_peer_context->previous_peers,
                                             connection_estimate(num_peers, DEFAULT_BUCKET_SIZE),
-                                            2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE));
+                                            target_total_connections);
 
       if ((find_peer_context->last_sent < 8) ||
           ((find_peer_context->current_peers - find_peer_context->previous_peers > FIND_PEER_THRESHOLD) &&
           (find_peer_context->current_peers < 2 * connection_estimate(num_peers, DEFAULT_BUCKET_SIZE)) &&
-          (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0)))
+          (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).rel_value > 0) &&
+          (find_peer_context->current_peers < target_total_connections)))
         {
           GNUNET_SCHEDULER_add_now(&schedule_find_peer_requests, find_peer_context);
         }
@@ -2018,7 +2025,7 @@ schedule_find_peer_requests (void *cls, const struct GNUNET_SCHEDULER_TaskContex
     find_peer_ctx->total = num_peers;
 
   find_peer_ctx->last_sent = find_peer_ctx->total;
-  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending %u find peer messages (goal at least %u connections)\n", find_peer_ctx->total, connection_estimate(num_peers, DEFAULT_BUCKET_SIZE));
+  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Sending %u find peer messages (goal at least %u connections)\n", find_peer_ctx->total, target_total_connections);
 
   find_peer_offset = GNUNET_TIME_relative_divide(find_peer_delay, find_peer_ctx->total);
   for (i = 0; i < find_peer_ctx->total; i++)
@@ -2959,6 +2966,14 @@ run (void *cls,
       total_rounds = 1;
     }
 
+  if ((GNUNET_SYSERR ==
+        GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "target_total_connections",
+                                               &target_total_connections)) ||
+                                               (target_total_connections == 0))
+    {
+      target_total_connections = connection_estimate(num_peers, DEFAULT_BUCKET_SIZE);
+    }
+
   topology_str = NULL;
   if ((GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology",
index 00fa62398963bbde15ecd34a0a8e729d431e4c14..823ad0f55f82eb676bd23ae0e53b80a12d746118 100644 (file)
@@ -2727,7 +2727,7 @@ get_forward_count (unsigned int hop_count, size_t target_replication)
 {
   uint32_t random_value;
   unsigned int forward_count;
-  unsigned int target_value;
+  float target_value;
   unsigned int diameter;
 
   /**