/*
This file is part of GNUnet.
- Copyright (C) 2010-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010-2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file ats-tests/ats-testing-experiment.c
/* Store logging data here */
for (cur = peer_head; NULL != cur; cur = cur->next)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging peer id %llu\n", cur->id);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Logging peer id %llu\n", cur->id);
log_p = GNUNET_new (struct LoggingPeer);
log_p->id = cur->id;
{
log_p->pref_abs[c] = cur->pref_abs[c];
log_p->pref_norm[c] = cur->pref_norm[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t %s = %.2f %.2f [abs/rel]\n",
- GNUNET_ATS_print_preference_type(c),
- log_p->pref_abs[c], log_p->pref_norm[c]);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "\t %s = %.2f %.2f [abs/rel]\n",
+ GNUNET_ATS_print_preference_type(c),
+ log_p->pref_abs[c], log_p->pref_norm[c]);
}
GNUNET_CONTAINER_DLL_insert_tail(lts->head, lts->tail, log_p);
for (cur_addr = cur->addr_head; NULL != cur_addr; cur_addr = cur_addr->next)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging peer id %llu address %llu \n",
- cur->id, cur_addr->aid);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Logging peer id %llu address %llu\n",
+ cur->id, cur_addr->aid);
log_a = GNUNET_new (struct LoggingAddress);
log_a->aid = cur_addr->aid;
log_a->active = cur_addr->ats_addr->active;
{
log_a->prop_abs[c] = cur_addr->prop_abs[c];
log_a->prop_norm[c] = cur_addr->prop_norm[c];
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t %s = %.2f %.2f [abs/rel]\n",
- GNUNET_ATS_print_property_type(c),
- log_a->prop_abs[c], log_a->prop_norm[c]);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "\t %s = %.2f %.2f [abs/rel]\n",
+ GNUNET_ATS_print_property_type(c),
+ log_a->prop_abs[c],
+ log_a->prop_norm[c]);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t Active = %i\n", log_a->active);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t BW in = %llu\n", log_a->assigned_bw_in);
}
}
+
static void
-logging_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+logging_task (void *cls)
{
struct LoggingHandle *l = cls;
- l->logging_task = NULL;
+ l->logging_task = NULL;
GNUNET_ATS_solver_logging_now (l);
-
- l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq, &logging_task, l);
-
+ l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq,
+ &logging_task,
+ l);
}
struct LoggingHandle *
GNUNET_ATS_print_property_type(c),
log_a->prop_abs[c], log_a->prop_norm[c]);*/
GNUNET_asprintf(&propstring_tmp,"%s%.3f;%.3f;",
- propstring, log_a->prop_abs[c], log_a->prop_norm[c]);
+ propstring,
+ log_a->prop_abs[c],
+ log_a->prop_norm[c]);
GNUNET_free (propstring);
propstring = GNUNET_strdup(propstring_tmp);
GNUNET_free (propstring_tmp);
/**
* Property Generators
*/
-
static struct PropertyGenerator *prop_gen_head;
static struct PropertyGenerator *prop_gen_tail;
+
static double
get_property (struct PropertyGenerator *pg)
{
static void
-set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_prop_task (void *cls)
{
struct PropertyGenerator *pg = cls;
struct TestPeer *p;
return pref_value;
}
+
static void
-set_feedback_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_feedback_task (void *cls)
{
struct PreferenceGenerator *pg = cls;
struct TestPeer *p;
static void
-set_pref_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+set_pref_task (void *cls)
{
struct PreferenceGenerator *pg = cls;
struct TestPeer *p;
sh->sf->s_pref (sh->sf->cls, &p->peer_id, pg->kind, pref_value);
}
else
- normalize_preference (NULL + (pg->client_id),
- &p->peer_id,
- pg->kind,
- pref_value);
+ update_preference (NULL + (pg->client_id),
+ &p->peer_id,
+ pg->kind,
+ pref_value);
pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
&set_pref_task,
return e_counter;
}
+
static void
-timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
+timeout_experiment (void *cls)
{
struct Experiment *e = cls;
+
e->experiment_timeout_task = NULL;
fprintf (stderr, "Experiment timeout!\n");
op->address_id,
op->peer_id);
- sh->sf->s_del (sh->sf->cls, a->ats_addr, GNUNET_NO);
+ sh->sf->s_del (sh->sf->cls, a->ats_addr);
if (NULL != l)
{
enforce_start_request (struct GNUNET_ATS_TEST_Operation *op)
{
struct TestPeer *p;
- const struct ATS_Address *res;
if (NULL == (p = find_peer_by_id (op->peer_id)))
{
op->peer_id);
p->is_requested = GNUNET_YES;
- res = sh->sf->s_get (sh->sf->cls, &p->peer_id);
- if (NULL != res)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Suggested address for peer %u: %llu %llu\n",
- op->peer_id,
- res->assigned_bw_in,
- res->assigned_bw_out);
- if (NULL != l)
- GNUNET_ATS_solver_logging_now (l);
- }
+ sh->sf->s_get (sh->sf->cls, &p->peer_id);
}
+
static void
enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
{
return;
}
-
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop requesting address for peer %u\n",
- op->peer_id);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Stop requesting address for peer %u\n",
+ op->peer_id);
p->is_requested = GNUNET_NO;
p->assigned_bw_in = 0;
p->assigned_bw_out = 0;
}
}
+
static void
-timeout_episode (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc)
+timeout_episode (void *cls)
{
struct Experiment *e = cls;
+
e->episode_timeout_task = NULL;
if (NULL != e->ep_done_cb)
e->ep_done_cb (e->cur);
}
else
return GAS_preference_get_by_peer (NULL,
- id);
+ id);
}