aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-16 13:15:35 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-16 13:15:35 +0000
commit2cb5aae84e71bab1ed6da6c3651f6373f1d2d36a (patch)
tree000c111468f78ef5b666e6f8d1255b3d97c20b3c /src/ats
parentb14e4bb20e4323512d6b62aaa36cc170c106b182 (diff)
downloadgnunet-2cb5aae84e71bab1ed6da6c3651f6373f1d2d36a.tar.gz
gnunet-2cb5aae84e71bab1ed6da6c3651f6373f1d2d36a.zip
- improved configuration and statistics handling
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/ats.conf.in18
-rw-r--r--src/ats/gnunet-service-ats_addresses.c100
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c58
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.h3
-rw-r--r--src/ats/test_ats_api.conf32
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;
10UNIXPATH = /tmp/gnunet-service-ats.sock 10UNIXPATH = /tmp/gnunet-service-ats.sock
11UNIX_MATCH_UID = YES 11UNIX_MATCH_UID = YES
12UNIX_MATCH_GID = YES 12UNIX_MATCH_GID = YES
13
14# Enable MLP mode (default: NO)
13MLP = NO 15MLP = NO
14WAN_QUOTA_IN = 65536 16# Network specific inbound/outbound quotas
15WAN_QUOTA_OUT = 65536 17# LOOPBACK
18LOOPBACK_QUOTA_IN = unlimited
19LOOPBACK_QUOTA_OUT = unlimited
20# LAN
21LAN_QUOTA_IN = unlimited
22LAN_QUOTA_OUT = unlimited
23# WAN
24WAN_QUOTA_IN = 64 KiB
25WAN_QUOTA_OUT = 64 KiB
26# WLAN
27WLAN_QUOTA_IN = 1 MiB
28WLAN_QUOTA_OUT = 1 MiB
16# ATS options 29# ATS options
30
17DUMP_MLP = NO 31DUMP_MLP = NO
18DUMP_SOLUTION = NO 32DUMP_SOLUTION = NO
19DUMP_OVERWRITE = NO 33DUMP_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
713GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, 713GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
714 const struct GNUNET_STATISTICS_Handle *stats) 714 const struct GNUNET_STATISTICS_Handle *stats)
715{ 715{
716 GNUNET_assert (GNUNET_OK == 716 int mode;
717 GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 717
718 "WAN_QUOTA_IN", 718 char *quota_wan_in_str;
719 &wan_quota_in)); 719 char *quota_wan_out_str;
720 GNUNET_assert (GNUNET_OK == 720
721 GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 721 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_wan_in_str))
722 "WAN_QUOTA_OUT", 722 {
723 &wan_quota_out)); 723 if (0 == strcmp(quota_wan_in_str, "unlimited") ||
724 724 (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_in_str, &wan_quota_in)))
725 switch (GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP")) 725 wan_quota_in = (UINT32_MAX) /10;
726
727 GNUNET_free (quota_wan_in_str);
728 quota_wan_in_str = NULL;
729 }
730 else
731 {
732 wan_quota_in = (UINT32_MAX) /10;
733 }
734
735 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", &quota_wan_out_str))
726 { 736 {
727 /* MLP = YES */ 737 if (0 == strcmp(quota_wan_out_str, "unlimited") ||
728 case GNUNET_YES: 738 (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_wan_out_str, &wan_quota_out)))
739 wan_quota_out = (UINT32_MAX) /10;
740
741 GNUNET_free (quota_wan_out_str);
742 quota_wan_out_str = NULL;
743 }
744 else
745 {
746 wan_quota_out = (UINT32_MAX) /10;
747 }
748
749
750 mode = GNUNET_CONFIGURATION_get_value_yesno (cfg, "ats", "MLP");
751 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode %u", mode);
752 switch (mode)
753 {
754 /* MLP = YES */
755 case GNUNET_YES:
729#if HAVE_LIBGLPK 756#if HAVE_LIBGLPK
730 ats_mode = MLP; 757 ats_mode = MLP;
731 /* Init the MLP solver with default values */ 758 /* Init the MLP solver with default values */
732 mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); 759 mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS);
733 break; 760 if (NULL == mlp)
761 {
762 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode\n");
763 GNUNET_STATISTICS_update (GSA_stats, "MLP mode enabled", 0, GNUNET_NO);
764 break;
765 }
766 else
767 {
768 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 1, GNUNET_NO);
769 break;
770 }
734#else 771#else
735 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode"); 772 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP mode was configured, but libglpk is not installed, switching to simple mode");
736 ats_mode = SIMPLE; 773 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
737 break; 774 ats_mode = SIMPLE;
775 break;
738#endif 776#endif
739 /* MLP = NO */ 777 /* MLP = NO */
740 case GNUNET_NO: 778 case GNUNET_NO:
741 ats_mode = SIMPLE; 779 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
742 break; 780 ats_mode = SIMPLE;
743 /* No configuration value */ 781 break;
744 case GNUNET_SYSERR: 782 /* No configuration value */
745 ats_mode = SIMPLE; 783 case GNUNET_SYSERR:
746 break; 784 GNUNET_STATISTICS_update (GSA_stats, "MLP enabled", 0, GNUNET_NO);
747 default: 785 ats_mode = SIMPLE;
748 break; 786 break;
787 default:
788 break;
749 } 789 }
750 790 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS started with %s mode\n", (SIMPLE == ats_mode) ? "SIMPLE" : "MLP");
751 addresses = GNUNET_CONTAINER_multihashmap_create (128); 791 addresses = GNUNET_CONTAINER_multihashmap_create (128);
752} 792}
753 793
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,
1110 unsigned int n_min; 1110 unsigned int n_min;
1111 struct GNUNET_TIME_Relative i_exec; 1111 struct GNUNET_TIME_Relative i_exec;
1112 int c; 1112 int c;
1113 char * quota_out_str;
1114 char * quota_in_str;
1113 1115
1114 /* Init GLPK environment */ 1116 /* Init GLPK environment */
1115 GNUNET_assert (glp_init_env() == 0); 1117 GNUNET_assert (glp_init_env() == 0);
@@ -1118,7 +1120,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1118 mlp->prob = glp_create_prob(); 1120 mlp->prob = glp_create_prob();
1119 GNUNET_assert (mlp->prob != NULL); 1121 GNUNET_assert (mlp->prob != NULL);
1120 1122
1121 mlp->BIG_M = (double) (UINT32_MAX) /10; 1123 mlp->BIG_M = (double) BIG_M_VALUE;
1122 1124
1123 /* Get diversity coefficient from configuration */ 1125 /* Get diversity coefficient from configuration */
1124 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", 1126 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats",
@@ -1231,37 +1233,57 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1231 if ((entry_in == NULL) || (entry_out == NULL)) 1233 if ((entry_in == NULL) || (entry_out == NULL))
1232 continue; 1234 continue;
1233 1235
1234 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_out, &quota_out)) 1236 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, &quota_out_str))
1237 {
1238 if (0 == strcmp(quota_out_str, BIG_M_STRING) ||
1239 (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, &quota_out)))
1240 quota_out = mlp->BIG_M;
1241
1242 GNUNET_free (quota_out_str);
1243 quota_out_str = NULL;
1244 }
1245 else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
1246 {
1247 quota_out = 0;
1248 }
1249 else
1235 { 1250 {
1236 quota_out = mlp->BIG_M; 1251 quota_out = mlp->BIG_M;
1237 } 1252 }
1238 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", entry_in, &quota_in)) 1253
1254 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, &quota_in_str))
1255 {
1256 if (0 == strcmp(quota_in_str, BIG_M_STRING) ||
1257 (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, &quota_in)))
1258 quota_in = mlp->BIG_M;
1259
1260 GNUNET_free (quota_in_str);
1261 quota_in_str = NULL;
1262 }
1263 else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c])
1264 {
1265 quota_in = 0;
1266 }
1267 else
1239 { 1268 {
1240 quota_in = mlp->BIG_M; 1269 quota_in = mlp->BIG_M;
1241 } 1270 }
1271
1242 /* Check if defined quota could make problem unsolvable */ 1272 /* Check if defined quota could make problem unsolvable */
1243 if ((n_min * b_min) > quota_out) 1273 if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != quotas[c]))
1244 { 1274 {
1245 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " \ 1275 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " \
1246 "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); 1276 "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);
1247 unsigned int default_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); 1277
1248 if ((quota_out / n_min) > default_min) 1278 GAS_mlp_done(mlp);
1249 { 1279 mlp = NULL;
1250 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Reducing minimum bandwidth per peer to %u Bps\n", 1280 return NULL;
1251 (quota_out / n_min));
1252 b_min = (quota_out / n_min);
1253 }
1254 else
1255 {
1256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Reducing minimum bandwidth per peer to %u Bps and minimum connections to %u \n",
1257 default_min, (quota_out / default_min));
1258 b_min = default_min;
1259 n_min = (quota_out / default_min);
1260 }
1261 } 1281 }
1262 1282
1263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n", 1283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n",
1264 entry_out, quota_out, entry_in, quota_in); 1284 entry_out, quota_out, entry_in, quota_in);
1285 GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_out, quota_out, GNUNET_NO);
1286 GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_in, quota_in, GNUNET_NO);
1265 mlp->quota_out[c] = quota_out; 1287 mlp->quota_out[c] = quota_out;
1266 mlp->quota_in[c] = quota_in; 1288 mlp->quota_in[c] = quota_in;
1267 } 1289 }
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 @@
36 36
37#define DEBUG_MLP GNUNET_EXTRA_LOGGING 37#define DEBUG_MLP GNUNET_EXTRA_LOGGING
38 38
39#define BIG_M_VALUE (UINT32_MAX) /10
40#define BIG_M_STRING "unlimited"
41
39#define MLP_AVERAGING_QUEUE_LENGTH 3 42#define MLP_AVERAGING_QUEUE_LENGTH 3
40 43
41#define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) 44#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
8 8
9[ats] 9[ats]
10#DEBUG = YES 10#DEBUG = YES
11#PREFIX = valgrind --leak-check=full 11PREFIX = valgrind --leak-check=full
12#WAN_QUOTA_OUT = 4294967295
13#WAN_QUOTA_IN = 4294967295
14AUTOSTART = YES 12AUTOSTART = YES
15PORT = 12002 13PORT = 12002
16HOSTNAME = localhost 14HOSTNAME = localhost
@@ -21,4 +19,30 @@ ACCEPT_FROM = 127.0.0.1;
21ACCEPT_FROM6 = ::1; 19ACCEPT_FROM6 = ::1;
22UNIXPATH = /tmp/test-ats-scheduling-ats.sock 20UNIXPATH = /tmp/test-ats-scheduling-ats.sock
23UNIX_MATCH_UID = YES 21UNIX_MATCH_UID = YES
24UNIX_MATCH_GID = YES \ No newline at end of file 22UNIX_MATCH_GID = YES
23
24# Enable MLP mode (default: NO)
25MLP = YES
26# Network specific inbound/outbound quotas
27# LOOPBACK
28LOOPBACK_QUOTA_IN = unlimited
29LOOPBACK_QUOTA_OUT = unlimited
30# LAN
31LAN_QUOTA_IN = unlimited
32LAN_QUOTA_OUT = unlimited
33# WAN
34WAN_QUOTA_IN = 64 KiB
35WAN_QUOTA_OUT = 64 KiB
36# WLAN
37WLAN_QUOTA_IN = 1 MiB
38WLAN_QUOTA_OUT = 1 MiB
39
40# ATS extended options
41DUMP_MLP = NO
42DUMP_SOLUTION = NO
43DUMP_OVERWRITE = NO
44DUMP_MIN_PEERS = 0
45DUMP_MIN_ADDRS = 0
46DUMP_OVERWRITE = NO
47ATS_MIN_INTERVAL = 15000
48ATS_EXEC_INTERVAL = 30000