diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-05-12 11:48:57 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-05-12 11:48:57 +0000 |
commit | 0a5ba38fd207877aa65e02f3a0caa9b1a66fbca7 (patch) | |
tree | 54ba5fd423ccfed03f1ed6863069860051059c16 | |
parent | 5d7cfb058ce600b97b1e65269d3da89793e8bb4d (diff) | |
download | gnunet-0a5ba38fd207877aa65e02f3a0caa9b1a66fbca7.tar.gz gnunet-0a5ba38fd207877aa65e02f3a0caa9b1a66fbca7.zip |
bug fixed
-rw-r--r-- | src/transport/gnunet-service-transport.c | 236 |
1 files changed, 148 insertions, 88 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index d93cf6568..3312857ad 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -890,6 +890,29 @@ struct ATS_stat | |||
890 | int solution; | 890 | int solution; |
891 | 891 | ||
892 | /** | 892 | /** |
893 | * Ressource costs or quality metrics changed | ||
894 | * update problem before solving | ||
895 | */ | ||
896 | int modified_resources; | ||
897 | |||
898 | /** | ||
899 | * Ressource costs or quality metrics changed, update matrix | ||
900 | * update problem before solving | ||
901 | */ | ||
902 | int modified_quality; | ||
903 | |||
904 | /** | ||
905 | * Peers have connected or disconnected | ||
906 | * problem has to be recreated | ||
907 | */ | ||
908 | int recreate_problem; | ||
909 | |||
910 | /** | ||
911 | * Was the available basis invalid and we needed to rerun simplex? | ||
912 | */ | ||
913 | int simplex_rerun_required; | ||
914 | |||
915 | /** | ||
893 | * is problem currently valid and can it be solved | 916 | * is problem currently valid and can it be solved |
894 | */ | 917 | */ |
895 | int valid; | 918 | int valid; |
@@ -924,10 +947,29 @@ struct ATS_stat | |||
924 | */ | 947 | */ |
925 | int end_cr; | 948 | int end_cr; |
926 | 949 | ||
950 | /** | ||
951 | * column index for objective function value d | ||
952 | */ | ||
927 | int col_d; | 953 | int col_d; |
954 | |||
955 | /** | ||
956 | * column index for objective function value u | ||
957 | */ | ||
928 | int col_u; | 958 | int col_u; |
959 | |||
960 | /** | ||
961 | * column index for objective function value r | ||
962 | */ | ||
929 | int col_r; | 963 | int col_r; |
964 | |||
965 | /** | ||
966 | * column index for objective function value quality metrics | ||
967 | */ | ||
930 | int col_qm; | 968 | int col_qm; |
969 | |||
970 | /** | ||
971 | * column index for objective function value cost ressources | ||
972 | */ | ||
931 | int col_cr; | 973 | int col_cr; |
932 | }; | 974 | }; |
933 | 975 | ||
@@ -1031,8 +1073,14 @@ struct ATS_info | |||
1031 | */ | 1073 | */ |
1032 | struct ATS_peer * peers; | 1074 | struct ATS_peer * peers; |
1033 | 1075 | ||
1076 | /** | ||
1077 | * number of successful executions | ||
1078 | */ | ||
1034 | int successful_executions; | 1079 | int successful_executions; |
1035 | 1080 | ||
1081 | /** | ||
1082 | * number with an invalid result | ||
1083 | */ | ||
1036 | int invalid_executions; | 1084 | int invalid_executions; |
1037 | 1085 | ||
1038 | /** | 1086 | /** |
@@ -1066,29 +1114,6 @@ struct ATS_info | |||
1066 | int dump_overwrite; | 1114 | int dump_overwrite; |
1067 | 1115 | ||
1068 | /** | 1116 | /** |
1069 | * Ressource costs or quality metrics changed | ||
1070 | * update problem before solving | ||
1071 | */ | ||
1072 | int modified_resources; | ||
1073 | |||
1074 | /** | ||
1075 | * Ressource costs or quality metrics changed, update matrix | ||
1076 | * update problem before solving | ||
1077 | */ | ||
1078 | int modified_quality; | ||
1079 | |||
1080 | /** | ||
1081 | * Peers have connected or disconnected | ||
1082 | * problem has to be recreated | ||
1083 | */ | ||
1084 | int modified_addr; | ||
1085 | |||
1086 | /** | ||
1087 | * Was the available basis invalid and we needed to rerun simplex? | ||
1088 | */ | ||
1089 | int simplex_rerun_required; | ||
1090 | |||
1091 | /** | ||
1092 | * Diversity weight | 1117 | * Diversity weight |
1093 | */ | 1118 | */ |
1094 | double D; | 1119 | double D; |
@@ -1279,7 +1304,7 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i | |||
1279 | fal->quality[c].values[1] = fal->quality[c].values[2]; | 1304 | fal->quality[c].values[1] = fal->quality[c].values[2]; |
1280 | fal->quality[c].values[2] = value; | 1305 | fal->quality[c].values[2] = value; |
1281 | set = GNUNET_YES; | 1306 | set = GNUNET_YES; |
1282 | ats->modified_quality = GNUNET_YES; | 1307 | ats->stat.modified_quality = GNUNET_YES; |
1283 | } | 1308 | } |
1284 | } | 1309 | } |
1285 | if (set == GNUNET_NO) | 1310 | if (set == GNUNET_NO) |
@@ -1290,7 +1315,7 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i | |||
1290 | { | 1315 | { |
1291 | fal->ressources[c].c = value; | 1316 | fal->ressources[c].c = value; |
1292 | set = GNUNET_YES; | 1317 | set = GNUNET_YES; |
1293 | ats->modified_resources = GNUNET_YES; | 1318 | ats->stat.modified_resources = GNUNET_YES; |
1294 | } | 1319 | } |
1295 | } | 1320 | } |
1296 | } | 1321 | } |
@@ -2531,7 +2556,7 @@ plugin_env_session_end (void *cls, | |||
2531 | GNUNET_free_non_null(pos->ressources); | 2556 | GNUNET_free_non_null(pos->ressources); |
2532 | GNUNET_free_non_null(pos->quality); | 2557 | GNUNET_free_non_null(pos->quality); |
2533 | GNUNET_free (pos); | 2558 | GNUNET_free (pos); |
2534 | ats->modified_addr = GNUNET_YES; | 2559 | ats->stat.recreate_problem = GNUNET_YES; |
2535 | if (nl->received_pong == GNUNET_NO) | 2560 | if (nl->received_pong == GNUNET_NO) |
2536 | return; /* nothing to do, never connected... */ | 2561 | return; /* nothing to do, never connected... */ |
2537 | /* check if we have any validated addresses left */ | 2562 | /* check if we have any validated addresses left */ |
@@ -4853,6 +4878,7 @@ disconnect_neighbour (struct NeighbourList *n, int check) | |||
4853 | GNUNET_free(peer_pos->quality); | 4878 | GNUNET_free(peer_pos->quality); |
4854 | peer_pos->ressources = NULL; | 4879 | peer_pos->ressources = NULL; |
4855 | GNUNET_free(peer_pos); | 4880 | GNUNET_free(peer_pos); |
4881 | ats->stat.recreate_problem = GNUNET_YES; | ||
4856 | } | 4882 | } |
4857 | GNUNET_free (rpos); | 4883 | GNUNET_free (rpos); |
4858 | } | 4884 | } |
@@ -5287,18 +5313,18 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
5287 | /* Force ressource and quality update */ | 5313 | /* Force ressource and quality update */ |
5288 | if (value == 4) | 5314 | if (value == 4) |
5289 | { | 5315 | { |
5290 | ats->modified_resources = GNUNET_YES; | 5316 | ats->stat.modified_resources = GNUNET_YES; |
5291 | ats->modified_quality = GNUNET_YES; | 5317 | ats->stat.modified_quality = GNUNET_YES; |
5292 | } | 5318 | } |
5293 | /* Force cost update */ | 5319 | /* Force cost update */ |
5294 | if (value == 3) | 5320 | if (value == 3) |
5295 | ats->modified_resources = GNUNET_YES; | 5321 | ats->stat.modified_resources = GNUNET_YES; |
5296 | /* Force quality update */ | 5322 | /* Force quality update */ |
5297 | if (value == 2) | 5323 | if (value == 2) |
5298 | ats->modified_quality = GNUNET_YES; | 5324 | ats->stat.modified_quality = GNUNET_YES; |
5299 | /* Force full rebuild */ | 5325 | /* Force full rebuild */ |
5300 | if (value == 1) | 5326 | if (value == 1) |
5301 | ats->modified_addr = GNUNET_YES; | 5327 | ats->stat.recreate_problem = GNUNET_YES; |
5302 | } | 5328 | } |
5303 | 5329 | ||
5304 | #if DEBUG_PING_PONG | 5330 | #if DEBUG_PING_PONG |
@@ -6065,7 +6091,7 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
6065 | // maximum duration | 6091 | // maximum duration |
6066 | opt_lp.tm_lim = max_dur; | 6092 | opt_lp.tm_lim = max_dur; |
6067 | 6093 | ||
6068 | if (ats->modified_addr == GNUNET_YES) | 6094 | if (ats->stat.recreate_problem == GNUNET_YES) |
6069 | opt_lp.presolve = GLP_ON; | 6095 | opt_lp.presolve = GLP_ON; |
6070 | result = glp_simplex(ats->prob, &opt_lp); | 6096 | result = glp_simplex(ats->prob, &opt_lp); |
6071 | lp_solution = glp_get_status (ats->prob); | 6097 | lp_solution = glp_get_status (ats->prob); |
@@ -6083,13 +6109,13 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
6083 | } | 6109 | } |
6084 | else | 6110 | else |
6085 | { | 6111 | { |
6086 | ats->simplex_rerun_required = GNUNET_YES; | 6112 | ats->stat.simplex_rerun_required = GNUNET_YES; |
6087 | opt_lp.presolve = GLP_ON; | 6113 | opt_lp.presolve = GLP_ON; |
6088 | result = glp_simplex(ats->prob, &opt_lp); | 6114 | result = glp_simplex(ats->prob, &opt_lp); |
6089 | lp_solution = glp_get_status (ats->prob); | 6115 | lp_solution = glp_get_status (ats->prob); |
6090 | 6116 | ||
6091 | // TODO: Remove if this does not appear until release | 6117 | // TODO: Remove if this does not appear until release |
6092 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "EXECUTED SIMPLEX WITH PRESOLVER! %i", lp_solution); | 6118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "EXECUTED SIMPLEX WITH PRESOLVER! %i \n", lp_solution); |
6093 | 6119 | ||
6094 | if (ats_evaluate_results(result, lp_solution, "LP") != GNUNET_YES) | 6120 | if (ats_evaluate_results(result, lp_solution, "LP") != GNUNET_YES) |
6095 | { | 6121 | { |
@@ -6099,6 +6125,7 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
6099 | glp_write_lp (ats->prob, NULL, filename); | 6125 | glp_write_lp (ats->prob, NULL, filename); |
6100 | GNUNET_free (filename); | 6126 | GNUNET_free (filename); |
6101 | stat->valid = GNUNET_NO; | 6127 | stat->valid = GNUNET_NO; |
6128 | ats->stat.recreate_problem = GNUNET_YES; | ||
6102 | return; | 6129 | return; |
6103 | } | 6130 | } |
6104 | stat->valid = GNUNET_YES; | 6131 | stat->valid = GNUNET_YES; |
@@ -6180,16 +6207,21 @@ static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsig | |||
6180 | 6207 | ||
6181 | static void ats_delete_problem () | 6208 | static void ats_delete_problem () |
6182 | { | 6209 | { |
6210 | #if DEBUG_ATS | ||
6211 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting problem\n"); | ||
6212 | #endif | ||
6183 | int c; | 6213 | int c; |
6184 | 6214 | ||
6185 | for (c=0; c< (ats->stat).c_mechs; c++) | 6215 | for (c=0; c< (ats->stat).c_mechs; c++) |
6186 | GNUNET_free_non_null (ats->mechanisms[c].rc); | 6216 | GNUNET_free_non_null (ats->mechanisms[c].rc); |
6187 | 6217 | ||
6218 | |||
6188 | if (ats->mechanisms!=NULL) | 6219 | if (ats->mechanisms!=NULL) |
6189 | { | 6220 | { |
6190 | GNUNET_free(ats->mechanisms); | 6221 | GNUNET_free(ats->mechanisms); |
6191 | ats->mechanisms = NULL; | 6222 | ats->mechanisms = NULL; |
6192 | } | 6223 | } |
6224 | |||
6193 | if (ats->peers!=NULL) | 6225 | if (ats->peers!=NULL) |
6194 | { | 6226 | { |
6195 | GNUNET_free(ats->peers); | 6227 | GNUNET_free(ats->peers); |
@@ -6240,9 +6272,13 @@ static void ats_update_problem_qm () | |||
6240 | { | 6272 | { |
6241 | ja[array_index] = c2; | 6273 | ja[array_index] = c2; |
6242 | 6274 | ||
6275 | GNUNET_assert (ats->mechanisms[c2].addr != NULL); | ||
6276 | GNUNET_assert (ats->mechanisms[c2].peer != NULL); | ||
6277 | |||
6243 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) | 6278 | if (qm[c-1].atis_index == GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY) |
6244 | { | 6279 | { |
6245 | double v0 = 0, v1 = 0, v2 = 0; | 6280 | double v0 = 0, v1 = 0, v2 = 0; |
6281 | |||
6246 | v0 = ats->mechanisms[c2].addr->quality[c-1].values[0]; | 6282 | v0 = ats->mechanisms[c2].addr->quality[c-1].values[0]; |
6247 | if (v1 < 1) v0 = 0.1; | 6283 | if (v1 < 1) v0 = 0.1; |
6248 | v1 = ats->mechanisms[c2].addr->quality[c-1].values[1]; | 6284 | v1 = ats->mechanisms[c2].addr->quality[c-1].values[1]; |
@@ -6278,7 +6314,7 @@ static void ats_update_problem_qm () | |||
6278 | 6314 | ||
6279 | #if VERBOSE_ATS | 6315 | #if VERBOSE_ATS |
6280 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, row_index, ja[array_index], ar[array_index]); | 6316 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "[index]=[%i]: [%i,%i]=%f \n",array_index, row_index, ja[array_index], ar[array_index]); |
6281 | #endif | 6317 | #endif |
6282 | glp_set_mat_row (ats->prob, row_index, array_index, ja, ar); | 6318 | glp_set_mat_row (ats->prob, row_index, array_index, ja, ar); |
6283 | 6319 | ||
6284 | array_index = 1; | 6320 | array_index = 1; |
@@ -6316,6 +6352,10 @@ static void ats_update_problem_cr () | |||
6316 | for (c2=1; c2<=ats->stat.c_mechs; c2++) | 6352 | for (c2=1; c2<=ats->stat.c_mechs; c2++) |
6317 | { | 6353 | { |
6318 | double value = 0; | 6354 | double value = 0; |
6355 | |||
6356 | GNUNET_assert (ats->mechanisms[c2].addr != NULL); | ||
6357 | GNUNET_assert (ats->mechanisms[c2].peer != NULL); | ||
6358 | |||
6319 | ja[array_index] = c2; | 6359 | ja[array_index] = c2; |
6320 | value = ats->mechanisms[c2].addr->ressources[c].c; | 6360 | value = ats->mechanisms[c2].addr->ressources[c].c; |
6321 | ar[array_index] = value; | 6361 | ar[array_index] = value; |
@@ -6386,8 +6426,7 @@ static void ats_update_problem_qm_TEST () | |||
6386 | GNUNET_free_non_null (ja); | 6426 | GNUNET_free_non_null (ja); |
6387 | GNUNET_free_non_null (ar); | 6427 | GNUNET_free_non_null (ar); |
6388 | } | 6428 | } |
6389 | #endif | 6429 | #endif //END: HAVE_LIBGLPK |
6390 | |||
6391 | 6430 | ||
6392 | /** solve the bandwidth distribution problem | 6431 | /** solve the bandwidth distribution problem |
6393 | * @param max_it maximum iterations | 6432 | * @param max_it maximum iterations |
@@ -6402,9 +6441,6 @@ static void ats_update_problem_qm_TEST () | |||
6402 | */ | 6441 | */ |
6403 | static int ats_create_problem (double D, double U, double R, int v_b_min, int v_n_min, struct ATS_stat *stat) | 6442 | static int ats_create_problem (double D, double U, double R, int v_b_min, int v_n_min, struct ATS_stat *stat) |
6404 | { | 6443 | { |
6405 | if (ats->prob != NULL) | ||
6406 | glp_delete_prob(ats->prob); | ||
6407 | |||
6408 | ats->prob = glp_create_prob(); | 6444 | ats->prob = glp_create_prob(); |
6409 | 6445 | ||
6410 | int c; | 6446 | int c; |
@@ -6424,6 +6460,7 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6424 | struct NeighbourList *next = neighbours; | 6460 | struct NeighbourList *next = neighbours; |
6425 | while (next!=NULL) | 6461 | while (next!=NULL) |
6426 | { | 6462 | { |
6463 | int found_addresses = GNUNET_NO; | ||
6427 | struct ReadyList *r_next = next->plugins; | 6464 | struct ReadyList *r_next = next->plugins; |
6428 | while (r_next != NULL) | 6465 | while (r_next != NULL) |
6429 | { | 6466 | { |
@@ -6431,12 +6468,13 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6431 | while (a_next != NULL) | 6468 | while (a_next != NULL) |
6432 | { | 6469 | { |
6433 | c_mechs++; | 6470 | c_mechs++; |
6471 | found_addresses = GNUNET_YES; | ||
6434 | a_next = a_next->next; | 6472 | a_next = a_next->next; |
6435 | } | 6473 | } |
6436 | r_next = r_next->next; | 6474 | r_next = r_next->next; |
6437 | } | 6475 | } |
6476 | if (found_addresses) c_peers++; | ||
6438 | next = next->next; | 6477 | next = next->next; |
6439 | c_peers++; | ||
6440 | } | 6478 | } |
6441 | 6479 | ||
6442 | if (c_mechs==0) | 6480 | if (c_mechs==0) |
@@ -6458,21 +6496,25 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6458 | 6496 | ||
6459 | c_mechs = 1; | 6497 | c_mechs = 1; |
6460 | c_peers = 1; | 6498 | c_peers = 1; |
6499 | |||
6461 | next = neighbours; | 6500 | next = neighbours; |
6462 | while (next!=NULL) | 6501 | while (next!=NULL) |
6463 | { | 6502 | { |
6464 | peers[c_peers].peer = next->id; | 6503 | int found_addresses = GNUNET_NO; |
6465 | peers[c_peers].m_head = NULL; | ||
6466 | peers[c_peers].m_tail = NULL; | ||
6467 | // FIXME | ||
6468 | peers[c_peers].f = 1.0 / c_mechs; | ||
6469 | |||
6470 | struct ReadyList *r_next = next->plugins; | 6504 | struct ReadyList *r_next = next->plugins; |
6471 | while (r_next != NULL) | 6505 | while (r_next != NULL) |
6472 | { | 6506 | { |
6473 | struct ForeignAddressList * a_next = r_next->addresses; | 6507 | struct ForeignAddressList * a_next = r_next->addresses; |
6474 | while (a_next != NULL) | 6508 | while (a_next != NULL) |
6475 | { | 6509 | { |
6510 | if (found_addresses == GNUNET_NO) | ||
6511 | { | ||
6512 | peers[c_peers].peer = next->id; | ||
6513 | peers[c_peers].m_head = NULL; | ||
6514 | peers[c_peers].m_tail = NULL; | ||
6515 | peers[c_peers].f = 1.0 / c_mechs; | ||
6516 | } | ||
6517 | |||
6476 | mechanisms[c_mechs].addr = a_next; | 6518 | mechanisms[c_mechs].addr = a_next; |
6477 | mechanisms[c_mechs].col_index = c_mechs; | 6519 | mechanisms[c_mechs].col_index = c_mechs; |
6478 | mechanisms[c_mechs].peer = &peers[c_peers]; | 6520 | mechanisms[c_mechs].peer = &peers[c_peers]; |
@@ -6480,12 +6522,15 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6480 | mechanisms[c_mechs].plugin = r_next->plugin; | 6522 | mechanisms[c_mechs].plugin = r_next->plugin; |
6481 | 6523 | ||
6482 | GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]); | 6524 | GNUNET_CONTAINER_DLL_insert_tail(peers[c_peers].m_head, peers[c_peers].m_tail, &mechanisms[c_mechs]); |
6525 | found_addresses = GNUNET_YES; | ||
6483 | c_mechs++; | 6526 | c_mechs++; |
6527 | |||
6484 | a_next = a_next->next; | 6528 | a_next = a_next->next; |
6485 | } | 6529 | } |
6486 | r_next = r_next->next; | 6530 | r_next = r_next->next; |
6487 | } | 6531 | } |
6488 | c_peers++; | 6532 | if (found_addresses == GNUNET_YES) |
6533 | c_peers++; | ||
6489 | next = next->next; | 6534 | next = next->next; |
6490 | } | 6535 | } |
6491 | c_mechs--; | 6536 | c_mechs--; |
@@ -6539,6 +6584,9 @@ static int ats_create_problem (double D, double U, double R, int v_b_min, int v_ | |||
6539 | glp_add_rows(ats->prob, c_peers); | 6584 | glp_add_rows(ats->prob, c_peers); |
6540 | for (c=1; c<=c_peers; c++) | 6585 | for (c=1; c<=c_peers; c++) |
6541 | { | 6586 | { |
6587 | #if VERBOSE_ATS | ||
6588 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "bounds [row]=[%i] \n",row_index); | ||
6589 | #endif | ||
6542 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 1.0, 1.0); | 6590 | glp_set_row_bnds(ats->prob, row_index, GLP_FX, 1.0, 1.0); |
6543 | 6591 | ||
6544 | struct ATS_mechanism *m = peers[c].m_head; | 6592 | struct ATS_mechanism *m = peers[c].m_head; |
@@ -6896,30 +6944,31 @@ ats_calculate_bandwidth_distribution () | |||
6896 | dur = INT_MAX; | 6944 | dur = INT_MAX; |
6897 | else | 6945 | else |
6898 | dur = (int) ats->max_exec_duration.rel_value; | 6946 | dur = (int) ats->max_exec_duration.rel_value; |
6899 | ats->simplex_rerun_required = GNUNET_NO; | ||
6900 | 6947 | ||
6948 | ats->stat.simplex_rerun_required = GNUNET_NO; | ||
6901 | start = GNUNET_TIME_absolute_get(); | 6949 | start = GNUNET_TIME_absolute_get(); |
6902 | if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL) || (ats->stat.valid == GNUNET_NO)) | 6950 | if ((ats->stat.recreate_problem == GNUNET_YES) || (ats->prob==NULL) || (ats->stat.valid == GNUNET_NO)) |
6903 | { | 6951 | { |
6904 | text = "new"; | 6952 | text = "new"; |
6905 | ats->modified_addr = GNUNET_YES; | 6953 | ats->stat.recreate_problem = GNUNET_YES; |
6906 | ats_delete_problem (); | 6954 | ats_delete_problem (); |
6907 | |||
6908 | ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat); | 6955 | ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat); |
6909 | #if DEBUG_ATS | 6956 | #if DEBUG_ATS |
6910 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were modified... new problem: %i peer, %i mechs\n", ats->stat.c_peers, ats->stat.c_mechs); | 6957 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peers/Addresses were modified... new problem: %i peer, %i mechs\n", ats->stat.c_peers, ats->stat.c_mechs); |
6911 | #endif | 6958 | #endif |
6912 | } | 6959 | } |
6913 | else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_resources == GNUNET_YES) && (ats->stat.valid == GNUNET_YES)) | 6960 | |
6961 | else if ((ats->stat.recreate_problem == GNUNET_NO) && (ats->stat.modified_resources == GNUNET_YES) && (ats->stat.valid == GNUNET_YES)) | ||
6914 | { | 6962 | { |
6915 | ats_update_problem_cr(); | ||
6916 | text = "modified resources"; | 6963 | text = "modified resources"; |
6964 | ats_update_problem_cr(); | ||
6917 | } | 6965 | } |
6918 | else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_quality == GNUNET_YES) && (ats->stat.valid == GNUNET_YES)) | 6966 | else if ((ats->stat.recreate_problem == GNUNET_NO) && (ats->stat.modified_quality == GNUNET_YES) && (ats->stat.valid == GNUNET_YES)) |
6919 | { | 6967 | { |
6968 | text = "modified quality"; | ||
6920 | ats_update_problem_qm(); | 6969 | ats_update_problem_qm(); |
6921 | //ats_update_problem_qm_TEST (); | 6970 | //ats_update_problem_qm_TEST (); |
6922 | text = "modified quality"; | 6971 | |
6923 | } | 6972 | } |
6924 | #if DEBUG_ATS | 6973 | #if DEBUG_ATS |
6925 | else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); | 6974 | else GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem is unmodified\n"); |
@@ -6928,51 +6977,61 @@ ats_calculate_bandwidth_distribution () | |||
6928 | creation = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); | 6977 | creation = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); |
6929 | start = GNUNET_TIME_absolute_get(); | 6978 | start = GNUNET_TIME_absolute_get(); |
6930 | 6979 | ||
6980 | ats->stat.solution = GNUNET_SYSERR; | ||
6931 | if (ats->stat.valid == GNUNET_YES) | 6981 | if (ats->stat.valid == GNUNET_YES) |
6932 | { | 6982 | { |
6933 | ats->stat.solution = GNUNET_SYSERR; | ||
6934 | ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat); | 6983 | ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat); |
6935 | } | 6984 | } |
6936 | solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); | 6985 | solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); |
6937 | 6986 | ||
6938 | if (ats->stat.valid == GNUNET_YES) | 6987 | if (ats->stat.valid == GNUNET_YES) |
6939 | { | 6988 | { |
6989 | int msg_type = GNUNET_ERROR_TYPE_DEBUG; | ||
6940 | #if DEBUG_ATS | 6990 | #if DEBUG_ATS |
6941 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP %s: creation time in [ms] %llu execution time in [ms] %llu for %i mechanisms: simplex rerun: %s\n", | 6991 | msg_type = GNUNET_ERROR_TYPE_ERROR; |
6942 | text, creation.rel_value, solving.rel_value, | ||
6943 | ats->stat.c_mechs, | ||
6944 | (ats->simplex_rerun_required == GNUNET_NO) ? " NO" : "YES"); | ||
6945 | #endif | 6992 | #endif |
6993 | GNUNET_log (msg_type, "MLP %s: creation time: %llu, execution time: %llu, %i mechanisms, simplex rerun: %s, solution %s\n", | ||
6994 | text, creation.rel_value, solving.rel_value, | ||
6995 | ats->stat.c_mechs, | ||
6996 | (ats->stat.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES", (ats->stat.solution == 5) ? "OPTIMAL" : "INVALID"); | ||
6946 | ats->successful_executions ++; | 6997 | ats->successful_executions ++; |
6947 | GNUNET_STATISTICS_set (stats, "# ATS successful executions", ats->successful_executions, GNUNET_NO); | 6998 | GNUNET_STATISTICS_set (stats, "# ATS successful executions", ats->successful_executions, GNUNET_NO); |
6948 | GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO); | ||
6949 | GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO); | ||
6950 | GNUNET_STATISTICS_set (stats, "ATS peers", ats->stat.c_peers, GNUNET_NO); | ||
6951 | GNUNET_STATISTICS_set (stats, "ATS solution", ats->stat.solution, GNUNET_NO); | ||
6952 | GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO); | ||
6953 | 6999 | ||
6954 | if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) | 7000 | if ((ats->stat.recreate_problem == GNUNET_YES) || (ats->prob==NULL)) |
6955 | GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO); | 7001 | GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO); |
6956 | else if ((ats->modified_resources == GNUNET_YES) && | 7002 | else if ((ats->stat.modified_resources == GNUNET_YES) && |
6957 | (ats->modified_quality == GNUNET_NO)) | 7003 | (ats->stat.modified_quality == GNUNET_NO)) |
6958 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_C_UPDATED, GNUNET_NO); | 7004 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_C_UPDATED, GNUNET_NO); |
6959 | else if ((ats->modified_resources == GNUNET_NO) && | 7005 | else if ((ats->stat.modified_resources == GNUNET_NO) && |
6960 | (ats->modified_quality == GNUNET_YES) && | 7006 | (ats->stat.modified_quality == GNUNET_YES) && |
6961 | (ats->simplex_rerun_required == GNUNET_NO)) | 7007 | (ats->stat.simplex_rerun_required == GNUNET_NO)) |
6962 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_Q_UPDATED, GNUNET_NO); | 7008 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_Q_UPDATED, GNUNET_NO); |
6963 | else if ((ats->modified_resources == GNUNET_YES) && | 7009 | else if ((ats->stat.modified_resources == GNUNET_YES) && |
6964 | (ats->modified_quality == GNUNET_YES) && | 7010 | (ats->stat.modified_quality == GNUNET_YES) && |
6965 | (ats->simplex_rerun_required == GNUNET_NO)) | 7011 | (ats->stat.simplex_rerun_required == GNUNET_NO)) |
6966 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_QC_UPDATED, GNUNET_NO); | 7012 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_QC_UPDATED, GNUNET_NO); |
6967 | else if (ats->simplex_rerun_required == GNUNET_NO) | 7013 | else if (ats->stat.simplex_rerun_required == GNUNET_NO) |
6968 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO); | 7014 | GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO); |
6969 | } | 7015 | } |
6970 | else | 7016 | else |
6971 | { | 7017 | { |
6972 | ats->invalid_executions ++; | 7018 | if (ats->stat.c_peers != 0) |
6973 | GNUNET_STATISTICS_set (stats, "# ATS invalid executions", ats->invalid_executions, GNUNET_NO); | 7019 | { |
7020 | ats->invalid_executions ++; | ||
7021 | GNUNET_STATISTICS_set (stats, "# ATS invalid executions", ats->invalid_executions, GNUNET_NO); | ||
7022 | } | ||
7023 | else | ||
7024 | { | ||
7025 | GNUNET_STATISTICS_set (stats, "# ATS successful executions", ats->successful_executions, GNUNET_NO); | ||
7026 | } | ||
6974 | } | 7027 | } |
6975 | 7028 | ||
7029 | GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO); | ||
7030 | GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO); | ||
7031 | GNUNET_STATISTICS_set (stats, "ATS peers", ats->stat.c_peers, GNUNET_NO); | ||
7032 | GNUNET_STATISTICS_set (stats, "ATS solution", ats->stat.solution, GNUNET_NO); | ||
7033 | GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO); | ||
7034 | |||
6976 | if ((ats->save_mlp == GNUNET_YES) && (ats->stat.c_mechs >= ats->dump_min_peers) && (ats->stat.c_mechs >= ats->dump_min_addr)) | 7035 | if ((ats->save_mlp == GNUNET_YES) && (ats->stat.c_mechs >= ats->dump_min_peers) && (ats->stat.c_mechs >= ats->dump_min_addr)) |
6977 | { | 7036 | { |
6978 | char * filename; | 7037 | char * filename; |
@@ -7007,10 +7066,11 @@ ats_calculate_bandwidth_distribution () | |||
7007 | } | 7066 | } |
7008 | GNUNET_free (filename); | 7067 | GNUNET_free (filename); |
7009 | } | 7068 | } |
7069 | |||
7010 | ats->last = GNUNET_TIME_absolute_get(); | 7070 | ats->last = GNUNET_TIME_absolute_get(); |
7011 | ats->modified_addr = GNUNET_NO; | 7071 | ats->stat.recreate_problem = GNUNET_NO; |
7012 | ats->modified_resources = GNUNET_NO; | 7072 | ats->stat.modified_resources = GNUNET_NO; |
7013 | ats->modified_quality = GNUNET_NO; | 7073 | ats->stat.modified_quality = GNUNET_NO; |
7014 | #endif | 7074 | #endif |
7015 | } | 7075 | } |
7016 | 7076 | ||
@@ -7062,6 +7122,10 @@ void ats_init () | |||
7062 | ats->dump_min_peers = 1; | 7122 | ats->dump_min_peers = 1; |
7063 | ats->dump_min_addr = 1; | 7123 | ats->dump_min_addr = 1; |
7064 | ats->dump_overwrite = GNUNET_NO; | 7124 | ats->dump_overwrite = GNUNET_NO; |
7125 | ats->mechanisms = NULL; | ||
7126 | ats->peers = NULL; | ||
7127 | ats->successful_executions = 0; | ||
7128 | ats->invalid_executions = 0; | ||
7065 | 7129 | ||
7066 | #if HAVE_LIBGLPK | 7130 | #if HAVE_LIBGLPK |
7067 | ats->prob = NULL; | 7131 | ats->prob = NULL; |
@@ -7135,8 +7199,7 @@ void ats_init () | |||
7135 | GNUNET_CONFIGURATION_get_value_number(cfg, "transport","ATS_MIN_INTERVAL", &value); | 7199 | GNUNET_CONFIGURATION_get_value_number(cfg, "transport","ATS_MIN_INTERVAL", &value); |
7136 | ats->min_delta.rel_value = value; | 7200 | ats->min_delta.rel_value = value; |
7137 | } | 7201 | } |
7138 | ats->successful_executions = 0; | 7202 | |
7139 | ats->invalid_executions = 0; | ||
7140 | ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); | 7203 | ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); |
7141 | } | 7204 | } |
7142 | 7205 | ||
@@ -7166,8 +7229,7 @@ void ats_notify_peer_connect ( | |||
7166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_connect: %s\n",GNUNET_i2s(peer)); | 7229 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_connect: %s\n",GNUNET_i2s(peer)); |
7167 | #endif | 7230 | #endif |
7168 | //update_addr_ats(); | 7231 | //update_addr_ats(); |
7169 | ats->modified_addr = GNUNET_YES; | 7232 | ats->stat.recreate_problem = GNUNET_YES; |
7170 | |||
7171 | ats_calculate_bandwidth_distribution(ats); | 7233 | ats_calculate_bandwidth_distribution(ats); |
7172 | } | 7234 | } |
7173 | 7235 | ||
@@ -7177,9 +7239,7 @@ void ats_notify_peer_disconnect ( | |||
7177 | #if DEBUG_ATS | 7239 | #if DEBUG_ATS |
7178 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_disconnect: %s\n",GNUNET_i2s(peer)); | 7240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ats_notify_peer_disconnect: %s\n",GNUNET_i2s(peer)); |
7179 | #endif | 7241 | #endif |
7180 | 7242 | ats->stat.recreate_problem = GNUNET_YES; | |
7181 | ats->modified_addr = GNUNET_YES; | ||
7182 | |||
7183 | ats_calculate_bandwidth_distribution (ats); | 7243 | ats_calculate_bandwidth_distribution (ats); |
7184 | } | 7244 | } |
7185 | 7245 | ||