diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-22 10:40:04 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-22 10:40:04 +0000 |
commit | 7c241d90b842906019706995a48ba93eaa7acb9e (patch) | |
tree | a81ada9bd8137347183306d9f57017c88a84a549 /src | |
parent | 611a4740a7425e70f073e8183f96d51fa065502d (diff) |
improvements
Diffstat (limited to 'src')
-rw-r--r-- | src/ats-tests/Makefile.am | 12 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.c | 39 | ||||
-rw-r--r-- | src/ats-tests/ats-testing.h | 32 | ||||
-rw-r--r-- | src/ats-tests/gnunet-ats-sim.c | 18 | ||||
-rw-r--r-- | src/ats-tests/perf_ats.c | 87 | ||||
-rw-r--r-- | src/ats-tests/perf_ats.h | 6 |
6 files changed, 107 insertions, 87 deletions
diff --git a/src/ats-tests/Makefile.am b/src/ats-tests/Makefile.am index 22b5592a87..54c784664e 100644 --- a/src/ats-tests/Makefile.am +++ b/src/ats-tests/Makefile.am @@ -52,7 +52,7 @@ noinst_PROGRAMS = \ gnunet-ats-sim libgnunetatstesting_la_SOURCES = \ - ats-testing.c ats-testing.h + ats-testing.c ats-testing-log.c ats-testing.h libgnunetatstesting_la_LIBADD = \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/hello/libgnunethello.la \ @@ -65,7 +65,7 @@ libgnunettransporttesting_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) gnunet_ats_sim_SOURCES = \ - gnunet-ats-sim.c + gnunet-ats-sim.c gnunet_ats_sim_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ @@ -79,7 +79,7 @@ gnunet_ats_sim_DEPENDENCIES = \ perf_ats_proportional_core_none_SOURCES = \ - perf_ats.c perf_ats_logging.c perf_ats.h + perf_ats.c perf_ats_proportional_core_none_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ @@ -92,7 +92,7 @@ perf_ats_proportional_core_DEPENDENCIES = \ $(top_builddir)/src/util/libgnunetutil.la perf_ats_proportional_transport_none_SOURCES = \ - perf_ats.c perf_ats_logging.c + perf_ats.c perf_ats_proportional_transport_none_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ @@ -100,9 +100,9 @@ perf_ats_proportional_transport_none_LDADD = \ $(top_builddir)/src/ats/libgnunetats.la \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/transport/libgnunettransport.la -perf_ats_proportional_transport_DEPENDENCIES = \ +perf_ats_proportional_transport_none_DEPENDENCIES = \ $(top_builddir)/src/ats-tests/libgnunetatstesting.la \ - $(top_builddir)/src/util/libgnunetutil.la + $(top_builddir)/src/util/libgnunetutil.la perf_ats_proportional_core_bandwidth_SOURCES = \ perf_ats.c perf_ats_logging.c diff --git a/src/ats-tests/ats-testing.c b/src/ats-tests/ats-testing.c index a8e451673c..b93a097d9d 100644 --- a/src/ats-tests/ats-testing.c +++ b/src/ats-tests/ats-testing.c @@ -18,21 +18,14 @@ Boston, MA 02111-1307, USA. */ /** - * @file ats/perf_ats.c - * @brief ats benchmark: start peers and modify preferences, monitor change over time + * @file ats-tests/ats-testing.c + * @brief ats testing library: setup topology and provide logging to test ats + * solvers * @author Christian Grothoff * @author Matthias Wachs */ -#include "platform.h" -#include "gnunet_util_lib.h" -#include "gnunet_testbed_service.h" -#include "gnunet_ats_service.h" -#include "gnunet_core_service.h" #include "ats-testing.h" - - - static struct GNUNET_ATS_TEST_Topology *top; /** @@ -48,20 +41,11 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) int c_s; int c_op; struct BenchmarkPeer *p; -/* - if (GNUNET_YES == logging) - perf_logging_stop(); -*/ + + if (GNUNET_YES == top->logging) + GNUNET_ATS_TEST_logging_stop (); + top->shutdown_task = GNUNET_SCHEDULER_NO_TASK; -/* - if (GNUNET_SCHEDULER_NO_TASK != progress_task) - { - fprintf (stderr, "0\n"); - GNUNET_SCHEDULER_cancel (progress_task); - } - progress_task = GNUNET_SCHEDULER_NO_TASK; -*/ - //evaluate (); top->state.benchmarking = GNUNET_NO; GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking done\n")); @@ -604,10 +588,9 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, GNUNET_assert(NULL != peers_); top->shutdown_task = GNUNET_SCHEDULER_add_delayed ( - GNUNET_TIME_relative_multiply (TEST_TIMEOUT, top->num_masters + top->num_slaves), - &do_shutdown, top ); + GNUNET_TIME_UNIT_FOREVER_REL, &do_shutdown, top); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u masters and %u slaves\n", + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting up %u masters and %u slaves\n", top->num_masters, top->num_slaves); /* Setup master peers */ @@ -618,7 +601,7 @@ main_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, top->mps[c_m].no = c_m; top->mps[c_m].master = GNUNET_YES; top->mps[c_m].pref_partner = &top->sps[c_m]; - top->mps[c_m].pref_value = TEST_ATS_PREFRENCE_START; + top->mps[c_m].pref_value = TEST_ATS_PREFERENCE_DEFAULT; top->mps[c_m].partners = GNUNET_malloc (top->num_slaves * sizeof (struct BenchmarkPartner)); top->mps[c_m].num_partners = top->num_slaves; @@ -720,4 +703,4 @@ GNUNET_ATS_TEST_shutdown_topology (void) GNUNET_SCHEDULER_shutdown(); } -/* end of file perf_ats.c */ +/* end of file ats-testing.c */ diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h index ce336511ec..540f2bd8c9 100644 --- a/src/ats-tests/ats-testing.h +++ b/src/ats-tests/ats-testing.h @@ -18,8 +18,8 @@ Boston, MA 02111-1307, USA. */ /** - * @file ats/perf_ats.c - * @brief ats benchmark: start peers and modify preferences, monitor change over time + * @file ats-tests/ats-testing.h + * @brief ats testing library: setup topology and provide logging to test ats * @author Christian Grothoff * @author Matthias Wachs */ @@ -29,21 +29,7 @@ #include "gnunet_ats_service.h" #include "gnunet_core_service.h" -#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) -#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) -#define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) -#define TESTNAME_PREFIX "perf_ats_" -#define DEFAULT_SLAVES_NUM 2 -#define DEFAULT_MASTERS_NUM 1 - -#define TEST_ATS_PREFRENCE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) -#define TEST_ATS_PREFRENCE_START 1.0 -#define TEST_ATS_PREFRENCE_DELTA 1.0 - -#define TEST_MESSAGE_TYPE_PING 12345 -#define TEST_MESSAGE_TYPE_PONG 12346 -#define TEST_MESSAGE_SIZE 1000 -#define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) +#define TEST_ATS_PREFERENCE_DEFAULT 1.0 /** * Overall state of the performance benchmark @@ -394,6 +380,16 @@ struct GNUNET_ATS_TEST_Topology }; void +GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, + char * testname, struct BenchmarkPeer *masters, int num_masters); + +void +GNUNET_ATS_TEST_logging_now (void); + +void +GNUNET_ATS_TEST_logging_stop (void); + +void GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, unsigned int num_slaves, unsigned int num_masters, @@ -407,4 +403,4 @@ GNUNET_ATS_TEST_create_topology (char *name, char *cfg_file, void GNUNET_ATS_TEST_shutdown_topology (void); -/* end of file perf_ats.c */ +/* end of file ats-testing.h */ diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c index 0b0e9dd7e9..b394cb8a48 100644 --- a/src/ats-tests/gnunet-ats-sim.c +++ b/src/ats-tests/gnunet-ats-sim.c @@ -18,8 +18,10 @@ Boston, MA 02111-1307, USA. */ /** - * @file ats/perf_ats.c - * @brief ats benchmark: start peers and modify preferences, monitor change over time + * @file ats-test/gnunet-ats-sim.c + * @brief ats traffic simulator: this tool uses the ats-test library to setup a + * topology and generate traffic between these peers. The traffic description + * is loaded from a experiment description file * @author Christian Grothoff * @author Matthias Wachs */ @@ -36,8 +38,14 @@ #define TEST_MESSAGE_TYPE_PING 12345 #define TEST_MESSAGE_TYPE_PONG 12346 +/** + * Number of master peers to use + */ static int c_masters; +/** + * Number of slave peers to use + */ static int c_slaves; static int @@ -76,6 +84,9 @@ static void topology_setup_done (void *cls, struct BenchmarkPeer *slaves) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Topology setup complete!\n"); + + + /* Shutdown a topology with */ GNUNET_ATS_TEST_shutdown_topology (); } @@ -90,6 +101,7 @@ main (int argc, char *argv[]) c_slaves = DEFAULT_NUM_SLAVES; c_masters = DEFAULT_NUM_MASTERS; + /* Setup a topology with */ GNUNET_ATS_TEST_create_topology ("gnunet-ats-sim", "perf_ats_proportional_none.conf", c_slaves, c_masters, @@ -101,4 +113,4 @@ main (int argc, char *argv[]) &ats_performance_info_cb); return 0; } -/* end of file perf_ats_topogy.c */ +/* end of file gnunet-ats-sim.c */ diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index c79e291b83..53533a82a3 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c @@ -40,7 +40,12 @@ #define TEST_MESSAGE_SIZE 1000 #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) - +#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) +#define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) +#define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) +#define TESTNAME_PREFIX "perf_ats_" +#define DEFAULT_SLAVES_NUM 2 +#define DEFAULT_MASTERS_NUM 1 /** * Shutdown task */ @@ -124,6 +129,12 @@ evaluate () struct BenchmarkPeer *mp; struct BenchmarkPartner *p; + unsigned int kb_sent_sec; + double kb_sent_percent; + unsigned int kb_recv_sec; + double kb_recv_percent; + unsigned int rtt; + duration = (perf_duration.rel_value_us / (1000 * 1000)); for (c_m = 0; c_m < num_masters; c_m++) { @@ -138,19 +149,35 @@ evaluate () for (c_s = 0; c_s < num_slaves; c_s++) { p = &mp->partners[c_s]; + + kb_sent_sec = 0; + kb_recv_sec = 0; + kb_sent_percent = 0.0; + kb_recv_percent = 0.0; + rtt = 0; + + if (duration > 0) + { + kb_sent_percent = (p->bytes_sent / 1024) / duration; + kb_recv_percent = (p->bytes_received / 1024) / duration; + } + if (mp->total_bytes_sent > 0) + kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; + if (mp->total_bytes_received > 0) + kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; + if (1000 * p->messages_sent > 0) + rtt = p->total_app_rtt / (1000 * p->messages_sent); fprintf (stderr, "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", (mp->pref_partner == p->dest) ? '*' : ' ', mp->no, p->dest->no, - (p->bytes_sent / 1024) / duration, - ((double) p->bytes_sent * 100) / mp->total_bytes_sent, - (p->bytes_received / 1024) / duration, - ((double) p->bytes_received * 100) / mp->total_bytes_received ); + kb_sent_sec, kb_sent_percent, + kb_recv_sec, kb_recv_percent); + fprintf (stderr, "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", (mp->pref_partner == p->dest) ? '*' : ' ', - mp->no, p->dest->no, - p->total_app_rtt / (1000 * p->messages_sent)); + mp->no, p->dest->no, rtt); } } } @@ -164,10 +191,10 @@ evaluate () static void do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - /* + if (GNUNET_YES == logging) - perf_logging_stop(); -*/ + GNUNET_ATS_TEST_logging_stop(); + shutdown_task = GNUNET_SCHEDULER_NO_TASK; if (GNUNET_SCHEDULER_NO_TASK != progress_task) { @@ -300,10 +327,8 @@ do_benchmark (void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *sl masters[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &masters[c_m]); } - /* if (GNUNET_YES == logging) - perf_logging_start (log_frequency, testname, mps, num_masters); -*/ + GNUNET_ATS_TEST_logging_start (log_frequency, testname, mps, num_masters); } @@ -349,7 +374,6 @@ find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer) return &me->partners[c_m]; } } - return NULL; } @@ -422,11 +446,10 @@ comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, } - static void -transport_recv_cb (void *cls, - const struct GNUNET_PeerIdentity * peer, - const struct GNUNET_MessageHeader * message) +test_recv_cb (void *cls, + const struct GNUNET_PeerIdentity * peer, + const struct GNUNET_MessageHeader * message) { if (TEST_MESSAGE_SIZE != ntohs (message->size) || (TEST_MESSAGE_TYPE_PING != ntohs (message->type) && @@ -442,9 +465,6 @@ transport_recv_cb (void *cls, } - - - static void ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, @@ -532,17 +552,17 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, break; } } - /* + if ((GNUNET_YES == logging) && (GNUNET_YES == log)) - collect_log_now(); - */ + GNUNET_ATS_TEST_logging_now(); + GNUNET_free(peer_id); } - - - +/* + * Start the performance test case + */ int main (int argc, char *argv[]) { @@ -720,14 +740,23 @@ main (int argc, char *argv[]) return GNUNET_SYSERR; } + /** + * Core message handler to use for PING/PONG messages + */ static struct GNUNET_CORE_MessageHandler handlers[] = { {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, { NULL, 0, 0 } }; + /** + * Setup the topology + */ GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, - num_slaves, num_masters, test_core, - &do_benchmark, NULL, handlers, &transport_recv_cb, + num_slaves, num_masters, + test_core, + &do_benchmark, + NULL, handlers, + &test_recv_cb, &ats_performance_info_cb); return result; diff --git a/src/ats-tests/perf_ats.h b/src/ats-tests/perf_ats.h index 983d30dd60..a1cd431735 100644 --- a/src/ats-tests/perf_ats.h +++ b/src/ats-tests/perf_ats.h @@ -248,13 +248,13 @@ struct BenchmarkPeer void -collect_log_now (void); +GNUNET_ATS_TEST_logging_now (void); void -perf_logging_stop (); +GNUNET_ATS_TEST_logging_stop (); void -perf_logging_start (struct GNUNET_TIME_Relative log_frequency, +GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, char * testname, struct BenchmarkPeer *masters, int num_masters); |