test_dht_api_LDADD = \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/hello/libgnunethello.la \
- $(top_builddir)/src/dht/libgnunetdht.la
+ $(top_builddir)/src/dht/libgnunetdhtnew.la
test_dht_api_DEPENDENCIES = \
libgnunetdht.la
struct GNUNET_TRANSPORT_Handle *GDS_transport_handle;
-
/**
* Handle to get our current HELLO.
*/
#define GNUNET_SERVICE_DHT_H
#include "gnunet_util_lib.h"
+#include "gnunet_statistics_service.h"
+#include "gnunet_transport_service.h"
/**
* Configuration we use.
*/
extern struct GNUNET_BLOCK_Context *GDS_block_context;
-
/**
* Handle for the statistics service.
*/
int32_t reply_bf_mutator;
struct GNUNET_CONTAINER_BloomFilter *reply_bf;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# GET requests from clients injected into P2P network"), 1,
+ GNUNET_NO);
reply_bf_mutator = (int32_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
UINT32_MAX);
reply_bf = GNUNET_BLOCK_construct_bloomfilter (reply_bf_mutator,
GNUNET_break (0);
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# PUT requests received from clients"), 1,
+ GNUNET_NO);
dht_msg = (const struct GNUNET_DHT_ClientPutMessage *) message;
/* give to local clients */
GDS_CLIENTS_handle_reply (GNUNET_TIME_absolute_ntoh (dht_msg->expiration),
xquery_size = size - sizeof (struct GNUNET_DHT_ClientGetMessage);
get = (const struct GNUNET_DHT_ClientGetMessage *) message;
xquery = (const char*) &get[1];
-
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# GET requests received from clients"), 1,
+ GNUNET_NO);
cqr = GNUNET_malloc (sizeof (struct ClientQueryRecord) + xquery_size);
cqr->key = get->key;
(const struct GNUNET_DHT_ClientGetStopMessage *) message;
struct RemoveByUniqueIdContext ctx;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# GET STOP requests received from clients"), 1,
+ GNUNET_NO);
ctx.client = find_active_client (client);
ctx.unique_id = dht_stop_msg->unique_id;
GNUNET_CONTAINER_multihashmap_get_multiple (forward_map,
sizeof (struct PendingMessage) + ntohs (frc->pm->msg->size));
pm->next = pm->prev = NULL;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# RESULTS queued for clients"), 1,
+ GNUNET_NO);
reply = (struct GNUNET_DHT_ClientResultMessage*) &pm[1];
reply->unique_id = record->unique_id;
add_pending_message (record->client, pm);
return;
}
/* Put size is actual data size plus struct overhead plus path length (if any) */
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# ITEMS stored in datacache"), 1,
+ GNUNET_NO);
pe = (struct DHTPutEntry *) buf;
pe->data_size = htons (data_size);
pe->path_length = htons ((uint16_t) put_path_length);
case GNUNET_BLOCK_EVALUATION_OK_LAST:
case GNUNET_BLOCK_EVALUATION_OK_MORE:
/* forward to local clients */
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Good RESULTS found in datacache"), 1,
+ GNUNET_NO);
GDS_CLIENTS_handle_reply (exp,
key,
0, NULL,
0, NULL, rdata, rdata_size);
break;
case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Duplicate RESULTS found in datacache"), 1,
+ GNUNET_NO);
break;
case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Invalid RESULTS found in datacache"), 1,
+ GNUNET_NO);
break;
case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
GNUNET_break (0);
GNUNET_break_op (0);
return GNUNET_SYSERR;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Unsupported RESULTS found in datacache"), 1,
+ GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Unsupported block type (%u) in local response!\n",
type);
if (datacache == NULL)
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# GET requests given to datacache"), 1,
+ GNUNET_NO);
ctx.eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
ctx.key = *key;
ctx.xquery = xquery;
ex = GNUNET_HELLO_get_last_expiration (hello);
if (GNUNET_TIME_absolute_get_remaining (ex).rel_value == 0)
return;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# HELLOs obtained from peerinfo"), 1,
+ GNUNET_NO);
hm = GNUNET_CONTAINER_multihashmap_get (peer_to_hello,
&peer->hashPubKey);
GNUNET_free_non_null (hm);
&update_core_preference, peer);
return;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Preference updates given to core"), 1,
+ GNUNET_NO);
peer->info_ctx =
GNUNET_CORE_peer_change_preference (coreAPI, &peer->id,
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_CONTAINER_multihashmap_iterate (all_known_peers,
&add_known_to_bloom,
&bcc);
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# FIND PEER messages initiated"), 1,
+ GNUNET_NO);
// FIXME: pass priority!?
GDS_NEIGHBOURS_handle_get (GNUNET_BLOCK_TYPE_DHT_HELLO,
GNUNET_DHT_RO_FIND_PEER,
GNUNET_break (0);
return;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peers connected"), 1,
+ GNUNET_NO);
peer_bucket = find_bucket (&peer->hashPubKey);
GNUNET_assert ( (peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS) );
ret = GNUNET_malloc (sizeof (struct PeerInfo));
GNUNET_break (0);
return;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peers connected"), -1,
+ GNUNET_NO);
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_remove (all_known_peers,
&peer->hashPubKey,
while ( (NULL != (pending = peer->head)) &&
(size - off >= (msize = ntohs (pending->msg->size))) )
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Bytes transmitted to other peers"), msize,
+ GNUNET_NO);
memcpy (&cbuf[off], pending->msg, msize);
off += msize;
peer->pending_count--;
struct PeerPutMessage *ppm;
struct GNUNET_PeerIdentity *pp;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# PUT requests routed"), 1,
+ GNUNET_NO);
target_count = get_target_peers (key, bf, hop_count,
desired_replication_level,
&targets);
GNUNET_break (0);
return;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peers selected as targets for PUT requests"), target_count,
+ GNUNET_NO);
for (i=0;i<target_count;i++)
{
target = targets[i];
char *xq;
size_t reply_bf_size;
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# GET requests routed"), 1,
+ GNUNET_NO);
target_count = get_target_peers (key, peer_bf, hop_count,
desired_replication_level,
&targets);
GNUNET_break (0);
return;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Peers selected as targets for GET requests"), target_count,
+ GNUNET_NO);
/* forward request */
for (i=0;i<target_count;i++)
{
/* peer disconnected in the meantime, drop reply */
return;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# REPLIES routed"), 1,
+ GNUNET_NO);
pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
pending->importance = 0; /* FIXME */
pending->timeout = expiration_time;
GNUNET_break_op (0);
return GNUNET_YES;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# P2P PUT requests received"), 1,
+ GNUNET_NO);
put_path = (const struct GNUNET_PeerIdentity*) &put[1];
payload = &put_path[putlen];
options = ntohl (put->options);
GNUNET_break_op (0);
return GNUNET_YES;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# P2P GET requests received"), 1,
+ GNUNET_NO);
reply_bf_size = msize - (sizeof (struct PeerGetMessage) + xquery_size);
type = ntohl (get->type);
options = ntohl (get->options);
{
if ( (0 != (options & GNUNET_DHT_RO_FIND_PEER)))
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# P2P FIND PEER requests processed"), 1,
+ GNUNET_NO);
handle_find_peer (peer,
&get->key,
reply_bf,
GNUNET_break_op (0);
return GNUNET_YES;
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# P2P RESULTS received"), 1,
+ GNUNET_NO);
put_path = (const struct GNUNET_PeerIdentity*) &prm[1];
get_path = &put_path[put_path_length];
type = ntohl (prm->type);
update_network_size_estimate (void *cls, struct GNUNET_TIME_Absolute timestamp,
double logestimate, double std_dev)
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Network size estimates received"), 1,
+ GNUNET_NO);
log_of_network_size_estimate = logestimate;
}
{
case GNUNET_BLOCK_EVALUATION_OK_MORE:
case GNUNET_BLOCK_EVALUATION_OK_LAST:
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Good REPLIES matched against routing table"), 1,
+ GNUNET_NO);
GDS_NEIGHBOURS_handle_reply (&rr->peer,
pc->type,
pc->expiration_time,
pc->data_size);
break;
case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Duplicate REPLIES matched against routing table"), 1,
+ GNUNET_NO);
return GNUNET_OK;
case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
- GNUNET_break_op (0);
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Invalid REPLIES matched against routing table"), 1,
+ GNUNET_NO);
return GNUNET_SYSERR;
case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
GNUNET_break (0);
return GNUNET_OK;
case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Unsupported REPLIES matched against routing table"), 1,
+ GNUNET_NO);
return GNUNET_SYSERR;
default:
GNUNET_break (0);
while (GNUNET_CONTAINER_heap_get_size (recent_heap) >= DHT_MAX_RECENT)
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Entries removed from routing table"), 1,
+ GNUNET_NO);
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap);
GNUNET_assert (recent_req != NULL);
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node);
GNUNET_free (recent_req);
}
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Entries added to routing table"), 1,
+ GNUNET_NO);
recent_req = GNUNET_malloc (sizeof (struct RecentRequest) + xquery_size);
recent_req->peer = *sender;
recent_req->key = *key;
while (GNUNET_CONTAINER_heap_get_size (recent_heap) > 0)
{
+ GNUNET_STATISTICS_update (GDS_stats,
+ gettext_noop ("# Entries removed from routing table"), 1,
+ GNUNET_NO);
recent_req = GNUNET_CONTAINER_heap_peek (recent_heap);
GNUNET_assert (recent_req != NULL);
GNUNET_CONTAINER_heap_remove_node (recent_req->heap_node);
#include "gnunet_os_lib.h"
#include "gnunet_program_lib.h"
#include "gnunet_scheduler_lib.h"
-#include "gnunet_dht_service.h"
+#include "gnunet_dht_service_new.h"
#include "gnunet_hello_lib.h"
#define VERBOSE GNUNET_NO
struct GNUNET_DHT_Handle *dht_handle;
struct GNUNET_PeerIdentity id;
struct GNUNET_DHT_GetHandle *get_handle;
- struct GNUNET_DHT_FindPeerHandle *find_peer_handle;
-
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
#endif
fprintf (stderr, "Ending on an unhappy note.\n");
#endif
- if ((retry_context.peer_ctx != NULL) &&
- (retry_context.peer_ctx->find_peer_handle != NULL))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping find peer request!\n");
- GNUNET_DHT_find_peer_stop (retry_context.peer_ctx->find_peer_handle);
- }
if ((retry_context.peer_ctx != NULL) &&
(retry_context.peer_ctx->get_handle != NULL))
{
* @param cls closure
* @param tc context information (why was this task triggered now)
*/
-void
-test_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct PeerContext *peer = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_find_peer_stop!\n");
- if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0)
- {
- GNUNET_break (0);
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
- return;
- }
-
- GNUNET_assert (peer->dht_handle != NULL);
-
- GNUNET_DHT_find_peer_stop (peer->find_peer_handle);
- peer->find_peer_handle = NULL;
-
-#if HAVE_MALICIOUS
- GNUNET_DHT_set_malicious_getter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS,
- NULL, NULL);
- GNUNET_DHT_set_malicious_putter (peer->dht_handle, GNUNET_TIME_UNIT_SECONDS,
- NULL, NULL);
- GNUNET_DHT_set_malicious_dropper (peer->dht_handle, NULL, NULL);
-#endif
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 1), &end, &p1);
-}
-
-
-/**
- * Iterator called on each result obtained from a find peer
- * operation
- *
- * @param cls closure (NULL)
- * @param peer the peer we learned about
- * @param reply response
- */
-void
-test_find_peer_processor (void *cls, const struct GNUNET_HELLO_Message *hello)
-{
- struct RetryContext *retry_ctx = cls;
- struct GNUNET_PeerIdentity peer;
-
- if (GNUNET_OK == GNUNET_HELLO_get_id (hello, &peer))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test_find_peer_processor called (peer `%s'), stopping find peer request!\n",
- GNUNET_i2s (&peer));
-
- if (retry_ctx->retry_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (retry_ctx->retry_task);
- retry_ctx->retry_task = GNUNET_SCHEDULER_NO_TASK;
- }
-
- GNUNET_SCHEDULER_add_continuation (&test_find_peer_stop, &p1,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "received find peer request, but hello_get_id failed!\n");
- }
-
-}
-
-/**
- * Retry the find_peer task on timeout. (Forward declaration)
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now?)
- */
-void
-retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
-
-/**
- * Retry the find_peer task on timeout.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now)
- */
-void
-retry_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct RetryContext *retry_ctx = cls;
- GNUNET_HashCode hash;
-
- memset (&hash, 42, sizeof (GNUNET_HashCode));
-
- if (GNUNET_TIME_absolute_get_remaining (retry_ctx->real_timeout).rel_value >
- 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test_find_peer timed out, retrying!\n");
- retry_ctx->next_timeout =
- GNUNET_TIME_relative_multiply (retry_ctx->next_timeout, 2);
- retry_ctx->peer_ctx->find_peer_handle =
- GNUNET_DHT_find_peer_start (retry_ctx->peer_ctx->dht_handle,
- retry_ctx->next_timeout, &hash,
- GNUNET_DHT_RO_NONE,
- &test_find_peer_processor, retry_ctx);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "test_find_peer timed out for good, failing!\n");
-
- retry_ctx->peer_ctx->find_peer_handle = NULL;
- }
-
- if (retry_ctx->peer_ctx->find_peer_handle == NULL)
- {
- GNUNET_break (0);
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, &p1);
- return;
- }
- retry_ctx->retry_task =
- GNUNET_SCHEDULER_add_delayed (retry_ctx->next_timeout,
- &retry_find_peer_stop, retry_ctx);
-}
-
-/**
- * Retry the find_peer task on timeout.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now?)
- */
-void
-retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct RetryContext *retry_ctx = cls;
- GNUNET_HashCode hash;
-
- memset (&hash, 42, sizeof (GNUNET_HashCode));
-
- if (retry_ctx->peer_ctx->find_peer_handle != NULL)
- {
- GNUNET_DHT_find_peer_stop (retry_ctx->peer_ctx->find_peer_handle);
- retry_ctx->peer_ctx->find_peer_handle = NULL;
- }
- GNUNET_SCHEDULER_add_now (&retry_find_peer, retry_ctx);
-}
-
-/**
- * Entry point for test of find_peer functionality.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now)
- */
-void
-test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct PeerContext *peer = cls;
- GNUNET_HashCode hash;
-
- memset (&hash, 42, sizeof (GNUNET_HashCode));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called test_find_peer!\n");
- GNUNET_assert (peer->dht_handle != NULL);
-
- retry_context.real_timeout = GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT);
- retry_context.next_timeout = BASE_TIMEOUT;
- retry_context.peer_ctx = peer;
-
- peer->find_peer_handle =
- GNUNET_DHT_find_peer_start (peer->dht_handle, retry_context.next_timeout,
- &hash, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- &test_find_peer_processor, &retry_context);
-
- if (peer->find_peer_handle == NULL)
- {
- GNUNET_break (0);
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_now (&end_badly, &p1);
- return;
- }
- retry_context.retry_task =
- GNUNET_SCHEDULER_add_delayed (retry_context.next_timeout,
- &retry_find_peer_stop, &retry_context);
-}
-
-/**
- * Signature of the main function of a task.
- *
- * @param cls closure
- * @param tc context information (why was this task triggered now)
- */
-void
+static void
test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerContext *peer = cls;
GNUNET_assert (peer->dht_handle != NULL);
GNUNET_DHT_get_stop (peer->get_handle);
peer->get_handle = NULL;
- GNUNET_SCHEDULER_add_now (&test_find_peer, &p1);
+ GNUNET_SCHEDULER_add_now (&end, &p1);
}
-void
+
+static void
test_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
- const struct GNUNET_PeerIdentity *const *get_path,
- const struct GNUNET_PeerIdentity *const *put_path,
+ const struct GNUNET_PeerIdentity *get_path,
+ unsigned int get_path_length,
+ const struct GNUNET_PeerIdentity *put_path,
+ unsigned int put_path_length,
enum GNUNET_BLOCK_Type type, size_t size, const void *data)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
peer->get_handle =
GNUNET_DHT_get_start (peer->dht_handle, TOTAL_TIMEOUT,
GNUNET_BLOCK_TYPE_TEST, &hash,
- DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL,
- 0, NULL, 0, &test_get_iterator, NULL);
+ 1, GNUNET_DHT_RO_NONE, NULL,
+ 0, &test_get_iterator, NULL);
if (peer->get_handle == NULL)
{
GNUNET_assert (peer->dht_handle != NULL);
- GNUNET_DHT_put (peer->dht_handle, &hash, DEFAULT_PUT_REPLICATION,
+ GNUNET_DHT_put (peer->dht_handle, &hash, 1,
GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, data_size, data,
GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT),
TOTAL_TIMEOUT, &test_get, &p1);
ACCEPT_FROM = 127.0.0.1;
HOSTNAME = localhost
PORT = 2100
+BINARY = gnunet-service-dht-new
[block]
plugins = dht test