[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10580 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10580 - gnunet/src/transport |
Date: |
Sat, 13 Mar 2010 10:11:17 +0100 |
Author: grothoff
Date: 2010-03-13 10:11:17 +0100 (Sat, 13 Mar 2010)
New Revision: 10580
Modified:
gnunet/src/transport/Makefile.am
gnunet/src/transport/gnunet-service-transport.c
gnunet/src/transport/plugin_transport.h
gnunet/src/transport/plugin_transport_tcp.c
Log:
add stats
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2010-03-12 17:33:43 UTC (rev 10579)
+++ gnunet/src/transport/Makefile.am 2010-03-13 09:11:17 UTC (rev 10580)
@@ -58,6 +58,7 @@
gnunet-service-transport_blacklist.c gnunet-service-transport_blacklist.h
gnunet_service_transport_LDADD = \
$(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(GN_LIBINTL)
Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c 2010-03-12 17:33:43 UTC
(rev 10579)
+++ gnunet/src/transport/gnunet-service-transport.c 2010-03-13 09:11:17 UTC
(rev 10580)
@@ -827,6 +827,12 @@
/**
+ * Handle for reporting statistics.
+ */
+static struct GNUNET_STATISTICS_Handle *stats;
+
+
+/**
* The peer specified by the given neighbour has timed-out or a plugin
* has disconnected. We may either need to do nothing (other plugins
* still up), or trigger a full disconnect and clean up. This
@@ -1073,10 +1079,6 @@
transmit_send_ok (mq->client, n, result);
GNUNET_free (mq);
try_transmission_to_peer (n);
- /** Never disconnect a neighbor here...
- if (result != GNUNET_OK)
- disconnect_neighbour (n, GNUNET_YES);
- */
}
@@ -1235,6 +1237,10 @@
mq->specific_address->addrlen),
rl->plugin->short_name);
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# bytes transmitted to other peers"),
+ mq->message_buf_size,
+ GNUNET_NO);
rl->plugin->api->send (rl->plugin->api->cls,
&mq->neighbour_id,
mq->message_buf,
@@ -1372,6 +1378,10 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Refreshed my `%s', new size is %d\n", "HELLO",
GNUNET_HELLO_size(hello));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# refreshed my HELLO"),
+ 1,
+ GNUNET_NO);
cpos = clients;
while (cpos != NULL)
{
@@ -1393,6 +1403,10 @@
"Transmitting updated `%s' to neighbour `%4s'\n",
"HELLO", GNUNET_i2s (&npos->id));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# transmitted my HELLO to other
peers"),
+ 1,
+ GNUNET_NO);
transmit_to_peer (NULL, NULL, 0,
HELLO_ADDRESS_EXPIRATION,
(const char *) our_hello,
@@ -1555,6 +1569,10 @@
"Notifying clients about connection from `%s'\n",
GNUNET_i2s (peer));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# peers connected"),
+ 1,
+ GNUNET_NO);
cim.header.size = htons (sizeof (struct ConnectInfoMessage));
cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
cim.distance = htonl (distance);
@@ -1583,6 +1601,10 @@
"Notifying clients about lost connection to `%s'\n",
GNUNET_i2s (peer));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# peers connected"),
+ -1,
+ GNUNET_NO);
dim.header.size = htons (sizeof (struct DisconnectInfoMessage));
dim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT);
dim.reserved = htonl (0);
@@ -1770,6 +1792,10 @@
ve->addrlen),
ve->transport_name);
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# address validation successes"),
+ 1,
+ GNUNET_NO);
/* create the updated HELLO */
GNUNET_CRYPTO_hash (&ve->publicKey,
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
@@ -1869,6 +1895,10 @@
"Receiving `%s' message from `%4s'.\n", "PONG",
GNUNET_i2s (peer));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# PONG messages received"),
+ 1,
+ GNUNET_NO);
if (GNUNET_SYSERR !=
GNUNET_CONTAINER_multihashmap_get_multiple (validation_map,
&peer->hashPubKey,
@@ -1913,6 +1943,10 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Neighbour `%4s' has timed out!\n", GNUNET_i2s (&n->id));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# disconnects due to timeout"),
+ 1,
+ GNUNET_NO);
n->timeout_task = GNUNET_SCHEDULER_NO_TASK;
disconnect_neighbour (n, GNUNET_NO);
}
@@ -2041,6 +2075,10 @@
struct ValidationEntry *va = cls;
struct GNUNET_PeerIdentity pid;
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# address validation timeouts"),
+ 1,
+ GNUNET_NO);
GNUNET_CRYPTO_hash (&va->publicKey,
sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
@@ -2163,6 +2201,10 @@
"HELLO", hello_size,
"PING", sizeof (struct TransportPingMessage));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# PING messages sent"),
+ 1,
+ GNUNET_NO);
transmit_to_peer (NULL, peer_address,
GNUNET_SCHEDULER_PRIORITY_DEFAULT,
HELLO_VERIFICATION_TIMEOUT,
@@ -2657,6 +2699,10 @@
GNUNET_a2s ((const struct sockaddr *)sender_address,
sender_address_len));
#endif
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# PING messages received"),
+ 1,
+ GNUNET_NO);
pong = GNUNET_malloc (sizeof (struct TransportPongMessage) +
sender_address_len);
pong->header.size = htons (sizeof (struct TransportPongMessage) +
sender_address_len);
pong->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_PONG);
@@ -2760,6 +2806,10 @@
}
/* update traffic received amount ... */
msize = ntohs (message->size);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# bytes received from other
peers"),
+ msize,
+ GNUNET_NO);
n->distance = distance;
n->peer_timeout =
GNUNET_TIME_relative_to_absolute
@@ -2779,11 +2829,19 @@
("Dropping incoming message due to repeated bandwidth
quota (%u b/s) violations (total of %u).\n"),
n->in_tracker.available_bytes_per_s__,
n->quota_violation_count);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# bandwidth quota violations
by other peers"),
+ 1,
+ GNUNET_NO);
return GNUNET_TIME_UNIT_MINUTES; /* minimum penalty, likely ignored
(UDP...) */
}
switch (ntohs (message->type))
{
case GNUNET_MESSAGE_TYPE_HELLO:
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# HELLO messages received
from other peers"),
+ 1,
+ GNUNET_NO);
process_hello (plugin, message);
break;
case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
@@ -2803,6 +2861,10 @@
n->quota_violation_count++;
else
n->quota_violation_count = 0; /* back within limits */
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# payload received from
other peers"),
+ msize,
+ GNUNET_NO);
/* transmit message to all clients */
im = GNUNET_malloc (sizeof (struct InboundMessage) + msize);
im->header.size = htons (sizeof (struct InboundMessage) + msize);
@@ -2821,11 +2883,17 @@
}
ret = GNUNET_BANDWIDTH_tracker_get_delay (&n->in_tracker, 0);
if (ret.value > 0)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Throttling read (%llu bytes excess at %u b/s), waiting %llums
before reading more.\n",
- (unsigned long long)
n->in_tracker.consumption_since_last_update__,
- (unsigned int) n->in_tracker.available_bytes_per_s__,
- (unsigned long long) ret.value);
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Throttling read (%llu bytes excess at %u b/s), waiting
%llums before reading more.\n",
+ (unsigned long long)
n->in_tracker.consumption_since_last_update__,
+ (unsigned int) n->in_tracker.available_bytes_per_s__,
+ (unsigned long long) ret.value);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# ms throttling suggested"),
+ (int64_t) ret.value,
+ GNUNET_NO);
+ }
return ret;
}
@@ -2942,6 +3010,10 @@
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# payload received for other peers"),
+ size,
+ GNUNET_NO);
obm = (const struct OutboundMessage *) message;
#if DEBUG_TRANSPORT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2992,11 +3064,19 @@
const struct QuotaSetMessage *qsm =
(const struct QuotaSetMessage *) message;
struct NeighbourList *n;
-
+
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# SET QUOTA messages received"),
+ 1,
+ GNUNET_NO);
n = find_neighbour (&qsm->peer);
if (n == NULL)
{
GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# SET QUOTA messages ignored (no
such peer)"),
+ 1,
+ GNUNET_NO);
return;
}
#if DEBUG_TRANSPORT
@@ -3128,6 +3208,7 @@
plug->env.receive = &plugin_env_receive;
plug->env.notify_address = &plugin_env_notify_address;
plug->env.max_connections = max_connect_per_transport;
+ plug->env.stats = stats;
}
@@ -3291,6 +3372,12 @@
&abort_validation,
NULL);
GNUNET_CONTAINER_multihashmap_destroy (validation_map);
+ validation_map = NULL;
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
+ stats = NULL;
+ }
}
@@ -3316,6 +3403,7 @@
sched = s;
cfg = c;
+ stats = GNUNET_STATISTICS_create (sched, "transport", cfg);
validation_map = GNUNET_CONTAINER_multihashmap_create (64);
/* parse configuration */
if ((GNUNET_OK !=
@@ -3332,6 +3420,13 @@
_
("Transport service is lacking key configuration settings.
Exiting.\n"));
GNUNET_SCHEDULER_shutdown (s);
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
+ stats = NULL;
+ }
+ GNUNET_CONTAINER_multihashmap_destroy (validation_map);
+ validation_map = NULL;
return;
}
max_connect_per_transport = (uint32_t) tneigh;
@@ -3343,6 +3438,13 @@
_
("Transport service could not access hostkey. Exiting.\n"));
GNUNET_SCHEDULER_shutdown (s);
+ if (stats != NULL)
+ {
+ GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
+ stats = NULL;
+ }
+ GNUNET_CONTAINER_multihashmap_destroy (validation_map);
+ validation_map = NULL;
return;
}
GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
Modified: gnunet/src/transport/plugin_transport.h
===================================================================
--- gnunet/src/transport/plugin_transport.h 2010-03-12 17:33:43 UTC (rev
10579)
+++ gnunet/src/transport/plugin_transport.h 2010-03-13 09:11:17 UTC (rev
10580)
@@ -33,6 +33,7 @@
#include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h"
+#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
@@ -132,6 +133,11 @@
void *cls;
/**
+ * Handle for reporting statistics.
+ */
+ struct GNUNET_STATISTICS_Handle *stats;
+
+ /**
* Function that should be called by the transport plugin
* whenever a message is received.
*/
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-03-12 17:33:43 UTC (rev
10579)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-03-13 09:11:17 UTC (rev
10580)
@@ -310,6 +310,10 @@
GNUNET_CONTAINER_DLL_insert (ret->pending_messages_head,
ret->pending_messages_tail,
pm);
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ gettext_noop ("# TCP sessions active"),
+ 1,
+ GNUNET_NO);
return ret;
}
@@ -396,6 +400,10 @@
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
"tcp", "Transmitting %u bytes\n", ret);
#endif
+ GNUNET_STATISTICS_update (session->plugin->env->stats,
+ gettext_noop ("# bytes transmitted via TCP"),
+ ret,
+ GNUNET_NO);
return ret;
}
@@ -515,6 +523,10 @@
GNUNET_SERVER_client_drop (session->client);
session->client = NULL;
}
+ GNUNET_STATISTICS_update (session->plugin->env->stats,
+ gettext_noop ("# TCP sessions active"),
+ -1,
+ GNUNET_NO);
GNUNET_free_non_null (session->connect_addr);
GNUNET_free (session);
}
@@ -903,6 +915,10 @@
"WELCOME",
GNUNET_i2s (&wm->clientIdentity), client);
#endif
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ gettext_noop ("# TCP WELCOME messages received"),
+ 1,
+ GNUNET_NO);
session = find_session_by_client (plugin, client);
if (session == NULL)
{
@@ -1010,6 +1026,10 @@
(unsigned int) ntohs (message->type),
GNUNET_i2s (&session->target));
#endif
+ GNUNET_STATISTICS_update (plugin->env->stats,
+ gettext_noop ("# bytes received via TCP"),
+ ntohs (message->size),
+ GNUNET_NO);
delay = plugin->env->receive (plugin->env->cls, &session->target, message, 1,
session->connect_addr,
session->connect_alen);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10580 - gnunet/src/transport,
gnunet <=