test_ats_mlp_averaging.c   test_ats_mlp_averaging.c 
skipping to change at line 33 skipping to change at line 33
* @author Christian Grothoff * @author Christian Grothoff
* @author Matthias Wachs * @author Matthias Wachs
*/ */
#include "platform.h" #include "platform.h"
#include "gnunet_util_lib.h" #include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h" #include "gnunet_statistics_service.h"
#include "gnunet_ats_service.h" #include "gnunet_ats_service.h"
#include "gnunet-service-ats_addresses_mlp.h" #include "gnunet-service-ats_addresses_mlp.h"
#define VERBOSE GNUNET_YES
#define VERBOSE_ARM GNUNET_NO
#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_U NIT_SECONDS, 3) #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_U NIT_SECONDS, 3)
#define MLP_MAX_ITERATIONS INT_MAX #define MLP_MAX_ITERATIONS INT_MAX
static int ret; static int ret;
struct GNUNET_STATISTICS_Handle * stats; struct GNUNET_STATISTICS_Handle * stats;
struct GNUNET_CONTAINER_MultiHashMap * addresses; struct GNUNET_CONTAINER_MultiHashMap * addresses;
struct GAS_MLP_Handle *mlp; struct GAS_MLP_Handle *mlp;
static void static void
create_address (struct ATS_Address *addr, char * plugin, int ats_count, str uct GNUNET_ATS_Information *ats) create_address (struct ATS_Address *addr, char * plugin, int ats_count, str uct GNUNET_ATS_Information *ats)
{ {
addr->mlp_information = NULL; addr->mlp_information = NULL;
addr->next = NULL; addr->next = NULL;
addr->prev = NULL; addr->prev = NULL;
addr->plugin = strdup (plugin); addr->plugin = GNUNET_strdup (plugin);
addr->ats_count = ats_count; addr->ats_count = ats_count;
addr->ats = ats; addr->ats = ats;
} }
static void static void
set_ats (struct GNUNET_ATS_Information *ats, uint32_t type, uint32_t value) set_ats (struct GNUNET_ATS_Information *ats, uint32_t type, uint32_t value)
{ {
ats->type = type; ats->type = type;
ats->value = value; ats->value = value;
} }
skipping to change at line 77 skipping to change at line 74
const struct GNUNET_CONFIGURATION_Handle *cfg) const struct GNUNET_CONFIGURATION_Handle *cfg)
{ {
#if !HAVE_LIBGLPK #if !HAVE_LIBGLPK
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
ret = 1; ret = 1;
return; return;
#endif #endif
struct ATS_Address addr[10]; struct ATS_Address addr[10];
struct ATS_PreferedAddress *res[10]; struct ATS_PreferedAddress *res[10];
struct MLP_information *mlpi; struct MLP_information *mlpi;
struct GAS_MLP_SolutionContext ctx;
stats = GNUNET_STATISTICS_create("ats", cfg); stats = GNUNET_STATISTICS_create("ats", cfg);
addresses = GNUNET_CONTAINER_multihashmap_create (10); addresses = GNUNET_CONTAINER_multihashmap_create (10);
mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS) ; mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS) ;
mlp->auto_solve = GNUNET_NO; mlp->auto_solve = GNUNET_NO;
struct GNUNET_PeerIdentity p[10]; struct GNUNET_PeerIdentity p[10];
skipping to change at line 128 skipping to change at line 126
/* Update an peer 1 address 1 */ /* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10); set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 10);
GAS_mlp_address_update (mlp, addresses, &addr[0]); GAS_mlp_address_update (mlp, addresses, &addr[0]);
GNUNET_assert (mlp->addr_in_problem == 1); GNUNET_assert (mlp->addr_in_problem == 1);
/* Update an peer 1 address 1 */ /* Update an peer 1 address 1 */
set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 30); set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 30);
GAS_mlp_address_update (mlp, addresses, &addr[0]); GAS_mlp_address_update (mlp, addresses, &addr[0]);
GNUNET_assert (mlp->addr_in_problem == 1); GNUNET_assert (mlp->addr_in_problem == 1);
GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp)); GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx));
GNUNET_assert (GNUNET_OK == ctx.lp_result);
GNUNET_assert (GNUNET_OK == ctx.mlp_result);
res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]); res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound band width: %u Bps\n",res[0]->address->plugin, res[0]->bandwidth_out); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound band width: %u Bps\n",res[0]->address->plugin, res[0]->bandwidth_out);
GNUNET_free (res[0]); GNUNET_free (res[0]);
/* Delete an address */ /* Delete an address */
GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey , &addr[0]); GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey , &addr[0]);
GAS_mlp_address_delete (mlp, addresses, &addr[0]); GAS_mlp_address_delete (mlp, addresses, &addr[0]);
GNUNET_assert (mlp->addr_in_problem == 0); GNUNET_assert (mlp->addr_in_problem == 0);
skipping to change at line 157 skipping to change at line 157
return; return;
} }
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
static char *const argv2[] = { "test_ats_mlp", static char *const argv2[] = { "test_ats_mlp",
"-c", "-c",
"test_ats_api.conf", "test_ats_api.conf",
#if VERBOSE
"-L", "DEBUG",
#else
"-L", "WARNING", "-L", "WARNING",
#endif
NULL NULL
}; };
static struct GNUNET_GETOPT_CommandLineOption options[] = { static struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END GNUNET_GETOPT_OPTION_END
}; };
GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
"test_ats_mlp", "nohelp", options, "test_ats_mlp", "nohelp", options,
&check, NULL); &check, NULL);
 End of changes. 6 change blocks. 
9 lines changed or deleted 5 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/