diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-19 12:52:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-02-19 12:52:39 +0000 |
commit | 7e7b70bcdbc067949bfd5249944b27ad57b3777c (patch) | |
tree | 37ca8b30ca9e952328cc12148d0c8699eabe6af5 | |
parent | c5671ca70c59f5304a3ace8aa9c98d3d221fa92b (diff) | |
download | gnunet-7e7b70bcdbc067949bfd5249944b27ad57b3777c.tar.gz gnunet-7e7b70bcdbc067949bfd5249944b27ad57b3777c.zip |
refactoring and renaming
-rw-r--r-- | src/ats/Makefile.am | 3 | ||||
-rw-r--r-- | src/ats/ats.conf.in | 17 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 213 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.h | 10 | ||||
-rw-r--r-- | src/ats/test_ats_api_common.h | 2 | ||||
-rw-r--r-- | src/ats/test_ats_mlp.c | 103 |
6 files changed, 126 insertions, 222 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index 5ee5183e9..048f1e220 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am | |||
@@ -200,7 +200,8 @@ test_ats_mlp_SOURCES = \ | |||
200 | test_ats_mlp_LDADD = \ | 200 | test_ats_mlp_LDADD = \ |
201 | $(GN_LIBGLPK) \ | 201 | $(GN_LIBGLPK) \ |
202 | $(top_builddir)/src/util/libgnunetutil.la \ | 202 | $(top_builddir)/src/util/libgnunetutil.la \ |
203 | $(top_builddir)/src/statistics/libgnunetstatistics.la | 203 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
204 | $(top_builddir)/src/ats/libgnunetats.la | ||
204 | 205 | ||
205 | #test_ats_mlp_averaging_SOURCES = \ | 206 | #test_ats_mlp_averaging_SOURCES = \ |
206 | # $(GN_MLP_SRC) test_ats_mlp_averaging.c test_ats_api_common.c | 207 | # $(GN_MLP_SRC) test_ats_mlp_averaging.c test_ats_api_common.c |
diff --git a/src/ats/ats.conf.in b/src/ats/ats.conf.in index bdc064e2f..481c46ec4 100644 --- a/src/ats/ats.conf.in +++ b/src/ats/ats.conf.in | |||
@@ -32,16 +32,23 @@ WLAN_QUOTA_OUT = 1 MiB | |||
32 | 32 | ||
33 | 33 | ||
34 | # MLP specific settings | 34 | # MLP specific settings |
35 | # MAX_DURATION = 3 s | 35 | ATS_MIN_INTERVAL = 15000 |
36 | # MAX_ITERATIONS = 1024 | 36 | ATS_EXEC_INTERVAL = 30000 |
37 | |||
38 | 37 | ||
38 | # MLP defaults | ||
39 | # MLP_MAX_DURATION = 3 s | ||
40 | # MLP_MAX_ITERATIONS = 1024 | ||
41 | # MLP_COEFFICIENT_D = 1.0 | ||
42 | # MLP_COEFFICIENT_U = 1.0 | ||
43 | # MLP_COEFFICIENT_R = 1.0 | ||
44 | # MLP_MIN_BANDWIDTH = 1024 | ||
45 | # MLP_MIN_CONNECTIONS = 4 | ||
39 | 46 | ||
47 | # MLP Debugging settings | ||
40 | DUMP_MLP = NO | 48 | DUMP_MLP = NO |
41 | DUMP_SOLUTION = NO | 49 | DUMP_SOLUTION = NO |
42 | DUMP_OVERWRITE = NO | 50 | DUMP_OVERWRITE = NO |
43 | DUMP_MIN_PEERS = 0 | 51 | DUMP_MIN_PEERS = 0 |
44 | DUMP_MIN_ADDRS = 0 | 52 | DUMP_MIN_ADDRS = 0 |
45 | DUMP_OVERWRITE = NO | 53 | DUMP_OVERWRITE = NO |
46 | ATS_MIN_INTERVAL = 15000 | 54 | |
47 | ATS_EXEC_INTERVAL = 30000 | ||
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 98a77ae18..50983cec1 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -1101,8 +1101,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1101 | unsigned int n_min; | 1101 | unsigned int n_min; |
1102 | struct GNUNET_TIME_Relative i_exec; | 1102 | struct GNUNET_TIME_Relative i_exec; |
1103 | int c; | 1103 | int c; |
1104 | char * quota_out_str; | 1104 | int c2; |
1105 | char * quota_in_str; | 1105 | int found; |
1106 | 1106 | ||
1107 | struct GNUNET_TIME_Relative max_duration; | 1107 | struct GNUNET_TIME_Relative max_duration; |
1108 | long long unsigned int max_iterations; | 1108 | long long unsigned int max_iterations; |
@@ -1111,21 +1111,21 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1111 | int res = glp_init_env(); | 1111 | int res = glp_init_env(); |
1112 | switch (res) { | 1112 | switch (res) { |
1113 | case 0: | 1113 | case 0: |
1114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", | 1114 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", |
1115 | "initialization successful"); | 1115 | "initialization successful"); |
1116 | break; | 1116 | break; |
1117 | case 1: | 1117 | case 1: |
1118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", | 1118 | LOG (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n", |
1119 | "environment is already initialized"); | 1119 | "environment is already initialized"); |
1120 | break; | 1120 | break; |
1121 | case 2: | 1121 | case 2: |
1122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", | 1122 | LOG (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", |
1123 | "initialization failed (insufficient memory)"); | 1123 | "initialization failed (insufficient memory)"); |
1124 | GNUNET_free(mlp); | 1124 | GNUNET_free(mlp); |
1125 | return NULL; | 1125 | return NULL; |
1126 | break; | 1126 | break; |
1127 | case 3: | 1127 | case 3: |
1128 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", | 1128 | LOG (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n", |
1129 | "initialization failed (unsupported programming model)"); | 1129 | "initialization failed (unsupported programming model)"); |
1130 | GNUNET_free(mlp); | 1130 | GNUNET_free(mlp); |
1131 | return NULL; | 1131 | return NULL; |
@@ -1136,54 +1136,57 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1136 | 1136 | ||
1137 | /* Create initial MLP problem */ | 1137 | /* Create initial MLP problem */ |
1138 | mlp->prob = glp_create_prob(); | 1138 | mlp->prob = glp_create_prob(); |
1139 | GNUNET_assert (mlp->prob != NULL); | 1139 | if (NULL == mlp->prob) |
1140 | { | ||
1141 | GNUNET_assert (mlp->prob != NULL); | ||
1142 | } | ||
1140 | 1143 | ||
1141 | mlp->BIG_M = (double) BIG_M_VALUE; | 1144 | mlp->BIG_M = (double) BIG_M_VALUE; |
1142 | 1145 | ||
1143 | /* Get timeout for iterations */ | 1146 | /* Get timeout for iterations */ |
1144 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time(cfg, "ats", "MAX_DURATION", &max_duration)) | 1147 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time(cfg, "ats", "MLP_MAX_DURATION", &max_duration)) |
1145 | { | 1148 | { |
1146 | max_duration = MLP_MAX_EXEC_DURATION; | 1149 | max_duration = MLP_MAX_EXEC_DURATION; |
1147 | } | 1150 | } |
1148 | 1151 | ||
1149 | /* Get maximum number of iterations */ | 1152 | /* Get maximum number of iterations */ |
1150 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_size(cfg, "ats", "MAX_ITERATIONS", &max_iterations)) | 1153 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_size(cfg, "ats", "MLP_MAX_ITERATIONS", &max_iterations)) |
1151 | { | 1154 | { |
1152 | max_iterations = MLP_MAX_ITERATIONS; | 1155 | max_iterations = MLP_MAX_ITERATIONS; |
1153 | } | 1156 | } |
1154 | 1157 | ||
1155 | /* Get diversity coefficient from configuration */ | 1158 | /* Get diversity coefficient from configuration */ |
1156 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1159 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1157 | "COEFFICIENT_D", | 1160 | "MLP_COEFFICIENT_D", |
1158 | &tmp)) | 1161 | &tmp)) |
1159 | D = (double) tmp / 100; | 1162 | D = (double) tmp / 100; |
1160 | else | 1163 | else |
1161 | D = 1.0; | 1164 | D = DEFAULT_D; |
1162 | 1165 | ||
1163 | /* Get proportionality coefficient from configuration */ | 1166 | /* Get proportionality coefficient from configuration */ |
1164 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1167 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1165 | "COEFFICIENT_R", | 1168 | "MLP_COEFFICIENT_R", |
1166 | &tmp)) | 1169 | &tmp)) |
1167 | R = (double) tmp / 100; | 1170 | R = (double) tmp / 100; |
1168 | else | 1171 | else |
1169 | R = 1.0; | 1172 | R = DEFAULT_R; |
1170 | 1173 | ||
1171 | /* Get utilization coefficient from configuration */ | 1174 | /* Get utilization coefficient from configuration */ |
1172 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1175 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1173 | "COEFFICIENT_U", | 1176 | "MLP_COEFFICIENT_U", |
1174 | &tmp)) | 1177 | &tmp)) |
1175 | U = (double) tmp / 100; | 1178 | U = (double) tmp / 100; |
1176 | else | 1179 | else |
1177 | U = 1.0; | 1180 | U = DEFAULT_U; |
1178 | 1181 | ||
1179 | /* Get quality metric coefficients from configuration */ | 1182 | /* Get quality metric coefficients from configuration */ |
1180 | int i_delay = -1; | 1183 | int i_delay = NaN; |
1181 | int i_distance = -1; | 1184 | int i_distance = NaN; |
1182 | int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties; | 1185 | int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties; |
1183 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | 1186 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) |
1184 | { | 1187 | { |
1185 | /* initialize quality coefficients with default value 1.0 */ | 1188 | /* initialize quality coefficients with default value 1.0 */ |
1186 | mlp->co_Q[c] = 1.0; | 1189 | mlp->co_Q[c] = DEFAULT_QUALITY; |
1187 | 1190 | ||
1188 | mlp->q[c] = q[c]; | 1191 | mlp->q[c] = q[c]; |
1189 | if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY) | 1192 | if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY) |
@@ -1192,24 +1195,24 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1192 | i_distance = c; | 1195 | i_distance = c; |
1193 | } | 1196 | } |
1194 | 1197 | ||
1195 | if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1198 | if ((i_delay != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1196 | "COEFFICIENT_QUALITY_DELAY", | 1199 | "MLP_COEFFICIENT_QUALITY_DELAY", |
1197 | &tmp))) | 1200 | &tmp))) |
1198 | 1201 | ||
1199 | mlp->co_Q[i_delay] = (double) tmp / 100; | 1202 | mlp->co_Q[i_delay] = (double) tmp / 100; |
1200 | else | 1203 | else |
1201 | mlp->co_Q[i_delay] = 1.0; | 1204 | mlp->co_Q[i_delay] = DEFAULT_QUALITY; |
1202 | 1205 | ||
1203 | if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1206 | if ((i_distance != NaN) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1204 | "COEFFICIENT_QUALITY_DISTANCE", | 1207 | "MLP_COEFFICIENT_QUALITY_DISTANCE", |
1205 | &tmp))) | 1208 | &tmp))) |
1206 | mlp->co_Q[i_distance] = (double) tmp / 100; | 1209 | mlp->co_Q[i_distance] = (double) tmp / 100; |
1207 | else | 1210 | else |
1208 | mlp->co_Q[i_distance] = 1.0; | 1211 | mlp->co_Q[i_distance] = DEFAULT_QUALITY; |
1209 | 1212 | ||
1210 | /* Get minimum bandwidth per used address from configuration */ | 1213 | /* Get minimum bandwidth per used address from configuration */ |
1211 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1214 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1212 | "MIN_BANDWIDTH", | 1215 | "MLP_MIN_BANDWIDTH", |
1213 | &tmp)) | 1216 | &tmp)) |
1214 | b_min = tmp; | 1217 | b_min = tmp; |
1215 | else | 1218 | else |
@@ -1219,103 +1222,78 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1219 | 1222 | ||
1220 | /* Get minimum number of connections from configuration */ | 1223 | /* Get minimum number of connections from configuration */ |
1221 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | 1224 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", |
1222 | "MIN_CONNECTIONS", | 1225 | "MLP_MIN_CONNECTIONS", |
1223 | &tmp)) | 1226 | &tmp)) |
1224 | n_min = tmp; | 1227 | n_min = tmp; |
1225 | else | 1228 | else |
1226 | n_min = 4; | 1229 | n_min = DEFAULT_MIN_CONNECTIONS; |
1227 | 1230 | ||
1228 | /* Init network quotas */ | 1231 | /* Init network quotas */ |
1229 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; | 1232 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; |
1230 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 1233 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
1231 | { | 1234 | { |
1232 | mlp->quota_index[c] = quotas[c]; | 1235 | found = GNUNET_NO; |
1233 | static char * entry_in = NULL; | 1236 | for (c2 = 0; c2 < dest_length; c2++) |
1234 | static char * entry_out = NULL; | 1237 | { |
1235 | unsigned long long quota_in = 0; | 1238 | if (quotas[c] == network[c2]) |
1236 | unsigned long long quota_out = 0; | 1239 | { |
1237 | 1240 | mlp->quota_index[c] = network[c2]; | |
1238 | switch (quotas[c]) { | 1241 | mlp->quota_out[c] = out_dest[c2]; |
1239 | case GNUNET_ATS_NET_UNSPECIFIED: | 1242 | mlp->quota_in[c] = in_dest[c2]; |
1240 | entry_out = "UNSPECIFIED_QUOTA_OUT"; | 1243 | found = GNUNET_YES; |
1241 | entry_in = "UNSPECIFIED_QUOTA_IN"; | 1244 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Quota for network `%s' (in/out) %llu/%llu\n", |
1242 | break; | 1245 | GNUNET_ATS_print_network_type(mlp->quota_index[c]), |
1243 | case GNUNET_ATS_NET_LOOPBACK: | 1246 | mlp->quota_out[c], |
1244 | entry_out = "LOOPBACK_QUOTA_OUT"; | 1247 | mlp->quota_in[c]); |
1245 | entry_in = "LOOPBACK_QUOTA_IN"; | 1248 | break; |
1246 | break; | 1249 | } |
1247 | case GNUNET_ATS_NET_LAN: | 1250 | } |
1248 | entry_out = "LAN_QUOTA_OUT"; | 1251 | |
1249 | entry_in = "LAN_QUOTA_IN"; | 1252 | /* Check if defined quota could make problem unsolvable */ |
1250 | break; | 1253 | if ((n_min * b_min) > mlp->quota_out[c]) |
1251 | case GNUNET_ATS_NET_WAN: | 1254 | { |
1252 | entry_out = "WAN_QUOTA_OUT"; | 1255 | LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent outbound quota configuration for network `%s', is %llu must be at least %llu\n"), |
1253 | entry_in = "WAN_QUOTA_IN"; | 1256 | GNUNET_ATS_print_network_type(mlp->quota_index[c]), |
1254 | break; | 1257 | mlp->quota_out[c], |
1255 | case GNUNET_ATS_NET_WLAN: | 1258 | (n_min * b_min)); |
1256 | entry_out = "WLAN_QUOTA_OUT"; | 1259 | mlp->quota_out[c] = (n_min * b_min); |
1257 | entry_in = "WLAN_QUOTA_IN"; | 1260 | } |
1258 | break; | 1261 | if ((n_min * b_min) > mlp->quota_in[c]) |
1259 | default: | 1262 | { |
1260 | break; | 1263 | LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inconsistent inbound quota configuration for network `%s', is %llu must be at least %llu\n"), |
1261 | } | 1264 | GNUNET_ATS_print_network_type(mlp->quota_index[c]), |
1262 | 1265 | mlp->quota_in[c], | |
1263 | if ((entry_in == NULL) || (entry_out == NULL)) | 1266 | (n_min * b_min)); |
1264 | continue; | 1267 | mlp->quota_in[c] = (n_min * b_min); |
1265 | 1268 | } | |
1266 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_out, "a_out_str)) | ||
1267 | { | ||
1268 | if (0 == strcmp(quota_out_str, BIG_M_STRING) || | ||
1269 | (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str, "a_out))) | ||
1270 | quota_out = mlp->BIG_M; | ||
1271 | |||
1272 | GNUNET_free (quota_out_str); | ||
1273 | quota_out_str = NULL; | ||
1274 | } | ||
1275 | else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) | ||
1276 | { | ||
1277 | quota_out = mlp->BIG_M; | ||
1278 | } | ||
1279 | else | ||
1280 | { | ||
1281 | quota_out = mlp->BIG_M; | ||
1282 | } | ||
1283 | |||
1284 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats", entry_in, "a_in_str)) | ||
1285 | { | ||
1286 | if (0 == strcmp(quota_in_str, BIG_M_STRING) || | ||
1287 | (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str, "a_in))) | ||
1288 | quota_in = mlp->BIG_M; | ||
1289 | |||
1290 | GNUNET_free (quota_in_str); | ||
1291 | quota_in_str = NULL; | ||
1292 | } | ||
1293 | else if (GNUNET_ATS_NET_UNSPECIFIED == quotas[c]) | ||
1294 | { | ||
1295 | quota_in = mlp->BIG_M; | ||
1296 | } | ||
1297 | else | ||
1298 | { | ||
1299 | quota_in = mlp->BIG_M; | ||
1300 | } | ||
1301 | |||
1302 | /* Check if defined quota could make problem unsolvable */ | ||
1303 | if (((n_min * b_min) > quota_out) && (GNUNET_ATS_NET_UNSPECIFIED != quotas[c])) | ||
1304 | { | ||
1305 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " | ||
1306 | "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); | ||
1307 | 1269 | ||
1308 | GAS_mlp_done(mlp); | 1270 | /* Check if bandwidth is too big to make problem solvable */ |
1309 | mlp = NULL; | 1271 | if (mlp->BIG_M < mlp->quota_out[c]) |
1310 | return NULL; | 1272 | { |
1311 | } | 1273 | LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting outbound quota configuration for network `%s'from %llu to %.0f\n"), |
1274 | GNUNET_ATS_print_network_type(mlp->quota_index[c]), | ||
1275 | mlp->quota_out[c], | ||
1276 | mlp->BIG_M); | ||
1277 | mlp->quota_out[c] = mlp->BIG_M; | ||
1278 | } | ||
1279 | if (mlp->BIG_M < mlp->quota_in[c]) | ||
1280 | { | ||
1281 | LOG (GNUNET_ERROR_TYPE_INFO, _("Adjusting inbound quota configuration for network `%s' from %llu to %.0f\n"), | ||
1282 | GNUNET_ATS_print_network_type(mlp->quota_index[c]), | ||
1283 | mlp->quota_in[c], | ||
1284 | mlp->BIG_M); | ||
1285 | mlp->quota_in[c] = mlp->BIG_M; | ||
1286 | } | ||
1312 | 1287 | ||
1313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n", | 1288 | if (GNUNET_NO == found) |
1314 | entry_out, quota_out, entry_in, quota_in); | 1289 | { |
1315 | GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_out, quota_out, GNUNET_NO); | 1290 | mlp->quota_in[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); |
1316 | GNUNET_STATISTICS_update ((struct GNUNET_STATISTICS_Handle *) stats, entry_in, quota_in, GNUNET_NO); | 1291 | mlp->quota_out[c] = ntohl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); |
1317 | mlp->quota_out[c] = quota_out; | 1292 | LOG (GNUNET_ERROR_TYPE_INFO, _("Using default quota configuration for network `%s' (in/out) %llu/%llu\n"), |
1318 | mlp->quota_in[c] = quota_in; | 1293 | GNUNET_ATS_print_network_type(mlp->quota_index[c]), |
1294 | mlp->quota_in[c], | ||
1295 | mlp->quota_out[c]); | ||
1296 | } | ||
1319 | } | 1297 | } |
1320 | 1298 | ||
1321 | /* Get minimum number of connections from configuration */ | 1299 | /* Get minimum number of connections from configuration */ |
@@ -1326,6 +1304,8 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1326 | else | 1304 | else |
1327 | mlp->exec_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30); | 1305 | mlp->exec_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30); |
1328 | 1306 | ||
1307 | |||
1308 | /* Assign options to handle */ | ||
1329 | mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats; | 1309 | mlp->stats = (struct GNUNET_STATISTICS_Handle *) stats; |
1330 | mlp->max_iterations = max_iterations; | 1310 | mlp->max_iterations = max_iterations; |
1331 | mlp->max_exec_duration = max_duration; | 1311 | mlp->max_exec_duration = max_duration; |
@@ -1363,6 +1343,9 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1363 | mlp->n_min = n_min; | 1343 | mlp->n_min = n_min; |
1364 | mlp->m_q = GNUNET_ATS_QualityPropertiesCount; | 1344 | mlp->m_q = GNUNET_ATS_QualityPropertiesCount; |
1365 | mlp->semaphore = GNUNET_NO; | 1345 | mlp->semaphore = GNUNET_NO; |
1346 | |||
1347 | LOG (GNUNET_ERROR_TYPE_DEBUG, "solver ready\n"); | ||
1348 | |||
1366 | return mlp; | 1349 | return mlp; |
1367 | } | 1350 | } |
1368 | 1351 | ||
@@ -1538,7 +1521,7 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) | |||
1538 | void | 1521 | void |
1539 | GAS_mlp_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) | 1522 | GAS_mlp_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) |
1540 | { | 1523 | { |
1541 | 1524 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding address for peer `%s'\n", GNUNET_i2s(&address->peer)); | |
1542 | } | 1525 | } |
1543 | 1526 | ||
1544 | /** | 1527 | /** |
@@ -1572,6 +1555,8 @@ GAS_mlp_address_update (void *solver, | |||
1572 | struct MLP_information *mlpi; | 1555 | struct MLP_information *mlpi; |
1573 | struct GAS_MLP_SolutionContext ctx; | 1556 | struct GAS_MLP_SolutionContext ctx; |
1574 | 1557 | ||
1558 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Updating address for peer `%s'\n", GNUNET_i2s(&address->peer)); | ||
1559 | |||
1575 | GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO); | 1560 | GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO); |
1576 | 1561 | ||
1577 | /* We add a new address */ | 1562 | /* We add a new address */ |
@@ -1676,6 +1661,8 @@ GAS_mlp_address_delete (void *solver, | |||
1676 | int session_only) | 1661 | int session_only) |
1677 | { | 1662 | { |
1678 | struct GAS_MLP_Handle *mlp = solver; | 1663 | struct GAS_MLP_Handle *mlp = solver; |
1664 | |||
1665 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Deleting address for peer `%s'\n", GNUNET_i2s(&address->peer)); | ||
1679 | GNUNET_STATISTICS_update (mlp->stats,"# LP address deletions", 1, GNUNET_NO); | 1666 | GNUNET_STATISTICS_update (mlp->stats,"# LP address deletions", 1, GNUNET_NO); |
1680 | struct GAS_MLP_SolutionContext ctx; | 1667 | struct GAS_MLP_SolutionContext ctx; |
1681 | 1668 | ||
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index a49f585ed..f2ec79487 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h | |||
@@ -40,7 +40,15 @@ | |||
40 | #define MLP_AVERAGING_QUEUE_LENGTH 3 | 40 | #define MLP_AVERAGING_QUEUE_LENGTH 3 |
41 | 41 | ||
42 | #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) | 42 | #define MLP_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3) |
43 | #define MLP_MAX_ITERATIONS INT_MAX | 43 | #define MLP_MAX_ITERATIONS 1024 |
44 | |||
45 | #define DEFAULT_D 1.0 | ||
46 | #define DEFAULT_R 1.0 | ||
47 | #define DEFAULT_U 1.0 | ||
48 | #define DEFAULT_QUALITY 1.0 | ||
49 | #define DEFAULT_MIN_CONNECTIONS 4 | ||
50 | |||
51 | #define NaN -1 | ||
44 | 52 | ||
45 | struct ATS_Peer | 53 | struct ATS_Peer |
46 | { | 54 | { |
diff --git a/src/ats/test_ats_api_common.h b/src/ats/test_ats_api_common.h index 1f9bd10c1..223d0c038 100644 --- a/src/ats/test_ats_api_common.h +++ b/src/ats/test_ats_api_common.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "gnunet_ats_service.h" | 29 | #include "gnunet_ats_service.h" |
30 | #include "gnunet-service-ats_addresses.h" | 30 | #include "gnunet-service-ats_addresses.h" |
31 | 31 | ||
32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
33 | 33 | ||
34 | #define PEERID0 "2AK99KD8RM9UA9LC3QKA0IQ5UBFC0FBB50EBGCFQT8448DGGACNAC4CJQDD1CPFS494O41U88DJD1FLIG8VA5CQR9IN4L96GP104MVO" | 34 | #define PEERID0 "2AK99KD8RM9UA9LC3QKA0IQ5UBFC0FBB50EBGCFQT8448DGGACNAC4CJQDD1CPFS494O41U88DJD1FLIG8VA5CQR9IN4L96GP104MVO" |
35 | #define PEERID1 "5ED7I0AR3MSTAL7FQN04S22E0EQ3CR9RLASCDLVMM1BNFPUPTCT46DLKNJ4DACASJ6U0DR5J8S3R2UJL49682JS7MOVRAB8P8A4PJH0" | 35 | #define PEERID1 "5ED7I0AR3MSTAL7FQN04S22E0EQ3CR9RLASCDLVMM1BNFPUPTCT46DLKNJ4DACASJ6U0DR5J8S3R2UJL49682JS7MOVRAB8P8A4PJH0" |
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c index b2cbb36b2..ed315bf90 100644 --- a/src/ats/test_ats_mlp.c +++ b/src/ats/test_ats_mlp.c | |||
@@ -134,6 +134,7 @@ static void | |||
134 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 134 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
135 | { | 135 | { |
136 | timeout_task = GNUNET_SCHEDULER_NO_TASK; | 136 | timeout_task = GNUNET_SCHEDULER_NO_TASK; |
137 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test failed: timeout\n")); | ||
137 | end_now (1); | 138 | end_now (1); |
138 | } | 139 | } |
139 | 140 | ||
@@ -205,108 +206,8 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
205 | /* Adding address */ | 206 | /* Adding address */ |
206 | GAS_mlp_address_add (mlp, addresses, address); | 207 | GAS_mlp_address_add (mlp, addresses, address); |
207 | 208 | ||
209 | /* Retrieving preferred address for peer and wait for callback */ | ||
208 | GAS_mlp_get_preferred_address (mlp, addresses, &p); | 210 | GAS_mlp_get_preferred_address (mlp, addresses, &p); |
209 | |||
210 | |||
211 | #if 0 | ||
212 | struct ATS_Address addr[10]; | ||
213 | struct ATS_Address *res[10]; | ||
214 | struct GAS_MLP_SolutionContext ctx; | ||
215 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; | ||
216 | unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; | ||
217 | unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; | ||
218 | int quota_count; | ||
219 | |||
220 | |||
221 | |||
222 | |||
223 | |||
224 | quota_count = load_quotas(cfg, quotas_in, quotas_out, GNUNET_ATS_NetworkTypeCount); | ||
225 | mlp = GAS_mlp_init (cfg, NULL, quotas, quotas_in, quotas_out, quota_count); | ||
226 | mlp->auto_solve = GNUNET_NO; | ||
227 | |||
228 | struct GNUNET_PeerIdentity p[10]; | ||
229 | |||
230 | /* Creating peer 1 */ | ||
231 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[0].hashPubKey); | ||
232 | /* Creating peer 2 */ | ||
233 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[1].hashPubKey); | ||
234 | |||
235 | /* Creating peer 1 address 1 */ | ||
236 | addr[0].peer.hashPubKey = p[0].hashPubKey; | ||
237 | struct GNUNET_ATS_Information a1_ats[3]; | ||
238 | set_ats (&a1_ats[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); | ||
239 | set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 1); | ||
240 | set_ats (&a1_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); | ||
241 | create_address (&addr[0], "dummy", 3, &a1_ats[0]); | ||
242 | addr[0].atsp_network_type = GNUNET_ATS_NET_WAN; | ||
243 | |||
244 | /* Creating peer 1 address 2 */ | ||
245 | addr[1].peer.hashPubKey = p[0].hashPubKey; | ||
246 | struct GNUNET_ATS_Information a2_ats[3]; | ||
247 | set_ats (&a2_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); | ||
248 | set_ats (&a2_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 1); | ||
249 | set_ats (&a2_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); | ||
250 | create_address (&addr[1], "dummy2", 3, &a2_ats[0]); | ||
251 | addr[1].atsp_network_type = GNUNET_ATS_NET_LAN; | ||
252 | |||
253 | /* Creating peer 2 address 1 */ | ||
254 | addr[2].peer.hashPubKey = p[1].hashPubKey; | ||
255 | struct GNUNET_ATS_Information a3_ats[3]; | ||
256 | set_ats (&a3_ats[1], GNUNET_ATS_QUALITY_NET_DISTANCE, 1); | ||
257 | set_ats (&a3_ats[0], GNUNET_ATS_QUALITY_NET_DELAY, 1); | ||
258 | set_ats (&a3_ats[2], GNUNET_ATS_ARRAY_TERMINATOR, 0); | ||
259 | create_address (&addr[2], "dummy3", 3, &a3_ats[0]); | ||
260 | addr[2].atsp_network_type = GNUNET_ATS_NET_LAN; | ||
261 | |||
262 | GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[0], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
263 | |||
264 | /* Add peer 1 address 1 */ | ||
265 | GAS_mlp_address_update (mlp, addresses, &addr[0]); | ||
266 | |||
267 | GNUNET_assert (mlp != NULL); | ||
268 | GNUNET_assert (mlp->addr_in_problem == 1); | ||
269 | |||
270 | /* Update an peer 1 address 1 */ | ||
271 | set_ats (&a1_ats[1], GNUNET_ATS_QUALITY_NET_DELAY, 1); | ||
272 | GAS_mlp_address_update (mlp, addresses, &addr[0]); | ||
273 | GNUNET_assert (mlp->addr_in_problem == 1); | ||
274 | |||
275 | /* Add peer 1 address 2 */ | ||
276 | GNUNET_CONTAINER_multihashmap_put(addresses, &addr[0].peer.hashPubKey, &addr[1], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
277 | GAS_mlp_address_update (mlp, addresses, &addr[1]); | ||
278 | GNUNET_assert (mlp->addr_in_problem == 2); | ||
279 | |||
280 | /* Add peer 2 address 1 */ | ||
281 | GNUNET_CONTAINER_multihashmap_put(addresses, &addr[2].peer.hashPubKey, &addr[2], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
282 | GAS_mlp_address_update (mlp, addresses, &addr[2]); | ||
283 | GNUNET_assert (mlp->addr_in_problem == 3); | ||
284 | |||
285 | GNUNET_assert (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx)); | ||
286 | GNUNET_assert (GNUNET_OK == ctx.lp_result); | ||
287 | GNUNET_assert (GNUNET_OK == ctx.mlp_result); | ||
288 | |||
289 | res[0] = GAS_mlp_get_preferred_address(mlp, addresses, &p[0]); | ||
290 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[0]->plugin, res[0]->assigned_bw_out); | ||
291 | res[1] = GAS_mlp_get_preferred_address(mlp, addresses, &p[1]); | ||
292 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preferred address `%s' outbound bandwidth: %u Bps\n",res[1]->plugin, res[1]->assigned_bw_out); | ||
293 | |||
294 | /* Delete an address */ | ||
295 | GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[0].peer.hashPubKey, &addr[0]); | ||
296 | GAS_mlp_address_delete (mlp, addresses, &addr[0]); | ||
297 | GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[1].peer.hashPubKey, &addr[1]); | ||
298 | GAS_mlp_address_delete (mlp, addresses, &addr[1]); | ||
299 | GNUNET_CONTAINER_multihashmap_remove (addresses, &addr[2].peer.hashPubKey, &addr[2]); | ||
300 | GAS_mlp_address_delete (mlp, addresses, &addr[2]); | ||
301 | |||
302 | GNUNET_assert (mlp->addr_in_problem == 0); | ||
303 | |||
304 | GNUNET_free (addr[0].plugin); | ||
305 | GNUNET_free (addr[1].plugin); | ||
306 | #endif | ||
307 | |||
308 | ret = 0; | ||
309 | return; | ||
310 | } | 211 | } |
311 | 212 | ||
312 | 213 | ||