some dht changes
authorNathan S. Evans <evans@in.tum.de>
Fri, 30 Jul 2010 14:41:29 +0000 (14:41 +0000)
committerNathan S. Evans <evans@in.tum.de>
Fri, 30 Jul 2010 14:41:29 +0000 (14:41 +0000)
src/dht/Makefile.am
src/dht/dht_api.c
src/dht/dhtlog.c
src/dht/gnunet-dht-driver.c
src/dht/gnunet-service-dht.c
src/dht/plugin_dhtlog_mysql_dump.c
src/dht/test_dht_multipeer_data.conf
src/dht/test_dhtlog_data.conf

index b96ce45e716055bfe2f1c3dae1c7b5e5c42bf005..9c9ce7cad133f19a186e9eee27a390541d59cd33 100644 (file)
@@ -22,7 +22,18 @@ lib_LTLIBRARIES = libgnunetdht.la \
  libgnunetdhtlog.la
 
 plugin_LTLIBRARIES = \
- libgnunet_plugin_dhtlog_dummy.la $(MYSQL_PLUGIN)
+ libgnunet_plugin_dhtlog_dummy.la $(MYSQL_PLUGIN) \
+ libgnunet_plugin_dhtlog_mysql_dump.la 
+
+if HAVE_MYSQL
+libgnunet_plugin_dhtlog_mysql_la_SOURCES = \
+  plugin_dhtlog_mysql.c
+libgnunet_plugin_dhtlog_mysql_la_LIBADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(XLIB)
+libgnunet_plugin_dhtlog_mysql_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient $(ZLIB_LNK)
+endif 
 
 libgnunet_plugin_dhtlog_dummy_la_SOURCES = \
   plugin_dhtlog_dummy.c
@@ -31,6 +42,14 @@ libgnunet_plugin_dhtlog_dummy_la_LIBADD = \
   $(XLIB)
 libgnunet_plugin_dhtlog_dummy_la_LDFLAGS = \
  $(GN_PLUGIN_LDFLAGS)
+libgnunet_plugin_dhtlog_mysql_dump_la_SOURCES = \
+  plugin_dhtlog_mysql_dump.c
+libgnunet_plugin_dhtlog_mysql_dump_la_LIBADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(XLIB)
+libgnunet_plugin_dhtlog_mysql_dump_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
 
 libgnunetdhtlog_la_SOURCES = \
   dhtlog.c dhtlog.h
@@ -40,18 +59,6 @@ libgnunetdhtlog_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS) $(WINFLAGS) \
   -version-info 0:0:0
 
-if HAVE_MYSQL
-libgnunet_plugin_dhtlog_mysql_la_SOURCES = \
-  plugin_dhtlog_mysql.c
-libgnunet_plugin_dhtlog_mysql_la_LIBADD = \
-  $(top_builddir)/src/util/libgnunetutil.la \
-  $(XLIB)
-libgnunet_plugin_dhtlog_mysql_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS) $(MYSQL_LDFLAGS) -lmysqlclient $(ZLIB_LNK)
-libgnunet_plugin_dhtlog_mysql_la_CPPFLAGS = \
- $(MYSQL_CPPFLAGS) 
-endif 
-
 libgnunetdht_la_SOURCES = \
   dht_api.c dht.h
 libgnunetdht_la_LIBADD = \
@@ -75,7 +82,7 @@ bin_PROGRAMS = $(STUD_PROGS) \
  gnunet-dht-put 
 
 noinst_PROGRAMS = \
- gnunet-dht-driver
+ gnunet-dht-driver ${check_PROGRAMS}
 
 gnunet_service_dht_SOURCES = \
  gnunet-service-dht.c         
index 2558f3a7d8670138285388fc0fc0472c316c8858..58493dd0fe1da020699282d62dab488bbbd94fa1 100644 (file)
@@ -365,6 +365,7 @@ finish (struct GNUNET_DHT_Handle *handle, int code)
                                            GNUNET_SCHEDULER_REASON_PREREQ_DONE);
     }
 
+  GNUNET_assert(handle->th == NULL);
   if (pos->unique_id == 0)
     GNUNET_free(pos->msg);
   GNUNET_free (pos);
@@ -570,6 +571,7 @@ service_message_handler (void *cls,
                                               handle->cfg);
       if (handle->current != NULL)
         {
+          handle->th = NULL;
           finish(handle, GNUNET_SYSERR); /* If there was a current message, kill it! */
         }
 #if RETRANSMIT
@@ -686,7 +688,7 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
               "`%s': Called GNUNET_DHT_disconnect\n", "DHT API");
 #endif
   GNUNET_assert (handle != NULL);
-  if (handle->th != NULL)       /* We have a live transmit request in the Aether */
+  if (handle->th != NULL)       /* We have a live transmit request */
     {
       GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
       handle->th = NULL;
@@ -1176,6 +1178,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
 
   if ((handle->current != NULL) && (handle->retransmit_stage != DHT_RETRANSMITTING))
     {
+      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "handle->current is not null!\n");
       if (cont != NULL)
         {
           GNUNET_SCHEDULER_add_continuation (handle->sched, cont, cont_cls,
@@ -1204,6 +1207,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
 
   if (put_route == NULL) /* Route start failed! */
     {
+      GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "route start for PUT failed!\n");
       if (cont != NULL)
         {
           GNUNET_SCHEDULER_add_continuation (handle->sched, cont, cont_cls,
index 37e9c2d95c13de5a46b48cb433ee4c6c233e0c50..ebc7075dab743c2e699285ece8166f563e6c34e5 100644 (file)
@@ -65,6 +65,7 @@ GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c)
                   _("Failed to load dhtlog plugin for `%s'\n"), plugin_name);
       GNUNET_free (plugin_name);
       GNUNET_free (plugin);
+      return NULL;
     }
 
   api = plugin->dhtlog_api;
index 2081df9709e81d9ad809f716f93b6c8e48db8a0a..dd2ffe1b30b8970a5a79ea515ded9e12d385b1de 100644 (file)
  * @brief Driver for setting up a group of gnunet peers and
  *        then issuing GETS and PUTS on the DHT.  Coarse results
  *        are reported, fine grained results (if requested) are
- *        logged to a (mysql) database.
- *
- *  TODO: Add multiple database support; alternatively, dump
- *        sql readable (or easily transformed) logs to disk
- *        for reassembly later.  This could remove the mysql
- *        server as a bottleneck during testing.
+ *        logged to a (mysql) database, or to file.
  */
 #include "platform.h"
 #include "gnunet_testing_lib.h"
@@ -36,7 +31,7 @@
 #include "dhtlog.h"
 
 /* DEFINES */
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
 
 /* Timeout for entire driver to run */
 #define DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
@@ -405,6 +400,7 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 static void
 finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Ending test normally!\n", (char *)cls);
   GNUNET_assert (pg != NULL);
   struct TestPutContext *test_put = all_puts;
   struct TestGetContext *test_get = all_gets;
@@ -433,17 +429,20 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 
   /* FIXME: optionally get stats for dropped messages, etc. */
   if (dhtlog_handle != NULL)
-    dhtlog_handle->update_trial (trialuid, 0, 0, 0);
+    {
+      fprintf(stderr, "Update trial endtime\n");
+      dhtlog_handle->update_trial (trialuid, 0, 0, 0);
+    }
 
   if (hostkey_meter != NULL)
     free_meter(hostkey_meter);
-  if (hostkey_meter != NULL)
+  if (peer_start_meter != NULL)
     free_meter(peer_start_meter);
-  if (hostkey_meter != NULL)
+  if (peer_connect_meter != NULL)
     free_meter(peer_connect_meter);
-  if (hostkey_meter != NULL)
+  if (put_meter != NULL)
     free_meter(put_meter);
-  if (hostkey_meter != NULL)
+  if (get_meter != NULL)
     free_meter(get_meter);
 
   ok = 0;
@@ -458,7 +457,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 static void
 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failing test with error: `%s'!\n", (char *)cls);
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failing test with error: `%s'!\n", (char *)cls);
 
   struct TestPutContext *test_put = all_puts;
   struct TestGetContext *test_get = all_gets;
@@ -485,15 +484,22 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
 
   GNUNET_TESTING_daemons_stop (pg, DEFAULT_TIMEOUT, &shutdown_callback, NULL);
 
+  /* FIXME: optionally get stats for dropped messages, etc. */
+  if (dhtlog_handle != NULL)
+    {
+      fprintf(stderr, "Update trial endtime\n");
+      dhtlog_handle->update_trial (trialuid, 0, 0, 0);
+    }
+
   if (hostkey_meter != NULL)
     free_meter(hostkey_meter);
-  if (hostkey_meter != NULL)
+  if (peer_start_meter != NULL)
     free_meter(peer_start_meter);
-  if (hostkey_meter != NULL)
+  if (peer_connect_meter != NULL)
     free_meter(peer_connect_meter);
-  if (hostkey_meter != NULL)
+  if (put_meter != NULL)
     free_meter(put_meter);
-  if (hostkey_meter != NULL)
+  if (get_meter != NULL)
     free_meter(get_meter);
 
   ok = 1;
@@ -613,6 +619,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
     }
   if (test_get == NULL)
     return; /* End of the list */
+
   memset(data, test_get->uid, sizeof(data));
   GNUNET_CRYPTO_hash(data, test_data_size, &key);
 
@@ -654,6 +661,9 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
   outstanding_puts--;
   puts_completed++;
 
+  if (tc->reason == GNUNET_SCHEDULER_REASON_TIMEOUT)
+    fprintf(stderr, "PUT Request failed!\n");
+
   GNUNET_SCHEDULER_cancel(sched, test_put->disconnect_task);
   test_put->disconnect_task = GNUNET_SCHEDULER_add_now(sched, &put_disconnect_task, test_put);
   if (GNUNET_YES == update_meter(put_meter))
@@ -662,7 +672,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
       GNUNET_SCHEDULER_cancel (sched, die_task);
       die_task = GNUNET_SCHEDULER_add_delayed (sched, all_get_timeout,
                                                &end_badly, "from do gets");
-      GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100), &do_get, all_gets);
+      GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &do_get, all_gets);
       return;
     }
 }
@@ -749,7 +759,7 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
       all_gets = test_get;
     }
 
-  GNUNET_SCHEDULER_cancel (sched, die_task);
+  /*GNUNET_SCHEDULER_cancel (sched, die_task);*/
   die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, num_puts * 2),
                                            &end_badly, "from do puts");
   GNUNET_SCHEDULER_add_now (sched, &do_put, all_puts);
@@ -805,8 +815,8 @@ topology_callback (void *cls,
         dhtlog_handle->update_connections (trialuid, total_connections);
 
       GNUNET_SCHEDULER_cancel (sched, die_task);
-      die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT,
-                                               &end_badly, "from setup puts/gets");
+      /*die_task = GNUNET_SCHEDULER_add_delayed (sched, DEFAULT_TIMEOUT,
+                                               &end_badly, "from setup puts/gets");*/
 
       GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &setup_puts_and_gets, NULL);
     }
@@ -947,6 +957,8 @@ run (void *cls,
      char *const *args,
      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  struct GNUNET_TESTING_Host *hosts;
+  struct GNUNET_TESTING_Host *temphost;
   char * topology_str;
   char * connect_topology_str;
   char * blacklist_topology_str;
@@ -956,8 +968,14 @@ run (void *cls,
   char * topology_percentage_str;
   float topology_percentage;
   char * topology_probability_str;
+  char * hostfile;
   float topology_probability;
   unsigned long long temp_config_number;
+  char *buf;
+  char *data;
+
+  struct stat frstat;
+  int count;
 
   sched = s;
 
@@ -986,9 +1004,61 @@ run (void *cls,
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "comment",
-                                                 &trialmessage))
+                                             &trialmessage))
     trialmessage = NULL;
 
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
+                                             &hostfile))
+    hostfile = NULL;
+
+  hosts = NULL;
+  if (hostfile != NULL)
+    {
+      if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
+          GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ
+            | GNUNET_DISK_PERM_USER_WRITE);
+      if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0))
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "Could not open file specified for host list, ending test!");
+          ok = 1119;
+          GNUNET_free_non_null(trialmessage);
+          GNUNET_free(hostfile);
+          return;
+        }
+
+    data = GNUNET_malloc_large (frstat.st_size);
+    GNUNET_assert(data != NULL);
+    if (frstat.st_size !=
+        GNUNET_DISK_fn_read (hostfile, data, frstat.st_size))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "Could not read file %s specified for host list, ending test!", hostfile);
+        GNUNET_free (hostfile);
+        GNUNET_free (data);
+        return;
+      }
+
+    buf = data;
+    count = 0;
+    while (count < frstat.st_size)
+      {
+        count++;
+        if (((data[count] == '\n') || (data[count] == '\0')) && (buf != &data[count]))
+          {
+            data[count] = '\0';
+            temphost = GNUNET_malloc(sizeof(struct GNUNET_TESTING_Host));
+            temphost->hostname = buf;
+            temphost->next = hosts;
+            hosts = temphost;
+            buf = &data[count + 1];
+          }
+        else if ((data[count] == '\n') || (data[count] == '\0'))
+          buf = &data[count + 1];
+      }
+    }
+
   if (GNUNET_OK !=
           GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "malicious_getters",
                                                  &malicious_getters))
@@ -1199,7 +1269,7 @@ run (void *cls,
   hostkey_meter = create_meter(peers_left, "Hostkeys created ", GNUNET_YES);
   peer_start_meter = create_meter(peers_left, "Peers started ", GNUNET_YES);
 
-  put_meter = create_meter(num_gets, "Puts completed ", GNUNET_YES);
+  put_meter = create_meter(num_puts, "Puts completed ", GNUNET_YES);
   get_meter = create_meter(num_gets, "Gets completed ", GNUNET_YES);
   pg = GNUNET_TESTING_daemons_start (sched, cfg,
                                      peers_left,
@@ -1207,7 +1277,7 @@ run (void *cls,
                                      &hostkey_callback, NULL,
                                      &peers_started_callback, NULL,
                                      &topology_callback, NULL,
-                                     NULL);
+                                     hosts);
 
 }
 
index 31ceff7735475b7a50ad4c6e3e9c898e067063bf..00dc2fc720fe46ac5fa9af187a63ed1668f7a4ad 100644 (file)
  */
 #define MINIMUM_PEER_THRESHOLD 20
 
+#define DHT_DEFAULT_FIND_PEER_REPLICATION 20
+
+#define DHT_DEFAULT_FIND_PEER_OPTIONS GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
+
+#define DHT_DEFAULT_FIND_PEER_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
+
 /**
  * Real maximum number of hops, at which point we refuse
  * to forward the message.
@@ -1064,6 +1070,8 @@ add_pending_message (struct ClientList *client,
 }
 
 
+
+
 /**
  * Called when a reply needs to be sent to a client, as
  * a result it found to a GET or FIND PEER request.
@@ -1120,7 +1128,35 @@ static int route_result_message(void *cls,
   struct DHTQueryRecord *record;
   struct DHTRouteSource *pos;
   struct PeerInfo *peer_info;
+  struct GNUNET_MessageHeader *hello_msg;
 
+  /**
+   * If a find peer result message is received and contains a valid
+   * HELLO for another peer, offer it to the transport service.
+   *
+   * FIXME: Check whether we need this peer (based on routing table
+   * fullness) and only try to connect to it conditionally.  This should
+   * reduce trying to connect to say (500) peers when the bucket size will
+   * discard most of them.
+   */
+  if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT)
+    {
+      if (ntohs(msg->size) <= sizeof(struct GNUNET_MessageHeader))
+        GNUNET_break_op(0);
+
+      hello_msg = &msg[1];
+      if (ntohs(hello_msg->type) != GNUNET_MESSAGE_TYPE_HELLO)
+      {
+        GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Received non-HELLO message type in find peer result message!\n", my_short_id, "DHT");
+        GNUNET_break_op(0);
+      }
+      else
+      {
+        GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s Received HELLO message for another peer, offering to transport!\n", my_short_id, "DHT");
+        GNUNET_TRANSPORT_offer_hello(transport_handle, hello_msg);
+      }
+
+    }
   record = GNUNET_CONTAINER_multihashmap_get(forward_list.hashmap, message_context->key);
   if (record == NULL) /* No record of this message! */
     {
@@ -1131,13 +1167,6 @@ static int route_result_message(void *cls,
 #endif
 #if DEBUG_DHT_ROUTING
 
-      /*if ((debug_routes) && (dhtlog_handle != NULL))
-        {
-          dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_RESULT,
-                                       message_context->hop_count, GNUNET_SYSERR,
-                                       &my_identity, message_context->key);
-        }*/
-
       if ((debug_routes_extended) && (dhtlog_handle != NULL))
         {
           dhtlog_handle->insert_route (NULL,
@@ -1161,7 +1190,7 @@ static int route_result_message(void *cls,
   pos = record->head;
   while (pos != NULL)
     {
-      if (0 == memcmp(&pos->source, &my_identity, sizeof(struct GNUNET_PeerIdentity))) /* Local client initiated request! */
+      if (0 == memcmp(&pos->source, &my_identity, sizeof(struct GNUNET_PeerIdentity))) /* Local client (or DHT) initiated request! */
         {
 #if DEBUG_DHT
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1169,14 +1198,6 @@ static int route_result_message(void *cls,
                       "DHT", GNUNET_h2s (message_context->key), message_context->unique_id);
 #endif
 #if DEBUG_DHT_ROUTING
-          /*
-          if ((debug_routes) && (dhtlog_handle != NULL))
-            {
-              dhtlog_handle->insert_query (NULL, message_context->unique_id, DHTLOG_RESULT,
-                                           message_context->hop_count, GNUNET_YES,
-                                           &my_identity, message_context->key);
-            }*/
-
           if ((debug_routes_extended) && (dhtlog_handle != NULL))
             {
               dhtlog_handle->insert_route (NULL, message_context->unique_id, DHTLOG_RESULT,
@@ -1406,15 +1427,15 @@ handle_dht_find_peer (void *cls,
       GNUNET_break_op (0);
       return;
     }
+
   find_peer_result = GNUNET_malloc (tsize);
   find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT);
   find_peer_result->size = htons (tsize);
   memcpy (&find_peer_result[1], my_hello, hello_size);
-#if DEBUG_DHT_HELLO
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "`%s': Sending hello size %d to client.\n",
-                "DHT", hello_size);
-#endif
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "`%s': Sending hello size %d to requesting peer.\n",
+              "DHT", hello_size);
 
   new_msg_ctx = GNUNET_malloc(sizeof(struct DHT_MessageContext));
   memcpy(new_msg_ctx, message_context, sizeof(struct DHT_MessageContext));
@@ -1996,10 +2017,13 @@ static int route_message(void *cls,
           }
 #endif
       break;
-    case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest, check options, add to requests seen */
-      cache_response (cls, message_context);
-      if ((message_context->closest == GNUNET_YES) || (message_context->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE))
-        handle_dht_find_peer (cls, msg, message_context);
+    case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */
+      if (0 != memcmp(message_context->peer, &my_identity, sizeof(struct GNUNET_PeerIdentity)))
+      {
+        cache_response (cls, message_context);
+        if ((message_context->closest == GNUNET_YES) || (message_context->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE))
+          handle_dht_find_peer (cls, msg, message_context);
+      }
       break;
     default:
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2081,6 +2105,45 @@ find_active_client (struct GNUNET_SERVER_Client *client)
   return ret;
 }
 
+/**
+ * Task to send a find peer message for our own peer identifier
+ * so that we can find the closest peers in the network to ourselves
+ * and attempt to connect to them.
+ *
+ * @param cls closure for this task
+ * @param tc the context under which the task is running
+ */
+static void
+send_find_peer_message (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct GNUNET_MessageHeader *find_peer_msg;
+  struct DHT_MessageContext message_context;
+  int ret;
+
+  if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
+    return;
+
+  find_peer_msg = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
+  find_peer_msg->size = htons(sizeof(struct GNUNET_MessageHeader));
+  find_peer_msg->type = htons(GNUNET_MESSAGE_TYPE_DHT_FIND_PEER);
+  memset(&message_context, 0, sizeof(struct DHT_MessageContext));
+  message_context.key = &my_identity.hashPubKey;
+  message_context.unique_id = GNUNET_ntohll (GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK, (uint64_t)-1));
+  message_context.replication = ntohl (DHT_DEFAULT_FIND_PEER_REPLICATION);
+  message_context.msg_options = ntohl (DHT_DEFAULT_FIND_PEER_OPTIONS);
+  message_context.network_size = estimate_diameter();
+  message_context.peer = &my_identity;
+
+  ret = route_message(NULL, find_peer_msg, &message_context);
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "`%s:%s': Sent `%s' request to %d peers\n", my_short_id, "DHT",
+              "FIND PEER", ret);
+  GNUNET_SCHEDULER_add_delayed (sched,
+                                DHT_DEFAULT_FIND_PEER_INTERVAL,
+                                &send_find_peer_message, NULL);
+}
+
 /**
  * Handler for any generic DHT messages, calls the appropriate handler
  * depending on message type, sends confirmation if responses aren't otherwise
@@ -2491,10 +2554,13 @@ run (void *cls,
         {
           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                       "Could not connect to mysql logging server, logging will not happen!");
-          return;
         }
     }
 
+  GNUNET_SCHEDULER_add_delayed (sched,
+                                GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30),
+                                &send_find_peer_message, NULL);
+
   cleanup_task = GNUNET_SCHEDULER_add_delayed (sched,
                                                GNUNET_TIME_UNIT_FOREVER_REL,
                                                &shutdown_task, NULL);
index c71f38c876c6014e4423bcea528f576909479f0c..ade031c02eaea361162479a1a1215a3185cddeed 100644 (file)
@@ -122,6 +122,7 @@ iopen ()
       return GNUNET_SYSERR;
     }
 #undef PINIT
+
   return GNUNET_OK;
 }
 
@@ -160,7 +161,8 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
            int malicious_droppers, char *message)
 {
   int ret;
-  *trialuid = 0;
+  if (trialuid != NULL)
+    *trialuid = 0;
   if (outfile == NULL)
     return GNUNET_SYSERR;
 
@@ -180,11 +182,11 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
   if (ret < 0)
     return GNUNET_SYSERR;
   ret = fprintf(outfile, "execute insert_trial using "
-                         "@num, @topology, @bl, "
-                         "@connect, @c_t_o, @c_t_o_m, @t_p, "
-                         "@t_pr, @puts, @gets, "
-                         "@concurrent, @settle, @rounds, "
-                         "@m_gets, @m_puts, @m_drops, "
+                         "@num, @topology, @t_p, @t_pr,"
+                         " @bl, @connect, @c_t_o,"
+                         "@c_t_o_m, @puts, @gets,"
+                         "@concurrent, @settle, @rounds,"
+                         "@m_gets, @m_puts, @m_drops,"
                          "@message;\n");
 
   ret = fprintf(outfile, "execute select_trial;\n");
@@ -208,7 +210,8 @@ int
 add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey)
 {
   int ret;
-  *dhtkeyuid = 0;
+  if (dhtkeyuid != NULL)
+    *dhtkeyuid = 0;
 
   if (outfile == NULL)
     return GNUNET_SYSERR;
@@ -330,7 +333,7 @@ add_connections (unsigned long long trialuid, unsigned int totalConnections)
   if (ret < 0)
     return GNUNET_SYSERR;
 
-  ret = fprintf(outfile, "execute update_connections using @conns;\n");
+  ret = fprintf(outfile, "execute update_conn using @conns;\n");
 
   if (ret >= 0)
     return GNUNET_OK;
@@ -361,7 +364,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid,
   if (outfile == NULL)
     return GNUNET_SYSERR;
 
-  *sqlqueryuid = 0;
+  if (sqlqueryuid != NULL)
+    *sqlqueryuid = 0;
 
   if (key != NULL)
     ret = fprintf(outfile, "select dhtkeyuid from dhtkeys where trialuid = @temp_trial and dhtkey = \"%s\" into @temp_dhtkey;\n", GNUNET_h2s_full(key));
@@ -413,7 +417,8 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid,
   if (outfile == NULL)
     return GNUNET_SYSERR;
 
-  *sqlqueryuid = 0;
+  if (sqlqueryuid != NULL)
+    *sqlqueryuid = 0;
 
   if (key != NULL)
     ret = fprintf(outfile, "select dhtkeyuid from dhtkeys where trialuid = @temp_trial and dhtkey = \"%s\" into @temp_dhtkey;\n", GNUNET_h2s_full(key));
index f9283ee894f35a71248b88ec8e1d9ae26fc1dfa8..8c4c903ffffe286f9dc985f36b25e6aea3eae9fd 100644 (file)
@@ -2,11 +2,12 @@
 AUTOSTART = NO
 
 [dht]
-DEBUG = YES
-STOP_ON_CLOSEST = YES
+DEBUG = NO
+STOP_ON_CLOSEST = NO
 AUTOSTART = YES
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-dht
 #PREFIX = xterm -T dht -e gdb --args
 #PREFIX = valgrind --log-file=dht_%p
 CONFIG = $DEFAULTCONFIG
@@ -14,7 +15,6 @@ HOME = $SERVICEHOME
 HOSTNAME = localhost
 PORT = 2100
 
-
 [dhtcache]
 QUOTA = 1000000
 DATABASE = sqlite
@@ -31,6 +31,9 @@ HOME = $SERVICEHOME
 HOSTNAME = localhost
 PORT = 12365
 
+[DHTLOG]
+PLUGIN = mysql_dump
+
 [core]
 TOTAL_QUOTA_OUT = 3932160
 TOTAL_QUOTA_IN = 3932160
@@ -41,6 +44,7 @@ CONFIG = $DEFAULTCONFIG
 HOME = $SERVICEHOME
 HOSTNAME = localhost
 PORT = 12092
+DEBUG = NO
 
 [arm]
 DEFAULTSERVICES = core dht
@@ -51,25 +55,26 @@ CONFIG = $DEFAULTCONFIG
 HOME = $SERVICEHOME
 HOSTNAME = localhost
 PORT = 12366
-DEBUG = YES
+DEBUG = NO
 
 [transport-tcp]
 TIMEOUT = 300000
 PORT = 12368
 
 [DHT_TESTING]
-MYSQL_LOGGING_EXTENDED = NO
+MYSQL_LOGGING_EXTENDED = YES
 NUM_GETS = 10
-NUM_PUTS = 10
+NUM_PUTS = 50
 
 [TESTING]
-CONNECT_TOPOLOGY = CLIQUE
-CONNECT_TOPOLOGY_OPTION = CONNECT_RANDOM_SUBSET
-CONNECT_TOPOLOGY_OPTION_MODIFIER = 2
+TOPOLOGY = CLIQUE
+CONNECT_TOPOLOGY = RING
+#CONNECT_TOPOLOGY_OPTION = CONNECT_RANDOM_SUBSET
+#CONNECT_TOPOLOGY_OPTION_MODIFIER = 2
 #LOGNMODIFIER = .65
 #PERCENTAGE = .75
 WEAKRANDOM = YES
-NUM_PEERS = 5
+NUM_PEERS = 15
 
 [gnunetd]
 HOSTKEY = $SERVICEHOME/.hostkey
index d2a497f43b608f4c92d09403f7818775b51c0c11..609a0b38312120656948a04e202d5042abf7f0f1 100644 (file)
@@ -36,7 +36,8 @@ DEFAULTCONFIG = test_dhtlog_data.conf
 SERVICEHOME = /tmp/test-dhtlog/
 
 [DHTLOG]
-PLUGIN = dummy
+PLUGIN = mysql_dump
+#PLUGIN = dummy
 #PLUGIN = mysql
 
 [MYSQL]