configurable connect options
authorNathan S. Evans <evans@in.tum.de>
Sat, 5 Feb 2011 14:19:42 +0000 (14:19 +0000)
committerNathan S. Evans <evans@in.tum.de>
Sat, 5 Feb 2011 14:19:42 +0000 (14:19 +0000)
12 files changed:
src/dht/gnunet-dht-driver.c
src/fs/fs_test_lib.c
src/include/gnunet_testing_lib.h
src/testing/Makefile.am
src/testing/test_testing_group.c
src/testing/test_testing_group_remote.c
src/testing/test_testing_large_topology.c
src/testing/test_testing_topology.c
src/testing/test_testing_topology_blacklist.c
src/testing/test_testing_topology_churn.c
src/testing/testing_group.c
src/topology/test_gnunet_daemon_topology.c

index 97c8ed660e41fbd5e3fe1d04d29d77edbf7a07ec..af8812d482321d497aa5590180e2ffa1199df898 100644 (file)
@@ -67,7 +67,7 @@
 #define FIND_PEER_THRESHOLD 1
 
 /* If more than this many peers are added, slow down sending */
-#define MAX_FIND_PEER_CUTOFF 4000
+#define MAX_FIND_PEER_CUTOFF 2000
 
 /* If less than this many peers are added, speed up sending */
 #define MIN_FIND_PEER_CUTOFF 500
@@ -77,7 +77,7 @@
 
 #define DEFAULT_MAX_OUTSTANDING_PUTS 10
 
-#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 196
+#define DEFAULT_MAX_OUTSTANDING_FIND_PEERS 128
 
 #define DEFAULT_FIND_PEER_OFFSET GNUNET_TIME_relative_divide (DEFAULT_FIND_PEER_DELAY, DEFAULT_MAX_OUTSTANDING_FIND_PEERS)
 
@@ -371,6 +371,16 @@ enum DHT_ROUND_TYPES
 
 /* Globals */
 
+/**
+ * How long to try to connect two peers.
+ */
+struct GNUNET_TIME_Relative connect_timeout;
+
+/**
+ * How many times to re-attempt connecting two peers.
+ */
+static unsigned long long connect_attempts;
+
 /**
  * Timeout to let all GET requests happen.
  */
@@ -435,6 +445,11 @@ static unsigned int in_dht_replication;
  */
 static unsigned long long test_data_size = DEFAULT_TEST_DATA_SIZE;
 
+/**
+ * Maximum number of concurrent connections to peers.
+ */
+static unsigned long long max_outstanding_connections;
+
 /**
  * Maximum number of concurrent PUT requests.
  */
@@ -2533,7 +2548,7 @@ topology_callback (void *cls,
       GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Conns/sec in last %d seconds: %f, Conns/sec for entire duration: %f\n", CONN_UPDATE_DURATION, (float)new_connections / duration, (float)total_connections / total_duration);
       connect_last_time = GNUNET_TIME_absolute_get();
       previous_connections = total_connections;
-
+      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "have %u total_connections\n", total_connections);
     }
   if (emsg == NULL)
     {
@@ -2631,7 +2646,11 @@ peers_started_callback (void *cls,
       if ((pg != NULL) && (peers_left == 0))
         {
           connect_start_time = GNUNET_TIME_absolute_get();
-          expected_connections = GNUNET_TESTING_connect_topology (pg, connect_topology, connect_topology_option, connect_topology_option_modifier, NULL, NULL);
+          expected_connections = GNUNET_TESTING_connect_topology(pg,
+                                                                 connect_topology, connect_topology_option,
+                                                                 connect_topology_option_modifier,
+                                                                 connect_timeout, connect_attempts,
+                                                                 NULL, NULL);
 
           peer_connect_meter = create_meter(expected_connections, "Peer connection ", GNUNET_YES);
           fprintf(stderr, "Have %d expected connections\n", expected_connections);
@@ -2767,6 +2786,34 @@ run (void *cls,
     }
   GNUNET_assert(num_peers > 0 && num_peers < ULONG_MAX);
 
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+                                             &temp_config_number))
+    connect_timeout =
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_config_number);
+  else
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+      return;
+    }
+
+
+  if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+                                               &connect_attempts))
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+      return;
+    }
+
+  if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "max_outstanding_connections",
+                                               &max_outstanding_connections))
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections");
+      return;
+    }
+
   /**
    * Get DHT specific testing options.
    */
@@ -3314,6 +3361,7 @@ run (void *cls,
   get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES);
   pg = GNUNET_TESTING_daemons_start (cfg,
                                      peers_left,
+                                     max_outstanding_connections,
                                      GNUNET_TIME_relative_multiply(seconds_per_peer_start, num_peers),
                                      &hostkey_callback, NULL,
                                      &peers_started_callback, NULL,
index fd600951cf85ebf11b5f5d969a215310d0bca316..287c0eb1c85fdc85bf7bdd554c2d19faf418dd86 100644 (file)
@@ -394,6 +394,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file,
     daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon));
   sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg,
                                              total,
+                                             total, /* Outstanding connections */
                                              timeout,
                                              NULL,
                                              NULL,
index 7830ac2262e7a17dd8fd34403cd3728d7cae7dd8..b0c43c44bfcfef5502c621c7239531ca1ef2baec 100644 (file)
@@ -559,13 +559,15 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
 
 
 /**
- * Start count gnunetd processes with the same set of transports and
+ * Start count gnunet instances with the same set of transports and
  * applications.  The port numbers (any option called "PORT") will be
  * adjusted to ensure that no two peers running on the same system
  * have the same port(s) in their respective configurations.
  *
  * @param cfg configuration template to use
  * @param total number of daemons to start
+ * @param max_concurrent_connections for testing, how many peers can
+ *                                   we connect to simultaneously
  * @param timeout total time allowed for peers to start
  * @param hostkey_callback function to call on each peers hostkey generation
  *        if NULL, peers will be started by this call, if non-null,
@@ -576,16 +578,18 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
  * @param cb_cls closure for cb
  * @param connect_callback function to call each time two hosts are connected
  * @param connect_callback_cls closure for connect_callback
- * @param hostnames linked list of hosts to use to start peers on (NULL to run on localhost only)
+ * @param hostnames linked list of host structs to use to start peers on
+ *                  (NULL to run on localhost only)
  *
  * @return NULL on error, otherwise handle to control peer group
  */
 struct GNUNET_TESTING_PeerGroup *
 GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
                               unsigned int total,
+                              unsigned int max_concurrent_connections,
                               struct GNUNET_TIME_Relative timeout,
-                              GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
-                              void *hostkey_cls,
+                              GNUNET_TESTING_NotifyHostkeyCreated
+                              hostkey_callback, void *hostkey_cls,
                               GNUNET_TESTING_NotifyDaemonRunning cb,
                               void *cb_cls,
                               GNUNET_TESTING_NotifyConnection
@@ -894,20 +898,24 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
  * @param topology which topology to connect the peers in
  * @param options options for connecting the topology
  * @param option_modifier modifier for options that take a parameter
+ * @param connect_timeout how long to wait before giving up on connecting
+ *                        two peers
+ * @param connect_attempts how many times to attempt to connect two peers
+ *                         over the connect_timeout duration
  * @param notify_callback notification to be called once all connections completed
  * @param notify_cls closure for notification callback
  *
- * @return the number of connections that will be attempted (multiple of two,
- *         each bidirectional connection counts twice!), GNUNET_SYSERR on error
- *
+ * @return the number of connections that will be attempted, GNUNET_SYSERR on error
  */
 int
 GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
                                  enum GNUNET_TESTING_Topology topology,
                                  enum GNUNET_TESTING_TopologyOption options,
                                  double option_modifier,
-                                 GNUNET_TESTING_NotifyCompletion notify_callback,
-                                 void *notify_cls);
+                                 struct GNUNET_TIME_Relative connect_timeout,
+                                 unsigned int connect_attempts,
+                                 GNUNET_TESTING_NotifyCompletion
+                                 notify_callback, void *notify_cls);
 
 /**
  * Start or stop an individual peer from the given group.
index 8084a9779855a2f650bf8a90906a3f445d0fda41..f6035ff2c44cf86d9a90544e41b6e00d83b7390e 100644 (file)
@@ -20,6 +20,8 @@ libgnunettesting_la_LIBADD = $(XLIB) \
  $(top_builddir)/src/transport/libgnunettransport.la \
  -lm \
  $(top_builddir)/src/util/libgnunetutil.la 
+noinst_PROGRAMS = ${check_PROGRAMS}
 
 check_PROGRAMS = \
  test_testing \
@@ -27,6 +29,8 @@ check_PROGRAMS = \
  test_testing_reconnect \
  test_testing_group \
  test_testing_topology_stability \
+ test_testing_large_topology_clique \
+ test_testing_topology_from_file \
  test_testing_topology_clique \
  test_testing_topology_clique_random \
  test_testing_topology_clique_minimum \
@@ -42,30 +46,35 @@ check_PROGRAMS = \
  test_testing_topology_erdos_renyi \
  test_testing_topology_internat \
  test_testing_topology_none \
- test_testing_topology_scale_free
+ test_testing_topology_scale_free \
+ test_testing_topology_connect_only \
+ test_testing_topology_2d_torus_plus
 
+# test_testing_topology_stability
 if !DISABLE_TEST_RUN 
 TESTS = \
  test_testing \
  test_testing_connect \
  test_testing_reconnect \
  test_testing_group \
- test_testing_topology_clique
-# test_testing_topology_stability \
-# test_testing_topology_clique_random \
-# test_testing_topology_clique_minimum \
-# test_testing_topology_clique_dfs \
-# test_testing_topology_churn \
-# test_testing_topology_line
-# test_testing_topology_blacklist \
-# test_testing_group_remote \
-# test_testing_topology_ring \
-# test_testing_topology_2d_torus \
-# test_testing_topology_small_world_ring \
-# test_testing_topology_small_world_torus \
-# test_testing_topology_erdos_renyi \
-# test_testing_topology_internat \
-# test_testing_topology_scale_free
+ test_testing_topology_clique \
+ test_testing_topology_from_file \
+ test_testing_topology_clique_random \
+ test_testing_topology_clique_minimum \
+ test_testing_topology_clique_dfs \
+ test_testing_topology_churn \
+ test_testing_topology_line \
+ test_testing_topology_blacklist \
+ test_testing_group_remote \
+ test_testing_topology_ring \
+ test_testing_topology_2d_torus \
+ test_testing_topology_small_world_ring \
+ test_testing_topology_small_world_torus \
+ test_testing_topology_erdos_renyi \
+ test_testing_topology_internat \
+ test_testing_topology_scale_free \
+ test_testing_topology_connect_only \
+ test_testing_topology_2d_torus_plus
 endif
 
 test_testing_SOURCES = \
@@ -80,42 +89,54 @@ test_testing_connect_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
 
-test_testing_reconnect_SOURCES = \
- test_testing_reconnect.c
-test_testing_reconnect_LDADD = \
- $(top_builddir)/src/testing/libgnunettesting.la \
- $(top_builddir)/src/util/libgnunetutil.la  
-
 test_testing_group_SOURCES = \
  test_testing_group.c
 test_testing_group_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
-
 test_testing_topology_clique_SOURCES = \
  test_testing_topology.c
 test_testing_topology_clique_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
+test_testing_topology_connect_only_SOURCES = \
+ test_testing_topology.c
+test_testing_topology_connect_only_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+test_testing_topology_from_file_SOURCES = \
+ test_testing_topology.c
+test_testing_topology_from_file_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+test_testing_large_topology_clique_SOURCES = \
+ test_testing_large_topology.c
+test_testing_large_topology_clique_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
 test_testing_topology_stability_SOURCES = \
  test_testing_topology.c
 test_testing_topology_stability_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
 test_testing_topology_blacklist_SOURCES = \
  test_testing_topology_blacklist.c
 test_testing_topology_blacklist_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la 
-
 test_testing_topology_churn_SOURCES = \
  test_testing_topology_churn.c
 test_testing_topology_churn_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la 
-
 test_testing_topology_clique_random_SOURCES = \
  test_testing_topology.c
 test_testing_topology_clique_random_LDADD = \
@@ -127,7 +148,7 @@ test_testing_topology_clique_minimum_SOURCES = \
 test_testing_topology_clique_minimum_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
 test_testing_topology_clique_dfs_SOURCES = \
  test_testing_topology.c
 test_testing_topology_clique_dfs_LDADD = \
@@ -139,7 +160,12 @@ test_testing_topology_line_SOURCES = \
 test_testing_topology_line_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
-
+   
+test_testing_reconnect_SOURCES = \
+ test_testing_reconnect.c
+test_testing_reconnect_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
 
 test_testing_group_remote_SOURCES = \
  test_testing_group_remote.c
@@ -152,25 +178,31 @@ test_testing_topology_ring_SOURCES = \
 test_testing_topology_ring_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la  
-
 test_testing_topology_2d_torus_SOURCES = \
   test_testing_topology.c
 test_testing_topology_2d_torus_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la 
-
+test_testing_topology_2d_torus_plus_SOURCES = \
+  test_testing_topology.c
+test_testing_topology_2d_torus_plus_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la 
 test_testing_topology_small_world_ring_SOURCES = \
   test_testing_topology.c
 test_testing_topology_small_world_ring_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
 test_testing_topology_small_world_torus_SOURCES = \
   test_testing_topology.c
 test_testing_topology_small_world_torus_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
 test_testing_topology_internat_SOURCES = \
   test_testing_topology.c
 test_testing_topology_internat_LDADD = \
@@ -182,7 +214,7 @@ test_testing_topology_erdos_renyi_SOURCES = \
 test_testing_topology_erdos_renyi_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
 test_testing_topology_scale_free_SOURCES = \
   test_testing_topology.c
 test_testing_topology_scale_free_LDADD = \
@@ -194,8 +226,8 @@ test_testing_topology_none_SOURCES = \
 test_testing_topology_none_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
-
-
 EXTRA_DIST = \
  test_testing_data.conf \
  test_testing_connect_peer1.conf \
@@ -214,4 +246,4 @@ EXTRA_DIST = \
  test_testing_data_topology_blacklist.conf \
  test_testing_data_topology_churn.conf \
  test_testing_data_topology_none.conf
-
index e3a3b2e630d5c97fd00e8dc56c408b448b2d6b15..1facaa63f7df6c1caa9312f4b18d8efff5602acc 100644 (file)
@@ -117,6 +117,7 @@ run (void *cls,
   peers_left = NUM_PEERS;
   pg = GNUNET_TESTING_daemons_start (cfg,
                                      peers_left,
+                                     NUM_PEERS,
                                      TIMEOUT,
                                      NULL, NULL,
                                      &my_cb, NULL, NULL, NULL, NULL);
index 5156007a65e911158e4c6baffa7c8813bde7899c..02f76f826d0d4e3e254c8db6099a9f5101bcea9b 100644 (file)
@@ -202,6 +202,7 @@ run (void *cls,
 
   peers_left = num_peers;
   pg = GNUNET_TESTING_daemons_start (cfg,
+                                     peers_left,
                                      peers_left,
                                      TIMEOUT,
                                      NULL,
index d93f11168bde45e9995b0e846f771fd5e7e131da..46626618a2b24c435d0e9bac8a4cb9127192993e 100644 (file)
@@ -40,6 +40,10 @@ static float fail_percentage = 0.05;
 
 static int ok;
 
+struct GNUNET_TIME_Relative connect_timeout;
+
+static unsigned long long connect_attempts;
+
 static unsigned long long num_peers;
 
 static unsigned int topology_connections;
@@ -775,6 +779,8 @@ connect_topology ()
         GNUNET_TESTING_connect_topology (pg, connection_topology,
                                          connect_topology_option,
                                          connect_topology_option_modifier,
+                                         connect_timeout,
+                                         connect_attempts,
                                          &topology_creation_finished, NULL);
 #if VERBOSE > 1
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1076,6 +1082,26 @@ run (void *cls,
                                              &num_peers))
     num_peers = DEFAULT_NUM_PEERS;
 
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+                                             &temp_settle))
+    connect_timeout =
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
+  else
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+      return;
+    }
+
+
+  if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+                                               &connect_attempts))
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+      return;
+    }
+
   main_cfg = cfg;
 
   peers_left = num_peers;
@@ -1104,6 +1130,7 @@ run (void *cls,
   GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
   pg = GNUNET_TESTING_daemons_start (cfg,
                                      peers_left,
+                                     peers_left / 2,
                                      timeout,
                                      &hostkey_callback, NULL,
                                      &peers_started_callback, NULL,
index 0e64f93aa5ac22af5f487432bd0b45330020fee4..0461af89ccfeb5f9e6150645fd9fc9ce4f305d68 100644 (file)
@@ -52,6 +52,10 @@ static int ok;
 
 static unsigned long long num_peers;
 
+struct GNUNET_TIME_Relative connect_timeout;
+
+static unsigned long long connect_attempts;
+
 static unsigned int topology_connections;
 
 static unsigned int total_connections;
@@ -814,6 +818,8 @@ connect_topology ()
         GNUNET_TESTING_connect_topology (pg, connection_topology,
                                          connect_topology_option,
                                          connect_topology_option_modifier,
+                                         connect_timeout,
+                                         connect_attempts,
                                          &topology_creation_finished, NULL);
 #if VERBOSE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1112,6 +1118,26 @@ run (void *cls,
     settle_time =
       GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
 
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+                                             &temp_settle))
+    connect_timeout =
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
+  else
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+      return;
+    }
+
+
+  if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+                                               &connect_attempts))
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+      return;
+    }
+
   if (GNUNET_SYSERR ==
       GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
                                              &num_peers))
@@ -1136,6 +1162,7 @@ run (void *cls,
   GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
   pg = GNUNET_TESTING_daemons_start (cfg,
                                      peers_left,
+                                     peers_left / 2,
                                      GNUNET_TIME_relative_multiply
                                      (GNUNET_TIME_UNIT_SECONDS,
                                       SECONDS_PER_PEER_START * num_peers),
index aa4a9cac7d981330240b64ab55881748a3bccbe4..2c1a8b31c8b4faa8c26bbee6774fe049bf5759d3 100644 (file)
 
 static int ok;
 
+struct GNUNET_TIME_Relative connect_timeout;
+
+static unsigned long long connect_attempts;
+
 static unsigned long long num_peers;
 
 static unsigned int total_connections;
@@ -256,6 +260,8 @@ connect_topology ()
         GNUNET_TESTING_connect_topology (pg, connection_topology,
                                          connect_topology_option,
                                          connect_topology_option_modifier,
+                                         connect_timeout,
+                                         connect_attempts,
                                          NULL, NULL);
 #if VERBOSE
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -393,6 +399,7 @@ run (void *cls,
   unsigned long long connect_topology_num;
   unsigned long long blacklist_topology_num;
   unsigned long long connect_topology_option_num;
+  unsigned long long temp_connect;
   char *connect_topology_option_modifier_string;
   ok = 1;
 
@@ -487,6 +494,26 @@ run (void *cls,
                                              &num_peers))
     num_peers = DEFAULT_NUM_PEERS;
 
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
+                                             &temp_connect))
+    connect_timeout =
+      GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_connect);
+  else
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout");
+      return;
+    }
+
+
+  if (GNUNET_OK !=
+        GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
+                                               &connect_attempts))
+    {
+      GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts");
+      return;
+    }
+
   main_cfg = cfg;
 
   GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
@@ -508,7 +535,8 @@ run (void *cls,
                                            "didn't start all daemons in reasonable amount of time!!!");
 
   pg = GNUNET_TESTING_daemons_start (cfg,
-                                     peers_left, TIMEOUT, &hostkey_callback,
+                                     peers_left, peers_left,
+                                     TIMEOUT, &hostkey_callback,
                                      NULL, &peers_started_callback, NULL,
                                      &topology_callback, NULL, NULL);
 
index 8b2a1206941495305e3aac8ecbcb213773c401dc..33f3a07378e09c3ececa8d4c3af0cef8b786161b 100644 (file)
@@ -280,6 +280,7 @@ run (void *cls,
                                            "didn't start all daemons in reasonable amount of time!!!");
 
   pg = GNUNET_TESTING_daemons_start (cfg,
+                                     peers_left,
                                      peers_left, TIMEOUT, NULL, NULL,
                                      &peers_started_callback, NULL, NULL,
                                      NULL, NULL);
index 24a98e612c583e43d132fbeba1f8ca0fa26a5378..929cc912897c3667c042817e18559bbd166bdee4 100644 (file)
  */
 #define HIGH_PORT 56000
 
-#define MAX_OUTSTANDING_CONNECTIONS 200
-
 /* Maximum time to delay connect attempt */
 #define MAX_CONNECT_DELAY 300
 
 #define MAX_CONCURRENT_HOSTKEYS 500
 
-#define MAX_CONCURRENT_STARTING 200
-
-#define MAX_CONCURRENT_SHUTDOWN 200
-
-#define CONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
-
-#define CONNECT_ATTEMPTS 12
-
 /**
  * Which list of peers do we need to modify?
  */
@@ -105,6 +95,11 @@ typedef unsigned int (*GNUNET_TESTING_ConnectionProcessor) (struct
  */
 struct ChurnContext
 {
+  /**
+   * The peergroup we are dealing with.
+   */
+  struct GNUNET_TESTING_PeerGroup *pg;
+
   /**
    * Callback used to notify of churning finished
    */
@@ -168,6 +163,7 @@ struct RestartContext
 
 struct ShutdownContext
 {
+  struct GNUNET_TESTING_PeerGroup *pg;
   /**
    * Total peers to wait for
    */
@@ -348,6 +344,11 @@ struct InternalStartContext
 
 struct ChurnRestartContext
 {
+  /**
+   * PeerGroup that we are working with.
+   */
+  struct GNUNET_TESTING_PeerGroup *pg;
+
   /**
    * Number of restarts currently in flight.
    */
@@ -493,6 +494,11 @@ struct HostData
 
 struct TopologyIterateContext
 {
+  /**
+   * The peergroup we are working with.
+   */
+  struct GNUNET_TESTING_PeerGroup *pg;
+
   /**
    * Callback for notifying of two connected peers.
    */
@@ -521,6 +527,11 @@ struct TopologyIterateContext
 
 struct StatsIterateContext
 {
+  /**
+   * The peergroup that we are dealing with.
+   */
+  struct GNUNET_TESTING_PeerGroup *pg;
+
   /**
    * Continuation to call once all stats information has been retrieved.
    */
@@ -638,6 +649,18 @@ struct GNUNET_TESTING_PeerGroup
    */
   unsigned int started;
 
+  /**
+   * Number of possible connections to peers
+   * at a time.
+   */
+  unsigned int max_outstanding_connections;
+
+  /**
+   * Number of connects we are waiting on, allows us to rate limit
+   * connect attempts.
+   */
+  unsigned int outstanding_connects;
+
   /**
    * Hostkeys loaded from a file.
    */
@@ -700,6 +723,16 @@ struct ConnectContext
    */
   struct ConnectTopologyContext *ct_ctx;
 
+  /**
+   * How long to try this connection before timing out.
+   */
+  struct GNUNET_TIME_Relative connect_timeout;
+
+  /**
+   * How many times to retry connecting the two peers.
+   */
+  unsigned int connect_attempts;
+
   /**
    * Whether this connection has been accounted for in the schedule_connect call.
    */
@@ -836,12 +869,6 @@ uid_from_hash (const GNUNET_HashCode * hash, uint32_t * uid)
 }
 #endif
 
-/**
- * Number of connects we are waiting on, allows us to rate limit
- * connect attempts.
- */
-static int outstanding_connects;
-
 /**
  * Get a topology from a string input.
  *
@@ -2806,7 +2833,7 @@ internal_connect_notify (void *cls,
 {
   struct ConnectTopologyContext *ct_ctx = cls;
   struct GNUNET_TESTING_PeerGroup *pg = ct_ctx->pg;
-  outstanding_connects--;
+  pg->outstanding_connects--;
   ct_ctx->remaining_connections--;
   if (ct_ctx->remaining_connections == 0)
     {
@@ -2833,11 +2860,12 @@ static void
 schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct ConnectContext *connect_context = cls;
+  struct GNUNET_TESTING_PeerGroup *pg = connect_context->ct_ctx->pg;
 
   if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
     return;
 
-  if (outstanding_connects > MAX_OUTSTANDING_CONNECTIONS)
+  if (pg->outstanding_connects > pg->max_outstanding_connections)
     {
 #if VERBOSE_TESTING > 2
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2855,11 +2883,11 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                   _("Creating connection, outstanding_connections is %d\n"),
                   outstanding_connects);
 #endif
-      outstanding_connects++;
+      pg->outstanding_connects++;
       GNUNET_TESTING_daemons_connect (connect_context->first,
                                       connect_context->second,
-                                      CONNECT_TIMEOUT,
-                                      CONNECT_ATTEMPTS,
+                                      connect_context->connect_timeout,
+                                      connect_context->connect_attempts,
                                       &internal_connect_notify,
                                       connect_context->ct_ctx);
       GNUNET_free (connect_context);
@@ -2970,6 +2998,8 @@ copy_allowed_topology (struct GNUNET_TESTING_PeerGroup *pg)
  * of each peer in the peer group
  *
  * @param pg the peer group we are dealing with
+ * @param connect_timeout how long try connecting two peers
+ * @param connect_attempts how many times (max) to attempt
  * @param notify_callback callback to notify when finished
  * @param notify_cls closure for notify callback
  *
@@ -2977,6 +3007,8 @@ copy_allowed_topology (struct GNUNET_TESTING_PeerGroup *pg)
  */
 static int
 connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
+                  struct GNUNET_TIME_Relative connect_timeout,
+                  unsigned int connect_attempts,
                   GNUNET_TESTING_NotifyCompletion notify_callback,
                   void *notify_cls)
 {
@@ -3030,6 +3062,8 @@ connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
           connect_context->first = pg->peers[pg_iter].daemon;
           connect_context->second = pg->peers[connection_iter->index].daemon;
           connect_context->ct_ctx = ct_ctx;
+          connect_context->connect_timeout = connect_timeout;
+          connect_context->connect_attempts = connect_attempts;
           GNUNET_SCHEDULER_add_now (&schedule_connect, connect_context);
           connection_iter = connection_iter->next;
           total++;
@@ -4010,7 +4044,7 @@ schedule_get_topology (void *cls,
   if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
     return;
 
-  if (topology_context->connected > MAX_OUTSTANDING_CONNECTIONS)
+  if (topology_context->connected > topology_context->pg->max_outstanding_connections)
     {
 #if VERBOSE_TESTING > 2
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4058,6 +4092,7 @@ GNUNET_TESTING_get_topology (struct GNUNET_TESTING_PeerGroup *pg,
   topology_context = GNUNET_malloc (sizeof (struct TopologyIterateContext));
   topology_context->topology_cb = cb;
   topology_context->cls = cls;
+  topology_context->pg = pg;
   total_count = 0;
   for (i = 0; i < pg->total; i++)
     {
@@ -4152,7 +4187,7 @@ schedule_get_statistics (void *cls,
   if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
     return;
 
-  if (stats_context->connected > MAX_OUTSTANDING_CONNECTIONS)
+  if (stats_context->connected > stats_context->pg->max_outstanding_connections)
     {
 #if VERBOSE_TESTING > 2
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4290,6 +4325,7 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
   stats_context->cont = cont;
   stats_context->proc = proc;
   stats_context->cls = cls;
+  stats_context->pg = pg;
   total_count = 0;
 
   for (i = 0; i < pg->total; i++)
@@ -4338,6 +4374,10 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
  * @param topology which topology to connect the peers in
  * @param options options for connecting the topology
  * @param option_modifier modifier for options that take a parameter
+ * @param connect_timeout how long to wait before giving up on connecting
+ *                        two peers
+ * @param connect_attempts how many times to attempt to connect two peers
+ *                         over the connect_timeout duration
  * @param notify_callback notification to be called once all connections completed
  * @param notify_cls closure for notification callback
  *
@@ -4348,6 +4388,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
                                  enum GNUNET_TESTING_Topology topology,
                                  enum GNUNET_TESTING_TopologyOption options,
                                  double option_modifier,
+                                 struct GNUNET_TIME_Relative connect_timeout,
+                                 unsigned int connect_attempts,
                                  GNUNET_TESTING_NotifyCompletion
                                  notify_callback, void *notify_cls)
 {
@@ -4480,7 +4522,7 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
       break;
     }
 
-  return connect_topology (pg, notify_callback, notify_cls);
+  return connect_topology (pg, connect_timeout, connect_attempts, notify_callback, notify_cls);
 }
 
 /**
@@ -4547,7 +4589,7 @@ internal_continue_startup (void *cls,
       return;
     }
 
-  if (internal_context->peer->pg->starting < MAX_CONCURRENT_STARTING)
+  if (internal_context->peer->pg->starting < internal_context->peer->pg->max_outstanding_connections)
     {
       internal_context->peer->pg->starting++;
       GNUNET_TESTING_daemon_continue_startup (internal_context->peer->daemon);
@@ -4630,7 +4672,7 @@ schedule_churn_restart (void *cls,
   struct ChurnRestartContext *startup_ctx =
     peer_restart_ctx->churn_restart_ctx;
 
-  if (startup_ctx->outstanding > MAX_CONCURRENT_STARTING)
+  if (startup_ctx->outstanding > startup_ctx->pg->max_outstanding_connections)
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                   (GNUNET_TIME_UNIT_MILLISECONDS, 100),
                                   &schedule_churn_restart, peer_restart_ctx);
@@ -4706,6 +4748,8 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg)
  *
  * @param cfg configuration template to use
  * @param total number of daemons to start
+ * @param max_concurrent_connections for testing, how many peers can
+ *                                   we connect to simultaneously
  * @param timeout total time allowed for peers to start
  * @param hostkey_callback function to call on each peers hostkey generation
  *        if NULL, peers will be started by this call, if non-null,
@@ -4724,6 +4768,7 @@ GNUNET_TESTING_daemons_continue_startup (struct GNUNET_TESTING_PeerGroup *pg)
 struct GNUNET_TESTING_PeerGroup *
 GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
                               unsigned int total,
+                              unsigned int max_concurrent_connections,
                               struct GNUNET_TIME_Relative timeout,
                               GNUNET_TESTING_NotifyHostkeyCreated
                               hostkey_callback, void *hostkey_cls,
@@ -4776,6 +4821,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
   pg->total = total;
   pg->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
   pg->peers = GNUNET_malloc (total * sizeof (struct PeerData));
+  pg->max_outstanding_connections = max_concurrent_connections;
   if (NULL != hostnames)
     {
       off = 0;
@@ -5176,12 +5222,12 @@ schedule_churn_shutdown_task (void *cls,
 {
   struct PeerShutdownContext *peer_shutdown_ctx = cls;
   struct ShutdownContext *shutdown_ctx;
-
+  struct ChurnContext *churn_ctx;
   GNUNET_assert (peer_shutdown_ctx != NULL);
   shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
   GNUNET_assert (shutdown_ctx != NULL);
-
-  if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)
+  churn_ctx = (struct ChurnContext *)shutdown_ctx->cb_cls;
+  if (shutdown_ctx->outstanding > churn_ctx->pg->max_outstanding_connections)
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                   (GNUNET_TIME_UNIT_MILLISECONDS, 100),
                                   &schedule_churn_shutdown_task,
@@ -5308,6 +5354,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
   churn_ctx->num_to_stop = voff;
   churn_ctx->cb = cb;
   churn_ctx->cb_cls = cb_cls;
+  churn_ctx->pg = pg;
 
   for (i = 0; i < pg->total; i++)
     {
@@ -5362,6 +5409,7 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
       churn_startup_ctx = GNUNET_malloc (sizeof (struct ChurnRestartContext));
       churn_startup_ctx->churn_ctx = churn_ctx;
       churn_startup_ctx->timeout = timeout;
+      churn_startup_ctx->pg = pg;
     }
   for (i = 0; i < von; i++)
     {
@@ -5529,7 +5577,7 @@ schedule_shutdown_task (void *cls,
   shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
   GNUNET_assert (shutdown_ctx != NULL);
 
-  if (shutdown_ctx->outstanding > MAX_CONCURRENT_SHUTDOWN)
+  if (shutdown_ctx->outstanding > shutdown_ctx->pg->max_outstanding_connections)
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
                                   (GNUNET_TIME_UNIT_MILLISECONDS, 100),
                                   &schedule_shutdown_task, peer_shutdown_ctx);
@@ -5572,6 +5620,7 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
   shutdown_ctx->cb_cls = cb_cls;
   shutdown_ctx->total_peers = pg->total;
   shutdown_ctx->timeout = timeout;
+  shutdown_ctx->pg = pg;
   /* shtudown_ctx->outstanding = 0; */
 
   for (off = 0; off < pg->total; off++)
index 529496f1157098a6fae9716b1f94ce3ea7323290..ae96b071cb5b3b3f0508ee2d7aed7dae5f364da0 100644 (file)
@@ -153,6 +153,7 @@ run (void *cls,
 #endif
   peers_left = NUM_PEERS;
   pg = GNUNET_TESTING_daemons_start (cfg,
+                                    peers_left,
                                     peers_left,
                                     TIMEOUT,
                                     NULL, NULL,