[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17147 - gnunet/src/dht
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17147 - gnunet/src/dht |
Date: |
Fri, 30 Sep 2011 22:55:21 +0200 |
Author: grothoff
Date: 2011-09-30 22:55:21 +0200 (Fri, 30 Sep 2011)
New Revision: 17147
Modified:
gnunet/src/dht/Makefile.am
gnunet/src/dht/dht.h
gnunet/src/dht/gnunet-service-dht_neighbours.c
gnunet/src/dht/multipeer_topo.dat
gnunet/src/dht/test_dht_multipeer.c
Log:
fixing bloomfilter code, fixing testcase
Modified: gnunet/src/dht/Makefile.am
===================================================================
--- gnunet/src/dht/Makefile.am 2011-09-30 18:58:43 UTC (rev 17146)
+++ gnunet/src/dht/Makefile.am 2011-09-30 20:55:21 UTC (rev 17147)
@@ -83,8 +83,8 @@
test_dht_twopeer \
test_dht_twopeer_put_get \
test_dht_twopeer_get_put \
- test_dht_twopeer_path_tracking
-# test_dht_multipeer
+ test_dht_twopeer_path_tracking \
+ test_dht_multipeer
endif
test_dht_api_SOURCES = \
Modified: gnunet/src/dht/dht.h
===================================================================
--- gnunet/src/dht/dht.h 2011-09-30 18:58:43 UTC (rev 17146)
+++ gnunet/src/dht/dht.h 2011-09-30 20:55:21 UTC (rev 17147)
@@ -31,7 +31,7 @@
/**
* Size of the bloom filter the DHT uses to filter peers.
*/
-#define DHT_BLOOM_SIZE 1024
+#define DHT_BLOOM_SIZE 128
/**
Modified: gnunet/src/dht/gnunet-service-dht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht_neighbours.c 2011-09-30 18:58:43 UTC
(rev 17146)
+++ gnunet/src/dht/gnunet-service-dht_neighbours.c 2011-09-30 20:55:21 UTC
(rev 17147)
@@ -56,7 +56,7 @@
/**
* What is the maximum number of peers in a given bucket.
*/
-#define DEFAULT_BUCKET_SIZE 4
+#define DEFAULT_BUCKET_SIZE 8
/**
* Desired replication level for FIND PEER requests
@@ -559,6 +559,10 @@
GNUNET_HashCode mh;
GNUNET_BLOCK_mingle_hash (key, ctx->bf_mutator, &mh);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding known peer (%s) to bloomfilter for FIND PEER with
mutation %u\n",
+ GNUNET_h2s (key),
+ ctx->bf_mutator);
GNUNET_CONTAINER_bloomfilter_add (ctx->bloom, &mh);
return GNUNET_YES;
}
@@ -643,7 +647,7 @@
/* Check for connect to self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connected %s to %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (&peer->hashPubKey));
@@ -705,7 +709,7 @@
/* Check for disconnect from self message */
if (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnected %s from %s\n",
GNUNET_i2s (&my_identity),
GNUNET_h2s (&peer->hashPubKey));
@@ -777,16 +781,28 @@
size_t msize;
peer->th = NULL;
- if (buf == NULL)
+ while ( (NULL != (pending = peer->head)) &&
+ (GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value ==
0) )
{
- /* client disconnected */
- return 0;
+ peer->pending_count--;
+ GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
+ GNUNET_free (pending);
}
- if (peer->head == NULL)
+ if (pending == NULL)
{
/* no messages pending */
return 0;
}
+ if (buf == NULL)
+ {
+ peer->th
+ = GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES,
+ pending->importance,
+ GNUNET_TIME_absolute_get_remaining
(pending->timeout),
+ &peer->id, ntohs
(pending->msg->size),
+ &core_transmit_notify, peer);
+ return 0;
+ }
off = 0;
while ( (NULL != (pending = peer->head)) &&
(size - off >= (msize = ntohs (pending->msg->size))) )
@@ -857,12 +873,12 @@
uint32_t forward_count;
float target_value;
- if (hop_count > GDS_NSE_get () * 4.0)
+ if (hop_count > GDS_NSE_get () * 6.0)
{
/* forcefully terminate */
return 0;
}
- if (hop_count > GDS_NSE_get () * 2.0)
+ if (hop_count > GDS_NSE_get () * 4.0)
{
/* Once we have reached our ideal number of hops, only forward to 1 peer */
return 1;
@@ -1046,7 +1062,7 @@
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Excluded peer `%s' due to BF match in greedy routing for
%s\n",
GNUNET_i2s (&pos->id),
GNUNET_h2s (key));
@@ -1080,7 +1096,7 @@
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# Peers excluded from routing
due to Bloomfilter"), 1,
GNUNET_NO);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Excluded peer `%s' due to BF match in random routing for
%s\n",
GNUNET_i2s (&pos->id),
GNUNET_h2s (key));
@@ -1164,15 +1180,15 @@
rtargets[off] = nxt;
GNUNET_break (GNUNET_NO ==
GNUNET_CONTAINER_bloomfilter_test (bloom,
&nxt->id.hashPubKey));
+ GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[off]->id.hashPubKey);
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Selected %u/%u peers at hop %u for %s (target was %u)\n",
off,
GNUNET_CONTAINER_multihashmap_size (all_known_peers),
(unsigned int) hop_count,
GNUNET_h2s (key),
ret);
-
if (0 == off)
{
GNUNET_free (rtargets);
@@ -1180,8 +1196,6 @@
return 0;
}
*targets = rtargets;
- for (ret = 0; ret < off; ret++)
- GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[ret]->id.hashPubKey);
return off;
}
@@ -1228,6 +1242,10 @@
struct GNUNET_PeerIdentity *pp;
GNUNET_assert (NULL != bf);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding myself (%s) to PUT bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (key));
GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity.hashPubKey);
GNUNET_STATISTICS_update (GDS_stats,
gettext_noop ("# PUT requests routed"), 1,
@@ -1237,7 +1255,7 @@
&targets);
if (0 == target_count)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s terminates after %u hops at %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
@@ -1261,7 +1279,7 @@
for (i=0;i<target_count;i++)
{
target = targets[i];
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing PUT for %s after %u hops to %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
@@ -1344,10 +1362,14 @@
target_count = get_target_peers (key, peer_bf, hop_count,
desired_replication_level,
&targets);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding myself (%s) to GET bloomfilter for %s\n",
+ GNUNET_i2s (&my_identity),
+ GNUNET_h2s (key));
GNUNET_CONTAINER_bloomfilter_add (peer_bf, &my_identity.hashPubKey);
if (0 == target_count)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing GET for %s terminates after %u hops at %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
@@ -1368,7 +1390,7 @@
for (i=0;i<target_count;i++)
{
target = targets[i];
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Routing GET for %s after %u hops to %s\n",
GNUNET_h2s (key),
(unsigned int) hop_count,
@@ -1576,7 +1598,7 @@
/* cannot verify, good luck */
break;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PUT for %s at %s\n",
GNUNET_h2s (&put->key),
GNUNET_i2s (&my_identity));
@@ -1810,7 +1832,7 @@
&get->key,
xquery, xquery_size,
reply_bf, get->bf_mutator);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GET for %s at %s after %u hops\n",
GNUNET_h2s (&get->key),
GNUNET_i2s (&my_identity),
Modified: gnunet/src/dht/multipeer_topo.dat
===================================================================
--- gnunet/src/dht/multipeer_topo.dat 2011-09-30 18:58:43 UTC (rev 17146)
+++ gnunet/src/dht/multipeer_topo.dat 2011-09-30 20:55:21 UTC (rev 17147)
@@ -9,3 +9,23 @@
8:9
9:10
10:1
+4:2
+5:3
+6:4
+7:5
+8:6
+9:7
+10:8
+1:9
+2:10
+3:1
+6:2
+7:3
+8:4
+9:5
+10:6
+1:7
+2:8
+3:9
+4:10
+5:1
Modified: gnunet/src/dht/test_dht_multipeer.c
===================================================================
--- gnunet/src/dht/test_dht_multipeer.c 2011-09-30 18:58:43 UTC (rev 17146)
+++ gnunet/src/dht/test_dht_multipeer.c 2011-09-30 20:55:21 UTC (rev 17147)
@@ -34,10 +34,10 @@
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 30)
/* Timeout for waiting for replies to get requests */
-#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
+#define GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
300)
/* */
-#define START_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
+#define START_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
/* Timeout for waiting for gets to complete */
#define GET_DELAY GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS,
50)
@@ -50,11 +50,11 @@
#define TEST_DATA_SIZE 8
-#define MAX_OUTSTANDING_PUTS 10
+#define MAX_OUTSTANDING_PUTS 100
-#define MAX_OUTSTANDING_GETS 10
+#define MAX_OUTSTANDING_GETS 100
-#define PATH_TRACKING GNUNET_YES
+#define PATH_TRACKING GNUNET_NO
@@ -348,9 +348,6 @@
GNUNET_DHT_disconnect (test_get->dht_handle);
test_get->dht_handle = NULL;
- fprintf (stderr,
- "%llu gets succeeded, %llu gets failed!\n",
- gets_completed, gets_failed);
GNUNET_CONTAINER_DLL_remove (all_gets_head,
all_gets_tail,
test_get);
@@ -358,6 +355,9 @@
if ((gets_failed > 0) && (outstanding_gets == 0)) /* Had some failures
*/
{
+ fprintf (stderr,
+ "%llu gets succeeded, %llu gets failed!\n",
+ gets_completed, gets_failed);
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_add_now (&end_badly, "not all gets succeeded");
return;
@@ -394,7 +394,6 @@
struct TestGetContext *test_get = cls;
GNUNET_HashCode search_key; /* Key stored under */
char original_data[TEST_DATA_SIZE]; /* Made up data to store */
- unsigned int i;
memset (original_data, test_get->uid, sizeof (original_data));
GNUNET_CRYPTO_hash (original_data, TEST_DATA_SIZE, &search_key);
@@ -404,6 +403,8 @@
#if PATH_TRACKING
if (put_path != NULL)
{
+ unsigned int i;
+
fprintf (stderr, "PUT (%u) Path: ",
test_get->uid);
for (i = 0; i<put_path_length; i++)
@@ -412,6 +413,8 @@
}
if (get_path != NULL)
{
+ unsigned int i;
+
fprintf (stderr, "GET (%u) Path: ",
test_get->uid);
for (i = 0; i < get_path_length; i++)
@@ -485,29 +488,20 @@
/**
- * Called when the PUT request has been transmitted to the DHT service.
- * Schedule the GET request for some time in the future.
+ * Schedule the GET requests
*/
static void
-put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+start_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- struct TestPutContext *test_put = cls;
unsigned long long i;
unsigned long long j;
struct TestGetContext *test_get;
- outstanding_puts--;
- puts_completed++;
- GNUNET_SCHEDULER_cancel (test_put->task);
- test_put->task =
- GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
- if (puts_completed != num_peers * num_peers)
- return;
-
- GNUNET_assert (outstanding_puts == 0);
+#if VERBOSE
fprintf (stderr,
"Issuing %llu GETs\n",
num_peers * num_peers);
+#endif
for (i = 0; i < num_peers; i++)
for (j = 0; j < num_peers; j++)
{
@@ -524,6 +518,29 @@
/**
+ * Called when the PUT request has been transmitted to the DHT service.
+ */
+static void
+put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct TestPutContext *test_put = cls;
+
+ outstanding_puts--;
+ puts_completed++;
+ GNUNET_SCHEDULER_cancel (test_put->task);
+ test_put->task =
+ GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
+ if (puts_completed != num_peers * num_peers)
+ return;
+
+ GNUNET_assert (outstanding_puts == 0);
+ GNUNET_SCHEDULER_add_delayed (START_DELAY,
+ &start_gets,
+ NULL);
+}
+
+
+/**
* Set up some data, and call API PUT function
*/
static void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17147 - gnunet/src/dht,
gnunet <=