diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-20 17:39:01 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-20 17:39:01 +0000 |
commit | b67d58d180d846fd25dc1e7133345af05317db61 (patch) | |
tree | e416348e6e6ff939f07bc0180dc12f028dfcabfa /src/ats | |
parent | 41433c728b2256e10849596ff093132d0f319a00 (diff) | |
download | gnunet-b67d58d180d846fd25dc1e7133345af05317db61.tar.gz gnunet-b67d58d180d846fd25dc1e7133345af05317db61.zip |
- changes
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 133 |
1 files changed, 81 insertions, 52 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index 57033f07b..e365151ce 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -350,6 +350,7 @@ create_constraint_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
350 | /* c 10) obey network specific quotas | 350 | /* c 10) obey network specific quotas |
351 | * (1)*b_1 + ... + (1)*b_m <= quota_n | 351 | * (1)*b_1 + ... + (1)*b_m <= quota_n |
352 | */ | 352 | */ |
353 | |||
353 | int cur_row = 0; | 354 | int cur_row = 0; |
354 | int c; | 355 | int c; |
355 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 356 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
@@ -525,8 +526,12 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON | |||
525 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 526 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
526 | { | 527 | { |
527 | mlp->r_quota[c] = glp_add_rows (mlp->prob, 1); | 528 | mlp->r_quota[c] = glp_add_rows (mlp->prob, 1); |
529 | char * text; | ||
530 | GNUNET_asprintf(&text, "quota_ats_%i", mlp->quota_index[c]); | ||
531 | glp_set_row_name (mlp->prob, mlp->r_quota[c], text); | ||
532 | GNUNET_free (text); | ||
528 | /* Set bounds to 0 <= x <= quota_out */ | 533 | /* Set bounds to 0 <= x <= quota_out */ |
529 | glp_set_row_bnds (mlp->prob, mlp->r_quota[c], GLP_DB, 0.0, mlp->quota_out[c]); | 534 | glp_set_row_bnds (mlp->prob, mlp->r_quota[c], GLP_UP, 0.0, mlp->quota_out[c]); |
530 | } | 535 | } |
531 | 536 | ||
532 | GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp); | 537 | GNUNET_CONTAINER_multihashmap_iterate (addresses, create_constraint_it, mlp); |
@@ -551,6 +556,7 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON | |||
551 | /* Set row bound == 0 */ | 556 | /* Set row bound == 0 */ |
552 | glp_set_row_bnds (mlp->prob, mlp->r_c8, GLP_FX, 0.0, 0.0); | 557 | glp_set_row_bnds (mlp->prob, mlp->r_c8, GLP_FX, 0.0, 0.0); |
553 | /* -u */ | 558 | /* -u */ |
559 | |||
554 | ia[mlp->ci] = mlp->r_c8; | 560 | ia[mlp->ci] = mlp->r_c8; |
555 | ja[mlp->ci] = mlp->c_u; | 561 | ja[mlp->ci] = mlp->c_u; |
556 | ar[mlp->ci] = -1; | 562 | ar[mlp->ci] = -1; |
@@ -584,11 +590,14 @@ mlp_add_constraints_all_addresses (struct GAS_MLP_Handle *mlp, struct GNUNET_CON | |||
584 | ar[mlp->ci] = -1; | 590 | ar[mlp->ci] = -1; |
585 | mlp->ci++; | 591 | mlp->ci++; |
586 | 592 | ||
593 | |||
594 | |||
587 | while (addr != NULL) | 595 | while (addr != NULL) |
588 | { | 596 | { |
589 | mlpi = (struct MLP_information *) addr->mlp_information; | 597 | mlpi = (struct MLP_information *) addr->mlp_information; |
590 | 598 | ||
591 | /* coefficient for c 2) */ | 599 | /* coefficient for c 2) */ |
600 | |||
592 | ia[mlp->ci] = peer->r_c2; | 601 | ia[mlp->ci] = peer->r_c2; |
593 | ja[mlp->ci] = mlpi->c_n; | 602 | ja[mlp->ci] = mlpi->c_n; |
594 | ar[mlp->ci] = 1; | 603 | ar[mlp->ci] = 1; |
@@ -695,6 +704,7 @@ create_columns_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
695 | mlpi->c_b = col; | 704 | mlpi->c_b = col; |
696 | mlpi->c_n = col + 1; | 705 | mlpi->c_n = col + 1; |
697 | 706 | ||
707 | |||
698 | GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin); | 708 | GNUNET_asprintf (&name, "b_%s_%s", GNUNET_i2s (&address->peer), address->plugin); |
699 | glp_set_col_name (mlp->prob, mlpi->c_b , name); | 709 | glp_set_col_name (mlp->prob, mlpi->c_b , name); |
700 | GNUNET_free (name); | 710 | GNUNET_free (name); |
@@ -1112,6 +1122,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1112 | unsigned int b_min; | 1122 | unsigned int b_min; |
1113 | unsigned int n_min; | 1123 | unsigned int n_min; |
1114 | struct GNUNET_TIME_Relative i_exec; | 1124 | struct GNUNET_TIME_Relative i_exec; |
1125 | int c; | ||
1115 | 1126 | ||
1116 | /* Init GLPK environment */ | 1127 | /* Init GLPK environment */ |
1117 | GNUNET_assert (glp_init_env() == 0); | 1128 | GNUNET_assert (glp_init_env() == 0); |
@@ -1144,10 +1155,57 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1144 | else | 1155 | else |
1145 | U = 1.0; | 1156 | U = 1.0; |
1146 | 1157 | ||
1158 | /* Get quality metric coefficients from configuration */ | ||
1159 | int i_delay = -1; | ||
1160 | int i_distance = -1; | ||
1161 | int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties; | ||
1162 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | ||
1163 | { | ||
1164 | /* initialize quality coefficients with default value 1.0 */ | ||
1165 | mlp->co_Q[c] = 1.0; | ||
1166 | |||
1167 | mlp->q[c] = q[c]; | ||
1168 | if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY) | ||
1169 | i_delay = c; | ||
1170 | if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE) | ||
1171 | i_distance = c; | ||
1172 | } | ||
1173 | |||
1174 | if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1175 | "COEFFICIENT_QUALITY_DELAY", | ||
1176 | &tmp))) | ||
1177 | |||
1178 | mlp->co_Q[i_delay] = (double) tmp / 100; | ||
1179 | else | ||
1180 | mlp->co_Q[i_delay] = 1.0; | ||
1181 | |||
1182 | if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1183 | "COEFFICIENT_QUALITY_DISTANCE", | ||
1184 | &tmp))) | ||
1185 | mlp->co_Q[i_distance] = (double) tmp / 100; | ||
1186 | else | ||
1187 | mlp->co_Q[i_distance] = 1.0; | ||
1188 | |||
1189 | /* Get minimum bandwidth per used address from configuration */ | ||
1190 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1191 | "MIN_BANDWIDTH", | ||
1192 | &tmp)) | ||
1193 | b_min = tmp; | ||
1194 | else | ||
1195 | { | ||
1196 | b_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); | ||
1197 | } | ||
1198 | |||
1199 | /* Get minimum number of connections from configuration */ | ||
1200 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1201 | "MIN_CONNECTIONS", | ||
1202 | &tmp)) | ||
1203 | n_min = tmp; | ||
1204 | else | ||
1205 | n_min = 4; | ||
1206 | |||
1147 | /* Init network quotas */ | 1207 | /* Init network quotas */ |
1148 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; | 1208 | int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType; |
1149 | int c; | ||
1150 | |||
1151 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) | 1209 | for (c = 0; c < GNUNET_ATS_NetworkTypeCount; c++) |
1152 | { | 1210 | { |
1153 | mlp->quota_index[c] = quotas[c]; | 1211 | mlp->quota_index[c] = quotas[c]; |
@@ -1192,6 +1250,26 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1192 | { | 1250 | { |
1193 | quota_in = UINT32_MAX; | 1251 | quota_in = UINT32_MAX; |
1194 | } | 1252 | } |
1253 | /* Check if defined quota could make problem unsolvable */ | ||
1254 | if ((n_min * b_min) > quota_out) | ||
1255 | { | ||
1256 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Inconsistent quota configuration value `%s': " \ | ||
1257 | "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); | ||
1258 | unsigned int default_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); | ||
1259 | if ((quota_out / n_min) > default_min) | ||
1260 | { | ||
1261 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Reducing minimum bandwidth per peer to %u Bps\n", | ||
1262 | (quota_out / n_min)); | ||
1263 | b_min = (quota_out / n_min); | ||
1264 | } | ||
1265 | else | ||
1266 | { | ||
1267 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Reducing minimum bandwidth per peer to %u Bps and minimum connections to %u \n", | ||
1268 | default_min, (quota_out / default_min)); | ||
1269 | b_min = default_min; | ||
1270 | n_min = (quota_out / default_min); | ||
1271 | } | ||
1272 | } | ||
1195 | 1273 | ||
1196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n", | 1274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found `%s' quota %llu and `%s' quota %llu\n", |
1197 | entry_out, quota_out, entry_in, quota_in); | 1275 | entry_out, quota_out, entry_in, quota_in); |
@@ -1199,55 +1277,6 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1199 | mlp->quota_in[c] = quota_in; | 1277 | mlp->quota_in[c] = quota_in; |
1200 | } | 1278 | } |
1201 | 1279 | ||
1202 | /* Get quality metric coefficients from configuration */ | ||
1203 | int i_delay = -1; | ||
1204 | int i_distance = -1; | ||
1205 | int q[GNUNET_ATS_QualityPropertiesCount] = GNUNET_ATS_QualityProperties; | ||
1206 | for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++) | ||
1207 | { | ||
1208 | /* initialize quality coefficients with default value 1.0 */ | ||
1209 | mlp->co_Q[c] = 1.0; | ||
1210 | |||
1211 | mlp->q[c] = q[c]; | ||
1212 | if (q[c] == GNUNET_ATS_QUALITY_NET_DELAY) | ||
1213 | i_delay = c; | ||
1214 | if (q[c] == GNUNET_ATS_QUALITY_NET_DISTANCE) | ||
1215 | i_distance = c; | ||
1216 | } | ||
1217 | |||
1218 | if ((i_delay != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1219 | "COEFFICIENT_QUALITY_DELAY", | ||
1220 | &tmp))) | ||
1221 | |||
1222 | mlp->co_Q[i_delay] = (double) tmp / 100; | ||
1223 | else | ||
1224 | mlp->co_Q[i_delay] = 1.0; | ||
1225 | |||
1226 | if ((i_distance != -1) && (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1227 | "COEFFICIENT_QUALITY_DISTANCE", | ||
1228 | &tmp))) | ||
1229 | mlp->co_Q[i_distance] = (double) tmp / 100; | ||
1230 | else | ||
1231 | mlp->co_Q[i_distance] = 1.0; | ||
1232 | |||
1233 | /* Get minimum bandwidth per used address from configuration */ | ||
1234 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1235 | "MIN_BANDWIDTH", | ||
1236 | &tmp)) | ||
1237 | b_min = tmp; | ||
1238 | else | ||
1239 | { | ||
1240 | b_min = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); | ||
1241 | } | ||
1242 | |||
1243 | /* Get minimum number of connections from configuration */ | ||
1244 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_size (cfg, "ats", | ||
1245 | "MIN_CONNECTIONS", | ||
1246 | &tmp)) | ||
1247 | n_min = tmp; | ||
1248 | else | ||
1249 | n_min = 4; | ||
1250 | |||
1251 | /* Get minimum number of connections from configuration */ | 1280 | /* Get minimum number of connections from configuration */ |
1252 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (cfg, "ats", | 1281 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (cfg, "ats", |
1253 | "ATS_EXEC_INTERVAL", | 1282 | "ATS_EXEC_INTERVAL", |