From 0dfd98bd11129f3115dad316555eb7fa3a726c78 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Fri, 25 Mar 2011 16:16:51 +0000 Subject: [PATCH] ats --- src/transport/gnunet-service-transport.c | 100 ++++++++++++++------ src/transport/test_transport_ats_peer1.conf | 2 +- src/transport/test_transport_ats_peer2.conf | 2 +- src/transport/transport.h | 4 +- 4 files changed, 73 insertions(+), 35 deletions(-) diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 25a6446e7..191689d98 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_NO -#define VERBOSE_ATS GNUNET_NO +#define DEBUG_ATS GNUNET_YES +#define VERBOSE_ATS GNUNET_YES /** * Should we do some additional checks (to validate behavior @@ -933,7 +933,7 @@ static void disconnect_neighbour (struct NeighbourList *n, int check); * Check the ready list for the given neighbour and if a plugin is * ready for transmission (and if we have a message), do so! * - * @param neighbour target peer for which to transmit + * @param nexi target peer for which to transmit */ static void try_transmission_to_peer (struct NeighbourList *n); @@ -5559,6 +5559,7 @@ struct ATS_transports }; #if HAVE_LIBGLPK + static glp_prob * ats_create_problem (int peers, int transports, @@ -5582,10 +5583,6 @@ ats_create_problem (int peers, int start = 0; int cur_row = 0; - //int ia[1+(rows*cols)]; - //int ja[1+(rows*cols)]; - //double ar[1+(rows*cols)]; - int * ia = GNUNET_malloc (1+(rows*cols) * sizeof (int)); int * ja = GNUNET_malloc (1+(rows*cols) * sizeof (int)); double * ar = GNUNET_malloc(1+(rows*cols)* sizeof (double)); @@ -5666,7 +5663,7 @@ ats_create_problem (int peers, } /* constraint 4: Bandwidth assignment relativity to peer preference - * V b_i in B: b_i >= b_min + * bi/ {bmax, cmax } >= r*f */ start = index+1; for (c1=0; c1last,GNUNET_TIME_absolute_get()); - 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"); -#endif - return; - } - struct GNUNET_TIME_Absolute start; - int test = 3; - int mlp = GNUNET_YES; + int test = 11; + int mlp = GNUNET_NO; - //for (test=1; test<75000; test++) - //{ + for (test=start_peers; test<=end_peers; test++) + { int peers = test; int transports = 3; - double b_min = 1; - double b_max = 100000.0; + double b_min = 5; + double b_max = 50; double r = 0.85;//1.0; double R = 1.0; @@ -5869,7 +5866,7 @@ void ats_calculate_bandwidth_distribution () while (c < transports) { tl[c].id = c; - tl[c].c_max = 100000; + tl[c].c_max = 10000; tl[c].c_1 = 1; c++; //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %s %p \n",c , GNUNET_i2s(&pl[c].peer), &pl[c].peer); @@ -5883,13 +5880,54 @@ void ats_calculate_bandwidth_distribution () // test // start = GNUNET_TIME_absolute_get(); ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur, mlp); - if (DEBUG_ATS) - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s,%i,%llu,%i\n",(mlp)?"mlp":"lp", peers, + 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)))); GNUNET_free (pl); GNUNET_free (tl); - //} + } +} + +void ats_calculate_bandwidth_distribution () +{ + struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); + 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"); +#endif + return; + } + + struct GNUNET_TIME_Absolute start; + /* + int mlp = GNUNET_NO; + int peers; + int transports; + + double b_min; + double b_max; + double r; + double R; + + int it = ATS_MAX_ITERATIONS; + */ + int dur = 500; + if (INT_MAX < ats->max_exec_duration.rel_value) + dur = INT_MAX; + else + dur = (int) ats->max_exec_duration.rel_value; + + struct ATS_transports * tl = NULL; + struct ATS_peer * pl = NULL; + + start = GNUNET_TIME_absolute_get(); + ats_benchmark(10,3,10,10); + //ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur, mlp); + + GNUNET_free_non_null (pl); + GNUNET_free_non_null (tl); + ats->last = GNUNET_TIME_absolute_get(); } diff --git a/src/transport/test_transport_ats_peer1.conf b/src/transport/test_transport_ats_peer1.conf index ba868434e..7165d51af 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 = YES +DEBUG = NO #PREFIX = xterm -T transport2 -e gdb --command=cmd --args #PREFIX = valgrind --tool=memcheck --leak-check=full --log-file=transport%p ACCEPT_FROM6 = ::1; diff --git a/src/transport/test_transport_ats_peer2.conf b/src/transport/test_transport_ats_peer2.conf index 526bf50fd..3502cdc8f 100644 --- a/src/transport/test_transport_ats_peer2.conf +++ b/src/transport/test_transport_ats_peer2.conf @@ -41,7 +41,7 @@ MINIMUM-FRIENDS = 0 [transport] PLUGINS = tcp unix -DEBUG = YES +DEBUG = NO ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; NEIGHBOUR_LIMIT = 50 diff --git a/src/transport/transport.h b/src/transport/transport.h index 5cbfce34c..3d6890997 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, 250) -#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 1) +#define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 1000) +#define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 500) #define ATS_MAX_ITERATIONS INT_MAX -- 2.25.1