From d043dd0e4ca407081eaa1b9072b37b1d9e715813 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 16 Apr 2012 15:37:46 +0000 Subject: [PATCH] - changes --- src/ats/ats_api_scheduling.c | 6 ++- src/ats/gnunet-service-ats_addresses.c | 4 +- src/ats/gnunet-service-ats_addresses_mlp.c | 18 ++++--- src/ats/perf_ats_mlp.c | 63 ++++++++-------------- src/ats/test_ats_api.conf | 4 +- 5 files changed, 42 insertions(+), 53 deletions(-) diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 123398992..ec14e0e13 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -418,9 +418,13 @@ static void remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id, const struct GNUNET_PeerIdentity *peer) { + GNUNET_assert (peer != NULL); + GNUNET_assert (sh != NULL); + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api", - "Remove sessionID %u from peer %s in %p\n", "ats-scheduling-api", + "Release sessionID %u from peer %s in %p\n", (unsigned int) session_id, GNUNET_i2s (peer), sh); + if (0 == session_id) return; GNUNET_assert (session_id < sh->session_array_size); diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index fec55b69d..6ed625bf4 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -615,7 +615,7 @@ void request_address_mlp (const struct GNUNET_PeerIdentity *peer) if (aa == NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer)); return; } @@ -648,7 +648,7 @@ void request_address_simple (const struct GNUNET_PeerIdentity *peer) &find_address_it, &aa); if (aa == NULL) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, "Cannot suggest address for peer `%s'\n", GNUNET_i2s (peer)); return; } diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 175d4f41a..57692440b 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -869,8 +869,8 @@ lp_solv: mlp->lp_total_duration =+ duration.rel_value; GNUNET_STATISTICS_update (mlp->stats,"# LP problem solved", 1, GNUNET_NO); - GNUNET_STATISTICS_set (mlp->stats,"# LP execution time", duration.rel_value, GNUNET_NO); - GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average", + GNUNET_STATISTICS_set (mlp->stats,"# LP execution time (ms)", duration.rel_value, GNUNET_NO); + GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)", mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO); @@ -945,8 +945,8 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp) mlp->mlp_total_duration =+ duration.rel_value; GNUNET_STATISTICS_update (mlp->stats,"# MLP problem solved", 1, GNUNET_NO); - GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time", duration.rel_value, GNUNET_NO); - GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average", + GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time (ms)", duration.rel_value, GNUNET_NO); + GNUNET_STATISTICS_set (mlp->stats,"# MLP execution time average (ms)", mlp->mlp_total_duration / mlp->mlp_solved, GNUNET_NO); /* Analyze problem status */ @@ -1244,7 +1244,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, } else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) { - quota_out = 0; + quota_out = mlp->BIG_M; } else { @@ -1262,7 +1262,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, } else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) { - quota_in = 0; + quota_in = mlp->BIG_M; } else { @@ -1510,7 +1510,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult int new; struct MLP_information *mlpi; - GNUNET_STATISTICS_update (mlp->stats,"# LP address updates", 1, GNUNET_NO); + GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO); /* We add a new address */ if (address->mlp_information == NULL) @@ -1536,6 +1536,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult address->mlp_information = mlpi; mlp->addr_in_problem ++; + GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", 1, GNUNET_NO); /* Check for and add peer */ struct ATS_Peer *peer = mlp_find_peer (mlp, &address->peer); @@ -1562,6 +1563,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult GNUNET_CONTAINER_DLL_insert (peer->head, peer->tail, address); GNUNET_CONTAINER_DLL_insert (mlp->peer_head, mlp->peer_tail, peer); mlp->c_p ++; + GNUNET_STATISTICS_update (mlp->stats, "# peers in MLP", 1, GNUNET_NO); } else { @@ -1617,6 +1619,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult address->mlp_information = NULL; mlp->addr_in_problem --; + GNUNET_STATISTICS_update (mlp->stats, "# addresses in MLP", -1, GNUNET_NO); } /* Remove from peer list */ @@ -1635,6 +1638,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult GNUNET_CONTAINER_DLL_remove (mlp->peer_head, mlp->peer_tail, head); GNUNET_free (head); mlp->c_p --; + GNUNET_STATISTICS_update (mlp->stats, "# peers in MLP", -1, GNUNET_NO); } /* Update problem */ diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index a15e4b4b8..2daac4769 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c @@ -35,12 +35,17 @@ #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) #define MLP_MAX_ITERATIONS INT_MAX +#define DEF_PEERS 10 +#define DEF_ADDRESSES_PER_PEER 5 + +static unsigned int peers; +static unsigned int addresses; static int ret; struct GNUNET_STATISTICS_Handle * stats; -struct GNUNET_CONTAINER_MultiHashMap * addresses; +//struct GNUNET_CONTAINER_MultiHashMap * addresses; struct GAS_MLP_Handle *mlp; @@ -53,56 +58,26 @@ check (void *cls, char *const *args, const char *cfgfile, ret = 1; return; #endif - struct ATS_Address addr[10]; - - stats = GNUNET_STATISTICS_create("ats", cfg); - addresses = GNUNET_CONTAINER_multihashmap_create (10); + if (peers == 0) + peers = DEF_PEERS; + if (addresses == 0) + addresses = DEF_ADDRESSES_PER_PEER; - GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &addr[0].peer.hashPubKey); - addr[0].mlp_information = NULL; - addr[0].next = NULL; - addr[0].prev = NULL; - addr[0].plugin = strdup ("dummy"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Setting up %u peers with %u addresses per peer\n", peers, addresses); - addr[1].peer = addr[0].peer; - addr[1].mlp_information = NULL; - addr[1].next = NULL; - addr[1].prev = NULL; - addr[1].plugin = strdup ("dummy2"); - - GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); + GNUNET_HashCode hash; + //memset (&hash, '\0', sizeof (GNUNET_HashCode)); + //hash.bits[0] = 1; + //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "peer %s\n", GNUNET_h2s_full (&hash)); mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); + mlp->auto_solve = GNUNET_NO; - /* Add a new address */ -#if 0 - GAS_mlp_address_update (mlp, addresses, &addr[0]); - - GNUNET_assert (mlp != NULL); - GNUNET_assert (mlp->addr_in_problem == 1); - /* Update an new address */ - GAS_mlp_address_update (mlp, addresses, &addr[0]); - GNUNET_assert (mlp->addr_in_problem == 1); - /* Add a second address for same peer */ - GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - GAS_mlp_address_update (mlp, addresses, &addr[1]); - GNUNET_assert (mlp->addr_in_problem == 2); - - /* Delete an address */ - 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[1]); -#endif GAS_mlp_done (mlp); - GNUNET_free (addr[0].plugin); - GNUNET_free (addr[1].plugin); - GNUNET_CONTAINER_multihashmap_destroy (addresses); - GNUNET_STATISTICS_destroy(stats, GNUNET_NO); - ret = 0; return; } @@ -124,6 +99,12 @@ main (int argc, char *argv[]) }; static struct GNUNET_GETOPT_CommandLineOption options[] = { + {'a', "addresses", NULL, + gettext_noop ("addresses per peer"), 1, + &GNUNET_GETOPT_set_uint, &addresses}, + {'p', "peers", NULL, + gettext_noop ("peers"), 1, + &GNUNET_GETOPT_set_uint, &peers}, GNUNET_GETOPT_OPTION_END }; diff --git a/src/ats/test_ats_api.conf b/src/ats/test_ats_api.conf index 85aabf37e..efd7fc9c6 100644 --- a/src/ats/test_ats_api.conf +++ b/src/ats/test_ats_api.conf @@ -8,7 +8,7 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock [ats] #DEBUG = YES -PREFIX = valgrind --leak-check=full +#PREFIX = valgrind --leak-check=full AUTOSTART = YES PORT = 12002 HOSTNAME = localhost @@ -22,7 +22,7 @@ UNIX_MATCH_UID = YES UNIX_MATCH_GID = YES # Enable MLP mode (default: NO) -MLP = YES +MLP = NO # Network specific inbound/outbound quotas # LOOPBACK LOOPBACK_QUOTA_IN = unlimited -- 2.25.1