#include <glpk.h>
#endif
-#define DEBUG_BLACKLIST GNUNET_YES
+#define DEBUG_BLACKLIST GNUNET_NO
-#define DEBUG_PING_PONG GNUNET_YES
+#define DEBUG_PING_PONG GNUNET_NO
-#define DEBUG_TRANSPORT_HELLO GNUNET_YES
+#define DEBUG_TRANSPORT_HELLO GNUNET_NO
+#define DEBUG_ATS GNUNET_NO
#define VERBOSE_ATS GNUNET_NO
/**
* 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);
GNUNET_break (bc_head == NULL);
}
-struct ATS_transports
+struct ATS_mechanism
{
+ struct ATS_mechanism * prev;
+ struct ATS_mechanism * next;
+ struct ForeignAddressList * addr;
+ struct TransportPlugin * plugin;
+ struct ATS_peer * peer;
+ int col_index;
int id;
double c_max;
double c_1;
};
-#define FUNCTION ats_create_problem (int peers, int transports, double b_min, double b_max, double r, double R, const struct ATS_peer * pl, const struct ATS_transports * tl, int max_it, int max_dur)
+struct ATS_peer
+{
+ int id;
+ struct GNUNET_PeerIdentity peer;
+ struct NeighbourList * n;
+ struct ATS_mechanism * m_head;
+ struct ATS_mechanism * m_tail;
+
+ /* preference value f */
+ double f;
+ int t;
+};
-glp_prob * FUNCTION
+
+static void ats_create_problem (int max_it, int max_dur )
{
- int result = GLP_UNDEF;
- int c1, c2;
- glp_prob *lp;
- char * peer_n;
-
- int rows = 1 + (3*peers) + (transports);
- int cols = peers;
- int index = 1;
- int start = 0;
- int cur_row = 0;
-
- int ia[1+(rows*cols)], ja[1+(rows*cols)];
- double ar[1+(rows*cols)];
- double value;
-
- /* Setting GLPK options */
- glp_smcp * options = GNUNET_malloc( sizeof (glp_smcp));
- glp_init_smcp(options);
-
- /* maximum iterations */
- options->it_lim = max_it;
- /* maximum durations */
- options->tm_lim = max_dur;
- /* output level */
- if (VERBOSE_ATS)
- options->msg_lev = GLP_MSG_ALL;
- else
- options->msg_lev = GLP_MSG_OFF;
+#if !HAVE_LIBGLPK
+ if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no glpk installed\n");
+ return;
+#else
+ if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "glpk installed\n");
+#endif
- 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);
- lp = glp_create_prob();
- glp_set_prob_name(lp, "gnunet ats bandwidth distribution");
- glp_set_obj_dir(lp, GLP_MAX);
+ glp_prob *prob;
- /* Adding transports and objective function coefficients*/
- glp_add_cols(lp, cols);
- for (c1=1; c1<=cols; c1++)
- {
- GNUNET_asprintf(&peer_n,"%s",GNUNET_i2s(&pl[c1-1].peer));
- if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer[%i] , transport %i, %s: f: %f\n",c1-1 , pl[c1-1].t, peer_n, pl[c1-1].f);
- /* add a single transport*/
- glp_set_col_name(lp, c1, peer_n);
- /* add a lower bound */
- glp_set_col_bnds(lp, c1, GLP_LO, 0.0, 0.0);
- /* set coefficient function */
- value = pl[c1-1].f/b_max;
- value = 1.0;
- glp_set_obj_coef(lp, c1, value);
- GNUNET_free(peer_n);
- }
+ int c_peers = 0;
+ int c_mechs = 0;
- /* Adding constraints */
- glp_add_rows(lp, rows);
- cur_row = 1;
+ int c_c_ressources = 0;
+ int c_q_metrics = 0;
- /* constraint 1: Maximum bandwidth for all peers
- * sum(b_i) <= b_max
- */
- glp_set_row_bnds(lp, cur_row, GLP_UP, 0.0, b_max);
- for (index=1; index<=cols; index++)
- {
- ia[index] = 1, ja[index] = index, ar[index] = 1.0;
- }
+ double v_b_min = 100;
+ double v_n_min = 2;
+ double M = 1000000000;
- /* constraint 2: Maximum bandwidth per peer
- * V b_i in B: b_i <= b_max
- */
- cur_row = 2;
- start = index+1;
- for (c1=0; c1<peers; c1++)
+ struct NeighbourList *next = neighbours;
+ while (next!=NULL)
{
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "row: %i \n", cur_row);
- glp_set_row_bnds(lp, cur_row , GLP_UP, 0.0, b_max);
-
- for (c2 = 1; c2 <= cols; c2++)
+ struct ReadyList *r_next = next->plugins;
+ while (r_next != NULL)
{
- ia[index] = cur_row;
- ja[index] = c2;
- ar[index] = ((c1+1 == c2) ? 1.0 : 0.0);
- index++;
+ struct ForeignAddressList * a_next = r_next->addresses;
+ while (a_next != NULL)
+ {
+ c_mechs++;
+ a_next = a_next->next;
+ }
+ r_next = r_next->next;
}
- cur_row++;
+ next = next->next;
+ c_peers++;
}
- /* constraint 3: Minimum bandwidth
- * V b_i in B: b_i >= b_min
- */
- start = index+1;
- for (c1=0; c1<peers; c1++)
+ if (c_mechs==0)
{
- glp_set_row_bnds(lp, cur_row , GLP_LO, b_min, 0.0);
-
- for (c2 = 1; c2 <= cols; c2++)
- {
- ia[index] = cur_row;
- ja[index] = c2;
- ar[index] = ((c1+1 == c2) ? 1.0 : 0.0);
- index++;
- }
- cur_row++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No addresses for bw distribution available\n", c_peers);
+ return;
}
- /* constraint 4: Bandwidth assignment relativity to peer preference
- * V b_i in B: b_i >= b_min
- */
- start = index+1;
- for (c1=0; c1<peers; c1++)
+ struct ATS_mechanism * mechanisms = GNUNET_malloc((1+c_mechs) * sizeof (struct ATS_mechanism));
+ struct ATS_peer * peers = GNUNET_malloc((1+c_peers) * sizeof (struct ATS_peer));
+
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Found mechanisms: %i\n", c_mechs);
+ c_mechs = 1;
+ c_peers = 1;
+ next = neighbours;
+ while (next!=NULL)
{
+ peers[c_peers].peer = next->id;
+ peers[c_peers].m_head = NULL;
+ peers[c_peers].m_tail = NULL;
- value = pl[c1].f * r;
- glp_set_row_bnds(lp, cur_row , GLP_LO, value, 0.0);
- for (c2 = 1; c2 <= cols; c2++)
+ struct ReadyList *r_next = next->plugins;
+ while (r_next != NULL)
{
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "c1: %i c2 %i index: %i \n",c1 , c2, index);
- ia[index] = cur_row;
- ja[index] = c2;
- ar[index] = ((c1+1 == c2) ? (1.0/b_max) : 0.0);
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ia: %i ja %i ar: %f \n",cur_row , c2, ((c1+1 == c2) ? 1.0 : 0.0));
- index++;
+ struct ForeignAddressList * a_next = r_next->addresses;
+ while (a_next != NULL)
+ {
+ if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%i Peer: `%s' %x:\n", c_mechs, GNUNET_i2s(&next->id),
+ a_next);
+ mechanisms[c_mechs].addr = a_next;
+ mechanisms[c_mechs].col_index = c_mechs;
+ mechanisms[c_mechs].peer = &peers[c_peers];
+ mechanisms[c_mechs].next = NULL;
+
+ GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]);
+ c_mechs++;
+ a_next = a_next->next;
+ }
+ r_next = r_next->next;
}
- cur_row++;
+ c_peers++;
+ next = next->next;
}
+ c_mechs--;
+ c_peers--;
+
+ /* number of variables == coloumns */
+ //int c_cols = 2 * c_mechs + 3 + c_q_metrics;
+ /* number of constraints == rows */
+ //int c_rows = 2 * c_peers + 2 * c_mechs + c_c_ressources + c_q_metrics + 3;
+
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating problem with: %i peers, %i mechanisms\n", c_peers, c_mechs);
+
+ int size = 6 *c_mechs;
+ int row_index;
+ int array_index=0;
+ int * ia = GNUNET_malloc (size * sizeof (int));
+ int * ja = GNUNET_malloc (size * sizeof (int));
+ double * ar = GNUNET_malloc(size* sizeof (double));
+
+ prob = glp_create_prob();
+ glp_set_prob_name(prob, "gnunet ats bandwidth distribution");
+ glp_set_obj_dir(prob, GLP_MAX);
+
+ /* adding columns */
+ int c;
+ char * name;
+ glp_add_cols(prob, 2 * c_mechs);
+ for (c=1; c <= c_mechs; c++)
+ {
+ GNUNET_asprintf(&name, "b%i",c);
+ glp_set_col_name(prob, c, name);
+ GNUNET_free (name);
+ glp_set_col_bnds(prob, c, GLP_LO, 0.0, 0.0);
+ glp_set_obj_coef(prob, c, 1.0);
- /* constraint 4: transport capacity
- * sum of b * c_i < c_max */
- start = index+1;
- for (c1=0; c1<transports; c1++)
+ }
+ for (c=c_mechs; c <= 2*c_mechs; c++)
{
+ GNUNET_asprintf(&name, "n%i",c);
+ glp_set_col_name(prob, c, "n1");
+ glp_set_col_bnds(prob, c, GLP_LO, 0.0, 0.0);
+ glp_set_col_bnds(prob, c, GLP_LO, 0.0, 1.0);
+ glp_set_col_kind(prob, c, GLP_IV);
+ glp_set_obj_coef(prob, c, 1.0);
+ GNUNET_free (name);
+ }
- value = tl[c1].c_max;
- if (DEBUG_ATS) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport %i: c_max %5.2f c_1 %5.2f \n", c1, value, tl[c1].c_1);
- glp_set_row_bnds(lp, cur_row , GLP_UP, 0.0 , value);
+ /* feasibility constraints */
+ /* one address per peer*/
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 1\n");
+ row_index = 1;
+ glp_add_rows(prob, c_peers);
+ for (c=1; c<=c_peers; c++)
+ {
+ glp_set_row_bnds(prob, row_index, GLP_DB, 0.0, 1.0);
- for (c2 = 1; c2 <= cols; c2++)
+ struct ATS_mechanism *m = peers[c].m_head;
+ while (m!=NULL)
{
- ia[index] = cur_row;
- ja[index] = c2;
- ar[index] = ((pl[c1-1].t == tl[c1].id) ? (tl[c1].c_1) : 0.0);
- index++;
+ ia[array_index] = row_index;
+ ja[array_index] = (c_mechs + m->col_index);
+ ar[array_index] = 1;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ m = m->next;
}
- cur_row++;
+ row_index++;
}
+ GNUNET_assert (row_index-1==c_peers);
+ GNUNET_assert (array_index==c_mechs);
- glp_load_matrix(lp, rows * cols, ia, ja, ar);
- result = glp_simplex(lp, options);
- if (DEBUG_ATS)
+ /* Constraint 1: only active mechanism gets bandwidth assigned */
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 2\n");
+ glp_add_rows(prob, c_mechs);
+ for (c=1; c<=c_mechs; c++)
{
- switch (result) {
- case GLP_ESTOP : /* search terminated by application */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Search terminated by application ");
- case GLP_EITLIM : /* iteration limit exceeded */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration limit exceeded ");
- break;
- case GLP_ETMLIM : /* time limit exceeded */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Time limit exceeded ");
- break;
- case GLP_ENOFEAS: /* no primal/dual feasible solution */
- case GLP_ENOCVG : /* no convergence */
- case GLP_ERANGE : /* result out of range */
- case GLP_ENOPFS : /* no primal feasible solution */
- case GLP_ENODFS : /* no dual feasible solution */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No feasible solution");
- break;
-
- case GLP_EBADB : /* invalid basis */
- case GLP_ESING : /* singular matrix */
- case GLP_ECOND : /* ill-conditioned matrix */
- case GLP_EBOUND : /* invalid bounds */
- case GLP_EFAIL : /* solver failed */
- case GLP_EOBJLL : /* objective lower limit reached */
- case GLP_EOBJUL : /* objective upper limit reached */
- case GLP_EROOT : /* root LP optimum not provided */
- case GLP_EMIPGAP: /* relative mip gap tolerance reached */
- case GLP_EINSTAB: /* numerical instability */
- case GLP_EDATA : /* invalid data */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Invalid Input data\n");
- break;
-
- break;
- default:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Optimal solution\n");
- break;
- }
+ /* b_t - n_t * M <= 0 */
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
+ glp_set_row_bnds(prob, row_index, GLP_UP, 0.0, 0.0);
+
+ ia[array_index] = row_index;
+ ja[array_index] = mechanisms[c].col_index;
+ ar[array_index] = 1;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ ia[array_index] = row_index;
+ ja[array_index] = c_mechs + mechanisms[c].col_index;
+ ar[array_index] = -M;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ row_index ++;
}
+ GNUNET_assert (row_index-1==c_peers+c_mechs);
+ GNUNET_assert (array_index==c_mechs+(2*c_mechs));
- char * debug_solution = NULL;
- char * old = NULL;
- for (c1=1; c1<= peers; c1++ )
+ /* Constraint 3: minimum bandwidth*/
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 3\n");
+ glp_add_rows(prob, c_mechs);
+ for (c=1; c<=c_mechs; c++)
+ {
+ /* b_t - n_t * b_min <= 0 */
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
+ glp_set_row_bnds(prob, row_index, GLP_UP, 0.0, 0.0);
+
+ ia[array_index] = row_index;
+ ja[array_index] = mechanisms[c].col_index;
+ ar[array_index] = 1;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ ia[array_index] = row_index;
+ ja[array_index] = c_mechs + mechanisms[c].col_index;
+ ar[array_index] = -v_b_min;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ row_index ++;
+ }
+ GNUNET_assert (row_index-1==c_peers+(2*c_mechs));
+ GNUNET_assert (array_index==c_mechs+(4*c_mechs));
+
+ /* Constraint 4: max ressource capacity */
+ /*
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 3\n");
+ glp_add_rows(prob, c_mechs);
+ for (c=1; c<=c_mechs; c++)
{
- old = debug_solution;
- GNUNET_asprintf(&debug_solution, "%s %s = %g;", (debug_solution!=NULL) ? debug_solution : "", GNUNET_i2s(&pl[c1-1].peer), glp_get_col_prim(lp, c1));
- if (old!=NULL) GNUNET_free(old);
+ // b_t - n_t * b_min >= 0
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
+ glp_set_row_bnds(prob, row_index, GLP_LO, 0.0, 0.0);
+
+ ia[array_index] = row_index;
+ ja[array_index] = mechanisms[c].col_index;
+ ar[array_index] = 1;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ ia[array_index] = row_index;
+ ja[array_index] = c_mechs + mechanisms[c].col_index;
+ ar[array_index] = -v_b_min;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ row_index ++;
}
- GNUNET_asprintf(&debug_solution, "%s z = %g; \n", debug_solution, glp_get_obj_val(lp));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s \n",debug_solution);
- GNUNET_free(debug_solution);
+ GNUNET_assert (row_index-1==c_peers+(2*c_mechs));
+ GNUNET_assert (array_index==5*c_mechs);
+ */
+
+ /* Constraint 5: min number of connections*/
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Constraint 5\n");
+ glp_add_rows(prob, 1);
+ for (c=1; c<=c_mechs; c++)
+ {
+ // b_t - n_t * b_min >= 0
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index);
+ glp_set_row_bnds(prob, row_index, GLP_LO, v_n_min, 0.0);
+
+ ia[array_index] = row_index;
+ ja[array_index] = c_mechs + mechanisms[c].col_index;
+ ar[array_index] = 1;
+ if (VERBOSE_ATS) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, ia[array_index], ja[array_index], ar[array_index]);
+ array_index++;
+ }
+ row_index ++;
+ GNUNET_assert (row_index-1==c_peers+(2*c_mechs)+1);
+ GNUNET_assert (array_index==6*c_mechs);
- glp_delete_prob(lp);
- GNUNET_free(options);
- return lp;
-}
-#if HAVE_LIBGLPK
-#else
-void * FUNCTION
-{
+ glp_load_matrix(prob, array_index-1, ia, ja, ar);
-}
-#endif
+ glp_delete_prob(prob);
+ /* clean up */
-void ats_calculate_bandwidth_distribution ()
+ GNUNET_free (ja);
+ GNUNET_free (ia);
+ GNUNET_free (ar);
+
+ GNUNET_free(mechanisms);
+ GNUNET_free(peers);
+}
+
+/* To remove: just for testing */
+void ats_benchmark (int peers, int transports, int start_peers, int end_peers)
{
- 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;
+ struct GNUNET_TIME_Relative duration;
+/*
+ int test = 11;
+ int mlp = GNUNET_NO;
- int peers = 3;
+ for (test=start_peers; test<=end_peers; test++)
+ {
+ int peers = test;
int transports = 3;
- double b_min = 10;
- double b_max = 100.0;
+ double b_min = 5;
+ double b_max = 50;
double r = 0.85;//1.0;
double R = 1.0;
- int it = 50;
+ int it = ATS_MAX_ITERATIONS;
int dur = 500;
- //if (INT_MAX) ats.max_exec_duration.rel_value;
+ 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 = GNUNET_malloc(transports * sizeof (struct ATS_peer));
+
+ struct ATS_mechanism * tl = GNUNET_malloc(transports * sizeof (struct ATS_peer));
struct ATS_peer * pl = GNUNET_malloc(peers * sizeof (struct ATS_peer));
int c = 0;
pl[c].peer.hashPubKey.bits[0] = c+1;
pl[c].f = 1 / (double) peers ;
pl[c].t = 1;
- //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %s %p \n",c , GNUNET_i2s(&list[c].peer), &list[c].peer);
+ //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_calculate_bandwidth_distribution Peer[%i] : %s %p \n",c , GNUNET_i2s(&pl[c].peer), &pl[c].peer);
c++;
}
c = 0;
while (c < transports)
{
tl[c].id = c;
- tl[c].c_max = 100;
+ 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);
c++;
+
}
// test //
- pl[0].f = 0.33;
- pl[2].f = 0.43;
- pl[1].f = 0.33;
+ //pl[0].f = 0.33;
+ //pl[2].f = 0.43;
+ //pl[1].f = 0.33;
// test //
+ *
+ */
+ start = GNUNET_TIME_absolute_get();
+ ats_create_problem(5000,5000);
- ats_create_problem(peers, transports, b_min, b_max, r, R, pl, tl, it, dur);
+ duration = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
- GNUNET_free (pl);
- GNUNET_free (tl);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "benchmark result: %llu\n", duration);
- ats->last = GNUNET_TIME_absolute_get();
+ GNUNET_STATISTICS_set (stats, "ATS execution time 100 peers", duration.rel_value, GNUNET_NO);
+}
+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_mechanism * tl = NULL;
+ struct ATS_peer * pl = NULL;
+
+ start = GNUNET_TIME_absolute_get();
+ 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);
+ GNUNET_free_non_null (tl);
+
+ ats->last = GNUNET_TIME_absolute_get();
}
ats->min_delta = ATS_MIN_INTERVAL;
ats->exec_intervall = ATS_EXEC_INTERVAL;
ats->max_exec_duration = ATS_MAX_EXEC_DURATION;
+ ats->max_iterations = ATS_MAX_ITERATIONS;
ats->ats_task = GNUNET_SCHEDULER_NO_TASK;
/*
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;