diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-03-13 10:00:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-03-13 10:00:36 +0000 |
commit | ec5255591d3a2c2071bcc634a82ebf1581802760 (patch) | |
tree | b1be5fbd9c90d88ac67c0838842526aa004cb026 /src/topology | |
parent | ae48c073f3d599de311f30070bf315085eeeaa33 (diff) | |
download | gnunet-ec5255591d3a2c2071bcc634a82ebf1581802760.tar.gz gnunet-ec5255591d3a2c2071bcc634a82ebf1581802760.zip |
stats
Diffstat (limited to 'src/topology')
-rw-r--r-- | src/topology/Makefile.am | 1 | ||||
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 56 |
2 files changed, 56 insertions, 1 deletions
diff --git a/src/topology/Makefile.am b/src/topology/Makefile.am index 6d7f766bc..88d8800a1 100644 --- a/src/topology/Makefile.am +++ b/src/topology/Makefile.am | |||
@@ -13,6 +13,7 @@ gnunet_daemon_topology_SOURCES = \ | |||
13 | gnunet_daemon_topology_LDADD = \ | 13 | gnunet_daemon_topology_LDADD = \ |
14 | $(top_builddir)/src/core/libgnunetcore.la \ | 14 | $(top_builddir)/src/core/libgnunetcore.la \ |
15 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ | 15 | $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \ |
16 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
16 | $(top_builddir)/src/transport/libgnunettransport.la \ | 17 | $(top_builddir)/src/transport/libgnunettransport.la \ |
17 | $(top_builddir)/src/util/libgnunetutil.la \ | 18 | $(top_builddir)/src/util/libgnunetutil.la \ |
18 | $(GN_LIBINTL) | 19 | $(GN_LIBINTL) |
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index f69bc1468..1d5b41522 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_core_service.h" | 29 | #include "gnunet_core_service.h" |
30 | #include "gnunet_protocols.h" | 30 | #include "gnunet_protocols.h" |
31 | #include "gnunet_peerinfo_service.h" | 31 | #include "gnunet_peerinfo_service.h" |
32 | #include "gnunet_statistics_service.h" | ||
32 | #include "gnunet_transport_service.h" | 33 | #include "gnunet_transport_service.h" |
33 | #include "gnunet_util_lib.h" | 34 | #include "gnunet_util_lib.h" |
34 | 35 | ||
@@ -209,6 +210,11 @@ static struct GNUNET_PeerIdentity my_identity; | |||
209 | static struct PeerList *peers; | 210 | static struct PeerList *peers; |
210 | 211 | ||
211 | /** | 212 | /** |
213 | * Handle for reporting statistics. | ||
214 | */ | ||
215 | static struct GNUNET_STATISTICS_Handle *stats; | ||
216 | |||
217 | /** | ||
212 | * Flag to disallow non-friend connections (pure F2F mode). | 218 | * Flag to disallow non-friend connections (pure F2F mode). |
213 | */ | 219 | */ |
214 | static int friends_only; | 220 | static int friends_only; |
@@ -263,6 +269,10 @@ disconnect_done (void *cls, | |||
263 | { | 269 | { |
264 | struct DisconnectList *dl = cls; | 270 | struct DisconnectList *dl = cls; |
265 | 271 | ||
272 | GNUNET_STATISTICS_update (stats, | ||
273 | gettext_noop ("# peers blacklisted"), | ||
274 | 1, | ||
275 | GNUNET_NO); | ||
266 | GNUNET_CONTAINER_DLL_remove (disconnect_head, | 276 | GNUNET_CONTAINER_DLL_remove (disconnect_head, |
267 | disconnect_tail, | 277 | disconnect_tail, |
268 | dl); | 278 | dl); |
@@ -314,6 +324,10 @@ whitelist_done (void *cls, | |||
314 | struct PeerList *pl = cls; | 324 | struct PeerList *pl = cls; |
315 | 325 | ||
316 | pl->wh = NULL; | 326 | pl->wh = NULL; |
327 | GNUNET_STATISTICS_update (stats, | ||
328 | gettext_noop ("# peers blacklisted"), | ||
329 | -1, | ||
330 | GNUNET_NO); | ||
317 | } | 331 | } |
318 | 332 | ||
319 | 333 | ||
@@ -386,6 +400,10 @@ attempt_connect (struct PeerList *pos) | |||
386 | "Asking core to connect to `%s'\n", | 400 | "Asking core to connect to `%s'\n", |
387 | GNUNET_i2s (&pos->id)); | 401 | GNUNET_i2s (&pos->id)); |
388 | #endif | 402 | #endif |
403 | GNUNET_STATISTICS_update (stats, | ||
404 | gettext_noop ("# connect requests issued to core"), | ||
405 | 1, | ||
406 | GNUNET_NO); | ||
389 | pos->connect_req = GNUNET_CORE_peer_request_connect (sched, cfg, | 407 | pos->connect_req = GNUNET_CORE_peer_request_connect (sched, cfg, |
390 | GNUNET_TIME_UNIT_MINUTES, | 408 | GNUNET_TIME_UNIT_MINUTES, |
391 | &pos->id, | 409 | &pos->id, |
@@ -669,6 +687,10 @@ connect_notify (void *cls, | |||
669 | GNUNET_i2s (peer)); | 687 | GNUNET_i2s (peer)); |
670 | #endif | 688 | #endif |
671 | connection_count++; | 689 | connection_count++; |
690 | GNUNET_STATISTICS_set (stats, | ||
691 | gettext_noop ("# peers connected"), | ||
692 | connection_count, | ||
693 | GNUNET_NO); | ||
672 | pos = find_peer (peer); | 694 | pos = find_peer (peer); |
673 | if (pos == NULL) | 695 | if (pos == NULL) |
674 | { | 696 | { |
@@ -698,6 +720,10 @@ connect_notify (void *cls, | |||
698 | (GNUNET_YES != friends_only) ) | 720 | (GNUNET_YES != friends_only) ) |
699 | whitelist_peers (); | 721 | whitelist_peers (); |
700 | friend_count++; | 722 | friend_count++; |
723 | GNUNET_STATISTICS_set (stats, | ||
724 | gettext_noop ("# friends connected"), | ||
725 | connection_count, | ||
726 | GNUNET_NO); | ||
701 | } | 727 | } |
702 | reschedule_hellos (pos); | 728 | reschedule_hellos (pos); |
703 | } | 729 | } |
@@ -780,8 +806,18 @@ disconnect_notify (void *cls, | |||
780 | return; | 806 | return; |
781 | } | 807 | } |
782 | connection_count--; | 808 | connection_count--; |
809 | GNUNET_STATISTICS_set (stats, | ||
810 | gettext_noop ("# peers connected"), | ||
811 | connection_count, | ||
812 | GNUNET_NO); | ||
783 | if (pos->is_friend) | 813 | if (pos->is_friend) |
784 | friend_count--; | 814 | { |
815 | friend_count--; | ||
816 | GNUNET_STATISTICS_set (stats, | ||
817 | gettext_noop ("# friends connected"), | ||
818 | connection_count, | ||
819 | GNUNET_NO); | ||
820 | } | ||
785 | if ( (connection_count < target_connection_count) || | 821 | if ( (connection_count < target_connection_count) || |
786 | (friend_count < minimum_friend_count) ) | 822 | (friend_count < minimum_friend_count) ) |
787 | try_add_peers (); | 823 | try_add_peers (); |
@@ -1127,6 +1163,10 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1127 | } | 1163 | } |
1128 | GNUNET_free (data); | 1164 | GNUNET_free (data); |
1129 | GNUNET_free (fn); | 1165 | GNUNET_free (fn); |
1166 | GNUNET_STATISTICS_update (stats, | ||
1167 | gettext_noop ("# friends in configuration"), | ||
1168 | entries_found, | ||
1169 | GNUNET_NO); | ||
1130 | if ( (minimum_friend_count > entries_found) && | 1170 | if ( (minimum_friend_count > entries_found) && |
1131 | (friends_only == GNUNET_NO) ) | 1171 | (friends_only == GNUNET_NO) ) |
1132 | { | 1172 | { |
@@ -1169,6 +1209,10 @@ handle_encrypted_hello (void *cls, | |||
1169 | "HELLO", | 1209 | "HELLO", |
1170 | GNUNET_i2s (other)); | 1210 | GNUNET_i2s (other)); |
1171 | #endif | 1211 | #endif |
1212 | GNUNET_STATISTICS_update (stats, | ||
1213 | gettext_noop ("# HELLO messages received"), | ||
1214 | 1, | ||
1215 | GNUNET_NO); | ||
1172 | if (transport != NULL) | 1216 | if (transport != NULL) |
1173 | GNUNET_TRANSPORT_offer_hello (transport, | 1217 | GNUNET_TRANSPORT_offer_hello (transport, |
1174 | message); | 1218 | message); |
@@ -1236,6 +1280,10 @@ hello_advertising_ready (void *cls, | |||
1236 | (unsigned int) want, | 1280 | (unsigned int) want, |
1237 | "HELLO"); | 1281 | "HELLO"); |
1238 | #endif | 1282 | #endif |
1283 | GNUNET_STATISTICS_update (stats, | ||
1284 | gettext_noop ("# HELLO messages gossipped"), | ||
1285 | 1, | ||
1286 | GNUNET_NO); | ||
1239 | } | 1287 | } |
1240 | } | 1288 | } |
1241 | pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); | 1289 | pl->next_hello_allowed = GNUNET_TIME_relative_to_absolute (HELLO_ADVERTISEMENT_MIN_FREQUENCY); |
@@ -1278,6 +1326,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1278 | GNUNET_TRANSPORT_blacklist_cancel (dl->rh); | 1326 | GNUNET_TRANSPORT_blacklist_cancel (dl->rh); |
1279 | GNUNET_free (dl); | 1327 | GNUNET_free (dl); |
1280 | } | 1328 | } |
1329 | if (stats != NULL) | ||
1330 | { | ||
1331 | GNUNET_STATISTICS_destroy (stats, GNUNET_YES); | ||
1332 | stats = NULL; | ||
1333 | } | ||
1281 | } | 1334 | } |
1282 | 1335 | ||
1283 | 1336 | ||
@@ -1306,6 +1359,7 @@ run (void *cls, | |||
1306 | 1359 | ||
1307 | sched = s; | 1360 | sched = s; |
1308 | cfg = c; | 1361 | cfg = c; |
1362 | stats = GNUNET_STATISTICS_create (sched, "topology", cfg); | ||
1309 | autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 1363 | autoconnect = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
1310 | "TOPOLOGY", | 1364 | "TOPOLOGY", |
1311 | "AUTOCONNECT"); | 1365 | "AUTOCONNECT"); |