aboutsummaryrefslogtreecommitdiff
path: root/src/nse
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2013-05-08 09:52:40 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2013-05-08 09:52:40 +0000
commit5c466f88da9a8f1fb6f247ec2c9972db53fa5bc0 (patch)
tree3c51046017229c734133b58b2593f8e7723bdce9 /src/nse
parent063b0e3813bcb504e24de51f91e47c6836a413ad (diff)
downloadgnunet-5c466f88da9a8f1fb6f247ec2c9972db53fa5bc0.tar.gz
gnunet-5c466f88da9a8f1fb6f247ec2c9972db53fa5bc0.zip
- generate histograms based on configure option --enable-nse-histogram
Diffstat (limited to 'src/nse')
-rw-r--r--src/nse/Makefile.am7
-rw-r--r--src/nse/gnunet-service-nse.c82
2 files changed, 36 insertions, 53 deletions
diff --git a/src/nse/Makefile.am b/src/nse/Makefile.am
index 971d4c1b1..80886433a 100644
--- a/src/nse/Makefile.am
+++ b/src/nse/Makefile.am
@@ -57,6 +57,13 @@ gnunet_service_nse_LDADD = \
57 $(GN_LIBINTL) 57 $(GN_LIBINTL)
58gnunet_service_nse_DEPENDENCIES = \ 58gnunet_service_nse_DEPENDENCIES = \
59 libgnunetnse.la 59 libgnunetnse.la
60if ENABLE_NSE_HISTOGRAM
61 gnunet_service_nse_LDADD += \
62 $(top_builddir)/src/testbed/libgnunettestbedlogger.la
63 gnunet_service_nse_DEPENDENCIES += \
64 $(top_builddir)/src/testbed/libgnunettestbedlogger.la
65endif
66
60 67
61if HAVE_BENCHMARKS 68if HAVE_BENCHMARKS
62 MULTIPEER_TEST = test_nse_multipeer 69 MULTIPEER_TEST = test_nse_multipeer
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index d427602d1..536d36a35 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -44,6 +44,9 @@
44#include "gnunet_statistics_service.h" 44#include "gnunet_statistics_service.h"
45#include "gnunet_core_service.h" 45#include "gnunet_core_service.h"
46#include "gnunet_nse_service.h" 46#include "gnunet_nse_service.h"
47#if ENABLE_NSE_HISTOGRAM
48#include "gnunet_testbed_logger_service.h"
49#endif
47#include "nse.h" 50#include "nse.h"
48#include <gcrypt.h> 51#include <gcrypt.h>
49 52
@@ -56,14 +59,6 @@
56#define USE_RANDOM_DELAYS GNUNET_YES 59#define USE_RANDOM_DELAYS GNUNET_YES
57 60
58/** 61/**
59 * Should we generate a histogram with the time stamps of when we received
60 * NSE messages to disk? (for performance evaluation only, not useful in
61 * production). The associated code should also probably be removed
62 * once we're done with experiments.
63 */
64#define ENABLE_HISTOGRAM GNUNET_NO
65
66/**
67 * Over how many values do we calculate the weighted average? 62 * Over how many values do we calculate the weighted average?
68 */ 63 */
69#define HISTORY_SIZE 64 64#define HISTORY_SIZE 64
@@ -92,11 +87,11 @@ static struct GNUNET_TIME_Relative gnunet_nse_interval;
92 */ 87 */
93static struct GNUNET_TIME_Relative proof_find_delay; 88static struct GNUNET_TIME_Relative proof_find_delay;
94 89
95#if ENABLE_HISTOGRAM 90#if ENABLE_NSE_HISTOGRAM
96/** 91/**
97 * Handle for writing when we received messages to disk. 92 * Handle for writing when we received messages to disk.
98 */ 93 */
99static struct GNUNET_BIO_WriteHandle *wh; 94static struct GNUNET_TESTBED_LOGGER_Handle *lh;
100#endif 95#endif
101 96
102 97
@@ -128,7 +123,7 @@ struct NSEPeerEntry
128 */ 123 */
129 int previous_round; 124 int previous_round;
130 125
131#if ENABLE_HISTOGRAM 126#if ENABLE_NSE_HISTOGRAM
132 127
133 /** 128 /**
134 * Amount of messages received from this peer on this round. 129 * Amount of messages received from this peer on this round.
@@ -636,7 +631,7 @@ transmit_ready (void *cls, size_t size, void *buf)
636 GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO); 631 GNUNET_STATISTICS_update (stats, "# flood messages started", 1, GNUNET_NO);
637 GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1, 632 GNUNET_STATISTICS_update (stats, "# flood messages transmitted", 1,
638 GNUNET_NO); 633 GNUNET_NO);
639#if ENABLE_HISTOGRAM 634#if ENABLE_NSE_HISTOGRAM
640 peer_entry->transmitted_messages++; 635 peer_entry->transmitted_messages++;
641 peer_entry->last_transmitted_size = 636 peer_entry->last_transmitted_size =
642 ntohl(size_estimate_messages[idx].matching_bits); 637 ntohl(size_estimate_messages[idx].matching_bits);
@@ -751,7 +746,7 @@ schedule_current_round (void *cls,
751 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); 746 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task);
752 peer_entry->previous_round = GNUNET_NO; 747 peer_entry->previous_round = GNUNET_NO;
753 } 748 }
754#if ENABLE_HISTOGRAM 749#if ENABLE_NSE_HISTOGRAM
755 if (peer_entry->received_messages > 1) 750 if (peer_entry->received_messages > 1)
756 GNUNET_STATISTICS_update(stats, "# extra messages", 751 GNUNET_STATISTICS_update(stats, "# extra messages",
757 peer_entry->received_messages - 1, GNUNET_NO); 752 peer_entry->received_messages - 1, GNUNET_NO);
@@ -1039,9 +1034,13 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
1039 uint32_t matching_bits; 1034 uint32_t matching_bits;
1040 unsigned int idx; 1035 unsigned int idx;
1041 1036
1042#if ENABLE_HISTOGRAM 1037#if ENABLE_NSE_HISTOGRAM
1043 if (NULL != wh) 1038 {
1044 GNUNET_break (GNUNET_OK == GNUNET_BIO_write_int64 (wh, GNUNET_TIME_absolute_get ().abs_value)); 1039 uint64_t t;
1040
1041 t = GNUNET_TIME_absolute_get().abs_value;
1042 GNUNET_TESTBED_LOGGER_write (lh, &t, sizeof (uint64_t));
1043 }
1045#endif 1044#endif
1046 incoming_flood = (const struct GNUNET_NSE_FloodMessage *) message; 1045 incoming_flood = (const struct GNUNET_NSE_FloodMessage *) message;
1047 GNUNET_STATISTICS_update (stats, "# flood messages received", 1, GNUNET_NO); 1046 GNUNET_STATISTICS_update (stats, "# flood messages received", 1, GNUNET_NO);
@@ -1072,7 +1071,7 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
1072 GNUNET_break (0); 1071 GNUNET_break (0);
1073 return GNUNET_OK; 1072 return GNUNET_OK;
1074 } 1073 }
1075#if ENABLE_HISTOGRAM 1074#if ENABLE_NSE_HISTOGRAM
1076 peer_entry->received_messages++; 1075 peer_entry->received_messages++;
1077 if (peer_entry->transmitted_messages > 0 && 1076 if (peer_entry->transmitted_messages > 0 &&
1078 peer_entry->last_transmitted_size >= matching_bits) 1077 peer_entry->last_transmitted_size >= matching_bits)
@@ -1317,12 +1316,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1317 GNUNET_CRYPTO_ecc_key_free (my_private_key); 1316 GNUNET_CRYPTO_ecc_key_free (my_private_key);
1318 my_private_key = NULL; 1317 my_private_key = NULL;
1319 } 1318 }
1320#if ENABLE_HISTOGRAM 1319#if ENABLE_NSE_HISTOGRAM
1321 if (NULL != wh) 1320 GNUNET_TESTBED_LOGGER_disconnect (lh);
1322 { 1321 lh = NULL;
1323 GNUNET_break (GNUNET_OK == GNUNET_BIO_write_close (wh));
1324 wh = NULL;
1325 }
1326#endif 1322#endif
1327} 1323}
1328 1324
@@ -1450,36 +1446,6 @@ key_generation_cb (void *cls,
1450 GNUNET_SCHEDULER_shutdown (); 1446 GNUNET_SCHEDULER_shutdown ();
1451 return; 1447 return;
1452 } 1448 }
1453#if ENABLE_HISTOGRAM
1454 if (GNUNET_OK ==
1455 GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "HISTOGRAM_DIR", &proof))
1456 {
1457 char *hostname;
1458 char *hgram_file;
1459 unsigned long long peer_id;
1460
1461 hgram_file = NULL;
1462 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "TESTBED",
1463 "PEERID", &peer_id))
1464 (void) GNUNET_asprintf (&hgram_file, "%s/%llu.hist", proof, peer_id);
1465 else
1466 {
1467 hostname = GNUNET_malloc (GNUNET_OS_get_hostname_max_length ());
1468 if (0 == gethostname (hostname, HOST_NAME_MAX))
1469 (void) GNUNET_asprintf (&hgram_file, "%s/%s_%jd.hist",
1470 proof, hostname, (intmax_t) getpid());
1471 else
1472 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "gethostname");
1473 GNUNET_free (hostname);
1474 }
1475 if (NULL != hgram_file)
1476 {
1477 wh = GNUNET_BIO_write_open (hgram_file);
1478 GNUNET_free (hgram_file);
1479 }
1480 GNUNET_free (proof);
1481 }
1482#endif
1483 stats = GNUNET_STATISTICS_create ("nse", cfg); 1449 stats = GNUNET_STATISTICS_create ("nse", cfg);
1484 GNUNET_SERVER_resume (srv); 1450 GNUNET_SERVER_resume (srv);
1485} 1451}
@@ -1536,6 +1502,16 @@ run (void *cls,
1536 GNUNET_SCHEDULER_shutdown (); 1502 GNUNET_SCHEDULER_shutdown ();
1537 return; 1503 return;
1538 } 1504 }
1505#if ENABLE_NSE_HISTOGRAM
1506 if (NULL == (lh = GNUNET_TESTBED_LOGGER_connect (cfg)))
1507 {
1508 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1509 "Cannot connect to the testbed logger. Exiting.\n");
1510 GNUNET_SCHEDULER_shutdown ();
1511 return;
1512 }
1513#endif
1514
1539 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 1515 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
1540 NULL); 1516 NULL);
1541 GNUNET_SERVER_suspend (srv); 1517 GNUNET_SERVER_suspend (srv);