/*
This file is part of GNUnet.
- Copyright (C) 2010,2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2010,2011 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
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ Affero General Public License for more details.
- 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.
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
* @file ats/perf_ats_solver.c
}
-const double *
+static const double *
get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
{
- return GAS_normalization_get_preferences_by_peer (NULL, id);
-}
-
-
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address)
-{
- return GAS_normalization_get_properties (NULL,
- address);
+ return GAS_preference_get_by_peer (NULL, id);
}
}
+static unsigned int
+get_connectivity_cb (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
+{
+ return GNUNET_CONTAINER_multipeermap_contains (ph.addresses,
+ peer);
+}
+
+
/**
* Evaluate average results for all iterations
*/
GNUNET_CONTAINER_multipeermap_remove (ph.addresses,
pid,
cur));
- ph.sf->s_del (ph.sf->cls, cur, GNUNET_NO);
+ ph.sf->s_del (ph.sf->cls, cur);
GNUNET_free_non_null (cur->atsi);
GNUNET_free (cur);
return GNUNET_OK;
/* Add address */
/* Random network selection */
- //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_ATS_NetworkTypeCount - 1);
+ //net = 1 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_NT_COUNT - 1);
/* Random equally distributed network selection */
- net = 1 + (ca % (GNUNET_ATS_NetworkTypeCount - 1));
+ net = 1 + (ca % (GNUNET_NT_COUNT - 1));
/* fprintf (stderr, "Network: %u `%s'\n",
- * mod_net , GNUNET_ATS_print_network_type(mod_net)); */
+ * mod_net , GNUNET_NT_to_string(mod_net)); */
cur_addr->atsi = GNUNET_new (struct GNUNET_ATS_Information);
cur_addr->atsi_count = 1;
perf_address_initial_update (NULL, ph.addresses, cur_addr);
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"Adding address for peer %u address %u in network %s\n", cp, ca,
- GNUNET_ATS_print_network_type(net));
+ GNUNET_NT_to_string(net));
}
/* Notify solver about request */
ph.sf->s_get (ph.sf->cls, &ph.peers[cp].id);
&do_delete_address,
NULL);
}
+ if (GNUNET_NO == ph.bulk_running)
+ {
+ ph.sf->s_bulk_stop (ph.sf->cls);
+ ph.bulk_running = GNUNET_NO;
+ }
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"Iteration done\n");
char *solver;
char *plugin;
struct GNUNET_CONFIGURATION_Handle *solver_cfg;
- unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
- unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
+ unsigned long long quotas_in[GNUNET_NT_COUNT];
+ unsigned long long quotas_out[GNUNET_NT_COUNT];
int c;
int c2;
if (0 == strcmp(solver, "proportional"))
{
- ph.ats_mode = MODE_PROPORTIONAL;
ph.ats_string = "proportional";
}
else if (0 == strcmp(solver, "mlp"))
{
- ph.ats_mode = MODE_MLP;
ph.ats_string = "mlp";
}
else if ((0 == strcmp(solver, "ril")))
{
- ph.ats_mode = MODE_RIL;
ph.ats_string = "ril";
}
else
end_now (1);
return;
}
- if (GNUNET_ATS_NetworkTypeCount != load_quotas (solver_cfg,
- quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount))
+ if (GNUNET_NT_COUNT != load_quotas (solver_cfg,
+ quotas_out, quotas_in, GNUNET_NT_COUNT))
{
GNUNET_break(0);
end_now (1);
ph.addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
ph.env.addresses = ph.addresses;
ph.env.bandwidth_changed_cb = bandwidth_changed_cb;
+ ph.env.get_connectivity = &get_connectivity_cb;
ph.env.get_preferences = &get_preferences_cb;
- ph.env.get_property = &get_property_cb;
- ph.env.network_count = GNUNET_ATS_NetworkTypeCount;
+ ph.env.network_count = GNUNET_NT_COUNT;
ph.env.info_cb = &solver_info_cb;
- for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++)
+ for (c = 0; c < GNUNET_NT_COUNT; c++)
{
ph.env.out_quota[c] = quotas_out[c];
ph.env.in_quota[c] = quotas_in[c];
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Loading network quotas: `%s' %llu %llu \n",
- GNUNET_ATS_print_network_type (c),
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Loading network quotas: `%s' %llu %llu \n",
+ GNUNET_NT_to_string (c),
ph.env.out_quota[c],
ph.env.in_quota[c]);
}
GAS_normalization_start ();
GAS_preference_init ();
- GNUNET_asprintf (&plugin, "libgnunet_plugin_ats_%s", ph.ats_string);
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s'\n"), ph.ats_string);
+ GNUNET_asprintf (&plugin,
+ "libgnunet_plugin_ats_%s",
+ ph.ats_string);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Initializing solver `%s'\n"),
+ ph.ats_string);
if (NULL == (ph.sf = GNUNET_PLUGIN_load (plugin, &ph.env)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to initialize solver `%s'!\n"), plugin);
+ _("Failed to initialize solver `%s'!\n"),
+ plugin);
ret = 1;
return;
}
/* Do the benchmark */
for (ph.current_iteration = 1; ph.current_iteration <= ph.total_iterations; ph.current_iteration++)
{
- fprintf (stderr, "Iteration %u of %u starting\n", ph.current_iteration, ph.total_iterations);
+ fprintf (stderr,
+ "Iteration %u of %u starting\n",
+ ph.current_iteration,
+ ph.total_iterations);
perf_run_iteration ();
evaluate (ph.current_iteration);
- fprintf (stderr, "Iteration %u of %u done\n", ph.current_iteration, ph.total_iterations);
+ fprintf (stderr,
+ "Iteration %u of %u done\n",
+ ph.current_iteration,
+ ph.total_iterations);
}
if (ph.create_datafile)
write_all_iterations ();
/* Unload solver*/
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Unloading solver `%s'\n"), ph.ats_string);
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ _("Unloading solver `%s'\n"),
+ ph.ats_string);
GNUNET_PLUGIN_unload (plugin, ph.sf);
ph.sf = NULL;
GNUNET_free (plugin);
GNUNET_STATISTICS_destroy (ph.stat, GNUNET_NO);
}
+
/**
* Main function of the benchmark
*
ph.total_iterations = 1;
static struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 'a', "addresses", NULL,
- gettext_noop ("addresses to use"),
- 1, &GNUNET_GETOPT_set_uint, &ph.N_address },
- { 's', "start", NULL,
- gettext_noop ("start with peer"),
- 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_start },
- { 'e', "end", NULL,
- gettext_noop ("end with peer"),
- 1, &GNUNET_GETOPT_set_uint, &ph.N_peers_end },
- { 'i', "iterations", NULL,
- gettext_noop ("number of iterations used for averaging (default: 1)"),
- 1, &GNUNET_GETOPT_set_uint, &ph.total_iterations },
- { 'p', "percentage", NULL,
- gettext_noop ("update a fix percentage of addresses"),
- 1, &GNUNET_GETOPT_set_uint, &ph.opt_update_percent },
- { 'd', "data", NULL,
- gettext_noop ("create data file"),
- 0, &GNUNET_GETOPT_set_one, &ph.create_datafile},
- { 'u', "update", NULL,
- gettext_noop ("measure updates"),
- 0, &GNUNET_GETOPT_set_one, &ph.measure_updates},
+
+ GNUNET_GETOPT_option_uint ('a',
+ "addresses",
+ gettext_noop ("addresses to use"),
+ &ph.N_address),
+
+ GNUNET_GETOPT_option_uint ('s',
+ "start",
+ gettext_noop ("start with peer"),
+ &ph.N_peers_start),
+
+ GNUNET_GETOPT_option_uint ('e',
+ "end",
+ gettext_noop ("end with peer"),
+ &ph.N_peers_end),
+
+ GNUNET_GETOPT_option_uint ('i',
+ "iterations",
+ gettext_noop ("number of iterations used for averaging (default: 1)"),
+ &ph.total_iterations),
+
+ GNUNET_GETOPT_option_uint ('p',
+ "percentage",
+ gettext_noop ("update a fix percentage of addresses"),
+ &ph.opt_update_percent),
+
+ GNUNET_GETOPT_option_flag ('d',
+ "data",
+ gettext_noop ("create data file"),
+ &ph.create_datafile),
+
+ GNUNET_GETOPT_option_flag ('u',
+ "update",
+ gettext_noop ("measure updates"),
+ &ph.measure_updates),
+
GNUNET_GETOPT_OPTION_END
};