From: Matthias Wachs Date: Mon, 28 Mar 2011 15:46:25 +0000 (+0000) Subject: ats X-Git-Tag: initial-import-from-subversion-38251~18879 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d2d6687abfa7dc47ef7e8208522a835d4b852ef6;p=oweals%2Fgnunet.git ats --- diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 4706570e4..550b54d10 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -270,6 +270,7 @@ test_transport_ats_SOURCES = \ test_transport_ats_LDADD = \ $(top_builddir)/src/transport/libgnunettransport.la \ $(top_builddir)/src/hello/libgnunethello.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la test_transport_api_tcp_SOURCES = \ diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index e8ea352c7..1f3ed74f3 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -48,8 +48,8 @@ #define DEBUG_TRANSPORT_HELLO GNUNET_YES -#define DEBUG_ATS GNUNET_YES -#define VERBOSE_ATS GNUNET_YES +#define DEBUG_ATS GNUNET_NO +#define VERBOSE_ATS GNUNET_NO /** * Should we do some additional checks (to validate behavior @@ -5580,7 +5580,6 @@ ats_create_problem (int peers, int rows = 1 + (3*peers) + (transports); int cols = peers; int index = 1; - //int start = 0; int cur_row = 0; int size = 1+(rows*cols); @@ -5592,7 +5591,7 @@ ats_create_problem (int peers, double value; if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating LP problem: %i peers, relativity r %3.2f, b_max %5.2f, b_min %5.2f, \n",peers, r, b_max, b_min); - if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Current memory consumption %i\n",(1+(rows*cols) * (2*sizeof(int) + sizeof(double))) / (1024*1024)); + if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Current memory consumption %i\n",(1+(rows*cols) * (2*sizeof(int) + sizeof(double)))); lp = glp_create_prob(); glp_set_prob_name(lp, "gnunet ats bandwidth distribution"); glp_set_obj_dir(lp, GLP_MAX); @@ -5704,7 +5703,6 @@ ats_create_problem (int peers, if (pl[c2-1].t == tl[c1].id) value = tl[c1].c_1; else value = 0; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Transport %i peer %i: index %i size %i value %f\n", c1,c2, index, size, value); ar[index] = value; index++; } @@ -5836,6 +5834,7 @@ ats_create_problem (int peers, void ats_benchmark (int peers, int transports, int start_peers, int end_peers) { struct GNUNET_TIME_Absolute start; + struct GNUNET_TIME_Relative duration; int test = 11; int mlp = GNUNET_NO; @@ -5875,7 +5874,7 @@ void ats_benchmark (int peers, int transports, int start_peers, int end_peers) tl[c].id = c; tl[c].c_max = 10000; tl[c].c_1 = 1; - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %i \n",c , tl[c].id); + //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %i \n",c , tl[c].id); c++; } @@ -5888,9 +5887,14 @@ void ats_benchmark (int peers, int transports, int start_peers, int end_peers) // test // start = GNUNET_TIME_absolute_get(); ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur, mlp); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark result ({LP/MLP},peers,duration,mem):%s,%i,%llu,%i\n",(mlp)?"mlp":"lp", peers, - GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()).rel_value, (1+(peers*transports) * (2*sizeof(int) + sizeof(double)))); + duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); + + if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark result ({LP/MLP},peers,duration,mem):%s,%i,%llu,%i\n", + (mlp)?"mlp":"lp", (int )peers, duration.rel_value, + (1+(peers*transports) * (2*sizeof(int) + sizeof(double)))); + + GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO); GNUNET_free (pl); GNUNET_free (tl); } @@ -5902,7 +5906,7 @@ void ats_calculate_bandwidth_distribution () if (delta.rel_value < ats->min_delta.rel_value) { #if DEBUG_ATS - //GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n"); + GNUNET_log (GNUNET_ERROR_TYPE_BULK, "Minimum time between cycles not reached\n"); #endif return; } @@ -5930,7 +5934,7 @@ void ats_calculate_bandwidth_distribution () struct ATS_peer * pl = NULL; start = GNUNET_TIME_absolute_get(); - ats_benchmark(10,3,10,10); + ats_benchmark(100,3,100,100); //ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur, mlp); GNUNET_free_non_null (pl); @@ -6159,11 +6163,6 @@ run (void *cls, validation_map = NULL; return; } -#if HAVE_GLPK - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("HAVE\n")); -#else - //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("NOT HAVE\n")); -#endif ats = ats_init(); max_connect_per_transport = (uint32_t) tneigh; diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index 88e9706ec..ef33e0f8b 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c @@ -34,7 +34,9 @@ #include "gnunet_program_lib.h" #include "gnunet_scheduler_lib.h" #include "gnunet_transport_service.h" +#include "gnunet_statistics_service.h" #include "transport.h" +#include "gauger.h" #define VERBOSE GNUNET_NO @@ -45,7 +47,7 @@ /** * How long until we give up on transmitting the message? */ -#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) +#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) /** * How long until we give up on transmitting the message? @@ -59,6 +61,7 @@ struct PeerContext struct GNUNET_CONFIGURATION_Handle *cfg; struct GNUNET_TRANSPORT_Handle *th; struct GNUNET_PeerIdentity id; + struct GNUNET_STATISTICS_Handle *stats; #if START_ARM struct GNUNET_OS_Process *arm_proc; #endif @@ -66,6 +69,12 @@ struct PeerContext static struct PeerContext p1; +/** + * Handle for reporting statistics. + */ + + + static struct PeerContext p2; static int ok; @@ -90,11 +99,6 @@ static int is_wlan; static GNUNET_SCHEDULER_TaskIdentifier die_task; -static char * key_file_p1; -static char * cert_file_p1; - -static char * key_file_p2; -static char * cert_file_p2; #if VERBOSE #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) @@ -112,7 +116,8 @@ end () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); GNUNET_TRANSPORT_disconnect (p1.th); GNUNET_TRANSPORT_disconnect (p2.th); - + if (p1.stats != NULL) + GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO); die_task = GNUNET_SCHEDULER_NO_TASK; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transports disconnected, returning success!\n"); ok = 0; @@ -138,6 +143,8 @@ end_badly () GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from transports!\n"); //GNUNET_break (0); GNUNET_TRANSPORT_disconnect (p1.th); + if (p1.stats != NULL) + GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO); //GNUNET_TRANSPORT_disconnect (p2.th); ok = 1; } @@ -203,9 +210,6 @@ notify_connect (void *cls, { if (cls == &p1) { - GNUNET_SCHEDULER_cancel (die_task); - die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, - &end_badly, NULL); GNUNET_TRANSPORT_notify_transmit_ready (p1.th, &p2.id, @@ -225,6 +229,17 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) GNUNET_i2s (peer), cls); } +int stat_cb (void *cls, + const char *subsystem, + const char *name, + uint64_t value, + int is_persistent) +{ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Execution time for 100 Peers: %llu\n",value); + return GNUNET_NO; +} + static void setup_peer (struct PeerContext *p, const char *cfgname) @@ -239,69 +254,19 @@ setup_peer (struct PeerContext *p, const char *cfgname) "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - - if (is_https) - { - struct stat sbuf; - if (p==&p1) - { - if (GNUNET_CONFIGURATION_have_value (p->cfg, - "transport-https", "KEY_FILE")) - GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p1); - if (key_file_p1==NULL) - GNUNET_asprintf(&key_file_p1,"https.key"); - if (0 == stat (key_file_p1, &sbuf )) - { - if (0 == remove(key_file_p1)) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p1); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p1); - } - if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE")) - GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p1); - if (cert_file_p1==NULL) - GNUNET_asprintf(&cert_file_p1,"https.cert"); - if (0 == stat (cert_file_p1, &sbuf )) - { - if (0 == remove(cert_file_p1)) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p1); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p1); - } - } - else if (p==&p2) - { - if (GNUNET_CONFIGURATION_have_value (p->cfg, - "transport-https", "KEY_FILE")) - GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "KEY_FILE", &key_file_p2); - if (key_file_p2==NULL) - GNUNET_asprintf(&key_file_p2,"https.key"); - if (0 == stat (key_file_p2, &sbuf )) - { - if (0 == remove(key_file_p2)) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing private key file `%s'\n",key_file_p2); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove private key file `%s'\n",key_file_p2); - } - if (GNUNET_CONFIGURATION_have_value (p->cfg,"transport-https", "CERT_FILE")) - GNUNET_CONFIGURATION_get_value_string (p->cfg, "transport-https", "CERT_FILE", &cert_file_p2); - if (cert_file_p2==NULL) - GNUNET_asprintf(&cert_file_p2,"https.cert"); - if (0 == stat (cert_file_p2, &sbuf )) - { - if (0 == remove(cert_file_p2)) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Successfully removed existing certificate file `%s'\n",cert_file_p2); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove existing certificate file `%s'\n",cert_file_p2); - } - } - } + p->stats = GNUNET_STATISTICS_create ("transport", p->cfg); + GNUNET_assert (p->stats != NULL); + GNUNET_assert (GNUNET_OK == GNUNET_STATISTICS_watch (p->stats,"transport","ATS execution time 100 peers", stat_cb, NULL)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, ¬ify_receive, ¬ify_connect, ¬ify_disconnect); GNUNET_assert (p->th != NULL); + + GNUNET_SCHEDULER_cancel (die_task); + die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT_TRANSMIT, + &end_badly, NULL); } @@ -400,45 +365,6 @@ check () stop_arm (&p1); // stop_arm (&p2); - if (is_https) - { - struct stat sbuf; - if (0 == stat (cert_file_p1, &sbuf )) - { - if (0 == remove(cert_file_p1)) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p1); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p1); - } - - if (0 == stat (key_file_p1, &sbuf )) - { - if (0 == remove(key_file_p1)) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p1); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p1); - } - - if (0 == stat (cert_file_p2, &sbuf )) - { - if (0 == remove(cert_file_p2)) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed existing certificate file `%s'\n",cert_file_p2); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to remove certfile `%s'\n",cert_file_p2); - } - - if (0 == stat (key_file_p2, &sbuf )) - { - if (0 == remove(key_file_p2)) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully removed private key file `%s'\n",key_file_p2); - else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to private key file `%s'\n",key_file_p2); - } - GNUNET_free(key_file_p1); - GNUNET_free(key_file_p2); - GNUNET_free(cert_file_p1); - GNUNET_free(cert_file_p2); - } return ok; } diff --git a/src/transport/test_transport_ats_peer1.conf b/src/transport/test_transport_ats_peer1.conf index 7165d51af..e7f8349d1 100644 --- a/src/transport/test_transport_ats_peer1.conf +++ b/src/transport/test_transport_ats_peer1.conf @@ -41,7 +41,7 @@ MINIMUM-FRIENDS = 0 [transport] PLUGINS = tcp unix -DEBUG = NO +#DEBUG = YES #PREFIX = xterm -T transport2 -e gdb --command=cmd --args #PREFIX = valgrind --tool=memcheck --leak-check=full --log-file=transport%p ACCEPT_FROM6 = ::1; @@ -87,6 +87,7 @@ HOME = $SERVICEHOME HOSTNAME = localhost PORT = 12367 UNIXPATH = /tmp/gnunet-p1-service-statistics.sock +DEBUG = YES [arm] DEFAULTSERVICES = transport diff --git a/src/transport/transport.h b/src/transport/transport.h index dd6965a61..c2a27d870 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h @@ -31,8 +31,8 @@ #include "gnunet_transport_service.h" /* Minimum time between to calculations*/ -#define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) -#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) +#define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) +#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5) #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 500) #define ATS_MAX_ITERATIONS INT_MAX