[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1172 - in GNUnet: m4 src/applications/pingpong src/server
From: |
grothoff |
Subject: |
[GNUnet-SVN] r1172 - in GNUnet: m4 src/applications/pingpong src/server src/transports |
Date: |
Thu, 30 Jun 2005 11:57:57 -0700 (PDT) |
Author: grothoff
Date: 2005-06-30 11:57:50 -0700 (Thu, 30 Jun 2005)
New Revision: 1172
Modified:
GNUnet/m4/Makefile.in
GNUnet/src/applications/pingpong/pingpong.c
GNUnet/src/server/connection.c
GNUnet/src/transports/tcp.c
Log:
better stats
Modified: GNUnet/m4/Makefile.in
===================================================================
--- GNUnet/m4/Makefile.in 2005-06-30 18:08:35 UTC (rev 1171)
+++ GNUnet/m4/Makefile.in 2005-06-30 18:57:50 UTC (rev 1172)
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005 Free Software Foundation, Inc.
+# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -33,7 +33,6 @@
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
-build_triplet = @build@
host_triplet = @host@
subdir = m4
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
@@ -184,8 +183,6 @@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
@@ -352,7 +349,7 @@
clean-generic:
distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
Modified: GNUnet/src/applications/pingpong/pingpong.c
===================================================================
--- GNUnet/src/applications/pingpong/pingpong.c 2005-06-30 18:08:35 UTC (rev
1171)
+++ GNUnet/src/applications/pingpong/pingpong.c 2005-06-30 18:57:50 UTC (rev
1172)
@@ -29,6 +29,7 @@
#include "gnunet_protocols.h"
#include "gnunet_pingpong_service.h"
#include "gnunet_identity_service.h"
+#include "gnunet_stats_service.h"
#include "gnunet_transport_service.h"
/**
@@ -90,6 +91,22 @@
static Identity_ServiceAPI * identity;
+static Stats_ServiceAPI * stats;
+
+static int stat_encryptedPongReceived;
+
+static int stat_plaintextPongReceived;
+
+static int stat_pingReceived;
+
+static int stat_pingCreated;
+
+static int stat_pongSent;
+
+static int stat_plaintextPingSent;
+
+static int stat_ciphertextPingSent;
+
/**
* We received a PING message, send the PONG reply.
*/
@@ -103,6 +120,8 @@
"ping");
return SYSERR;
}
+ if (stats != NULL)
+ stats->change(stat_pingReceived, 1);
pmsg = (PINGPONG_Message *) msg;
if (!hostIdentityEquals(coreAPI->myIdentity,
&pmsg->receiver)) {
@@ -115,6 +134,8 @@
&pmsg->header,
0,
0); /* send now! */
+ if (stats != NULL)
+ stats->change(stat_pongSent, 1);
return OK;
}
@@ -205,6 +226,8 @@
&enc);
#endif
matched = 0;
+ if (stats != NULL)
+ stats->change(stat_encryptedPongReceived, 1);
MUTEX_LOCK(pingPongLock);
for (i=0;i<MAX_PING_PONG;i++) {
entry = &pingPongs[i];
@@ -260,6 +283,8 @@
"pong");
return SYSERR; /* bad pong */
}
+ if (stats != NULL)
+ stats->change(stat_plaintextPongReceived, 1);
matched = 0;
MUTEX_LOCK(pingPongLock);
for (i=0;i<MAX_PING_PONG;i++) {
@@ -349,6 +374,8 @@
entry->challenge = rand();
pmsg->challenge = htonl(entry->challenge);
MUTEX_UNLOCK(pingPongLock);
+ if (stats != NULL)
+ stats->change(stat_pingCreated, 1);
return &pmsg->header;
}
@@ -375,11 +402,15 @@
return SYSERR;
if (usePlaintext == YES) {
sendPlaintext(receiver, pmsg);
+ if (stats != NULL)
+ stats->change(stat_plaintextPingSent, 1);
} else {
coreAPI->unicast(receiver,
&pmsg->header,
0,
0);
+ if (stats != NULL)
+ stats->change(stat_ciphertextPingSent, 1);
}
FREE(pmsg);
return OK;
@@ -406,6 +437,8 @@
YES);
if (pmsg == NULL)
return SYSERR;
+ if (stats != NULL)
+ stats->change(stat_plaintextPingSent, 1);
coreAPI->sendPlaintext(session,
(char*)pmsg,
sizeof(PINGPONG_Message));
@@ -433,6 +466,24 @@
capi->releaseService(identity);
return NULL;
}
+ stats = capi->requestService("stats");
+ if (stats != NULL) {
+ stat_encryptedPongReceived
+ = stats->create(_("# encrypted PONG messages received"));
+ stat_plaintextPongReceived
+ = stats->create(_("# plaintext PONG messages received"));
+ stat_pingReceived
+ = stats->create(_("# encrypted PING messages received"));
+ stat_pingCreated
+ = stats->create(_("# PING messages created"));
+ stat_pongSent
+ = stats->create(_("# encrypted PONG messages sent"));
+ stat_plaintextPingSent
+ = stats->create(_("# plaintext PING messages sent"));
+ stat_ciphertextPingSent
+ = stats->create(_("# encrypted PING messages sent"));
+
+ }
pingPongLock = capi->getConnectionModuleLock();
pingPongs = (PingPongEntry*) MALLOC(sizeof(PingPongEntry)*MAX_PING_PONG);
memset(pingPongs,
@@ -463,6 +514,8 @@
int release_module_pingpong() {
int i;
+ coreAPI->releaseService(stats);
+ stats = NULL;
coreAPI->releaseService(transport);
transport = NULL;
coreAPI->releaseService(identity);
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2005-06-30 18:08:35 UTC (rev 1171)
+++ GNUnet/src/server/connection.c 2005-06-30 18:57:50 UTC (rev 1172)
@@ -52,6 +52,7 @@
#include "gnunet_session_service.h"
#include "gnunet_fragmentation_service.h"
#include "gnunet_topology_service.h"
+#include "gnunet_stats_service.h"
#include "connection.h"
#include "core.h"
#include "handler.h"
@@ -449,6 +450,11 @@
static Topology_ServiceAPI * topology;
/**
+ * Stats service (maybe NULL!)
+ */
+static Stats_ServiceAPI * stats;
+
+/**
* The buffer containing all current connections.
*/
static BufferEntry ** CONNECTION_buffer_;
@@ -491,6 +497,10 @@
*/
static unsigned int rsnSize;
+static int stat_messagesDropped;
+
+static int stat_sizeMessagesDropped;
+
/* ******************** CODE ********************* */
/**
@@ -1045,6 +1055,10 @@
(int) ((cronTime(NULL) - entry->transmissionTime) / cronSECONDS),
be->sendBufferSize);
#endif
+ if (stats != NULL) {
+ stats->change(stat_messagesDropped, 1);
+ stats->change(stat_sizeMessagesDropped, entry->len);
+ }
FREE(entry->closure);
FREE(entry);
be->sendBuffer[i] = be->sendBuffer[be->sendBufferSize-1];
@@ -2420,6 +2434,13 @@
GNUNET_ASSERT(fragmentation != NULL);
topology = requestService("topology");
GNUNET_ASSERT(topology != NULL);
+ stats = requestService("stats");
+ if (stats != NULL) {
+ stat_messagesDropped
+ = stats->create(_("# outgoing messages dropped"));
+ stat_sizeMessagesDropped
+ = stats->create(_("# bytes of outgoing messages dropped"));
+ }
transport->start(&core_receive);
}
@@ -2472,6 +2493,8 @@
fragmentation = NULL;
releaseService(topology);
topology = NULL;
+ releaseService(stats);
+ stats = NULL;
#if DEBUG_COLLECT_PRIO == YES
fclose(prioFile);
#endif
Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2005-06-30 18:08:35 UTC (rev 1171)
+++ GNUnet/src/transports/tcp.c 2005-06-30 18:57:50 UTC (rev 1172)
@@ -26,6 +26,7 @@
#include "gnunet_util.h"
#include "gnunet_protocols.h"
#include "gnunet_transport.h"
+#include "gnunet_stats_service.h"
#include "platform.h"
#include "ip.h"
@@ -172,6 +173,14 @@
static CoreAPIForTransport * coreAPI;
static TransportAPI tcpAPI;
+static Stats_ServiceAPI * stats;
+
+static int stat_bytesReceived;
+
+static int stat_bytesSent;
+
+static int stat_bytesDropped;
+
/**
* one thread for listening for new connections,
* and for reading on all open sockets
@@ -389,6 +398,10 @@
ret = READ(tcpSession->sock,
&tcpSession->rbuff[tcpSession->pos],
tcpSession->rsize - tcpSession->pos);
+ if ( (ret > 0) &&
+ (stats != NULL) )
+ stats->change(stat_bytesReceived,
+ ret);
cronTime(&tcpSession->lastUse);
if (ret == 0) {
tcpDisconnect(tsession);
@@ -731,7 +744,11 @@
Let's sleep and try again. */
gnunet_util_sleep(20);
goto try_again_1;
- }
+ }
+ if (stats != NULL)
+ stats->change(stat_bytesSent,
+ ret);
+
#if DEBUG_TCP
LOG(LOG_DEBUG,
"TCP: transmitted %u bytes\n",
@@ -828,13 +845,16 @@
LOG(LOG_DEBUG,
"write already pending, will not take additional message.\n");
#endif
+ if (stats != NULL)
+ stats->change(stat_bytesDropped,
+ ssize);
MUTEX_UNLOCK(&tcplock);
return SYSERR;
}
#if DEBUG_TCP
- LOG(LOG_DEBUG,
- "TCP: trying to send %u bytes\n",
- ssize);
+ LOG(LOG_DEBUG,
+ "TCP: trying to send %u bytes\n",
+ ssize);
#endif
success = SEND_NONBLOCKING(tcpSession->sock,
mp,
@@ -849,6 +869,10 @@
}
if (success == NO)
ret = 0;
+ if (stats != NULL)
+ stats->change(stat_bytesSent,
+ ret);
+
#if DEBUG_TCP
LOG(LOG_DEBUG,
"TCP: transmitted %u bytes\n",
@@ -1171,6 +1195,9 @@
LOG(LOG_DEBUG,
"tcpSend called while TCP is shutdown.\n");
#endif
+ if (stats != NULL)
+ stats->change(stat_bytesDropped,
+ size);
return SYSERR;
}
if (size == 0) {
@@ -1182,6 +1209,9 @@
LOG(LOG_DEBUG,
"tcpSend called after other side closed connection.\n");
#endif
+ if (stats != NULL)
+ stats->change(stat_bytesDropped,
+ size);
return SYSERR; /* other side closed connection */
}
mp = MALLOC(sizeof(TCPMessagePack) + size);
@@ -1376,6 +1406,15 @@
tsessionArrayLength,
32);
coreAPI = core;
+ stats = coreAPI->requestService("stats");
+ if (stats != NULL) {
+ stat_bytesReceived
+ = stats->create(_("# bytes received via TCP"));
+ stat_bytesSent
+ = stats->create(_("# bytes sent via TCP"));
+ stat_bytesDropped
+ = stats->create(_("# bytes dropped by TCP (outgoing)"));
+ }
tcpAPI.protocolNumber = TCP_PROTOCOL_NUMBER;
tcpAPI.mtu = 0;
tcpAPI.cost = 20000; /* about equal to udp */
@@ -1396,6 +1435,7 @@
void donetransport_tcp() {
int i;
+ coreAPI->releaseService(stats);
for (i=tsessionCount-1;i>=0;i--)
destroySession(i);
GROW(tsessions,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1172 - in GNUnet: m4 src/applications/pingpong src/server src/transports,
grothoff <=