From 3695f55c493a485a838b3defff6b15a63fddd987 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 1 Apr 2011 11:40:08 +0000 Subject: changes --- src/transport/gnunet-service-transport.c | 38 +++++++++------- src/transport/test_transport_ats.c | 74 +++++++++++++++++++++++++++++--- src/transport/transport.h | 4 +- 3 files changed, 92 insertions(+), 24 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 927e18d61..996720d56 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -5603,7 +5603,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub return GNUNET_SYSERR; #else if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n"); - +#endif glp_prob *prob; @@ -5676,6 +5676,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub mechanisms[c_mechs].col_index = c_mechs; mechanisms[c_mechs].peer = &peers[c_peers]; mechanisms[c_mechs].next = NULL; + mechanisms[c_mechs].plugin = r_next->plugin; GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]); c_mechs++; @@ -6058,22 +6059,27 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub default: break; } - - char * debug_solution = NULL; - char * old = NULL; - for (c=1; c<= (2*c_mechs) +3; c++ ) +#endif + int check; + double bw; + struct ATS_mechanism *t = NULL; + for (c=1; c<= (c_peers); c++ ) { - old = debug_solution; - GNUNET_asprintf(&debug_solution, "%s %s = %g;", (debug_solution!=NULL) ? debug_solution : "", glp_get_col_name(prob,c), glp_get_col_prim(prob, c)); - if (old!=NULL) GNUNET_free(old); + check = GNUNET_NO; + t = peers[c].m_head; + while (t!=NULL) + { + bw = glp_get_col_prim(prob, t->col_index); + GNUNET_assert (1); + if (bw != 0) + { + GNUNET_assert (check != GNUNET_YES); + check = GNUNET_YES; + if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[%i][%i] `%s' %s %s %f\n", c, t->col_index, GNUNET_h2s(&peers[c].peer.hashPubKey), t->plugin->short_name, glp_get_col_name(prob,t->col_index), bw); + } + t = t->next; + } } - old = debug_solution; - GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(prob)); - if (old!=NULL) GNUNET_free(old); - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s \n",debug_solution); - GNUNET_free(debug_solution); -#endif - res->c_mechs = c_mechs; res->c_peers = c_peers; res->solution = solution; @@ -6091,7 +6097,7 @@ static int ats_solve_problem (int max_it, int max_dur , double D, double U, doub GNUNET_free(peers); return c_mechs; -#endif + } void ats_calculate_bandwidth_distribution () diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index d4189d063..fca54ed52 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c @@ -46,7 +46,6 @@ static struct GNUNET_TESTING_PeerGroup *pg; static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; static GNUNET_SCHEDULER_TaskIdentifier stats_task; - struct GNUNET_TESTING_Daemon * master_deamon; struct GNUNET_STATISTICS_Handle * stats; @@ -65,6 +64,11 @@ static int r_index; static int peers; static struct TEST_result results[MEASUREMENTS]; +struct GNUNET_STATISTICS_GetHandle * s_solution; +struct GNUNET_STATISTICS_GetHandle * s_time; +struct GNUNET_STATISTICS_GetHandle * s_peers; +struct GNUNET_STATISTICS_GetHandle * s_mechs; +struct GNUNET_STATISTICS_GetHandle * s_duration; /** * Check whether peers successfully shut down. @@ -105,6 +109,33 @@ static void shutdown_peers() stats_task = GNUNET_SCHEDULER_NO_TASK; } + if (s_time != NULL) + { + GNUNET_STATISTICS_get_cancel(s_time); + s_time = NULL; + } + if (s_peers != NULL) + { + GNUNET_STATISTICS_get_cancel(s_peers); + s_peers = NULL; + } + if (s_mechs != NULL) + { + GNUNET_STATISTICS_get_cancel(s_mechs); + s_mechs = NULL; + } + if (s_solution != NULL) + { + GNUNET_STATISTICS_get_cancel(s_solution); + s_solution = NULL; + } + if (s_duration != NULL) + { + GNUNET_STATISTICS_get_cancel(s_duration); + s_duration = NULL; + } + + GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); } @@ -120,6 +151,8 @@ static void evaluate_measurements() output = temp; } GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"%s\n",output); + + shutdown_peers(); } @@ -129,6 +162,30 @@ int stats_cb (void *cls, uint64_t value, int is_persistent) { + if (0 == strcmp (name,"ATS solution")) + { + s_solution = NULL; + } + + if (0 == strcmp (name,"ATS peers")) + { + s_peers = NULL; + } + + if (0 == strcmp (name,"ATS mechanisms")) + { + s_mechs = NULL; + } + + if (0 == strcmp (name,"ATS duration")) + { + s_duration = NULL; + } + if (0 == strcmp (name,"ATS timestamp")) + { + s_time = NULL; + } + if ((measurement_started == GNUNET_NO) && (0 == strcmp (name, "ATS peers")) && (value == peers-1)) { measurement_started = GNUNET_YES; @@ -147,6 +204,11 @@ int stats_cb (void *cls, r_index++; if (r_index >= MEASUREMENTS) { + if (stats_task != GNUNET_SCHEDULER_NO_TASK) + { + GNUNET_SCHEDULER_cancel(stats_task); + stats_task = GNUNET_SCHEDULER_NO_TASK; + } evaluate_measurements(); return GNUNET_NO; } @@ -195,11 +257,11 @@ stats_get_task (void *cls, if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) return; - GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); - GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); - GNUNET_assert (NULL != GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL)); - GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); - GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); + s_time = GNUNET_STATISTICS_get (stats, "transport", "ATS timestamp", TIMEOUT, NULL, &stats_cb, NULL); + s_solution = GNUNET_STATISTICS_get (stats, "transport", "ATS solution", TIMEOUT, NULL, &stats_cb, NULL); + s_duration = GNUNET_STATISTICS_get (stats, "transport","ATS duration", TIMEOUT, NULL, &stats_cb, NULL); + s_peers = GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); + s_mechs = GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); } diff --git a/src/transport/transport.h b/src/transport/transport.h index e00b8d92a..f3e3b1c2c 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_MILLISECONDS, 200) -#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250) +#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, 2) #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 100) #define ATS_MAX_ITERATIONS INT_MAX -- cgit v1.2.3