/**
* 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
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;
}
/* 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));
/* 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));
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))) )
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;
}
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));
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));
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);
return 0;
}
*targets = rtargets;
- for (ret = 0; ret < off; ret++)
- GNUNET_CONTAINER_bloomfilter_add (bloom, &rtargets[ret]->id.hashPubKey);
return off;
}
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,
&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,
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,
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,
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,
/* 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));
&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),
#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)
#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
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);
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;
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);
#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++)
}
if (get_path != NULL)
{
+ unsigned int i;
+
fprintf (stderr, "GET (%u) Path: ",
test_get->uid);
for (i = 0; i < get_path_length; i++)
/**
- * 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++)
{
}
+/**
+ * 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
*/