From 2cb5aae84e71bab1ed6da6c3651f6373f1d2d36a Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 16 Apr 2012 13:15:35 +0000 Subject: [PATCH] - improved configuration and statistics handling --- src/ats/ats.conf.in | 18 +++- src/ats/gnunet-service-ats_addresses.c | 100 ++++++++++++++------- src/ats/gnunet-service-ats_addresses_mlp.c | 58 ++++++++---- src/ats/gnunet-service-ats_addresses_mlp.h | 3 + src/ats/test_ats_api.conf | 32 ++++++- 5 files changed, 157 insertions(+), 54 deletions(-) diff --git a/src/ats/ats.conf.in b/src/ats/ats.conf.in index 6ea0d417f..f81016e2b 100644 --- a/src/ats/ats.conf.in +++ b/src/ats/ats.conf.in @@ -10,10 +10,24 @@ ACCEPT_FROM6 = ::1; UNIXPATH = /tmp/gnunet-service-ats.sock UNIX_MATCH_UID = YES UNIX_MATCH_GID = YES + +# Enable MLP mode (default: NO) MLP = NO -WAN_QUOTA_IN = 65536 -WAN_QUOTA_OUT = 65536 +# Network specific inbound/outbound quotas +# LOOPBACK +LOOPBACK_QUOTA_IN = unlimited +LOOPBACK_QUOTA_OUT = unlimited +# LAN +LAN_QUOTA_IN = unlimited +LAN_QUOTA_OUT = unlimited +# WAN +WAN_QUOTA_IN = 64 KiB +WAN_QUOTA_OUT = 64 KiB +# WLAN +WLAN_QUOTA_IN = 1 MiB +WLAN_QUOTA_OUT = 1 MiB # ATS options + DUMP_MLP = NO DUMP_SOLUTION = NO DUMP_OVERWRITE = NO diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index c5923a099..fec55b69d 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -713,41 +713,81 @@ void GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_STATISTICS_Handle *stats) { - GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "WAN_QUOTA_IN", - &wan_quota_in)); - GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_size (cfg, "ats", - "WAN_QUOTA_OUT", - &wan_quota_out)); - - switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP")) + int mode; + + char *quota_wan_in_str; + char *quota_wan_out_str; + + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", "a_wan_in_str)) + { + if (0 == strcmp(quota_wan_in_str, "unlimited") || + (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_in_str, &wan_quota_in))) + wan_quota_in = (UINT32_MAX) /10; + + GNUNET_free (quota_wan_in_str); + quota_wan_in_str = NULL; + } + else + { + wan_quota_in = (UINT32_MAX) /10; + } + + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", "a_wan_out_str)) { - /* MLP = YES */ - case GNUNET_YES: + if (0 == strcmp(quota_wan_out_str, "unlimited") || + (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_out_str, &wan_quota_out))) + wan_quota_out = (UINT32_MAX) /10; + + GNUNET_free (quota_wan_out_str); + quota_wan_out_str = NULL; + } + else + { + wan_quota_out = (UINT32_MAX) /10; + } + + + mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP"); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode %u", mode); + switch (mode) + { + /* MLP = YES */ + case GNUNET_YES: #if HAVE_LIBGLPK - ats_mode = MLP; - /* Init the MLP solver with default values */ - mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); - break; + ats_mode = MLP; + /* Init the MLP solver with default values */ + mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); + if (NULL == mlp) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode\n"); + GNUNET_STATISTICS_update (GSA_stats, "MLP mode enabled", 0, GNUNET_NO); + break; + } + else + { + GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 1, GNUNET_NO); + break; + } #else - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); - ats_mode = SIMPLE; - break; + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); + GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO); + ats_mode = SIMPLE; + break; #endif - /* MLP = NO */ - case GNUNET_NO: - ats_mode = SIMPLE; - break; - /* No configuration value */ - case GNUNET_SYSERR: - ats_mode = SIMPLE; - break; - default: - break; + /* MLP = NO */ + case GNUNET_NO: + GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO); + ats_mode = SIMPLE; + break; + /* No configuration value */ + case GNUNET_SYSERR: + GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO); + ats_mode = SIMPLE; + break; + default: + break; } - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE == ats_mode) ? "SIMPLE" : "MLP"); addresses = GNUNET_CONTAINER_multihashmap_create (128); } diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 61aa73397..175d4f41a 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c @@ -1110,6 +1110,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int n_min; struct GNUNET_TIME_Relative i_exec; int c; + char * quota_out_str; + char * quota_in_str; /* Init GLPK environment */ GNUNET_assert (glp_init_env() == 0); @@ -1118,7 +1120,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, mlp->prob = glp_create_prob(); GNUNET_assert (mlp->prob != NULL); - mlp->BIG_M = (double) (UINT32_MAX) /10; + mlp->BIG_M = (double) BIG_M_VALUE; /* Get diversity coefficient from configuration */ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", @@ -1231,37 +1233,57 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, if ((entry_in == NULL) || (entry_out == NULL)) continue; - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_out, "a_out)) + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str)) + { + if (0 == strcmp(quota_out_str, BIG_M_STRING) || + (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, "a_out))) + quota_out = mlp->BIG_M; + + GNUNET_free (quota_out_str); + quota_out_str = NULL; + } + else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) + { + quota_out = 0; + } + else { quota_out = mlp->BIG_M; } - if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_in, "a_in)) + + if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, "a_in_str)) + { + if (0 == strcmp(quota_in_str, BIG_M_STRING) || + (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, "a_in))) + quota_in = mlp->BIG_M; + + GNUNET_free (quota_in_str); + quota_in_str = NULL; + } + else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) + { + quota_in = 0; + } + else { quota_in = mlp->BIG_M; } + /* Check if defined quota could make problem unsolvable */ - if ((n_min * b_min) > quota_out) + if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != quotas[c])) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " \ "outbound quota (%u Bps) too small for combination of minimum connections and minimum bandwidth per peer (%u * %u Bps = %u)\n", entry_out, quota_out, n_min, b_min, n_min * b_min); - unsigned int default_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); - if ((quota_out / n_min) > default_min) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Reducing minimum bandwidth per peer to %u Bps\n", - (quota_out / n_min)); - b_min = (quota_out / n_min); - } - else - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Reducing minimum bandwidth per peer to %u Bps and minimum connections to %u \n", - default_min, (quota_out / default_min)); - b_min = default_min; - n_min = (quota_out / default_min); - } + + GAS_mlp_done(mlp); + mlp = NULL; + return NULL; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n", entry_out, quota_out, entry_in, quota_in); + GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_out, quota_out, GNUNET_NO); + GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_in, quota_in, GNUNET_NO); mlp->quota_out[c] = quota_out; mlp->quota_in[c] = quota_in; } diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index 8f60a8598..e8db35c27 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h @@ -36,6 +36,9 @@ #define DEBUG_MLP GNUNET_EXTRA_LOGGING +#define BIG_M_VALUE (UINT32_MAX) /10 +#define BIG_M_STRING "unlimited" + #define MLP_AVERAGING_QUEUE_LENGTH 3 #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) diff --git a/src/ats/test_ats_api.conf b/src/ats/test_ats_api.conf index fa379c92e..85aabf37e 100644 --- a/src/ats/test_ats_api.conf +++ b/src/ats/test_ats_api.conf @@ -8,9 +8,7 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock [ats] #DEBUG = YES -#PREFIX = valgrind --leak-check=full -#WAN_QUOTA_OUT = 4294967295 -#WAN_QUOTA_IN = 4294967295 +PREFIX = valgrind --leak-check=full AUTOSTART = YES PORT = 12002 HOSTNAME = localhost @@ -21,4 +19,30 @@ ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; UNIXPATH = /tmp/test-ats-scheduling-ats.sock UNIX_MATCH_UID = YES -UNIX_MATCH_GID = YES \ No newline at end of file +UNIX_MATCH_GID = YES + +# Enable MLP mode (default: NO) +MLP = YES +# Network specific inbound/outbound quotas +# LOOPBACK +LOOPBACK_QUOTA_IN = unlimited +LOOPBACK_QUOTA_OUT = unlimited +# LAN +LAN_QUOTA_IN = unlimited +LAN_QUOTA_OUT = unlimited +# WAN +WAN_QUOTA_IN = 64 KiB +WAN_QUOTA_OUT = 64 KiB +# WLAN +WLAN_QUOTA_IN = 1 MiB +WLAN_QUOTA_OUT = 1 MiB + +# ATS extended options +DUMP_MLP = NO +DUMP_SOLUTION = NO +DUMP_OVERWRITE = NO +DUMP_MIN_PEERS = 0 +DUMP_MIN_ADDRS = 0 +DUMP_OVERWRITE = NO +ATS_MIN_INTERVAL = 15000 +ATS_EXEC_INTERVAL = 30000 -- 2.25.1