*/
static int opt_verbose;
+/**
+ * cmd option -p: print logs
+ */
+static int opt_print;
+
static int res;
static void
}
}
+struct AddressLookupCtx
+{
+ struct ATS_Address *res;
+ char *plugin;
+ char *addr;
+};
+
+
+int find_address_it (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ struct AddressLookupCtx *ctx = cls;
+ struct ATS_Address *addr = value;
+
+ if ( (0 == strcmp (ctx->plugin, addr->plugin)) &&
+ (0 == strcmp (ctx->addr, addr->addr)) )
+ {
+ ctx->res = addr;
+ return GNUNET_NO;
+ }
+ return GNUNET_YES;
+}
+
+static struct TestPeer *
+find_peer_by_id (int id)
+{
+ struct TestPeer *cur;
+ for (cur = peer_head; NULL != cur; cur = cur->next)
+ if (cur->id == id)
+ return cur;
+ return NULL;
+}
+
+static struct TestAddress *
+find_address_by_id (struct TestPeer *peer, int aid)
+{
+ struct TestAddress *cur;
+ for (cur = peer->addr_head; NULL != cur; cur = cur->next)
+ if (cur->aid == aid)
+ return cur;
+ return NULL;
+}
+
+
+
/**
* Logging
*/
+void
+GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
+{
+ struct LoggingTimeStep *lts;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging\n");
+
+ lts = GNUNET_new (struct LoggingTimeStep);
+ lts->timestamp = GNUNET_TIME_absolute_get();
+
+ /* Store logging data here */
+
+ GNUNET_CONTAINER_DLL_insert_tail(l->head, l->tail, lts);
+
+}
+
static void
logging_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct LoggingHandle *l = cls;
-
l->logging_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging\n");
+ GNUNET_ATS_solver_logging_now (l);
l->logging_task = GNUNET_SCHEDULER_add_delayed (l->log_freq, &logging_task, l);
return l;
}
-void
-GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
-{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Logging\n");
-}
-
void
GNUNET_ATS_solver_logging_stop (struct LoggingHandle *l)
{
void
GNUNET_ATS_solver_logging_eval (struct LoggingHandle *l)
{
+ struct LoggingTimeStep *lts;
+ for (lts = l->head; NULL != lts; lts = lts->next)
+ {
+ fprintf (stderr, "Log %llu: \n", (long long unsigned int) lts->timestamp.abs_value_us);
+ }
}
void
GNUNET_ATS_solver_logging_free (struct LoggingHandle *l)
{
+ struct LoggingTimeStep *cur;
+ struct LoggingTimeStep *next;
+
if (GNUNET_SCHEDULER_NO_TASK != l->logging_task)
GNUNET_SCHEDULER_cancel (l->logging_task);
l->logging_task = GNUNET_SCHEDULER_NO_TASK;
+
+ next = l->head;
+ while (NULL != (cur = next))
+ {
+ next = cur->next;
+ GNUNET_CONTAINER_DLL_remove (l->head, l->tail, cur);
+ GNUNET_free (cur);
+ }
+
GNUNET_free (l);
}
{
struct PropertyGenerator *pg = cls;
double pref_value;
+ struct GNUNET_ATS_Information atsi;
+
pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+ if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains_value (sh->addresses,
+ &pg->test_peer->peer_id, pg->test_address->ats_addr))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Setting property generation for unknown address [%u:%u]\n",
+ pg->peer, pg->address_id);
+ return;
+ }
+
pref_value = get_property (pg);
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
pg->peer, pg->address_id,
GNUNET_ATS_print_property_type (pg->ats_property), pref_value);
- /* set performance here!
- GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle,
- &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END);
-*/
+
+ atsi.type = htonl (pg->ats_property);
+ atsi.value = htonl ((uint32_t) pref_value);
+
+ /* set performance here! */
+ sh->env.sf.s_bulk_start (sh->solver);
+ GAS_normalization_normalize_property (sh->addresses,
+ pg->test_address->ats_addr, &atsi, 1);
+ sh->env.sf.s_bulk_stop (sh->solver);
switch (pg->ats_property) {
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
/**
- * Generate between the source master and the partner and set preferences with a
+ * Generate between the source master and the partner and set property with a
* value depending on the generator.
*
- * @param src source
- * @param dest partner
- * @param type type of preferences to generate
- * @param base_rate traffic base rate to send data with
- * @param max_rate traffic maximum rate to send data with
- * @param period duration of a period of traffic generation (~ 1/frequency)
- * @param duration how long to generate traffic
- * @return the traffic generator
+ * @param peer source
+ * @param address_id partner
+ * @param test_peer the peer
+ * @param test_address the address
+ * @param type type of generator
+ * @param base_value base value
+ * @param value_rate maximum value
+ * @param period duration of a period of generation (~ 1/frequency)
+ * @param frequency how long to generate property
+ * @param ats_property ATS property to generate
+ * @return the property generator
*/
struct PropertyGenerator *
GNUNET_ATS_solver_generate_property_start (unsigned int peer,
unsigned int address_id,
+ struct TestPeer *test_peer,
+ struct TestAddress *test_address,
enum GeneratorType type,
long int base_value,
long int value_rate,
GNUNET_CONTAINER_DLL_insert (prop_gen_head, prop_gen_tail, pg);
pg->type = type;
pg->peer = peer;
+ pg->test_address = test_address;
+ pg->test_peer = test_peer;
pg->address_id = address_id;
pg->ats_property = ats_property;
pg->base_value = base_value;
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PreferenceGenerator *pg = cls;
+ struct TestPeer *p;
double pref_value;
pg->set_task = GNUNET_SCHEDULER_NO_TASK;
+ if (NULL == (p = find_peer_by_id (pg->peer)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Setting preference for unknown peer %u\n", pg->peer);
+ return;
+ }
+
pref_value = get_preference (pg);
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Setting preference for peer [%u] address [%u] for %s to %f\n",
- pg->peer, pg->address_id,
+ "Setting preference for peer [%u] address [%u] for client %p pref %s to %f\n",
+ pg->peer, pg->address_id, NULL + (pg->client_id),
GNUNET_ATS_print_preference_type (pg->kind), pref_value);
- /* set performance here!
- GNUNET_ATS_performance_change_preference(p->me->ats_perf_handle,
- &p->dest->id, p->pg->kind, pref_value, GNUNET_ATS_PREFERENCE_END);
-*/
+ sh->env.sf.s_bulk_start (sh->solver);
+ GAS_normalization_normalize_preference (NULL + (pg->client_id), &p->peer_id,
+ pg->kind, pref_value);
+ sh->env.sf.s_bulk_stop (sh->solver);
switch (pg->kind) {
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
/**
- * Generate between the source master and the partner and set preferences with a
+ * Generate between the source master and the partner and set property with a
* value depending on the generator.
*
- * @param src source
- * @param dest partner
- * @param type type of preferences to generate
- * @param base_rate traffic base rate to send data with
- * @param max_rate traffic maximum rate to send data with
- * @param period duration of a period of traffic generation (~ 1/frequency)
- * @param duration how long to generate traffic
- * @return the traffic generator
+ * @param peer source
+ * @param address_id partner
+ * @param client_id the client
+ * @param type type of generator
+ * @param base_value base value
+ * @param value_rate maximum value
+ * @param period duration of a period of generation (~ 1/frequency)
+ * @param frequency how long to generate property
+ * @param kind ATS preference to generate
+ * @return the preference generator
*/
struct PreferenceGenerator *
GNUNET_ATS_solver_generate_preferences_start (unsigned int peer,
unsigned int address_id,
+ unsigned int client_id,
enum GeneratorType type,
long int base_value,
long int value_rate,
pg->type = type;
pg->peer = peer;
pg->address_id = address_id;
+ pg->client_id = client_id;
pg->kind = kind;
pg->base_value = base_value;
pg->max_value = value_rate;
struct Experiment *e;
e = GNUNET_new (struct Experiment);
e->name = NULL;
- e->num_masters = 0;
- e->num_slaves = 0;
e->start = NULL;
e->total_duration = GNUNET_TIME_UNIT_ZERO;
return e;
}
GNUNET_free (op_name);
+ /* address id */
+ GNUNET_asprintf(&op_name, "op-%u-client-id", op_counter);
+ if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
+ sec_name, op_name, &o->client_id))
+ {
+ fprintf (stderr, "Missing client-id in operation %u `%s' in episode `%s'\n",
+ op_counter, "START_SET_PREFERENCE", op_name);
+ GNUNET_free (op_name);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_free (op_name);
+
/* generator */
GNUNET_asprintf(&op_name, "op-%u-gen-type", op_counter);
if ( (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
fprintf (stderr, "Invalid property in operation %u `%s' in episode %u\n",
op_counter, op_name, e->id);
GNUNET_free (op_name);
- GNUNET_free (pref);
GNUNET_free_non_null (pref);
return GNUNET_SYSERR;
}
o->type = SOLVER_OP_START_SET_PREFERENCE;
res = load_op_start_set_preference (o, cur,
op_counter, sec_name, cfg);
- break;
}
else if (0 == strcmp (op, "stop_set_preference"))
{
op_counter++;
}
GNUNET_free (sec_name);
-
-
-#if 0
- /* Get source */
- GNUNET_asprintf(&op_name, "op-%u-src", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->src_id))
- {
- fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- return GNUNET_SYSERR;
- }
- if (o->src_id > (e->num_masters - 1))
- {
- fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
- o->src_id, op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get destination */
- GNUNET_asprintf(&op_name, "op-%u-dest", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->dest_id))
- {
- fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- return GNUNET_SYSERR;
- }
- if (o->dest_id > (e->num_slaves - 1))
- {
- fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
- o->dest_id, op_counter, op, cur->id);
- GNUNET_free (op);
- GNUNET_free (op_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
- if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
- sec_name, op_name, &type)) &&
- ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type)))
- {
- /* Load arguments for set_rate, start_send, set_preference */
- if (0 == strcmp (type, "constant"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
- }
- else if (0 == strcmp (type, "linear"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
- }
- else if (0 == strcmp (type, "sinus"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
- }
- else if (0 == strcmp (type, "random"))
- {
- o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
- }
- else
- {
- fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op);
- GNUNET_free (op_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get base rate */
- GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->base_rate))
- {
- fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op);
- GNUNET_free (op_name);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get max rate */
- GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->max_rate))
- {
- if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
- (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
- (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
- {
- fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- return GNUNET_SYSERR;
- }
- }
- GNUNET_free (op_name);
-
- /* Get period */
- GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
- sec_name, op_name, &o->period))
- {
- o->period = cur->duration;
- }
- GNUNET_free (op_name);
-
- if (START_PREFERENCE == o->type)
- {
- /* Get frequency */
- GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
- sec_name, op_name, &o->frequency))
- {
- fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- return GNUNET_SYSERR;
- }
- GNUNET_free (op_name);
-
- /* Get preference */
- GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
- sec_name, op_name, &pref))
- {
- fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- GNUNET_free_non_null (pref);
- return GNUNET_SYSERR;
- }
-
- if (0 == strcmp(pref, "bandwidth"))
- o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
- else if (0 == strcmp(pref, "latency"))
- o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
- else
- {
- fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n",
- op_counter, op, cur->id);
- GNUNET_free (type);
- GNUNET_free (op_name);
- GNUNET_free (op);
- GNUNET_free (pref);
- GNUNET_free_non_null (pref);
- return GNUNET_SYSERR;
- }
- GNUNET_free (pref);
- GNUNET_free (op_name);
- }
- }
-
- /* Safety checks */
- if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
- (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
- {
- if ((o->max_rate - o->base_rate) > o->base_rate)
- {
- /* This will cause an underflow */
- GNUNET_break (0);
- }
- fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
- }
-
- if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
- fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
- op_counter, cur->id, print_op (o->type), o->src_id,
- o->dest_id, (NULL != type) ? type : "",
- o->base_rate, o->max_rate,
- GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
- else
- fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
- op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
-
- GNUNET_free_non_null (type);
- GNUNET_free (op);
-#endif
-
return GNUNET_OK;
}
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
sec_name, "duration", &e_duration))
{
+ fprintf (stderr, "Missing duration in episode %u \n",e_counter);
GNUNET_free (sec_name);
break;
}
if (NULL == last)
e->start = cur;
else
- last->next = cur;
+ last->next = cur;
GNUNET_free (sec_name);
e_counter ++;
GNUNET_SYSERR);
}
-static struct TestPeer *
-find_peer_by_id (int id)
-{
- struct TestPeer *cur;
- for (cur = peer_head; NULL != cur; cur = cur->next)
- if (cur->id == id)
- return cur;
- return NULL;
-}
-
struct ATS_Address *
create_ats_address (const struct GNUNET_PeerIdentity *peer,
const char *plugin_name,
return aa;
}
+
+
static void
enforce_add_address (struct GNUNET_ATS_TEST_Operation *op)
{
- struct ATS_Address *addr;
struct TestPeer *p;
+ struct TestAddress *a;
if (NULL == (p = find_peer_by_id (op->peer_id)))
{
p = GNUNET_new (struct TestPeer);
p->id = op->peer_id;
- memset (&p->peer_id, '0', sizeof (p->peer_id));
+ memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, p);
}
- addr = create_ats_address (&p->peer_id, op->plugin, op->address,
+ if (NULL != (find_address_by_id (p, op->address_id)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Duplicate address %u for peer %u\n",
+ op->address_id, op->peer_id);
+ return;
+ }
+
+ a = GNUNET_new (struct TestAddress);
+ a->aid = op->address_id;
+ a->ats_addr = create_ats_address (&p->peer_id, op->plugin, op->address,
strlen (op->address) + 1, op->address_session);
+ memset (&p->peer_id, op->peer_id, sizeof (p->peer_id));
+ GNUNET_CONTAINER_DLL_insert (p->addr_head, p->addr_tail, a);
- GNUNET_CONTAINER_multipeermap_put (sh->addresses, &p->peer_id, addr,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_CONTAINER_multipeermap_put (sh->addresses, &p->peer_id, a->ats_addr,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Adding address %u for peer %u\n",
- op->address_id, op->peer_id);
+ op->address_id, op->peer_id);
- sh->env.sf.s_add (sh->solver, addr, op->address_network);
+ sh->env.sf.s_add (sh->solver, a->ats_addr, op->address_network);
}
-struct AddressLookupCtx
-{
- struct ATS_Address *res;
- struct GNUNET_ATS_TEST_Operation *op;
-};
-
-int find_address_it (void *cls,
- const struct GNUNET_PeerIdentity *key,
- void *value)
-{
- struct AddressLookupCtx *ctx = cls;
- struct ATS_Address *addr = value;
-
- if ( (0 == strcmp (ctx->op->plugin, addr->plugin)) &&
- (0 == strcmp (ctx->op->address, addr->addr)) )
- {
- ctx->res = addr;
- return GNUNET_NO;
- }
- return GNUNET_YES;
-}
static void
enforce_del_address (struct GNUNET_ATS_TEST_Operation *op)
return;
}
- ctx.op = op;
+ ctx.plugin = op->plugin;
+ ctx.addr = op->address;
ctx.res = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (sh->addresses, &p->peer_id,
find_address_it, &ctx);
return;
}
+ if (NULL == (find_address_by_id (p, op->address_id)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Deleting address for unknown peer %u\n", op->peer_id);
+ return;
+ }
+
GNUNET_CONTAINER_multipeermap_remove (sh->addresses, &p->peer_id, ctx.res);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Removing address %u for peer %u\n",
op->address_id, op->peer_id);
sh->env.sf.s_del (sh->solver, ctx.res, GNUNET_NO);
+ GNUNET_free (ctx.res);
+
}
static void
enforce_start_property (struct GNUNET_ATS_TEST_Operation *op)
{
struct PropertyGenerator *pg;
+ struct TestPeer *p;
+ struct TestAddress *a;
+
if (NULL != (pg = find_prop_gen (op->peer_id, op->address_id, op->prop_type)))
{
GNUNET_ATS_solver_generate_property_stop (pg);
GNUNET_free (pg);
}
+ if (NULL == (p = find_peer_by_id (op->peer_id)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Starting property generation for unknown peer %u\n", op->peer_id);
+ return;
+ }
+
+ if (NULL == (a = find_address_by_id (p, op->address_id)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Setting property for unknown address %u\n", op->peer_id);
+ return;
+ }
+
GNUNET_ATS_solver_generate_property_start (op->peer_id,
op->address_id,
+ p, a,
op->gen_type,
op->base_rate,
op->max_rate,
GNUNET_free (pg);
}
+ if (NULL == (find_peer_by_id (op->peer_id)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Starting preference generation for unknown peer %u\n", op->peer_id);
+ return;
+ }
+
GNUNET_ATS_solver_generate_preferences_start (op->peer_id,
op->address_id,
+ op->client_id,
op->gen_type,
op->base_rate,
op->max_rate,
static void
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)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Requesting address for unknown peer %u\n", op->peer_id);
+ return;
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting address for peer %u\n",
op->peer_id);
+
+ res = sh->env.sf.s_get (sh->solver, &p->peer_id);
+ if (NULL != res)
+ {
+
+ }
+
}
static void
enforce_stop_request (struct GNUNET_ATS_TEST_Operation *op)
{
+ struct TestPeer *p;
+
+ if (NULL == (p = find_peer_by_id (op->peer_id)))
+ {
+ GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Requesting address for unknown peer %u\n", op->peer_id);
+ return;
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stop requesting address for peer %u\n",
op->peer_id);
+
+ sh->env.sf.s_get_stop (sh->solver, &p->peer_id);
}
static void enforce_episode (struct Episode *ep)
}
else
{
- fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file);
+ fprintf (stderr, "Experiment configuration: `%s'\n", e->cfg_file);
e->cfg = GNUNET_CONFIGURATION_create();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (e->cfg, e->cfg_file))
{
}
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
- "masters", &e->num_masters))
- {
- fprintf (stderr, "Invalid %s", "masters");
- free_experiment (e);
- return NULL;
- }
- else
- fprintf (stderr, "Experiment masters: `%llu'\n",
- e->num_masters);
-
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment",
- "slaves", &e->num_slaves))
- {
- fprintf (stderr, "Invalid %s", "slaves");
- free_experiment (e);
- return NULL;
- }
- else
- fprintf (stderr, "Experiment slaves: `%llu'\n",
- e->num_slaves);
-
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
"log_freq", &e->log_freq))
{
return e;
}
+
+
/**
* Solver
*/
+static int
+free_all_it (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ struct ATS_Address *address = value;
+ GNUNET_break (GNUNET_OK != GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses,
+ key, value));
+ GNUNET_free (address);
+
+ return GNUNET_OK;
+}
+
void
GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh)
{
GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats,
GNUNET_NO);
- GNUNET_CONTAINER_multipeermap_destroy(sh->env.addresses);
GNUNET_PLUGIN_unload (sh->plugin, sh->solver);
+ GNUNET_CONTAINER_multipeermap_iterate (sh->addresses, &free_all_it, NULL);
GNUNET_CONTAINER_multipeermap_destroy(sh->addresses);
GNUNET_free (sh->plugin);
GNUNET_free (sh);
network_str[c], GNUNET_ATS_DefaultBandwidth);
out_dest[c] = GNUNET_ATS_DefaultBandwidth;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loaded quota for network `%s' (in/out): %llu %llu\n", network_str[c], in_dest[c], out_dest[c]);
GNUNET_free (entry_out);
GNUNET_free (entry_in);
}
/**
* Information callback for the solver
*
+ * @param cls the closure
* @param op the solver operation
* @param stat status of the solver operation
* @param add additional solver information
{
if ( (0 == ntohl (address->assigned_bw_out.value__)) &&
(0 == ntohl (address->assigned_bw_in.value__)) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Solver notified to disconnect peer `%s'\n",
+ GNUNET_i2s (&address->peer));
return;
+ }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Bandwidth changed addresses %s %p to %u Bps out / %u Bps in\n",
GNUNET_i2s (&address->peer),
address,
}
static void
-normalized_property_changed_cb (void *cls, struct ATS_Address *peer,
+normalized_property_changed_cb (void *cls, struct ATS_Address *address,
uint32_t type, double prop_rel)
{
- /* TODO */
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Normalized property %s for peer `%s' changed to %.3f \n",
+ GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
+ prop_rel);
+
+ sh->env.sf.s_address_update_property (sh->solver, address, type, 0, prop_rel);
+}
+
+
+static void
+normalized_preference_changed_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer,
+ enum GNUNET_ATS_PreferenceKind kind,
+ double pref_rel)
+{
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Normalized preference %s for peer `%s' changed to %.3f \n",
+ GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer),
+ pref_rel);
+
+ sh->env.sf.s_pref (sh->solver, peer, kind, pref_rel);
}
{
struct SolverHandle *sh;
char * solver_str;
- unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
- unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
switch (type) {
case GNUNET_ATS_SOLVER_PROPORTIONAL:
sh = GNUNET_new (struct SolverHandle);
GNUNET_asprintf (&sh->plugin, "libgnunet_plugin_ats_%s", solver_str);
+ sh->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
/* setup environment */
sh->env.cfg = e->cfg;
sh->env.stats = GNUNET_STATISTICS_create ("ats", e->cfg);
- sh->env.addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
+ sh->env.addresses = sh->addresses;
sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb;
sh->env.get_preferences = &get_preferences_cb;
sh->env.get_property = &get_property_cb;
sh->env.info_cb = &solver_info_cb;
sh->env.info_cb_cls = NULL;
+
/* start normalization */
- GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL );
+ GAS_normalization_start (&normalized_preference_changed_cb, NULL,
+ &normalized_property_changed_cb, NULL );
/* load quotas */
if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg,
- quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount))
+ sh->env.out_quota, sh->env.in_quota, GNUNET_ATS_NetworkTypeCount))
{
GNUNET_break(0);
GNUNET_free (sh->plugin);
end_now ();
return NULL;
}
-
- sh->addresses = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
-
return sh;
}
static void
done ()
{
- /* Clean up experiment */
+ struct TestPeer *cur;
+ struct TestPeer *next;
+
+ struct TestAddress *cur_a;
+ struct TestAddress *next_a;
+
+ /* Stop logging */
+ GNUNET_ATS_solver_logging_stop (l);
+
+ /* Stop all preference generation */
GNUNET_ATS_solver_generate_preferences_stop_all ();
+ /* Stop all property generation */
+ GNUNET_ATS_solver_generate_property_stop_all ();
+
+ /* Clean up experiment */
if (NULL != e)
{
GNUNET_ATS_solvers_experimentation_stop (e);
e = NULL;
}
+ if (opt_print)
+ GNUNET_ATS_solver_logging_eval (l);
+
if (NULL != l)
{
GNUNET_ATS_solver_logging_free (l);
l = NULL;
}
+ next = peer_head;
+ while (NULL != (cur = next))
+ {
+ next = cur->next;
+ GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur);
+ next_a = cur->addr_head;
+ while (NULL != (cur_a = next_a))
+ {
+ next_a = cur_a->next;
+ GNUNET_CONTAINER_DLL_remove (cur->addr_head, cur->addr_tail, cur_a);
+ GNUNET_free (cur_a);
+ }
+ GNUNET_free (cur);
+ }
+ if (NULL != sh)
+ {
+ GNUNET_ATS_solvers_solver_stop (sh);
+ sh = NULL;
+ }
/* Shutdown */
end_now();
-
}
static void
else
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n");
- /* Stop logging */
- GNUNET_ATS_solver_logging_stop (l);
-
- /* Stop traffic generation */
- // GNUNET_ATS_TEST_generate_traffic_stop_all();
-
- /* Stop all preference generations */
- GNUNET_ATS_solver_generate_preferences_stop_all ();
-
- /*
- evaluate (duration);
- if (opt_log)
- GNUNET_ATS_TEST_logging_write_to_file(l, opt_exp_file, opt_plot);
-
- if (NULL != l)
- {
- GNUNET_ATS_TEST_logging_stop (l);
- GNUNET_ATS_TEST_logging_clean_up (l);
- l = NULL;
- }
- */
GNUNET_SCHEDULER_add_now (&done, NULL);
}
{ 'e', "experiment", NULL,
gettext_noop ("experiment to use"),
1, &GNUNET_GETOPT_set_one, &opt_verbose},
+ { 'p', "print", NULL,
+ gettext_noop ("print logging"),
+ 0, &GNUNET_GETOPT_set_one, &opt_print},
GNUNET_GETOPT_OPTION_END
};