[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8604 - in GNUnet/src/applications/dv_dht: module tools
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8604 - in GNUnet/src/applications/dv_dht: module tools |
Date: |
Fri, 26 Jun 2009 14:14:09 -0600 |
Author: nevans
Date: 2009-06-26 14:14:08 -0600 (Fri, 26 Jun 2009)
New Revision: 8604
Added:
GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
Modified:
GNUnet/src/applications/dv_dht/module/routing.c
GNUnet/src/applications/dv_dht/module/table.c
GNUnet/src/applications/dv_dht/tools/Makefile.am
GNUnet/src/applications/dv_dht/tools/dv_dht_multi_topology_test.c
GNUnet/src/applications/dv_dht/tools/dv_test.conf
GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf
Log:
initial driver and some changes to dv_dht
Modified: GNUnet/src/applications/dv_dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/routing.c 2009-06-25 14:48:33 UTC
(rev 8603)
+++ GNUnet/src/applications/dv_dht/module/routing.c 2009-06-26 20:14:08 UTC
(rev 8604)
@@ -38,6 +38,7 @@
#include "gnunet_dhtlog_service.h"
#define DEBUG_ROUTING GNUNET_YES
+#define DEBUG_INSANE GNUNET_YES
/**
* What is the request priority for DV_DHT operations?
@@ -158,6 +159,7 @@
* Unique trial id for sql database interaction
*/
unsigned long long trialuid;
+
#endif
} DV_DHT_MESSAGE;
@@ -207,6 +209,10 @@
*/
static unsigned int rt_size;
+#if DEBUG_INSANE
+static unsigned int indentation;
+#endif
+
/*
* Whether or not to send routing debugging information
* to the dht logging server
@@ -247,7 +253,43 @@
static unsigned int stat_put_requests_received;
+#if DEBUG_INSANE
+static void
+print_entry (char *function)
+{
+ int i;
+ for (i = 0; i < indentation; i++)
+ {
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, " ");
+ }
+
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, _("Entering `%s'\n"), function);
+ indentation++;
+}
+
+static void
+print_exit (char *function)
+{
+ int i;
+ for (i = 0; i < indentation; i++)
+ {
+ if (indentation >= 1)
+ indentation--;
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, " ");
+ }
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, _("Exiting `%s'\n"), function);
+}
+#endif
+
/**
* To how many peers should we (on average)
* forward the request to obtain the desired
@@ -305,8 +347,9 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (key, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
- "DHT-Routing of result for key `%s'.\n", &enc);
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ _("DHT-Routing of result for key `%s'.\n"), &enc);
#endif
if (cls != NULL)
@@ -361,8 +404,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+ | GNUNET_GE_BULK,
"Seen the same result earlier, not routing it
again.\n");
#endif
break;
@@ -379,8 +422,8 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&pos->source.hashPubKey, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN |
+ GNUNET_GE_USER | GNUNET_GE_BULK,
"Route to peer `%s' has expired (%llu < %llu)\n",
&enc, pos->expire, now);
#endif
@@ -402,8 +445,8 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&pos->source.hashPubKey, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN |
+ GNUNET_GE_USER | GNUNET_GE_BULK,
"Routing result to `%s'\n", &enc);
#endif
if ((debug_routes_extended) && (dhtlog != NULL))
@@ -425,8 +468,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN |
+ GNUNET_GE_USER | GNUNET_GE_BULK,
"Routing result to local client\n");
#endif
pos->receiver (key, type, size, data, pos->receiver_closure);
@@ -442,7 +485,8 @@
GNUNET_mutex_unlock (lock);
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Routed result to %u out of %u pending requests\n",
routed, tracked);
#endif
@@ -537,8 +581,8 @@
pos->receiver_closure = cls;
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
- "Tracking request in slot %u\n", rt_pos);
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "Tracking request in slot %u\n", rt_pos);
#endif
GNUNET_mutex_unlock (lock);
if (stats != NULL)
@@ -578,7 +622,8 @@
if (sender != NULL)
GNUNET_hash_to_enc (&sender->hashPubKey, &henc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Received DV_DHT GET for key `%s' from `%s'.\n", &enc,
sender == NULL ? "me" : (char *) &henc);
#endif
@@ -589,8 +634,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Failed to add entry in routing table for request.\n");
fprintf (stderr, "Failed to add entry in routing table for request.\n");
if ((debug_routes) && (dhtlog != NULL))
@@ -609,8 +654,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Found %d results locally, will not route GET any
further\n",
total);
#endif
@@ -635,8 +680,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+ | GNUNET_GE_BULK,
"Failed to select peer for fowarding in round
%d/%d\n",
i + 1, GET_TRIES);
#endif
@@ -645,8 +690,8 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&next[j].hashPubKey, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Forwarding DV_DHT GET request to peer `%s'.\n", &enc);
#endif
if ((debug_routes_extended) && (dhtlog != NULL))
@@ -694,8 +739,9 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&put->key, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
- "Received DV_DHT PUT for key `%s'.\n", &enc);
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ _("Received DV_DHT PUT for key `%s'.\n"), &enc);
#endif
store = 0;
hop_count = htonl (put->hop_count);
@@ -718,8 +764,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+ | GNUNET_GE_BULK,
"Failed to select peer for PUT fowarding in round
%d/%d\n",
i + 1, PUT_TRIES);
#endif
@@ -733,8 +779,8 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&next[j].hashPubKey, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Forwarding DV_DHT PUT request to peer `%s'.\n", &enc);
#endif
if ((debug_routes_extended) && (dhtlog != NULL))
@@ -754,8 +800,8 @@
now = GNUNET_get_time ();
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Decided to cache data `%.*s' locally until %llu (for
%llu ms)\n",
ntohs (put->header.size) - sizeof (DV_DHT_MESSAGE),
&put[1], CONTENT_LIFETIME + now, CONTENT_LIFETIME);
@@ -778,8 +824,8 @@
{
#if DEBUG_ROUTING
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST |
- GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Decided NOT to cache data `%.*s' locally\n",
ntohs (put->header.size) - sizeof (DV_DHT_MESSAGE),
&put[1]);
@@ -812,7 +858,8 @@
#if DEBUG_ROUTING
GNUNET_hash_to_enc (&result->key, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Received REMOTE DV_DHT RESULT for key `%s'.\n", &enc);
#endif
@@ -860,7 +907,8 @@
get.queryuid = htonl (queryuid);
GNUNET_hash_to_enc (&get.key, &enc);
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_DEVELOPER,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
"Initiating DV_DHT GET (based on local request) for key
`%s'.\n",
&enc);
@@ -998,6 +1046,11 @@
unsigned long long nodeuid;
coreAPI = capi;
rts = 65536;
+
+#if DEBUG_INSANE
+ print_entry ("GNUNET_DV_DHT_init_routing");
+#endif
+
GNUNET_GC_get_configuration_value_number (coreAPI->cfg,
"DHT",
"TABLESIZE",
@@ -1086,11 +1139,21 @@
GNUNET_GE_BULK,
_("`%s' loading logging context %s\n"),
"dv_dht", "dhtlog_mysql");
+#if DEBUG_ROUTING
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ _
+ ("routing debugging enabled, expect lots of
messages!\n"));
+
+#endif
dhtlog = coreAPI->service_request ("dhtlog_mysql");
dhtlog->insert_node (&nodeuid, coreAPI->my_identity);
GNUNET_GE_ASSERT (coreAPI->ectx, dhtlog != NULL);
}
-
+#if DEBUG_INSANE
+ print_exit ("GNUNET_DV_DHT_init_routing");
+#endif
return GNUNET_OK;
}
Modified: GNUnet/src/applications/dv_dht/module/table.c
===================================================================
--- GNUnet/src/applications/dv_dht/module/table.c 2009-06-25 14:48:33 UTC
(rev 8603)
+++ GNUnet/src/applications/dv_dht/module/table.c 2009-06-26 20:14:08 UTC
(rev 8604)
@@ -57,6 +57,12 @@
#include "gnunet_dv_service.h"
+#define DEBUG_TABLE GNUNET_NO
+
+#if DEBUG_TABLE
+static unsigned int indentation;
+#endif
+
/**
* How often should the cron job for maintaining the DV_DHT
* run?
@@ -67,13 +73,13 @@
* What is the chance (1 in XXX) that we send DISCOVERY messages
* to another peer?
*/
-/*#define MAINTAIN_CHANCE (10 + 100 * total_peers)*/
-#define MAINTAIN_CHANCE (1 + total_peers)
+#define MAINTAIN_CHANCE (10 + 100 * total_peers)
+/*#define MAINTAIN_CHANCE (1 + total_peers)*/
/**
* How long can a peer be inactive before we time it out?
*/
-#define MAINTAIN_PEER_TIMEOUT MAINTAIN_FREQUENCY * MAINTAIN_CHANCE * 4 + 100
+#define MAINTAIN_PEER_TIMEOUT MAINTAIN_FREQUENCY * MAINTAIN_CHANCE * 4
/**
* What is the maximum number of known DV_DHT-enabled peers
@@ -233,6 +239,37 @@
} P2P_DV_DHT_ASK_HELLO;
+#if DEBUG_TABLE
+static FILE *debug_file;
+static char *debug_file_name;
+static void
+print_entry (char *function)
+{
+ int i;
+
+ for (i = 0; i < indentation; i++)
+ {
+ fprintf (debug_file, " ");
+ }
+
+ fprintf (debug_file, _("Entering `%s'\n"), function);
+ indentation++;
+}
+
+static void
+print_exit (char *function)
+{
+ int i;
+ if (indentation >= 1)
+ indentation--;
+ for (i = 0; i < indentation; i++)
+ {
+ fprintf (debug_file, " ");
+ }
+ fprintf (debug_file, _("Exiting `%s'\n"), function);
+}
+#endif
+
/**
* Compute a (rough) estimate of the networks diameter.
*
@@ -282,9 +319,20 @@
return NULL; /* myself! */
index = get_bit_distance (&peer->hashPubKey,
&coreAPI->my_identity->hashPubKey);
+/* Why are we not returning the bit distance as the bucket we'd like to store
+ * this peer in? If the first bit differs (none match) then it goes in bucket
+ * 0. If more match than we have buckets for it goes in the highest numbered
+ * bucket. Why do all this nonsense? Also why break in error when we have
+ * a peer that matches lots of our bits? We WANT that peer in our table,
+ * but returning NULL and erroring out keeps it far far away from us!
+ */
i = bucketCount - 1;
- while ((buckets[i].bstart >= index) && (i > 0))
+ while ((buckets[i].bstart > index) && (i > 0))
i--;
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "index is %d, bucket start is %d\n", index,
+ buckets[i].bstart);
if ((buckets[i].bstart <= index) && (buckets[i].bend >= index))
return &buckets[i];
GNUNET_GE_BREAK (NULL, 0);
@@ -489,7 +537,9 @@
unsigned int pc;
unsigned int i;
GNUNET_PeerIdentity *pos;
-
+#if DEBUG_TABLE
+ print_entry ("broadcast_dht_discovery");
+#endif
if (stats != NULL)
stats->change (stat_dht_advertisements, 1);
if (disco != NULL)
@@ -497,6 +547,9 @@
dvapi->dv_send (other,
&disco->header,
GNUNET_EXTREME_PRIORITY / 4, 2 * GNUNET_CRON_SECONDS);
+#if DEBUG_TABLE
+ print_exit ("broadcast_dht_discovery");
+#endif
return;
}
pc = total_peers;
@@ -532,15 +585,31 @@
dvapi->dv_send (other, &disco->header, GNUNET_EXTREME_PRIORITY / 4,
2 * GNUNET_CRON_SECONDS);
GNUNET_free (disco);
+#if DEBUG_TABLE
+ print_exit ("broadcast_dht_discovery");
+#endif
}
static void
broadcast_dht_discovery_prob (const GNUNET_PeerIdentity * other, void *cls)
{
+#if DEBUG_TABLE
+ print_entry ("broadcast_dht_discovery_prob");
+#endif
+
if (GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, MAINTAIN_CHANCE) != 0)
- return;
+ {
+#if DEBUG_TABLE
+ print_exit ("broadcast_dht_discovery_prob");
+#endif
+ return;
+ }
//fprintf(stderr, "sending discovery message\n");
broadcast_dht_discovery (other, cls);
+
+#if DEBUG_TABLE
+ print_exit ("broadcast_dht_discovery_prob");
+#endif
}
/**
@@ -549,6 +618,9 @@
static void
maintain_dht_job (void *unused)
{
+#if DEBUG_TABLE
+ print_entry ("maintain_dht_job");
+#endif
P2P_DV_DHT_Discovery disc;
if (total_peers == 0)
{
@@ -561,6 +633,9 @@
{
dvapi->dv_connections_iterate (&broadcast_dht_discovery_prob, NULL);
}
+#if DEBUG_TABLE
+ print_exit ("maintain_dht_job");
+#endif
}
/**
@@ -801,6 +876,54 @@
GNUNET_mutex_unlock (lock);
}
+
+void
+printPeerBits (GNUNET_PeerIdentity * peer)
+{
+ unsigned int i;
+ char loc[513];
+ loc[512] = '\0';
+ for (i = 0; i < sizeof (GNUNET_HashCode) * 8; i++)
+ {
+ if (GNUNET_hash_get_bit (&peer->hashPubKey, i) == 0)
+ {
+ loc[i] = '0';
+ }
+ else
+ {
+ loc[i] = '1';
+ }
+ }
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "%s\n", &loc);
+}
+
+void
+print_buckets ()
+{
+ unsigned int i;
+ unsigned int j;
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "My bit location:\n");
+ printPeerBits (coreAPI->my_identity);
+ for (i = 0; i < bucketCount; i++)
+ {
+ if (buckets[i].peers_size > 0)
+ {
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER
+ | GNUNET_GE_BULK, "Printing peers in bucket %d", i);
+ for (j = 0; j < buckets[i].peers_size; j++)
+ {
+ printPeerBits (&buckets[i].peers[j]->id);
+ }
+ }
+ }
+}
+
+
/**
* Initialize table DV_DHT component.
*
@@ -813,17 +936,76 @@
unsigned long long i;
coreAPI = capi;
+#if DEBUG_TABLE
+ char *gnunet_path;
+ GNUNET_GC_get_configuration_value_string (coreAPI->cfg, "PATHS",
+ "GNUNETD_HOME", "/tmp",
+ &gnunet_path);
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "gnunet_path %s\n", gnunet_path);
+ debug_file_name =
+ GNUNET_malloc (strlen (gnunet_path) + strlen ("table.log") + 2);
+ sprintf (debug_file_name, "%s/%s", gnunet_path, "table.log");
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "table log file is %s\n", debug_file_name);
+ debug_file = fopen (debug_file_name, "w");
+ if (debug_file == NULL)
+ {
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "unable to create/open file `%s', errno is %s\n",
+ debug_file_name, strerror (errno));
+ return GNUNET_SYSERR;
+ }
+#endif
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK, "My bit location:\n");
+ printPeerBits (coreAPI->my_identity);
/* use less than 50% of peer's ideal number of
connections for DV_DHT table size */
i = coreAPI->core_slots_count () / MAINTAIN_BUCKET_SIZE / 2;
+ i = sizeof (GNUNET_HashCode) * 8;
+ GNUNET_GE_LOG (coreAPI->ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ "core_slots_count returns %d, using %d buckets\n",
+ coreAPI->core_slots_count (), i);
if (i < 4)
i = 4;
GNUNET_array_grow (buckets, bucketCount, i);
+ /* I think this is wrong. First, we have just increased the
+ * number of buckets to i, but then we iterate only over whatever
+ * the old bucketCount was! And bucketCount is declared as
+ * static and never changed which means that it will always be
+ * 0. This results in having a single bucket for all peers,
+ * which is rather insane/useless. Also, why would bstart
+ * and bend be multiplied by 512?? Their bit distance should
+ * be between 2^i and 2^i+1 right??? Not 2^(512 + i) as that
+ * number is freaking huge and nuts. Are we trying to evenly
+ * spread the table over however many buckets we have? That
+ * makes more sense, but still doesn't get accomplished by
+ * the code below.
+ * for (i = 0; i < bucketCount; i++)
+ {
+ buckets[i].bstart = 512 * i / bucketCount;
+ buckets[i].bend = 512 * (i + 1) / bucketCount;
+ }
+ */
+
+ /* So if we are trying to cover all locations with i (not bucketCount,
+ * which will always be zero at this point) we set bucketCount = i.
+ */
+ bucketCount = i;
for (i = 0; i < bucketCount; i++)
{
buckets[i].bstart = 512 * i / bucketCount;
buckets[i].bend = 512 * (i + 1) / bucketCount;
}
+
lock = capi->global_lock_get ();
stats = capi->service_request ("stats");
dvapi = capi->service_request ("dv");
@@ -853,6 +1035,8 @@
GNUNET_cron_add_job (coreAPI->cron, &maintain_dht_job, MAINTAIN_FREQUENCY,
MAINTAIN_FREQUENCY, NULL);
+ GNUNET_cron_add_job (coreAPI->cron, &print_buckets, MAINTAIN_FREQUENCY * 30,
+ MAINTAIN_FREQUENCY * 30, NULL);
return GNUNET_OK;
}
Modified: GNUnet/src/applications/dv_dht/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/dv_dht/tools/Makefile.am 2009-06-25 14:48:33 UTC
(rev 8603)
+++ GNUnet/src/applications/dv_dht/tools/Makefile.am 2009-06-26 20:14:08 UTC
(rev 8604)
@@ -26,8 +26,18 @@
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
+bin_PROGRAMS = \
+ dv_dht_driver
+dv_dht_driver_SOURCES = \
+ dv_dht_driver.c
+dv_dht_driver_LDADD = \
+ $(top_builddir)/src/applications/stats/libgnunetstatsapi.la \
+ $(top_builddir)/src/applications/testing/libgnunettestingapi.la \
+ $(top_builddir)/src/applications/testing/libgnunetremoteapi.la \
+ $(top_builddir)/src/applications/dv_dht/tools/libgnunetdvdhtapi.la \
+ $(top_builddir)/src/util/libgnunetutil.la
check_PROGRAMS = \
dv_dht_loopback_test \
Added: GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c
(rev 0)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_driver.c 2009-06-26
20:14:08 UTC (rev 8604)
@@ -0,0 +1,451 @@
+/*
+ This file is part of GNUnet.
+ (C) 2007, 2008 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/dv_dht/tools/dv_dht_driver.c
+ * @brief DV_DHT Driver for testing DHT
+ * @author Christian Grothoff
+ * @author Nathan Evans
+ */
+
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_dv_dht_lib.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_stats_lib.h"
+#include "gnunet_util.h"
+#include "gnunet_remote_lib.h"
+#include "gnunet_dhtlog_service.h"
+
+
+
+static char *configFile = "dv_test.conf";
+static GNUNET_CoreAPIForPlugins capi;
+static struct GNUNET_GE_Context *ectx;
+static struct GNUNET_GC_Configuration *cfg;
+static GNUNET_ServicePluginInitializationMethod init;
+static GNUNET_ServicePluginShutdownMethod done;
+static GNUNET_dhtlog_ServiceAPI *sqlapi;
+
+static unsigned long long topology;
+static unsigned long long num_peers;
+static unsigned long long num_repeat;
+static unsigned long long num_rounds;
+static char *dotOutFileName = NULL;
+
+static struct GNUNET_CommandLineOption gnunetDHTDriverOptions[] = {
+ GNUNET_COMMAND_LINE_OPTION_CFG_FILE (&configFile), /* -c */
+ GNUNET_COMMAND_LINE_OPTION_HELP (gettext_noop ("Run tests on DHT")), /* -h
*/
+ GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+ {'O', "output", "DOT_OUTPUT",
+ gettext_noop
+ ("set output file for a dot input file which represents the graph of the
connected nodes"),
+ 1, &GNUNET_getopt_configure_set_string, &dotOutFileName},
+ GNUNET_COMMAND_LINE_OPTION_VERBOSE,
+ GNUNET_COMMAND_LINE_OPTION_END,
+};
+
+/**
+ * How many peers should the testcase run (default)?
+ */
+#define DEFAULT_NUM_PEERS 15
+
+/**
+ * How many times will we try the DV_DHT-GET operation before
+ * giving up for good (default)?
+ */
+#define DEFAULT_NUM_ROUNDS 20
+
+/**
+ * How often do we iterate the put-get loop (default)?
+ */
+#define DEFAULT_NUM_REPEAT 5
+
+static int ok;
+static int found;
+
+static void *
+rs (const char *name)
+{
+ return NULL;
+}
+
+static int
+rsx (void *s)
+{
+ return GNUNET_OK;
+}
+
+static int
+result_callback (const GNUNET_HashCode * key,
+ unsigned int type,
+ unsigned int size, const char *data, void *cls)
+{
+ int *i = cls;
+ char expect[8];
+
+ memset (expect, (*i), sizeof (expect));
+#if 0
+ fprintf (stderr, "Got %u %u `%.*s' (want `%.*s')\n", type, size, size, data,
+ sizeof (expect), expect);
+#endif
+ if ((8 != size) ||
+ (0 != memcmp (expect, data, size)) ||
+ (type != GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING))
+ return GNUNET_SYSERR;
+ found++;
+ return GNUNET_OK;
+}
+
+
+static int
+waitForConnect (const char *name, unsigned long long value, void *cls)
+{
+ if ((value > 0) && (0 == strcmp (_("# dv_dht connections"), name)))
+ {
+ ok = 1;
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+static int
+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;
+ return GNUNET_SYSERR;
+ }
+ 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)
+{
+ struct GNUNET_REMOTE_TESTING_DaemonContext *peers;
+ struct GNUNET_REMOTE_TESTING_DaemonContext *peer_array[num_peers];
+ struct GNUNET_REMOTE_TESTING_DaemonContext *pos;
+ int ret = 0;
+ GNUNET_HashCode key;
+ char value[8];
+ struct GNUNET_ClientServerConnection *sock;
+ struct GNUNET_DV_DHT_Context *dctx;
+ struct GNUNET_DV_DHT_GetRequest *get1;
+ int left;
+ int i;
+ int j;
+ int k;
+ int c;
+ int r;
+ int last;
+ char buf[128];
+ unsigned long long trialuid;
+
+ if (sqlapi == NULL)
+ {
+ return GNUNET_SYSERR;
+ }
+ else
+ {
+ ret = sqlapi->insert_trial (&trialuid, num_peers, topology);
+ }
+
+ if (ret != GNUNET_OK)
+ return GNUNET_SYSERR;
+ printf ("Starting %u peers...\n", (unsigned int) num_peers);
+ 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;
+ }
+ sleep (30);
+ found = 0;
+ for (r = 0; r < num_repeat; 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);
+ }
+
+ 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;
+ /* put loop */
+ printf ("Waiting for DV_DHT connections of peer");
+ for (i = 0; i < num_peers; i++)
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ ok = 0;
+ printf (" %d", i);
+ fflush (stdout);
+ GNUNET_snprintf (buf, sizeof (buf), "localhost:%u", 2087 + i * 10);
+ /* wait for some DV_DHT's to find each other! */
+ sock =
+ GNUNET_client_connection_create (NULL, peer_array[i]->config);
+ left = 30; /* how many iterations should we wait? */
+ while (GNUNET_OK ==
+ GNUNET_STATS_get_statistics (NULL, sock, &waitForConnect,
+ NULL))
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ if (9 == left % 10)
+ printf (".");
+ fflush (stdout);
+ GNUNET_thread_sleep (2 * GNUNET_CRON_SECONDS);
+ left--;
+ if (left == 0)
+ break;
+ }
+ GNUNET_client_connection_destroy (sock);
+ if (ok == 0)
+ {
+ printf ("ERROR!\n");
+ fflush (stdout);
+ pos = peers;
+ while (pos != NULL)
+ {
+ GNUNET_REMOTE_kill_daemon (pos);
+ pos = pos->next;
+ }
+ fprintf (stderr, "Peers' DV_DHTs failed to DV_DHT-connect!\n");
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+ GNUNET_hash (buf, strlen (buf), &key);
+ memset (value, 'A' + i, sizeof (value));
+ CHECK (GNUNET_OK == GNUNET_DV_DHT_put (peer_array[i]->config,
+ ectx,
+ &key,
+
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+ sizeof (value), value));
+ }
+ printf ("\n");
+ /* get loop */
+ for (i = 0; i < num_peers; i++)
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ GNUNET_snprintf (buf, sizeof (buf), "localhost:%u", 2087 + i * 10);
+
+ dctx =
+ GNUNET_DV_DHT_context_create (peer_array[i]->config, ectx,
+ &result_callback, &c);
+ printf ("Peer %d gets key", i);
+ fflush (stdout);
+ for (j = 0; j < num_peers; j++)
+ {
+ if (GNUNET_shutdown_test () == GNUNET_YES)
+ break;
+ c = 'A' + j;
+ GNUNET_snprintf (buf, sizeof (buf), "localhost:%u",
+ 2087 + j * 10);
+ GNUNET_hash (buf, strlen (buf), &key);
+ printf (" %d", j);
+ fflush (stdout);
+ last = found;
+ get1 = GNUNET_DV_DHT_get_start (dctx,
+
GNUNET_ECRS_BLOCKTYPE_DHT_STRING2STRING,
+ &key);
+ GNUNET_GE_ASSERT (NULL, get1 != NULL);
+ for (k = 0; k < 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 == num_rounds)
+ {
+ printf ("?");
+ fflush (stdout);
+ }
+ }
+ GNUNET_DV_DHT_context_destroy (dctx);
+ printf ("\n");
+ }
+ }
+ /* end of actual test code */
+ if (r == num_repeat)
+ printf ("Found %u out of %llu attempts.\n", found,
+ num_peers * num_peers * r);
+ if (found < num_peers * num_peers * r / 2)
+ {
+ printf
+ ("Not enough results (not even 50%%), marking test as failed!\n");
+ ret = 1;
+ }
+FAILURE:
+ pos = peers;
+ while (pos != NULL)
+ {
+ GNUNET_REMOTE_kill_daemon (pos);
+ pos = pos->next;
+ }
+ ret = sqlapi->update_trial (trialuid);
+ return ret;
+}
+
+/**
+ * Driver for testing DV_DHT routing (many peers).
+ * @return 0: ok, -1: error
+ */
+int
+main (int argc, char *const *argv)
+{
+ int ret = 0;
+ struct GNUNET_PluginHandle *plugin;
+ struct GNUNET_GC_Configuration *driverConfig;
+ ectx = NULL;
+ cfg = GNUNET_GC_create ();
+
+ ret =
+ GNUNET_init (argc, argv, "dvdhtdriver", &configFile,
+ gnunetDHTDriverOptions, &ectx, &driverConfig);
+
+ if (ret == -1)
+ {
+ GNUNET_fini (ectx, cfg);
+ return -1;
+ }
+
+ if (-1 == GNUNET_GC_parse_configuration (cfg, configFile))
+ {
+ GNUNET_GC_free (cfg);
+ return -1;
+ }
+ if (dotOutFileName != NULL)
+ {
+ GNUNET_GC_set_configuration_value_string (cfg, NULL,
+ "MULTIPLE_SERVER_TESTING",
+ "DOT_OUTPUT", dotOutFileName);
+ }
+
+ GNUNET_GC_get_configuration_value_number (cfg,
+ "MULTIPLE_SERVER_TESTING",
+ "TOPOLOGY", 0, -1, 0, &topology);
+
+ GNUNET_GC_get_configuration_value_number (cfg,
+ "MULTIPLE_SERVER_TESTING",
+ "NUM_PEERS",
+ 1,
+ -1,
+ DEFAULT_NUM_PEERS, &num_peers);
+
+ GNUNET_GC_get_configuration_value_number (cfg,
+ "MULTIPLE_SERVER_TESTING",
+ "NUM_ROUNDS",
+ 1,
+ -1,
+ DEFAULT_NUM_ROUNDS, &num_rounds);
+
+ GNUNET_GC_get_configuration_value_number (cfg,
+ "MULTIPLE_SERVER_TESTING",
+ "NUM_REPEAT",
+ 1,
+ -1,
+ DEFAULT_NUM_REPEAT, &num_repeat);
+
+ memset (&capi, 0, sizeof (GNUNET_CoreAPIForPlugins));
+ capi.cfg = cfg;
+ capi.service_request = &rs;
+ capi.service_release = &rsx;
+
+ plugin = GNUNET_plugin_load (NULL, "libgnunetmodule_", "dhtlog_mysql");
+ init =
+ GNUNET_plugin_resolve_function (plugin, "provide_module_", GNUNET_YES);
+ sqlapi = init (&capi);
+ if (sqlapi == NULL)
+ {
+ ret = GNUNET_SYSERR;
+ }
+ else
+ {
+ ret = do_testing (argc, argv);
+ }
+ done =
+ GNUNET_plugin_resolve_function (plugin, "release_module_", GNUNET_YES);
+ if (done != NULL)
+ done ();
+
+ GNUNET_plugin_unload (plugin);
+
+ GNUNET_GC_free (cfg);
+ return ret;
+}
+
+/* end of dv_dht_driver.c */
Modified: GNUnet/src/applications/dv_dht/tools/dv_dht_multi_topology_test.c
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_dht_multi_topology_test.c
2009-06-25 14:48:33 UTC (rev 8603)
+++ GNUnet/src/applications/dv_dht/tools/dv_dht_multi_topology_test.c
2009-06-26 20:14:08 UTC (rev 8604)
@@ -48,7 +48,7 @@
/**
* How often do we iterate the put-get loop?
*/
-#define NUM_REPEAT 50
+#define NUM_REPEAT 5
static int ok;
static int found;
@@ -175,15 +175,14 @@
break;
sleep (60);
}
- pos = peers;
+/* pos = peers;
while (pos != NULL)
{
GNUNET_REMOTE_kill_daemon (pos);
pos = pos->next;
}
GNUNET_GC_free (cfg);
- return ret;
-
+*/
for (r = 0; r < NUM_REPEAT; r++)
{
if (r > 0)
@@ -193,6 +192,18 @@
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;
/* put loop */
Modified: GNUnet/src/applications/dv_dht/tools/dv_test.conf
===================================================================
--- GNUnet/src/applications/dv_dht/tools/dv_test.conf 2009-06-25 14:48:33 UTC
(rev 8603)
+++ GNUnet/src/applications/dv_dht/tools/dv_test.conf 2009-06-26 20:14:08 UTC
(rev 8604)
@@ -4,5 +4,10 @@
STARTING_PORT=31387
PORT_INCREMENT=2
BASE_CONFIG=gnunetd_dv.conf
-TOPOLOGY=0
+TOPOLOGY=2
#PERCENTAGE=.45
+MYSQL_HOST = localhost
+MYSQL_DB = dhttests
+MYSQL_USER = dht
+MYSQL_PASSWORD = dht**
+
Modified: GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf
===================================================================
--- GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf 2009-06-25
14:48:33 UTC (rev 8603)
+++ GNUnet/src/applications/dv_dht/tools/gnunetd_dv.conf 2009-06-26
20:14:08 UTC (rev 8604)
@@ -48,7 +48,9 @@
DISABLE = NO
[LOGGING]
-DEVELOPER = NO
+DEVELOPER = YES
+ADMIN-LEVEL = DEBUG
+USER-LEVEL = DEBUG
[LOAD]
MAXNETDOWNBPSTOTAL = 50000
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8604 - in GNUnet/src/applications/dv_dht: module tools,
gnunet <=