[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8579 - GNUnet/src/applications/dv/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8579 - GNUnet/src/applications/dv/module |
Date: |
Mon, 15 Jun 2009 11:42:01 -0600 |
Author: nevans
Date: 2009-06-15 11:42:01 -0600 (Mon, 15 Jun 2009)
New Revision: 8579
Modified:
GNUnet/src/applications/dv/module/dv.c
GNUnet/src/applications/dv/module/dv_test.conf
GNUnet/src/applications/dv/module/dvtest.c
Log:
dv changes
Modified: GNUnet/src/applications/dv/module/dv.c
===================================================================
--- GNUnet/src/applications/dv/module/dv.c 2009-06-15 17:41:43 UTC (rev
8578)
+++ GNUnet/src/applications/dv/module/dv.c 2009-06-15 17:42:01 UTC (rev
8579)
@@ -30,6 +30,7 @@
#include "gnunet_util.h"
#include "gnunet_core.h"
#include "gnunet_dv_service.h"
+#include "gnunet_stats_service.h"
#include "dv.h"
#define DEBUG_DV_MAINTAIN GNUNET_YES
@@ -38,6 +39,18 @@
/* How long to allow a message to be delayed */
#define DV_DELAY (100 * GNUNET_CRON_MILLISECONDS)
#define DV_PRIORITY 0
+
+/**
+ * Statistics service.
+ */
+static GNUNET_Stats_ServiceAPI *stats;
+static int stat_dv_total_peers;
+static int stat_dv_sent_messages;
+static int stat_dv_received_messages;
+static int stat_dv_forwarded_messages;
+static int stat_dv_sent_gossips;
+static int stat_dv_received_gossips;
+
/*
* Global construct
*/
@@ -56,7 +69,6 @@
struct GNUNET_CONTAINER_Heap *neighbor_min_heap;
struct GNUNET_CONTAINER_Heap *neighbor_max_heap;
-
};
struct callbackWrapper
@@ -120,6 +132,8 @@
GNUNET_free (neighbor->referrer);
GNUNET_free (neighbor);
+ if (stats != NULL)
+ stats->change (stat_dv_total_peers, -1);
return GNUNET_OK;
}
@@ -419,6 +433,8 @@
"%s: Guessing packed message size %d, actual packed message
size %d\n",
&shortID, message_length, ntohs (packed_message->size));
#endif
+ if (stats != NULL)
+ stats->change (stat_dv_received_messages, 1);
if (memcmp
(coreAPI->my_identity, &incoming->recipient,
sizeof (GNUNET_PeerIdentity)) == 0)
@@ -439,6 +455,7 @@
#endif
coreAPI->loopback_send (&incoming->sender, (char *) packed_message,
ntohs (packed_message->size), GNUNET_YES, NULL);
+
}
else
{
@@ -455,6 +472,8 @@
(char *) &encSender, (char *) &encOrigin);
#endif
ret = forward_message (incoming);
+ if (stats != NULL)
+ stats->change (stat_dv_forwarded_messages, 1);
}
GNUNET_free (message_content);
return ret;
@@ -486,11 +505,45 @@
GNUNET_GE_BULK,
"%s: Entered GNUNET_DV_send_message!\n", &shortID);
#endif
-
+ if (stats != NULL)
+ stats->change (stat_dv_sent_messages, 1);
return send_message (recipient, coreAPI->my_identity, message, importance,
maxdelay);
}
+
+/**
+ * For core, Query how much bandwidth is availabe FROM the given
+ * node to this node in bpm (at the moment). For DV, currently
+ * only returns GNUNET_OK if node is known in DV tables. Should
+ * be obsoleted by DV/transports/Core integration. Necessary
+ * now because DHT uses this call to check if peer is known
+ * before adding to DHT routing tables.
+ *
+ * @param bpm set to the bandwidth
+ * @param last_seen set to last time peer was confirmed up
+ * @return GNUNET_OK on success, GNUNET_SYSERR if if we are NOT connected
+ */
+int
+GNUNET_DV_connection_get_bandwidth_assigned_to_peer (const
+ GNUNET_PeerIdentity *
+ node,
+ unsigned int *bpm,
+ GNUNET_CronTime *
+ last_seen)
+{
+ unsigned int ret;
+ ret = GNUNET_SYSERR;
+ GNUNET_mutex_lock (ctx->dvMutex);
+ //fprintf(stderr, "DV Table size %d\n",
GNUNET_multi_hash_map_size(ctx->extended_neighbors));
+ if (GNUNET_YES == GNUNET_multi_hash_map_contains (ctx->extended_neighbors,
+ &node->hashPubKey))
+ ret = GNUNET_OK;
+ GNUNET_mutex_unlock (ctx->dvMutex);
+ return ret;
+}
+
+
/*
* Handles when a peer is either added due to being newly connected
* or having been gossiped about, also called when a cost for a neighbor
@@ -582,6 +635,8 @@
GNUNET_CONTAINER_heap_insert (ctx->neighbor_max_heap, neighbor, cost);
GNUNET_CONTAINER_heap_insert (ctx->neighbor_min_heap, neighbor, cost);
+ if (stats != NULL)
+ stats->change (stat_dv_total_peers, 1);
}
else
{
@@ -674,7 +729,8 @@
nmsg = (const p2p_dv_MESSAGE_NeighborInfo *) message;
ret = addUpdateNeighbor (&nmsg->neighbor, sender, ntohl (nmsg->cost) + 1);
-
+ if (stats != NULL)
+ stats->change (stat_dv_received_gossips, 1);
if (GNUNET_OK != ret)
GNUNET_GE_LOG (coreAPI->ectx,
GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
@@ -958,6 +1014,8 @@
coreAPI->ciphertext_send (to->neighbor, &message->header, 0,
ctx->send_interval *
GNUNET_CRON_MILLISECONDS);
+ if (stats != NULL)
+ stats->change (stat_dv_sent_gossips, 1);
}
GNUNET_thread_sleep (ctx->send_interval * GNUNET_CRON_MILLISECONDS);
}
@@ -982,12 +1040,31 @@
api.dv_send = &GNUNET_DV_send_message;
api.dv_connections_iterate = &GNUNET_DV_connection_iterate_peers;
+ api.p2p_connection_status_check =
+ &GNUNET_DV_connection_get_bandwidth_assigned_to_peer;
+
+ stats = capi->service_request ("stats");
+ if (stats != NULL)
+ {
+ stat_dv_total_peers = stats->create (gettext_noop ("# dv connections"));
+ stat_dv_sent_messages =
+ stats->create (gettext_noop ("# dv messages sent"));
+ stat_dv_received_messages =
+ stats->create (gettext_noop ("# dv messages received"));
+ stat_dv_forwarded_messages =
+ stats->create (gettext_noop ("# dv messages forwarded"));
+ stat_dv_received_gossips =
+ stats->create (gettext_noop ("# dv gossips received"));
+ stat_dv_sent_gossips =
+ stats->create (gettext_noop ("# dv gossips sent"));
+
+ }
+
ctx = GNUNET_malloc (sizeof (struct GNUNET_DV_Context));
-
ctx->neighbor_min_heap = GNUNET_CONTAINER_heap_create (GNUNET_MIN_HEAP);
ctx->neighbor_max_heap = GNUNET_CONTAINER_heap_create (GNUNET_MAX_HEAP);
ctx->send_interval = GNUNET_DV_DEFAULT_SEND_INTERVAL;
- ctx->dvMutex = GNUNET_mutex_create (GNUNET_NO);
+ ctx->dvMutex = GNUNET_mutex_create (GNUNET_YES);
coreAPI = capi;
GNUNET_hash_to_enc (&coreAPI->my_identity->hashPubKey, &encMe);
strncpy ((char *) &shortID, (char *) &encMe, 4);
Modified: GNUnet/src/applications/dv/module/dv_test.conf
===================================================================
--- GNUnet/src/applications/dv/module/dv_test.conf 2009-06-15 17:41:43 UTC
(rev 8578)
+++ GNUnet/src/applications/dv/module/dv_test.conf 2009-06-15 17:42:01 UTC
(rev 8579)
@@ -4,4 +4,5 @@
STARTING_PORT=31387
PORT_INCREMENT=2
BASE_CONFIG=gnunetd_dv.conf
-TOPOLOGY=2
+TOPOLOGY=1
+PERCENTAGE=.45
Modified: GNUnet/src/applications/dv/module/dvtest.c
===================================================================
--- GNUnet/src/applications/dv/module/dvtest.c 2009-06-15 17:41:43 UTC (rev
8578)
+++ GNUnet/src/applications/dv/module/dvtest.c 2009-06-15 17:42:01 UTC (rev
8579)
@@ -34,6 +34,7 @@
#include "gnunet_directories.h"
#define START_PEERS 1
+#define NUM_RUNS 10
static struct GNUNET_REMOTE_TESTING_DaemonContext *peer1;
static struct GNUNET_REMOTE_TESTING_DaemonContext *peer2;
@@ -185,52 +186,55 @@
sock = GNUNET_client_connection_create (NULL, peers->config);
/* 'slow' pass: wait for bandwidth negotiation! */
- printf (_("Sleeping 15 seconds to let topology stabilize...\n"));
- sleep (15);
+ printf (_("Sleeping 45 seconds to let topology stabilize...\n"));
+ sleep (45);
printf (_("Running benchmark...\n"));
printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
(char *) &peer2enc);
- if (ret == 0)
- ret =
- test (sock, 64, 1, 1, 500 * GNUNET_CRON_MILLISECONDS, 1,
- 15 * GNUNET_CRON_SECONDS, *peer2->peer);
+ for (i = 0; i < NUM_RUNS; i++)
+ {
+ if (ret == 0)
+ ret =
+ test (sock, 64, 1, 1, 500 * GNUNET_CRON_MILLISECONDS, 1,
+ 15 * GNUNET_CRON_SECONDS, *peer2->peer);
- printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
- (char *) &peer3enc);
- if (ret == 0)
- ret =
- test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
- 5 * GNUNET_CRON_SECONDS, *peer3->peer);
+ printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
+ (char *) &peer3enc);
+ if (ret == 0)
+ ret =
+ test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+ 5 * GNUNET_CRON_SECONDS, *peer3->peer);
- printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
- (char *) &peer4enc);
- if (ret == 0)
- ret =
- test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
- 5 * GNUNET_CRON_SECONDS, *peer4->peer);
+ printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
+ (char *) &peer4enc);
+ if (ret == 0)
+ ret =
+ test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+ 5 * GNUNET_CRON_SECONDS, *peer4->peer);
- printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
- (char *) &peer5enc);
- if (ret == 0)
- ret =
- test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
- 5 * GNUNET_CRON_SECONDS, *peer5->peer);
+ printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
+ (char *) &peer5enc);
+ if (ret == 0)
+ ret =
+ test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+ 5 * GNUNET_CRON_SECONDS, *peer5->peer);
- printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
- (char *) &peer6enc);
- if (ret == 0)
- ret =
- test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
- 5 * GNUNET_CRON_SECONDS, *peer6->peer);
+ printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
+ (char *) &peer6enc);
+ if (ret == 0)
+ ret =
+ test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+ 5 * GNUNET_CRON_SECONDS, *peer6->peer);
- printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
- (char *) &peer7enc);
- if (ret == 0)
- ret =
- test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
- 5 * GNUNET_CRON_SECONDS, *peer7->peer);
-
+ printf (_("Sending from %s to %s...\n"), (char *) &peer1enc,
+ (char *) &peer7enc);
+ if (ret == 0)
+ ret =
+ test (sock, 64, 1, 1, 50 * GNUNET_CRON_MILLISECONDS, 1,
+ 5 * GNUNET_CRON_SECONDS, *peer7->peer);
+ sleep (300);
+ }
GNUNET_client_connection_destroy (sock);
#if START_PEERS
/*FIXME: Have GNUNET_REMOTE_TESTING_stop_daemons...
GNUNET_TESTING_stop_daemons (peers); */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8579 - GNUnet/src/applications/dv/module,
gnunet <=