myriad changes
authorNathan S. Evans <evans@in.tum.de>
Thu, 12 Aug 2010 16:21:04 +0000 (16:21 +0000)
committerNathan S. Evans <evans@in.tum.de>
Thu, 12 Aug 2010 16:21:04 +0000 (16:21 +0000)
src/dht/dhtlog.h
src/dht/gnunet-dht-driver.c
src/dht/gnunet-service-dht.c
src/dht/plugin_dhtlog_dummy.c
src/dht/plugin_dhtlog_mysql.c
src/dht/plugin_dhtlog_mysql_dump.c
src/dht/test_dhtlog.c

index 4d59ffb9c4723e5372f69ac40270ec300886fee3..a9b39fd4a3125ac32820b6a95815e52b3bdf19d3 100644 (file)
@@ -111,17 +111,25 @@ struct GNUNET_DHTLOG_Handle
    * @param malicious_getters number of malicious GET peers in the trial
    * @param malicious_putters number of malicious PUT peers in the trial
    * @param malicious_droppers number of malicious DROP peers in the trial
+   * @param malicious_get_frequency how often malicious gets are sent
+   * @param malicious_put_frequency how often malicious puts are sent
+   * @param stop_closest stop forwarding PUTs if closest node found
+   * @param stop_found stop forwarding GETs if data found
+   * @param strict_kademlia test used kademlia routing algorithm
+   * @param gets_succeeded how many gets did the test driver report success on
    * @param message string to put into DB for this trial
    *
    * @return GNUNET_OK on success, GNUNET_SYSERR on failure
    */
-  int (*insert_trial) (unsigned long long *trialuid, int num_nodes, int topology,
-                       int blacklist_topology, int connect_topology,
-                       int connect_topology_option, float connect_topology_option_modifier,
+  int (*insert_trial) (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
+                       unsigned int blacklist_topology, unsigned int connect_topology,
+                       unsigned int connect_topology_option, float connect_topology_option_modifier,
                        float topology_percentage, float topology_probability,
-                       int puts, int gets, int concurrent, int settle_time,
-                       int num_rounds, int malicious_getters, int malicious_putters,
-                       int malicious_droppers,
+                       unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
+                       unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
+                       unsigned int malicious_droppers, unsigned int malicious_get_frequency,
+                       unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
+                       unsigned int strict_kademlia, unsigned int gets_succeeded,
                        char *message);
 
   /*
@@ -162,16 +170,12 @@ struct GNUNET_DHTLOG_Handle
    * Update dhttests.trials table with current server time as end time
    *
    * @param trialuid trial to update
-   * @param totalMessagesDropped stats value for messages dropped
-   * @param totalBytesDropped stats value for total bytes dropped
-   * @param unknownPeers stats value for unknown peers
+   * @param gets_succeeded how many gets did the trial report successful
    *
    * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
    */
   int (*update_trial) (unsigned long long trialuid,
-                       unsigned long long totalMessagesDropped,
-                       unsigned long long totalBytesDropped,
-                       unsigned long long unknownPeers);
+                       unsigned int gets_succeeded);
 
   /*
    * Records the current topology (number of connections, time, trial)
index c2b61821896844c68e2904c4d3ce4f9a0d1bea6b..1e426e658dc684c7d6b003e679e06d1cd2103170 100644 (file)
@@ -23,6 +23,8 @@
  *        then issuing GETS and PUTS on the DHT.  Coarse results
  *        are reported, fine grained results (if requested) are
  *        logged to a (mysql) database, or to file.
+ *
+ * FIXME: Do churn, enable malicious peers!
  */
 #include "platform.h"
 #include "gnunet_testing_lib.h"
 
 #define DEFAULT_TOPOLOGY_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 8)
 
+/*
+ * Default frequency for sending malicious get messages
+ */
+#define DEFAULT_MALICIOUS_GET_FREQUENCY 1000 /* Number of milliseconds */
+
+/*
+ * Default frequency for sending malicious put messages
+ */
+#define DEFAULT_MALICIOUS_PUT_FREQUENCY 1000 /* Default is in milliseconds */
+
 /* Structs */
 
+struct MaliciousContext
+{
+  /**
+   * Handle to DHT service (via the API)
+   */
+  struct GNUNET_DHT_Handle *dht_handle;
+
+  /**
+   *  Handle to the peer daemon
+   */
+  struct GNUNET_TESTING_Daemon *daemon;
+
+  /**
+   * Task for disconnecting DHT handles
+   */
+  GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
+
+  /**
+   * What type of malicious to set this peer to.
+   */
+  int malicious_type;
+};
+
 struct TestPutContext
 {
   /* This is a linked list */
@@ -211,6 +246,10 @@ static unsigned long long malicious_putters;
 
 static unsigned long long malicious_droppers;
 
+static unsigned long long malicious_get_frequency;
+
+static unsigned long long malicious_put_frequency;
+
 static unsigned long long settle_time;
 
 static struct GNUNET_DHTLOG_Handle *dhtlog_handle;
@@ -222,6 +261,11 @@ static unsigned long long trialuid;
  */
 struct GNUNET_CONTAINER_MultiHashMap *stats_map;
 
+/**
+ * LL of malicious settings.
+ */
+struct MaliciousContext *all_malicious;
+
 /**
  * List of GETS to perform
  */
@@ -272,11 +316,6 @@ static unsigned long long num_peers;
  */
 static unsigned long long num_puts;
 
-/**
- * Total number of items to attempt to get.
- */
-static unsigned long long num_gets;
-
 /**
  * How many puts do we currently have in flight?
  */
@@ -287,6 +326,11 @@ static unsigned long long outstanding_puts;
  */
 static unsigned long long puts_completed;
 
+/**
+ * Total number of items to attempt to get.
+ */
+static unsigned long long num_gets;
+
 /**
  * How many puts do we currently have in flight?
  */
@@ -302,6 +346,17 @@ static unsigned long long gets_completed;
  */
 static unsigned long long gets_failed;
 
+/**
+ * How many malicious control messages do
+ * we currently have in flight?
+ */
+static unsigned long long outstanding_malicious;
+
+/**
+ * How many set malicious peers are done?
+ */
+static unsigned long long malicious_completed;
+
 /**
  * Global used to count how many connections we have currently
  * been notified about (how many times has topology_callback been called
@@ -481,7 +536,7 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
   if (dhtlog_handle != NULL)
     {
       fprintf(stderr, "Update trial endtime\n");
-      dhtlog_handle->update_trial (trialuid, 0, 0, 0);
+      dhtlog_handle->update_trial (trialuid, gets_completed);
       GNUNET_DHTLOG_disconnect(dhtlog_handle);
       dhtlog_handle = NULL;
     }
@@ -694,7 +749,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
   if (dhtlog_handle != NULL)
     {
       fprintf(stderr, "Update trial endtime\n");
-      dhtlog_handle->update_trial (trialuid, 0, 0, 0);
+      dhtlog_handle->update_trial (trialuid, gets_completed);
       GNUNET_DHTLOG_disconnect(dhtlog_handle);
       dhtlog_handle = NULL;
     }
@@ -1024,6 +1079,156 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t
     GNUNET_SCHEDULER_add_now (sched, &setup_puts_and_gets, NULL);
 }
 
+/**
+ * Task to release DHT handles
+ */
+static void
+malicious_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
+{
+  struct MaliciousContext *ctx = cls;
+  outstanding_malicious--;
+  malicious_completed++;
+  ctx->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
+  GNUNET_DHT_disconnect(ctx->dht_handle);
+  ctx->dht_handle = NULL;
+  GNUNET_free(ctx);
+
+  if (malicious_completed == malicious_getters + malicious_putters + malicious_droppers)
+    {
+      GNUNET_SCHEDULER_cancel(sched, die_task);
+      fprintf(stderr, "Finished setting all malicious peers up, calling continuation!\n");
+      if (dhtlog_handle != NULL)
+        GNUNET_SCHEDULER_add_now (sched,
+                                  &continue_puts_and_gets, NULL);
+      else
+        GNUNET_SCHEDULER_add_delayed (sched,
+                                    GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
+                                    &continue_puts_and_gets, NULL);
+    }
+
+}
+
+/**
+ * Task to release DHT handles
+ */
+static void
+malicious_done_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
+{
+  struct MaliciousContext *ctx = cls;
+  GNUNET_SCHEDULER_cancel(sched, ctx->disconnect_task);
+  GNUNET_SCHEDULER_add_now(sched, &malicious_disconnect_task, ctx);
+}
+
+/**
+ * Set up some data, and call API PUT function
+ */
+static void
+set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
+{
+  struct MaliciousContext *ctx = cls;
+  int ret;
+
+  if (outstanding_malicious > DEFAULT_MAX_OUTSTANDING_GETS)
+    {
+      GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx);
+      return;
+    }
+
+  if (ctx->dht_handle == NULL)
+    {
+      ctx->dht_handle = GNUNET_DHT_connect(sched, ctx->daemon->cfg, 1);
+      outstanding_malicious++;
+    }
+
+  GNUNET_assert(ctx->dht_handle != NULL);
+
+
+#if VERBOSE > 1
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting peer %s malicious type %d\n",
+                ctx->daemon->shortname, ctx->malicious_type);
+#endif
+
+  ret = GNUNET_YES;
+  switch (ctx->malicious_type)
+  {
+  case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET:
+    ret = GNUNET_DHT_set_malicious_getter(ctx->dht_handle, malicious_get_frequency, &malicious_done_task, ctx);
+    break;
+  case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT:
+    ret = GNUNET_DHT_set_malicious_putter(ctx->dht_handle, malicious_put_frequency, &malicious_done_task, ctx);
+    break;
+  case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP:
+    ret = GNUNET_DHT_set_malicious_dropper(ctx->dht_handle, &malicious_done_task, ctx);
+    break;
+  default:
+    break;
+  }
+
+  if (ret == GNUNET_NO)
+    {
+      GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100), &set_malicious, ctx);
+    }
+  else
+    ctx->disconnect_task = GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_get_forever(), &malicious_disconnect_task, ctx);
+}
+
+/**
+ * Select randomly from set of known peers,
+ * set the desired number of peers to the
+ * proper malicious types.
+ */
+static void
+setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
+{
+  struct MaliciousContext *ctx;
+  int i;
+  uint32_t temp_daemon;
+
+  for (i = 0; i < malicious_getters; i++)
+    {
+      ctx = GNUNET_malloc(sizeof(struct MaliciousContext));
+      temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
+      ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon);
+      ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET;
+      GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx);
+
+    }
+
+  for (i = 0; i < malicious_putters; i++)
+    {
+      ctx = GNUNET_malloc(sizeof(struct MaliciousContext));
+      temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
+      ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon);
+      ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT;
+      GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx);
+
+    }
+
+  for (i = 0; i < malicious_droppers; i++)
+    {
+      ctx = GNUNET_malloc(sizeof(struct MaliciousContext));
+      temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
+      ctx->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon);
+      ctx->malicious_type = GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP;
+      GNUNET_SCHEDULER_add_now (sched, &set_malicious, ctx);
+    }
+
+  if (malicious_getters + malicious_putters + malicious_droppers > 0)
+    die_task = GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, (malicious_getters + malicious_putters + malicious_droppers) * 2),
+                                             &end_badly, "from set malicious");
+  else
+    {
+      if (dhtlog_handle != NULL)
+        GNUNET_SCHEDULER_add_now (sched,
+                                  &continue_puts_and_gets, NULL);
+      else
+        GNUNET_SCHEDULER_add_delayed (sched,
+                                    GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
+                                    &continue_puts_and_gets, NULL);
+    }
+
+}
+
 /**
  * This function is called whenever a connection attempt is finished between two of
  * the started peers (started with GNUNET_TESTING_daemons_start).  The total
@@ -1084,11 +1289,17 @@ topology_callback (void *cls,
       if ((dhtlog_handle != NULL) && (settle_time > 0))
         {
           topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
-          topo_ctx->cont = &continue_puts_and_gets;
+          topo_ctx->cont = &setup_malicious_peers;
+          //topo_ctx->cont = &continue_puts_and_gets;
           GNUNET_SCHEDULER_add_now(sched, &capture_current_topology, topo_ctx);
         }
       else
-        GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &continue_puts_and_gets, NULL);
+        {
+          GNUNET_SCHEDULER_add_now(sched, &setup_malicious_peers, NULL);
+          /*GNUNET_SCHEDULER_add_delayed (sched,
+                                        GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time),
+                                        &continue_puts_and_gets, NULL);*/
+        }
     }
   else if (total_connections + failed_connections == expected_connections)
     {
@@ -1244,6 +1455,9 @@ run (void *cls,
   char *hostfile;
   float topology_probability;
   unsigned long long temp_config_number;
+  int stop_closest;
+  int stop_found;
+  int strict_kademlia;
   char *buf;
   char *data;
   int count;
@@ -1273,6 +1487,18 @@ run (void *cls,
         }
     }
 
+  stop_closest = GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht", "stop_on_closest");
+  if (stop_closest == GNUNET_SYSERR)
+    stop_closest = GNUNET_NO;
+
+  stop_found = GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht", "stop_found");
+  if (stop_found == GNUNET_SYSERR)
+    stop_found = GNUNET_NO;
+
+  strict_kademlia = GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht", "strict_kademlia");
+  if (strict_kademlia == GNUNET_SYSERR)
+    strict_kademlia = GNUNET_NO;
+
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "comment",
                                              &trialmessage))
@@ -1421,6 +1647,18 @@ run (void *cls,
   /**
    * Get testing related options.
    */
+
+  if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING",
+                                                          "MALICIOUS_GET_FREQUENCY",
+                                                          &malicious_get_frequency))
+    malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY;
+
+
+  if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING",
+                                                          "MALICIOUS_PUT_FREQUENCY",
+                                                          &malicious_put_frequency))
+    malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY;
+
   topology_str = NULL;
   if ((GNUNET_YES ==
       GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology",
@@ -1530,7 +1768,9 @@ run (void *cls,
                                     topology_probability, num_puts, num_gets,
                                     max_outstanding_gets, settle_time, 1,
                                     malicious_getters, malicious_putters,
-                                    malicious_droppers, trialmessage);
+                                    malicious_droppers, malicious_get_frequency,
+                                    malicious_put_frequency, stop_closest, stop_found,
+                                    strict_kademlia, 0, trialmessage);
     }
   else if (dhtlog_handle != NULL)
     {
@@ -1541,7 +1781,9 @@ run (void *cls,
                                     topology_probability, num_puts, num_gets,
                                     max_outstanding_gets, settle_time, 1,
                                     malicious_getters, malicious_putters,
-                                    malicious_droppers, "");
+                                    malicious_droppers, malicious_get_frequency,
+                                    malicious_put_frequency, stop_closest, stop_found,
+                                    strict_kademlia, 0, "");
     }
 
   GNUNET_free_non_null(trialmessage);
index 9c301183bbaad9d7eeeb1c02100ec2bebca0dd85..43ea630d54b270046eb032b5c2cf626df134146f 100644 (file)
  */
 #define DEFAULT_MALICIOUS_GET_FREQUENCY 1000 /* Number of milliseconds */
 
-/**
- * Type for a malicious request, so we can ignore it during testing
- */
-#define DHT_MALICIOUS_MESSAGE_TYPE 42
 /*
  * Default frequency for sending malicious put messages
  */
 #define DEFAULT_MALICIOUS_PUT_FREQUENCY 1000 /* Default is in milliseconds */
 
+/**
+ * Type for a malicious request, so we can ignore it during testing
+ */
+#define DHT_MALICIOUS_MESSAGE_TYPE 42
+
 #define DHT_DEFAULT_PING_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 1)
 
 /**
@@ -2537,6 +2538,10 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   static GNUNET_HashCode key;
   unsigned int mcsize;
   uint32_t random_key;
+
+  if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
+    return;
+
   put_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage));
   put_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_PUT);
   put_message.type = htons(DHT_MALICIOUS_MESSAGE_TYPE);
@@ -2552,6 +2557,9 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   message_context.msg_options = ntohl (0);
   message_context.network_size = estimate_diameter();
   message_context.peer = &my_identity;
+
+  if (dhtlog_handle != NULL)
+    dhtlog_handle->insert_dhtkey(NULL, &key);
   increment_stats(STAT_PUT_START);
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious PUT message with hash %s", my_short_id, "DHT", GNUNET_h2s(&key));
   route_message(NULL, &put_message.header, &message_context);
@@ -2573,6 +2581,10 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   static GNUNET_HashCode key;
   unsigned int mcsize;
   uint32_t random_key;
+
+  if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
+    return;
+
   get_message.header.size = htons(sizeof(struct GNUNET_DHT_GetMessage));
   get_message.header.type = htons(GNUNET_MESSAGE_TYPE_DHT_GET);
   get_message.type = htons(DHT_MALICIOUS_MESSAGE_TYPE);
@@ -2587,6 +2599,9 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   message_context.msg_options = ntohl (0);
   message_context.network_size = estimate_diameter();
   message_context.peer = &my_identity;
+
+  if (dhtlog_handle != NULL)
+    dhtlog_handle->insert_dhtkey(NULL, &key);
   increment_stats(STAT_GET_START);
   GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s Sending malicious GET message with hash %s", my_short_id, "DHT", GNUNET_h2s(&key));
   route_message(NULL, &get_message.header, &message_context);
@@ -2717,6 +2732,8 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client,
   case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET:
     if (ntohs(dht_control_msg->variable) > 0)
       malicious_get_frequency = ntohs(dht_control_msg->variable);
+    if (malicious_get_frequency == 0)
+      malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY;
     if (malicious_getter != GNUNET_YES)
       GNUNET_SCHEDULER_add_now(sched, &malicious_get_task, NULL);
     malicious_getter = GNUNET_YES;
@@ -2725,6 +2742,8 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client,
   case GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT:
     if (ntohs(dht_control_msg->variable) > 0)
       malicious_put_frequency = ntohs(dht_control_msg->variable);
+    if (malicious_put_frequency == 0)
+      malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY;
     if (malicious_putter != GNUNET_YES)
       GNUNET_SCHEDULER_add_now(sched, &malicious_put_task, NULL);
     malicious_putter = GNUNET_YES;
index 173d77370a27d2de5099fdede299332a64c2fbf7..12c97e5a753c2d49fcd0d27db5b5d8c479661a43 100644 (file)
 
 #define DEBUG_DHTLOG GNUNET_NO
 
-/*
- * Inserts the specified trial into the dhttests.trials table
- *
- * @param trialuid return the trialuid of the newly inserted trial
- * @param num_nodes how many nodes are in the trial
- * @param topology integer representing topology for this trial
- * @param blacklist_topology integer representing blacklist topology for this trial
- * @param connect_topology integer representing connect topology for this trial
- * @param connect_topology_option integer representing connect topology option
- * @param connect_topology_option_modifier float to modify connect option
- * @param topology_percentage percentage modifier for certain topologies
- * @param topology_probability probability modifier for certain topologies
- * @param puts number of puts to perform
- * @param gets number of gets to perform
- * @param concurrent number of concurrent requests
- * @param settle_time time to wait between creating topology and starting testing
- * @param num_rounds number of times to repeat the trial
- * @param malicious_getters number of malicious GET peers in the trial
- * @param malicious_putters number of malicious PUT peers in the trial
- * @param malicious_droppers number of malicious DROP peers in the trial
- * @param message string to put into DB for this trial
- *
- * @return GNUNET_OK on success, GNUNET_SYSERR on failure
- */
-int
-add_trial (unsigned long long *trialuid, int num_nodes, int topology,
-           int blacklist_topology, int connect_topology,
-           int connect_topology_option, float connect_topology_option_modifier,
-           float topology_percentage, float topology_probability,
-           int puts, int gets, int concurrent, int settle_time,
-           int num_rounds, int malicious_getters, int malicious_putters,
-           int malicious_droppers, char *message)
+  /*
+   * Inserts the specified trial into the dhttests.trials table
+   *
+   * @param trialuid return the trialuid of the newly inserted trial
+   * @param num_nodes how many nodes are in the trial
+   * @param topology integer representing topology for this trial
+   * @param blacklist_topology integer representing blacklist topology for this trial
+   * @param connect_topology integer representing connect topology for this trial
+   * @param connect_topology_option integer representing connect topology option
+   * @param connect_topology_option_modifier float to modify connect option
+   * @param topology_percentage percentage modifier for certain topologies
+   * @param topology_probability probability modifier for certain topologies
+   * @param puts number of puts to perform
+   * @param gets number of gets to perform
+   * @param concurrent number of concurrent requests
+   * @param settle_time time to wait between creating topology and starting testing
+   * @param num_rounds number of times to repeat the trial
+   * @param malicious_getters number of malicious GET peers in the trial
+   * @param malicious_putters number of malicious PUT peers in the trial
+   * @param malicious_droppers number of malicious DROP peers in the trial
+   * @param malicious_get_frequency how often malicious gets are sent
+   * @param malicious_put_frequency how often malicious puts are sent
+   * @param stop_closest stop forwarding PUTs if closest node found
+   * @param stop_found stop forwarding GETs if data found
+   * @param strict_kademlia test used kademlia routing algorithm
+   * @param gets_succeeded how many gets did the test driver report success on
+   * @param message string to put into DB for this trial
+   *
+   * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+   */
+int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
+               unsigned int blacklist_topology, unsigned int connect_topology,
+               unsigned int connect_topology_option, float connect_topology_option_modifier,
+               float topology_percentage, float topology_probability,
+               unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
+               unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
+               unsigned int malicious_droppers, unsigned int malicious_get_frequency,
+               unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
+               unsigned int strict_kademlia, unsigned int gets_succeeded,
+               char *message)
 {
   *trialuid = 42;
   return GNUNET_OK;
@@ -105,17 +113,13 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
  * Update dhttests.trials table with current server time as end time
  *
  * @param trialuid trial to update
- * @param totalMessagesDropped stats value for messages dropped
- * @param totalBytesDropped stats value for total bytes dropped
- * @param unknownPeers stats value for unknown peers
+ * @param gets_succeeded how many gets did the testcase report as successful
  *
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
  */
 int
 update_trials (unsigned long long trialuid,
-               unsigned long long totalMessagesDropped,
-               unsigned long long totalBytesDropped,
-               unsigned long long unknownPeers)
+               unsigned int gets_succeeded)
 {
   return GNUNET_OK;
 }
index 6bdc7d023dbafcea60df4e581cf55cb4ac46faa0..f46c834233e37e8a6d87054c7ff43f7a245a2e8f 100644 (file)
@@ -109,8 +109,10 @@ static struct StatementHandle *insert_node;
                             "blacklist_topology, connect_topology, connect_topology_option,"\
                             "connect_topology_option_modifier, puts, gets, "\
                             "concurrent, settle_time, num_rounds, malicious_getters,"\
-                            "malicious_putters, malicious_droppers, message) "\
-                            "VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
+                            "malicious_putters, malicious_droppers, malicious_get_frequency,"\
+                            "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, "\
+                            "gets_succeeded, message) "\
+                            "VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
 
 static struct StatementHandle *insert_trial;
 
@@ -129,7 +131,7 @@ static struct StatementHandle *insert_stat;
                           "VALUES (?, ?, ?)"
 static struct StatementHandle *insert_dhtkey;
 
-#define UPDATE_TRIALS_STMT "UPDATE trials set endtime=NOW(), total_messages_dropped = ?, total_bytes_dropped = ?, unknownPeers = ? where trialuid = ?"
+#define UPDATE_TRIALS_STMT "UPDATE trials set endtime=NOW(), gets_succeeded = ? where trialuid = ?"
 static struct StatementHandle *update_trial;
 
 #define UPDATE_CONNECTIONS_STMT "UPDATE trials set totalConnections = ? where trialuid = ?"
@@ -822,18 +824,26 @@ prepared_statement_run (struct StatementHandle *s,
  * @param malicious_getters number of malicious GET peers in the trial
  * @param malicious_putters number of malicious PUT peers in the trial
  * @param malicious_droppers number of malicious DROP peers in the trial
+ * @param malicious_get_frequency how often malicious gets are sent
+ * @param malicious_put_frequency how often malicious puts are sent
+ * @param stop_closest stop forwarding PUTs if closest node found
+ * @param stop_found stop forwarding GETs if data found
+ * @param strict_kademlia test used kademlia routing algorithm
+ * @param gets_succeeded how many gets did the test driver report success on
  * @param message string to put into DB for this trial
  *
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int
-add_trial (unsigned long long *trialuid, int num_nodes, int topology,
-           int blacklist_topology, int connect_topology,
-           int connect_topology_option, float connect_topology_option_modifier,
-           float topology_percentage, float topology_probability,
-           int puts, int gets, int concurrent, int settle_time,
-           int num_rounds, int malicious_getters, int malicious_putters,
-           int malicious_droppers, char *message)
+int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
+               unsigned int blacklist_topology, unsigned int connect_topology,
+               unsigned int connect_topology_option, float connect_topology_option_modifier,
+               float topology_percentage, float topology_probability,
+               unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
+               unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
+               unsigned int malicious_droppers, unsigned int malicious_get_frequency,
+               unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
+               unsigned int strict_kademlia, unsigned int gets_succeeded,
+               char *message)
 {
   MYSQL_STMT *stmt;
   int ret;
@@ -842,57 +852,31 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
 
   stmt = mysql_stmt_init(conn);
   if (GNUNET_OK !=
-      (ret = prepared_statement_run (insert_trial,
-                                      trialuid,
-                                      MYSQL_TYPE_LONG,
-                                      &num_nodes,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &topology,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_FLOAT,
-                                      &topology_percentage,
-                                      MYSQL_TYPE_FLOAT,
-                                      &topology_probability,
-                                      MYSQL_TYPE_LONG,
-                                      &blacklist_topology,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &connect_topology,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &connect_topology_option,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_FLOAT,
-                                      &connect_topology_option_modifier,
-                                      MYSQL_TYPE_LONG,
-                                      &puts,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &gets,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &concurrent,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &settle_time,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &num_rounds,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &malicious_getters,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &malicious_putters,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_LONG,
-                                      &malicious_droppers,
-                                      GNUNET_YES,
-                                      MYSQL_TYPE_BLOB,
-                                      message,
-                                      max_varchar_len +
-                                      max_varchar_len, &m_len,
+      (ret = prepared_statement_run (insert_trial, trialuid,
+                                     MYSQL_TYPE_LONG, &num_nodes, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &topology, GNUNET_YES,
+                                     MYSQL_TYPE_FLOAT, &topology_percentage,
+                                     MYSQL_TYPE_FLOAT, &topology_probability,
+                                     MYSQL_TYPE_LONG, &blacklist_topology, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &connect_topology, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &connect_topology_option, GNUNET_YES,
+                                     MYSQL_TYPE_FLOAT, &connect_topology_option_modifier,
+                                     MYSQL_TYPE_LONG, &puts, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &gets, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &concurrent, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &settle_time, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &num_rounds, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &malicious_getters, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &malicious_putters, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &malicious_droppers, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &malicious_get_frequency, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &malicious_put_frequency, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &stop_closest, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &stop_found, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &strict_kademlia, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &gets_succeeded, GNUNET_YES,
+                                     MYSQL_TYPE_BLOB, message, max_varchar_len +
+                                     max_varchar_len, &m_len,
                                       -1)))
     {
       if (ret == GNUNET_SYSERR)
@@ -1095,34 +1079,22 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
  * Update dhttests.trials table with current server time as end time
  *
  * @param trialuid trial to update
- * @param totalMessagesDropped stats value for messages dropped
- * @param totalBytesDropped stats value for total bytes dropped
- * @param unknownPeers stats value for unknown peers
+ * @param gets_succeeded how many gets did the testcase report as successful
  *
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
  */
 int
 update_trials (unsigned long long trialuid,
-               unsigned long long totalMessagesDropped,
-               unsigned long long totalBytesDropped,
-               unsigned long long unknownPeers)
+               unsigned int gets_succeeded)
 {
   int ret;
 
   if (GNUNET_OK !=
       (ret = prepared_statement_run (update_trial,
                                     NULL,
-                                    MYSQL_TYPE_LONGLONG,
-                                    &totalMessagesDropped,
-                                    GNUNET_YES,
-                                    MYSQL_TYPE_LONGLONG,
-                                    &totalBytesDropped,
-                                    GNUNET_YES,
-                                    MYSQL_TYPE_LONGLONG,
-                                    &unknownPeers,
-                                    GNUNET_YES,
-                                    MYSQL_TYPE_LONGLONG,
-                                    &trialuid, GNUNET_YES, -1)))
+                                    MYSQL_TYPE_LONG, &gets_succeeded, GNUNET_YES,
+                                    MYSQL_TYPE_LONGLONG, &trialuid, GNUNET_YES,
+                                    -1)))
     {
       if (ret == GNUNET_SYSERR)
         {
index 9db19a202a46e1fc140a3c4b835a276f90370b56..5c13a3a85f6f4e93e0e52f4a7dfa0de991b041f9 100644 (file)
@@ -74,8 +74,10 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
                            "blacklist_topology, connect_topology, connect_topology_option,"\
                            "connect_topology_option_modifier, puts, gets, "\
                            "concurrent, settle_time, num_rounds, malicious_getters,"\
-                           "malicious_putters, malicious_droppers, message) "\
-                           "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'"
+                           "malicious_putters, malicious_droppers, malicious_get_frequency,"\
+                           "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, "\
+                           "gets_succeeded, message) "\
+                           "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'"
 
 #define INSERT_STAT_STMT "prepare insert_stat from 'INSERT INTO node_statistics"\
                             "(trialuid, nodeuid, route_requests,"\
@@ -89,7 +91,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
 #define INSERT_DHTKEY_STMT "prepare insert_dhtkey from 'INSERT ignore INTO dhtkeys (dhtkey, trialuid) "\
                            "VALUES (?, @temp_trial)'"
 
-#define UPDATE_TRIALS_STMT "prepare update_trial from 'UPDATE trials set endtime= ?, total_messages_dropped = ?, total_bytes_dropped = ?, unknownPeers = ? where trialuid = @temp_trial'"
+#define UPDATE_TRIALS_STMT "prepare update_trial from 'UPDATE trials set endtime= ?, gets_succeeded = ? where trialuid = @temp_trial'"
 
 #define UPDATE_CONNECTIONS_STMT "prepare update_conn from 'UPDATE trials set totalConnections = ? where trialuid = @temp_trial'"
 
@@ -261,18 +263,26 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU
  * @param malicious_getters number of malicious GET peers in the trial
  * @param malicious_putters number of malicious PUT peers in the trial
  * @param malicious_droppers number of malicious DROP peers in the trial
+ * @param malicious_get_frequency how often malicious gets are sent
+ * @param malicious_put_frequency how often malicious puts are sent
+ * @param stop_closest stop forwarding PUTs if closest node found
+ * @param stop_found stop forwarding GETs if data found
+ * @param strict_kademlia test used kademlia routing algorithm
+ * @param gets_succeeded how many gets did the test driver report success on
  * @param message string to put into DB for this trial
  *
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure
  */
-int
-add_trial (unsigned long long *trialuid, int num_nodes, int topology,
-           int blacklist_topology, int connect_topology,
-           int connect_topology_option, float connect_topology_option_modifier,
-           float topology_percentage, float topology_probability,
-           int puts, int gets, int concurrent, int settle_time,
-           int num_rounds, int malicious_getters, int malicious_putters,
-           int malicious_droppers, char *message)
+int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
+               unsigned int blacklist_topology, unsigned int connect_topology,
+               unsigned int connect_topology_option, float connect_topology_option_modifier,
+               float topology_percentage, float topology_probability,
+               unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
+               unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
+               unsigned int malicious_droppers, unsigned int malicious_get_frequency,
+               unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
+               unsigned int strict_kademlia, unsigned int gets_succeeded,
+               char *message)
 {
   int ret;
   if (trialuid != NULL)
@@ -280,18 +290,21 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
   if (outfile == NULL)
     return GNUNET_SYSERR;
 
-  ret = fprintf(outfile, "set @date = \"%s\", @num = %d, @topology = %d, @bl = %d, "
-                   "@connect = %d, @c_t_o = %d, @c_t_o_m = %f, @t_p = %f, "
-                   "@t_pr = %f, @puts = %d, @gets = %d, "
-                   "@concurrent = %d, @settle = %d, @rounds = %d, "
-                   "@m_gets = %d, @m_puts = %d, @m_drops = %d, "
-                   "@message = \"%s\";\n", get_sql_time(), num_nodes, topology,
+  ret = fprintf(outfile, "set @date = \"%s\", @num = %u, @topology = %u, @bl = %u, "
+                   "@connect = %u, @c_t_o = %u, @c_t_o_m = %f, @t_p = %f, "
+                   "@t_pr = %f, @puts = %u, @gets = %u, "
+                   "@concurrent = %u, @settle = %u, @rounds = %u, "
+                   "@m_gets = %u, @m_puts = %u, @m_drops = %u, "
+                   "@m_g_f = %u, @m_p_f = %u, @s_c = %u, @s_f = %u,"
+                   "@s_k = %u, @g_s = %u, @message = \"%s\";\n",
+                   get_sql_time(), num_nodes, topology,
                    blacklist_topology, connect_topology,
                    connect_topology_option, connect_topology_option_modifier,
                    topology_percentage, topology_probability,
                    puts, gets, concurrent, settle_time,
                    num_rounds, malicious_getters, malicious_putters,
-                   malicious_droppers, message);
+                   malicious_droppers, malicious_get_frequency, malicious_put_frequency,
+                   stop_closest, stop_found, strict_kademlia, gets_succeeded, message);
 
   if (ret < 0)
     return GNUNET_SYSERR;
@@ -301,7 +314,8 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
                          "@c_t_o_m, @puts, @gets,"
                          "@concurrent, @settle, @rounds,"
                          "@m_gets, @m_puts, @m_drops,"
-                         "@message;\n");
+                         "@m_g_f, @m_p_f, @s_c, @s_f,"
+                         "@s_k, @g_s, @message;\n");
 
   ret = fprintf(outfile, "execute select_trial;\n");
 
@@ -446,17 +460,13 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity * node)
  * Update dhttests.trials table with current server time as end time
  *
  * @param trialuid trial to update
- * @param totalMessagesDropped stats value for messages dropped
- * @param totalBytesDropped stats value for total bytes dropped
- * @param unknownPeers stats value for unknown peers
+ * @param gets_succeeded how many gets did the testcase report as successful
  *
  * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
  */
 int
 update_trials (unsigned long long trialuid,
-               unsigned long long totalMessagesDropped,
-               unsigned long long totalBytesDropped,
-               unsigned long long unknownPeers)
+               unsigned int gets_succeeded)
 {
   int ret;
 #if DEBUG_DHTLOG
@@ -470,12 +480,12 @@ update_trials (unsigned long long trialuid,
   if (outfile == NULL)
     return GNUNET_SYSERR;
 
-  ret = fprintf(outfile, "set @date = \"%s\", @m_dropped = %llu, @b_dropped = %llu, @unknown = %llu;\n", get_sql_time(), totalMessagesDropped, totalBytesDropped, unknownPeers);
+  ret = fprintf(outfile, "set @date = \"%s\", @g_s = %u;\n", get_sql_time(), gets_succeeded);
 
   if (ret < 0)
     return GNUNET_SYSERR;
 
-  ret = fprintf(outfile, "execute update_trial using @date, @m_dropped, @b_dropped, @unknown;\n");
+  ret = fprintf(outfile, "execute update_trial using @date, @g_s;\n");
 
   if (ret >= 0)
     return GNUNET_OK;
index 467e3876e93799cb3d8f51c2c2f30a570c8cdd65..d54e2046fa9d9a7f2bef201e75a80ceb0cf7d431 100644 (file)
@@ -66,8 +66,8 @@ test (struct GNUNET_DHTLOG_Handle * api)
   ret =
     api->insert_trial (&trialuid, i, 5, 4, 3, 2,
                        .75, .25, .5, 42, 14,
-                       5, 1, 12, 0, 0, 0,
-                       "TEST INSERT TRIAL");
+                       5, 1, 12, 0, 0, 0, 1, 0, 1,
+                       0, 1, 0, "TEST INSERT TRIAL");
   CHECK(ret);
   ret = api->insert_topology(500);
   CHECK(ret);
@@ -101,7 +101,7 @@ test (struct GNUNET_DHTLOG_Handle * api)
   ret = api->insert_stat(&p1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
   ret = api->insert_stat(&p2, 12, 23, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
   CHECK(ret);
-  ret = api->update_trial (trialuid, 0, 0, 0);
+  ret = api->update_trial (trialuid, 787);
   CHECK(ret);
   return 0;
 }