gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8619 - GNUnet/src/applications/dv_dht/tools


From: gnunet
Subject: [GNUnet-SVN] r8619 - GNUnet/src/applications/dv_dht/tools
Date: Thu, 2 Jul 2009 12:54:46 -0600

Author: nevans
Date: 2009-07-02 12:54:46 -0600 (Thu, 02 Jul 2009)
New Revision: 8619

Modified:
   GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
   GNUnet/src/applications/dv_dht/tools/dv_test.conf
Log:
driver changes

Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c        2009-07-01 
21:11:10 UTC (rev 8618)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c        2009-07-02 
18:54:46 UTC (rev 8619)
@@ -54,6 +54,10 @@
 static unsigned long long num_peers;
 static unsigned long long num_repeat;
 static unsigned long long num_rounds;
+static unsigned long long settle_time;
+static unsigned long long put_items;
+static unsigned long long get_requests;
+
 static char *dotOutFileName = NULL;
 
 static struct GNUNET_CommandLineOption gnunetDHTDriverOptions[] = {
@@ -133,10 +137,14 @@
     return GNUNET_SYSERR;
 }
 
-
 static int
-waitForConnect (const char *name, unsigned long long value, void *cls)
+getPeers (const char *name, unsigned long long value, void *cls)
 {
+  if ((value > 0) && (strstr (name, _("# dv")) != NULL))
+    {
+      fprintf (stderr, "%s : %llu\n", name, value);
+    }
+
   if ((value > 0) && (0 == strcmp (_("# dv_dht connections"), name)))
     {
       ok = 1;
@@ -145,14 +153,188 @@
   return GNUNET_OK;
 }
 
-static int
-getPeers (const char *name, unsigned long long value, void *cls)
+#define CHECK(a) do { if (!(a)) { ret = 1; GNUNET_GE_BREAK(ectx, 0); goto 
FAILURE; } } while(0)
+
+int
+new_do_testing (int argc, char *const *argv)
 {
-  if ((value > 0) && (strstr (name, _("# dv")) != NULL))
+  struct GNUNET_REMOTE_TESTING_DaemonContext *peers;
+  struct GNUNET_REMOTE_TESTING_DaemonContext *peer_array[num_peers];
+  struct GNUNET_REMOTE_TESTING_DaemonContext *pos;
+  int ret = 0;
+
+  struct GNUNET_ClientServerConnection *sock;
+  struct GNUNET_DV_DHT_keys *keys = NULL;
+  struct GNUNET_DV_DHT_keys *key_pos;
+  struct GNUNET_DV_DHT_keys *temp_key_pos;
+  struct GNUNET_DV_DHT_Context *dctx;
+  struct GNUNET_DV_DHT_GetRequest *get1;
+
+  int i;
+  int k;
+  int r;
+  int l;
+  int last;
+  int key_count;
+  int random_peer;
+  unsigned long long trialuid;
+
+  key_count = 0;
+  if (sqlapi == NULL)
     {
-      fprintf (stderr, "%s : %llu\n", name, value);
+      return GNUNET_SYSERR;
     }
+  else
+    {
+      ret = sqlapi->insert_trial (&trialuid, num_peers, topology);
+    }
 
+  if (ret != GNUNET_OK)
+    return GNUNET_SYSERR;
+  printf ("Starting %u peers for trial %llu...\n", (unsigned int) num_peers, 
trialuid);
+  peers = GNUNET_REMOTE_start_daemons (cfg, num_peers);
+  if (peers == NULL)
+  {
+    GNUNET_GC_free (cfg);
+    return -1;
+  }
+  pos = peers;
+  for (i = 0; i < num_peers; i++)
+  {
+    peer_array[i] = pos;
+    pos = pos->next;
+  }
+
+  for (i = 0; i < put_items; i++)
+  {
+    key_pos = GNUNET_malloc(sizeof(struct GNUNET_DV_DHT_keys));
+    for (l = 0; l < 8; l++)
+    {
+      key_pos->data[l] = rand();
+    }
+    GNUNET_hash (key_pos->data, 8, &key_pos->key);
+    if (keys == NULL)
+    {
+      keys = key_pos;
+      key_pos->next = NULL;
+    }
+    else
+    {
+      key_pos->next = keys;
+      keys = key_pos;
+    }
+  }
+  sleep (30);
+  found = 0;
+
+  for (r = 0; r < settle_time; r++)
+  {
+    fprintf (stderr, "After %d minutes\n", r);
+    for (i = 0; i < num_peers; i++)
+    {
+      if (GNUNET_shutdown_test () == GNUNET_YES)
+        break;
+      fprintf (stderr, "Peer %d: ", i);
+      sock =
+        GNUNET_client_connection_create (NULL, peer_array[i]->config);
+      GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
+      GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+      GNUNET_client_connection_destroy (sock);
+    }
+    if (GNUNET_shutdown_test () == GNUNET_YES)
+      break;
+    sleep (60);
+  }
+
+  key_pos = keys;
+  key_count = 0;
+  while(key_pos != NULL)
+  {
+    random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
+    fprintf(stdout, "Inserting key %d at peer %d\n", key_count, random_peer);
+    CHECK (GNUNET_OK == GNUNET_DV_DHT_put (peer_array[random_peer]->config,
+                                         ectx,
+                                         &key_pos->key,
+                                         
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+                                         sizeof (key_pos->data), 
key_pos->data));
+
+    key_pos = key_pos->next;
+    key_count++;
+  }
+  fprintf(stdout, "Inserted %d items\n", key_count);
+  key_pos = keys;
+  key_count = 0;
+  for (i = 0; i < get_requests; i ++)
+  {
+    random_peer = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, num_peers);
+    dctx = GNUNET_DV_DHT_context_create (peer_array[random_peer]->config, ectx,
+                                         &result_callback, keys);
+    fprintf(stdout, "Searching for key %d from peer %d\n", key_count, 
random_peer);
+    get1 = GNUNET_DV_DHT_get_start (dctx,
+                                    GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+                                    &key_pos->key);
+    GNUNET_GE_ASSERT (NULL, get1 != NULL);
+    for (k = 0; k < DEFAULT_NUM_ROUNDS; k++)
+    {
+      if (GNUNET_shutdown_test () == GNUNET_YES)
+        break;
+      if (9 == (k % 10))
+        {
+          printf (".");
+          fflush (stdout);
+        }
+      fflush (stdout);
+      GNUNET_thread_sleep (50 * GNUNET_CRON_MILLISECONDS);
+      if (last < found)
+        break;
+    }
+    GNUNET_DV_DHT_get_stop (dctx, get1);
+    if (k == DEFAULT_NUM_ROUNDS)
+    {
+      printf ("?");
+      fflush (stdout);
+    }
+    GNUNET_DV_DHT_context_destroy(dctx);
+    if (key_pos->next != NULL)
+    {
+      key_pos = key_pos->next;
+      key_count++;
+    }
+    else
+    {
+      key_pos = keys;
+      key_count = 0;
+    }
+  }
+  printf ("Found %u out of %llu attempts.\n", found,
+            get_requests);
+
+FAILURE:
+  pos = peers;
+  while (pos != NULL)
+    {
+      GNUNET_REMOTE_kill_daemon (pos);
+      pos = pos->next;
+    }
+
+  key_pos = keys;
+  while(key_pos != NULL)
+  {
+    temp_key_pos = key_pos->next;
+    GNUNET_free(key_pos);
+    key_pos = temp_key_pos;
+  }
+
+  ret = sqlapi->update_trial (trialuid);
+  return ret;
+}
+
+#if 0
+
+
+static int
+waitForConnect (const char *name, unsigned long long value, void *cls)
+{
   if ((value > 0) && (0 == strcmp (_("# dv_dht connections"), name)))
     {
       ok = 1;
@@ -161,9 +343,6 @@
   return GNUNET_OK;
 }
 
-#define CHECK(a) do { if (!(a)) { ret = 1; GNUNET_GE_BREAK(ectx, 0); goto 
FAILURE; } } while(0)
-
-
 int
 do_testing (int argc, char *const *argv)
 {
@@ -239,7 +418,7 @@
   }
   sleep (30);
   found = 0;
-  for (r = 0; r < 5; r++)
+  for (r = 0; r < settle_time; r++)
     {
       fprintf (stderr, "After %d minutes\n", r);
       for (i = 0; i < num_peers; i++)
@@ -259,28 +438,20 @@
       sleep (60);
     }
 
-  for (r = 0; r < num_repeat; r++)
-    {
-      if (r > 0)
-        {
-          printf ("Found %u out of %llu attempts.\n", found,
-                  num_peers * num_peers * r);
-          if (found >= num_peers * num_peers * r / 2)
-            break;              /* good enough */
-        }
-      for (i = 0; i < num_peers; i++)
-        {
-          if (GNUNET_shutdown_test () == GNUNET_YES)
-            break;
-          fprintf (stderr, "Peer %d: ", i);
-          sock =
-            GNUNET_client_connection_create (NULL, peer_array[i]->config);
-          GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
-          GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
-          GNUNET_client_connection_destroy (sock);
-        }
-      if (GNUNET_shutdown_test () == GNUNET_YES)
-        break;
+
+  for (i = 0; i < num_peers; i++)
+  {
+    if (GNUNET_shutdown_test () == GNUNET_YES)
+      break;
+    fprintf (stderr, "Peer %d: ", i);
+    sock =
+      GNUNET_client_connection_create (NULL, peer_array[i]->config);
+    GNUNET_STATS_get_statistics (NULL, sock, &getPeers, NULL);
+    GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+    GNUNET_client_connection_destroy (sock);
+  }
+      if (GNUNET_shutdown_test () != GNUNET_YES)
+      {
       /* put loop */
       printf ("Waiting for DV_DHT connections of peer");
       key_pos = keys;
@@ -423,7 +594,6 @@
             num_peers);
           new_found = 0;
         }
-    }
   /* end of actual test code */
   if (r == num_repeat)
     printf ("Found %u out of %llu attempts.\n", found,
@@ -434,7 +604,7 @@
         ("Not enough results (not even 50%%), marking test as failed!\n");
       ret = 1;
     }
-FAILURE:
+FAILURE2:
   pos = peers;
   while (pos != NULL)
     {
@@ -451,6 +621,7 @@
   }
   return ret;
 }
+#endif
 
 /**
  * Driver for testing DV_DHT routing (many peers).
@@ -501,6 +672,27 @@
 
   GNUNET_GC_get_configuration_value_number (cfg,
                                             "MULTIPLE_SERVER_TESTING",
+                                            "SETTLE_TIME",
+                                            0,
+                                            -1,
+                                            0, &settle_time);
+
+  GNUNET_GC_get_configuration_value_number (cfg,
+                                            "MULTIPLE_SERVER_TESTING",
+                                            "PUT_ITEMS",
+                                            1,
+                                            -1,
+                                            100, &put_items);
+
+  GNUNET_GC_get_configuration_value_number (cfg,
+                                            "MULTIPLE_SERVER_TESTING",
+                                            "GET_REQUESTS",
+                                            1,
+                                            -1,
+                                            100, &get_requests);
+
+  GNUNET_GC_get_configuration_value_number (cfg,
+                                            "MULTIPLE_SERVER_TESTING",
                                             "NUM_ROUNDS",
                                             1,
                                             -1,
@@ -528,7 +720,7 @@
     }
   else
     {
-      ret = do_testing (argc, argv);
+      ret = new_do_testing (argc, argv);
     }
   done =
     GNUNET_plugin_resolve_function (plugin, "release_module_", GNUNET_YES);

Modified: GNUnet/src/applications/dv_dht/tools/dv_test.conf
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_test.conf   2009-07-01 21:11:10 UTC 
(rev 8618)
+++ GNUnet/src/applications/dv_dht/tools/dv_test.conf   2009-07-02 18:54:46 UTC 
(rev 8619)
@@ -1,14 +1,21 @@
 [MULTIPLE_SERVER_TESTING]
-CONTROL_HOST=127.0.0.1;
-HOSTNAMES=localhost
+CONTROL_HOST=130.253.106.13;
+HOSTNAMES=130.253.191.150 130.253.191.152 130.253.191.155
+SSH_USERNAME=natevans
 STARTING_PORT=31387
 PORT_INCREMENT=2
 BASE_CONFIG=gnunetd_dv.conf
 TOPOLOGY=1
+SETTLE_TIME=10
 NUM_PEERS=30
+PUT_ITEMS=400
+GET_REQUESTS=10000
 #PERCENTAGE=.45
-#MYSQL_SERVER = localhost
-#MYSQL_DB = dhttests
-#MYSQL_USER = dht
-#MYSQL_PASSWORD = dht**
+MYSQL_SERVER = 130.253.190.125
+MYSQL_DB = dhttests
+MYSQL_USER = dht
+MYSQL_PASSWORD = dht**
 DOT_OUTPUT=topology.dot
+REMOTE_CONFIG_PATH=/tmp/config/
+REMOTE_GNUNETD_PATH=/u/home/natevans/gnunet/bin/
+





reply via email to

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