aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-04-19 13:59:26 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-04-19 13:59:26 +0000
commit793243a2d8e70740311850e6adef8d79d0e8ec87 (patch)
tree93f65b767beacea88088cbb771ba85e284dab625 /src
parent71bd1643801c12dc65a94a5ce35b0b51bce6a7c3 (diff)
downloadgnunet-793243a2d8e70740311850e6adef8d79d0e8ec87.tar.gz
gnunet-793243a2d8e70740311850e6adef8d79d0e8ec87.zip
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c231
1 files changed, 141 insertions, 90 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 9494fd1d8..efae6b6c0 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -996,7 +996,7 @@ struct ATS_info
996 /** 996 /**
997 * Regular intervall when execution is triggered 997 * Regular intervall when execution is triggered
998 */ 998 */
999 struct GNUNET_TIME_Relative exec_intervall; 999 struct GNUNET_TIME_Relative exec_interval;
1000 /** 1000 /**
1001 * Maximum execution time per calculation 1001 * Maximum execution time per calculation
1002 */ 1002 */
@@ -1031,12 +1031,6 @@ struct ATS_info
1031 */ 1031 */
1032 struct ATS_peer * peers; 1032 struct ATS_peer * peers;
1033 1033
1034
1035 /**
1036 * Use built-in MLP presolver or simplex
1037 */
1038 int builtin_mlp_presolver;
1039
1040 /** 1034 /**
1041 * Maximum number of LP iterations per calculation 1035 * Maximum number of LP iterations per calculation
1042 */ 1036 */
@@ -1071,6 +1065,11 @@ struct ATS_info
1071 int modified_addr; 1065 int modified_addr;
1072 1066
1073 /** 1067 /**
1068 * Was the available basis invalid and we needed to rerun simplex?
1069 */
1070 int simplex_rerun_required;
1071
1072 /**
1074 * Diversity weight 1073 * Diversity weight
1075 */ 1074 */
1076 double D; 1075 double D;
@@ -1712,7 +1711,7 @@ transmit_to_client (struct TransportClient *client,
1712 GNUNET_CONTAINER_DLL_insert_after (client->message_queue_head, 1711 GNUNET_CONTAINER_DLL_insert_after (client->message_queue_head,
1713 client->message_queue_tail, 1712 client->message_queue_tail,
1714 client->message_queue_tail, 1713 client->message_queue_tail,
1715 q); 1714 q);
1716 client->message_count++; 1715 client->message_count++;
1717 if (client->th == NULL) 1716 if (client->th == NULL)
1718 { 1717 {
@@ -2293,7 +2292,7 @@ expire_address_task (void *cls,
2293 * expired 2292 * expired
2294 */ 2293 */
2295static void 2294static void
2296update_addresses (struct TransportPlugin *plugin, 2295update_addresses (struct TransportPlugin *plugin,
2297 int fresh) 2296 int fresh)
2298{ 2297{
2299 static struct GNUNET_TIME_Absolute last_update; 2298 static struct GNUNET_TIME_Absolute last_update;
@@ -2427,7 +2426,7 @@ try_fast_reconnect (struct TransportPlugin *p,
2427 Furthermore, the same mechanism (or small variation) could be used 2426 Furthermore, the same mechanism (or small variation) could be used
2428 to switch to a better-performing plugin (ATS). 2427 to switch to a better-performing plugin (ATS).
2429 2428
2430 Finally, this needs to be tested throughly... */ 2429 Finally, this needs to be tested throughly... */
2431 2430
2432 /* 2431 /*
2433 * GNUNET_NO in the call below makes transport disconnect the peer, 2432 * GNUNET_NO in the call below makes transport disconnect the peer,
@@ -2569,9 +2568,9 @@ plugin_env_notify_address (void *cls,
2569 al = p->addresses; 2568 al = p->addresses;
2570 while (al != NULL) 2569 while (al != NULL)
2571 { 2570 {
2572 if ( (addrlen == al->addrlen) && 2571 if ( (addrlen == al->addrlen) &&
2573 (0 == memcmp (addr, &al[1], addrlen)) ) 2572 (0 == memcmp (addr, &al[1], addrlen)) )
2574 { 2573 {
2575 al->expires = abex; 2574 al->expires = abex;
2576 update_addresses (p, GNUNET_NO); 2575 update_addresses (p, GNUNET_NO);
2577 return; 2576 return;
@@ -3448,7 +3447,7 @@ do_blacklist_check (void *cls,
3448 if (bl == NULL) 3447 if (bl == NULL)
3449 { 3448 {
3450 bc->cont (bc->cont_cls, 3449 bc->cont (bc->cont_cls,
3451 setup_new_neighbour (&bc->peer, bc->do_hello)); 3450 setup_new_neighbour (&bc->peer, bc->do_hello));
3452 GNUNET_free (bc); 3451 GNUNET_free (bc);
3453 return; 3452 return;
3454 } 3453 }
@@ -3826,7 +3825,7 @@ schedule_next_ping (struct ForeignAddressList *fal)
3826 { 3825 {
3827 delay = GNUNET_TIME_UNIT_ZERO; 3826 delay = GNUNET_TIME_UNIT_ZERO;
3828 fal->estimated = GNUNET_YES; 3827 fal->estimated = GNUNET_YES;
3829 } 3828 }
3830 if (GNUNET_YES == fal->connected) 3829 if (GNUNET_YES == fal->connected)
3831 { 3830 {
3832 delay = GNUNET_TIME_relative_min (delay, 3831 delay = GNUNET_TIME_relative_min (delay,
@@ -3888,14 +3887,14 @@ handle_payload_message (const struct GNUNET_MessageHeader *message,
3888 { 3887 {
3889 n->quota_violation_count++; 3888 n->quota_violation_count++;
3890#if DEBUG_TRANSPORT 3889#if DEBUG_TRANSPORT
3891 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3890 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3892 "Bandwidth quota (%u b/s) violation detected (total of %u).\n", 3891 "Bandwidth quota (%u b/s) violation detected (total of %u).\n",
3893 n->in_tracker.available_bytes_per_s__, 3892 n->in_tracker.available_bytes_per_s__,
3894 n->quota_violation_count); 3893 n->quota_violation_count);
3895#endif 3894#endif
3896 /* Discount 32k per violation */ 3895 /* Discount 32k per violation */
3897 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker, 3896 GNUNET_BANDWIDTH_tracker_consume (&n->in_tracker,
3898 - 32 * 1024); 3897 - 32 * 1024);
3899 } 3898 }
3900 else 3899 else
3901 { 3900 {
@@ -4067,7 +4066,7 @@ check_pending_validation (void *cls,
4067 a2s (ve->transport_name, 4066 a2s (ve->transport_name,
4068 &addr[slen], 4067 &addr[slen],
4069 alen)); 4068 alen));
4070 return GNUNET_NO; 4069 return GNUNET_NO;
4071 } 4070 }
4072 if (GNUNET_OK != 4071 if (GNUNET_OK !=
4073 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING, 4072 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_PONG_USING,
@@ -4539,7 +4538,7 @@ check_hello_validated (void *cls,
4539 GNUNET_CONTAINER_DLL_remove (chvc_head, 4538 GNUNET_CONTAINER_DLL_remove (chvc_head,
4540 chvc_tail, 4539 chvc_tail,
4541 chvc); 4540 chvc);
4542 GNUNET_free (chvc); 4541 GNUNET_free (chvc);
4543 } 4542 }
4544 return; 4543 return;
4545 } 4544 }
@@ -5058,7 +5057,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
5058 GNUNET_assert (GNUNET_OK == 5057 GNUNET_assert (GNUNET_OK ==
5059 GNUNET_CRYPTO_rsa_sign (my_private_key, 5058 GNUNET_CRYPTO_rsa_sign (my_private_key,
5060 &pong->purpose, 5059 &pong->purpose,
5061 &oal->pong_signature)); 5060 &oal->pong_signature));
5062 memcpy (&pong->signature, 5061 memcpy (&pong->signature,
5063 &oal->pong_signature, 5062 &oal->pong_signature,
5064 sizeof (struct GNUNET_CRYPTO_RsaSignature)); 5063 sizeof (struct GNUNET_CRYPTO_RsaSignature));
@@ -5070,7 +5069,7 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message,
5070 GNUNET_assert (GNUNET_OK == 5069 GNUNET_assert (GNUNET_OK ==
5071 GNUNET_CRYPTO_rsa_sign (my_private_key, 5070 GNUNET_CRYPTO_rsa_sign (my_private_key,
5072 &pong->purpose, 5071 &pong->purpose,
5073 &pong->signature)); 5072 &pong->signature));
5074 } 5073 }
5075 else 5074 else
5076 { 5075 {
@@ -5811,7 +5810,7 @@ client_disconnect_notification (void *cls,
5811 if (bc->th != NULL) 5810 if (bc->th != NULL)
5812 { 5811 {
5813 GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th); 5812 GNUNET_CONNECTION_notify_transmit_ready_cancel (bc->th);
5814 bc->th = NULL; 5813 bc->th = NULL;
5815 } 5814 }
5816 if (bc->task == GNUNET_SCHEDULER_NO_TASK) 5815 if (bc->task == GNUNET_SCHEDULER_NO_TASK)
5817 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, 5816 bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check,
@@ -5970,11 +5969,11 @@ static int ats_evaluate_results (int result, int solution, char * problem)
5970 GNUNET_log (error_kind, "%s , Search terminated by application ", problem); 5969 GNUNET_log (error_kind, "%s , Search terminated by application ", problem);
5971 break; 5970 break;
5972 case GLP_EITLIM : /* iteration limit exceeded */ 5971 case GLP_EITLIM : /* iteration limit exceeded */
5973 GNUNET_log (error_kind, "%s Iteration limit exceeded ", problem); 5972 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s Iteration limit exceeded ", problem);
5974 break; 5973 break;
5975 break; 5974 break;
5976 case GLP_ETMLIM : /* time limit exceeded */ 5975 case GLP_ETMLIM : /* time limit exceeded */
5977 GNUNET_log (error_kind, "%s Time limit exceeded ", problem); 5976 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s Time limit exceeded ", problem);
5978 break; 5977 break;
5979 case GLP_ENOPFS : /* no primal feasible solution */ 5978 case GLP_ENOPFS : /* no primal feasible solution */
5980 case GLP_ENODFS : /* no dual feasible solution */ 5979 case GLP_ENODFS : /* no dual feasible solution */
@@ -6026,45 +6025,91 @@ return cont;
6026static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsigned int c_peers, unsigned int c_mechs, struct ATS_stat *stat) 6025static void ats_solve_problem (unsigned int max_it, unsigned int max_dur, unsigned int c_peers, unsigned int c_mechs, struct ATS_stat *stat)
6027{ 6026{
6028 int result; 6027 int result;
6029 int solution; 6028 int lp_solution;
6029 int mlp_solution;
6030 6030
6031 // Solving simplex 6031 // Solving simplex
6032 if (ats->builtin_mlp_presolver == GNUNET_NO) 6032
6033 { 6033 glp_smcp opt_lp;
6034 glp_smcp opt_lp; 6034 glp_init_smcp(&opt_lp);
6035 glp_init_smcp(&opt_lp);
6036#if VERBOSE_ATS 6035#if VERBOSE_ATS
6037 opt_lp.msg_lev = GLP_MSG_ALL; 6036 opt_lp.msg_lev = GLP_MSG_ALL;
6038#else 6037#else
6039 opt_lp.msg_lev = GLP_MSG_OFF; 6038 opt_lp.msg_lev = GLP_MSG_OFF;
6040#endif 6039#endif
6041 result = glp_simplex(ats->prob, &opt_lp); 6040
6042 solution = glp_get_status (ats->prob); 6041 // setting iteration limit
6042 opt_lp.it_lim = max_it;
6043 // maximum duration
6044 opt_lp.tm_lim = max_dur;
6045
6046 if (ats->modified_addr == GNUNET_YES)
6047 opt_lp.presolve = GLP_ON;
6048 result = glp_simplex(ats->prob, &opt_lp);
6049 lp_solution = glp_get_status (ats->prob);
6050
6051 if ((result == GLP_ETMLIM) || (result == GLP_ETMLIM))
6052 {
6053 ats->stat.valid = GNUNET_NO;
6054 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ATS exceeded time or iteration limit!\n");
6055 return;
6043 } 6056 }
6044 if (((ats->builtin_mlp_presolver == GNUNET_NO) && (GNUNET_YES == ats_evaluate_results(result, solution, "LP"))) || (ats->builtin_mlp_presolver == GNUNET_YES)) 6057
6058 if (ats_evaluate_results(result, lp_solution, "LP") == GNUNET_YES)
6045 { 6059 {
6046 /* Solving mlp */ 6060 stat->valid = GNUNET_YES;
6047 glp_iocp opt_mlp; 6061 }
6048 glp_init_iocp(&opt_mlp); 6062 else
6049 /* maximum duration */ 6063 {
6050 if (ats->builtin_mlp_presolver == GNUNET_YES) 6064 ats->simplex_rerun_required = GNUNET_YES;
6051 opt_mlp.presolve = GLP_ON; 6065 opt_lp.presolve = GLP_ON;
6052 opt_mlp.tm_lim = max_dur; 6066 result = glp_simplex(ats->prob, &opt_lp);
6053 /* output level */ 6067 lp_solution = glp_get_status (ats->prob);
6068
6069 // TODO: Remove if this does not appear until release
6070 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "EXECUTED SIMPLEX WITH PRESOLVER! %i", lp_solution);
6071
6072 if (ats_evaluate_results(result, lp_solution, "LP") != GNUNET_YES)
6073 {
6074 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "After execution simplex with presolver: STILL INVALID!\n");
6075 char * filename;
6076 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value);
6077 glp_write_lp (ats->prob, NULL, filename);
6078 GNUNET_free (filename);
6079 stat->valid = GNUNET_NO;
6080 return;
6081 }
6082 stat->valid = GNUNET_YES;
6083 }
6084
6085 // Solving mlp
6086 glp_iocp opt_mlp;
6087 glp_init_iocp(&opt_mlp);
6088 // maximum duration
6089 opt_mlp.tm_lim = max_dur;
6090 // output level
6054#if VERBOSE_ATS 6091#if VERBOSE_ATS
6055 opt_mlp.msg_lev = GLP_MSG_ALL; 6092 opt_mlp.msg_lev = GLP_MSG_ALL;
6056#else 6093#else
6057 opt_mlp.msg_lev = GLP_MSG_OFF; 6094 opt_mlp.msg_lev = GLP_MSG_OFF;
6058#endif 6095#endif
6059 result = glp_intopt (ats->prob, &opt_mlp); 6096
6060 solution = glp_mip_status (ats->prob); 6097 result = glp_intopt (ats->prob, &opt_mlp);
6061 stat->solution = solution; 6098 mlp_solution = glp_mip_status (ats->prob);
6099 stat->solution = mlp_solution;
6100
6101 if (ats_evaluate_results(result, mlp_solution, "MLP") == GNUNET_YES)
6102 {
6103 stat->valid = GNUNET_YES;
6104 }
6105 else
6106 {
6107 // TODO: Remove if this does not appear until release
6108 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP SOLUTION INVALID: %i\n", lp_solution);
6062 stat->valid = GNUNET_NO; 6109 stat->valid = GNUNET_NO;
6063 if (ats_evaluate_results(result, solution, "MLP") == GNUNET_YES)
6064 stat->valid = GNUNET_YES;
6065 } 6110 }
6066 6111
6067 /* 6112/*
6068 int check; 6113 int check;
6069 int error = GNUNET_NO; 6114 int error = GNUNET_NO;
6070 double bw; 6115 double bw;
@@ -6145,6 +6190,7 @@ static void ats_delete_problem ()
6145 ats->stat.valid = GNUNET_SYSERR; 6190 ats->stat.valid = GNUNET_SYSERR;
6146} 6191}
6147 6192
6193
6148static void ats_update_problem_qm () 6194static void ats_update_problem_qm ()
6149{ 6195{
6150 int array_index; 6196 int array_index;
@@ -6222,7 +6268,6 @@ static void ats_update_problem_qm ()
6222} 6268}
6223 6269
6224 6270
6225
6226static void ats_update_problem_cr () 6271static void ats_update_problem_cr ()
6227{ 6272{
6228 6273
@@ -6267,6 +6312,7 @@ static void ats_update_problem_cr ()
6267 GNUNET_free_non_null (ar); 6312 GNUNET_free_non_null (ar);
6268} 6313}
6269 6314
6315#if 0
6270static void ats_update_problem_qm_TEST () 6316static void ats_update_problem_qm_TEST ()
6271{ 6317{
6272 int row_index; 6318 int row_index;
@@ -6282,7 +6328,11 @@ static void ats_update_problem_qm_TEST ()
6282#if DEBUG_ATS 6328#if DEBUG_ATS
6283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics TEST\n"); 6329 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Updating problem quality metrics TEST\n");
6284#endif 6330#endif
6285 row_index = ats->stat.begin_qm; 6331 if (ats->stat.begin_qm >0)
6332 row_index = ats->stat.begin_qm;
6333 else
6334 return;
6335
6286 6336
6287 for (c=0; c<available_quality_metrics; c++) 6337 for (c=0; c<available_quality_metrics; c++)
6288 { 6338 {
@@ -6294,9 +6344,9 @@ static void ats_update_problem_qm_TEST ()
6294 for (c2=1; c2<=c_old; c2++) 6344 for (c2=1; c2<=c_old; c2++)
6295 { 6345 {
6296 ja[c2] = old_ja[c2]; 6346 ja[c2] = old_ja[c2];
6297 if ((changed < 3) && (c2>2)) 6347 if ((changed < 3) && (c2>2) && (old_ar[c2] != -1))
6298 { 6348 {
6299 ar[c2] = old_ar[c2] + 500 - changed; 6349 ar[c2] = old_ar[c2] + 5 - changed;
6300 changed ++; 6350 changed ++;
6301 } 6351 }
6302 else 6352 else
@@ -6310,10 +6360,11 @@ static void ats_update_problem_qm_TEST ()
6310 row_index ++; 6360 row_index ++;
6311 } 6361 }
6312 6362
6313
6314 GNUNET_free_non_null (ja); 6363 GNUNET_free_non_null (ja);
6315 GNUNET_free_non_null (ar); 6364 GNUNET_free_non_null (ar);
6316} 6365}
6366#endif
6367
6317 6368
6318/** solve the bandwidth distribution problem 6369/** solve the bandwidth distribution problem
6319 * @param max_it maximum iterations 6370 * @param max_it maximum iterations
@@ -6794,7 +6845,7 @@ void ats_notify_ats_data (
6794#if DEBUG_ATS 6845#if DEBUG_ATS
6795 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "ATS_notify_ats_data: %s\n",GNUNET_i2s(peer)); 6846 GNUNET_log (GNUNET_ERROR_TYPE_BULK, "ATS_notify_ats_data: %s\n",GNUNET_i2s(peer));
6796#endif 6847#endif
6797 ats_calculate_bandwidth_distribution(ats); 6848 ats_calculate_bandwidth_distribution();
6798} 6849}
6799#endif 6850#endif
6800#endif 6851#endif
@@ -6808,7 +6859,7 @@ ats_calculate_bandwidth_distribution ()
6808 struct GNUNET_TIME_Relative solving; 6859 struct GNUNET_TIME_Relative solving;
6809 char *text = "unmodified"; 6860 char *text = "unmodified";
6810 6861
6811 struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference(ats->last,GNUNET_TIME_absolute_get()); 6862 struct GNUNET_TIME_Relative delta = GNUNET_TIME_absolute_get_difference (ats->last, GNUNET_TIME_absolute_get());
6812 if (delta.rel_value < ats->min_delta.rel_value) 6863 if (delta.rel_value < ats->min_delta.rel_value)
6813 { 6864 {
6814#if DEBUG_ATS 6865#if DEBUG_ATS
@@ -6822,11 +6873,13 @@ ats_calculate_bandwidth_distribution ()
6822 dur = INT_MAX; 6873 dur = INT_MAX;
6823 else 6874 else
6824 dur = (int) ats->max_exec_duration.rel_value; 6875 dur = (int) ats->max_exec_duration.rel_value;
6876 ats->simplex_rerun_required = GNUNET_NO;
6825 6877
6826 start = GNUNET_TIME_absolute_get(); 6878 start = GNUNET_TIME_absolute_get();
6827 if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) 6879 if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL))
6828 { 6880 {
6829 text = "new"; 6881 text = "new";
6882 ats->modified_addr = GNUNET_YES;
6830 ats_delete_problem (); 6883 ats_delete_problem ();
6831 ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat); 6884 ats_create_problem (ats->D, ats->U, ats->R, ats->v_b_min, ats->v_n_min, &ats->stat);
6832#if DEBUG_ATS 6885#if DEBUG_ATS
@@ -6841,7 +6894,7 @@ ats_calculate_bandwidth_distribution ()
6841 else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_quality == GNUNET_YES)) 6894 else if ((ats->modified_addr == GNUNET_NO) && (ats->modified_quality == GNUNET_YES))
6842 { 6895 {
6843 ats_update_problem_qm(); 6896 ats_update_problem_qm();
6844 ats_update_problem_qm_TEST (); 6897 //ats_update_problem_qm_TEST ();
6845 text = "modified quality"; 6898 text = "modified quality";
6846 } 6899 }
6847#if DEBUG_ATS 6900#if DEBUG_ATS
@@ -6855,70 +6908,64 @@ ats_calculate_bandwidth_distribution ()
6855 { 6908 {
6856 ats->stat.solution = GNUNET_SYSERR; 6909 ats->stat.solution = GNUNET_SYSERR;
6857 ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat); 6910 ats_solve_problem(ats->max_iterations, ats->max_exec_duration.rel_value, ats->stat.c_peers, ats->stat.c_mechs, &ats->stat);
6858 //if (ats->stat.solution != 5)
6859 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solution is not optimal: %i\n", ats->stat.solution);
6860 } 6911 }
6861
6862 solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get()); 6912 solving = GNUNET_TIME_absolute_get_difference(start,GNUNET_TIME_absolute_get());
6863 6913
6864 if (ats->stat.valid == GNUNET_YES) 6914 if (ats->stat.valid == GNUNET_YES)
6865 { 6915 {
6866#if DEBUG_ATS 6916#if DEBUG_ATS
6867 6917 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",
6868 //if (ats->stat.c_peers > 1) 6918 text, creation.rel_value, solving.rel_value,
6869 //{ 6919 ats->stat.c_mechs,
6870 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP %s: creation time in [ms] %llu execution time in [ms] %llu for %i mechanisms\n", text, creation.rel_value, solving.rel_value, ats->stat.c_mechs); 6920 (ats->simplex_rerun_required == GNUNET_NO) ? " NO" : "YES");
6871 //}
6872#endif 6921#endif
6873 GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO); 6922 GNUNET_STATISTICS_set (stats, "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO);
6874 GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO); 6923 GNUNET_STATISTICS_set (stats, "ATS mechanisms", ats->stat.c_mechs, GNUNET_NO);
6875 GNUNET_STATISTICS_set (stats, "ATS peers", ats->stat.c_peers, GNUNET_NO); 6924 GNUNET_STATISTICS_set (stats, "ATS peers", ats->stat.c_peers, GNUNET_NO);
6876 GNUNET_STATISTICS_set (stats, "ATS solution", ats->stat.solution, GNUNET_NO); 6925 GNUNET_STATISTICS_set (stats, "ATS solution", ats->stat.solution, GNUNET_NO);
6877 GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO); 6926 GNUNET_STATISTICS_set (stats, "ATS timestamp", start.abs_value, GNUNET_NO);
6927
6878 if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL)) 6928 if ((ats->modified_addr == GNUNET_YES) || (ats->prob==NULL))
6879 GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO); 6929 GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO);
6880 else if ((ats->modified_resources == GNUNET_YES) && (ats->modified_quality == GNUNET_NO)) 6930 else if ((ats->modified_resources == GNUNET_YES) &&
6931 (ats->modified_quality == GNUNET_NO))
6881 GNUNET_STATISTICS_set (stats, "ATS state", ATS_C_UPDATED, GNUNET_NO); 6932 GNUNET_STATISTICS_set (stats, "ATS state", ATS_C_UPDATED, GNUNET_NO);
6882 else if ((ats->modified_resources == GNUNET_NO) && (ats->modified_quality == GNUNET_YES)) 6933 else if ((ats->modified_resources == GNUNET_NO) &&
6934 (ats->modified_quality == GNUNET_YES) &&
6935 (ats->simplex_rerun_required == GNUNET_NO))
6883 GNUNET_STATISTICS_set (stats, "ATS state", ATS_Q_UPDATED, GNUNET_NO); 6936 GNUNET_STATISTICS_set (stats, "ATS state", ATS_Q_UPDATED, GNUNET_NO);
6884 else if ((ats->modified_resources == GNUNET_YES) && (ats->modified_quality == GNUNET_YES)) 6937 else if ((ats->modified_resources == GNUNET_YES) &&
6938 (ats->modified_quality == GNUNET_YES) &&
6939 (ats->simplex_rerun_required == GNUNET_NO))
6885 GNUNET_STATISTICS_set (stats, "ATS state", ATS_QC_UPDATED, GNUNET_NO); 6940 GNUNET_STATISTICS_set (stats, "ATS state", ATS_QC_UPDATED, GNUNET_NO);
6886 else 6941 else if (ats->simplex_rerun_required == GNUNET_NO)
6887 GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO); 6942 GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO);
6888
6889 } 6943 }
6890#if DEBUG_ATS
6891 else if (ats->stat.valid == GNUNET_NO)
6892 {
6893 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP not executed: no addresses\n");
6894 }
6895#endif
6896 6944
6897 if ((ats->save_mlp == GNUNET_YES) && (ats->stat.c_peers > 1)) 6945 if (ats->save_mlp == GNUNET_YES)
6898 { 6946 {
6899 char * filename; 6947 char * filename;
6900 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value); 6948 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.mlp",
6949 ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value);
6901 //if (GNUNET_NO == GNUNET_DISK_file_test(filename)) 6950 //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
6902 glp_write_lp (ats->prob, NULL, filename); 6951 glp_write_lp (ats->prob, NULL, filename);
6903 GNUNET_free (filename); 6952 GNUNET_free (filename);
6904 } 6953 }
6905 if ((ats->save_solution == GNUNET_YES) && (ats->stat.c_peers > 1)) 6954 if (ats->save_solution == GNUNET_YES)
6906 { 6955 {
6907 char * filename; 6956 char * filename;
6908 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol", ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value); 6957 GNUNET_asprintf (&filename, "ats_mlp_p%i_m%i_%llu.sol",
6958 ats->stat.c_peers, ats->stat.c_mechs, GNUNET_TIME_absolute_get().abs_value);
6909 //if (GNUNET_NO == GNUNET_DISK_file_test(filename)) 6959 //if (GNUNET_NO == GNUNET_DISK_file_test(filename))
6910 glp_print_sol (ats->prob, filename); 6960 glp_print_sol (ats->prob, filename);
6911 GNUNET_free (filename); 6961 GNUNET_free (filename);
6912 } 6962 }
6913
6914 ats->last = GNUNET_TIME_absolute_get(); 6963 ats->last = GNUNET_TIME_absolute_get();
6915
6916 ats->modified_addr = GNUNET_NO; 6964 ats->modified_addr = GNUNET_NO;
6917 ats->modified_resources = GNUNET_NO; 6965 ats->modified_resources = GNUNET_NO;
6918 ats->modified_quality = GNUNET_NO; 6966 ats->modified_quality = GNUNET_NO;
6919#endif
6920} 6967}
6921 6968#endif
6922 6969
6923 6970
6924static void 6971static void
@@ -6926,8 +6973,7 @@ ats_schedule_calculation (void *cls,
6926 const struct GNUNET_SCHEDULER_TaskContext *tc) 6973 const struct GNUNET_SCHEDULER_TaskContext *tc)
6927{ 6974{
6928 struct ATS_info *ats = (struct ATS_info *) cls; 6975 struct ATS_info *ats = (struct ATS_info *) cls;
6929 if (ats==NULL) 6976 if (ats==NULL) return;
6930 return;
6931 6977
6932 ats->ats_task = GNUNET_SCHEDULER_NO_TASK; 6978 ats->ats_task = GNUNET_SCHEDULER_NO_TASK;
6933 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 6979 if ( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
@@ -6939,7 +6985,7 @@ ats_schedule_calculation (void *cls,
6939 6985
6940 ats_calculate_bandwidth_distribution (ats); 6986 ats_calculate_bandwidth_distribution (ats);
6941 6987
6942 ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->exec_intervall, 6988 ats->ats_task = GNUNET_SCHEDULER_add_delayed (ats->exec_interval,
6943 &ats_schedule_calculation, ats); 6989 &ats_schedule_calculation, ats);
6944} 6990}
6945 6991
@@ -6952,7 +6998,7 @@ void ats_init ()
6952 ats = GNUNET_malloc(sizeof (struct ATS_info)); 6998 ats = GNUNET_malloc(sizeof (struct ATS_info));
6953 6999
6954 ats->min_delta = ATS_MIN_INTERVAL; 7000 ats->min_delta = ATS_MIN_INTERVAL;
6955 ats->exec_intervall = ATS_EXEC_INTERVAL; 7001 ats->exec_interval = ATS_EXEC_INTERVAL;
6956 ats->max_exec_duration = ATS_MAX_EXEC_DURATION; 7002 ats->max_exec_duration = ATS_MAX_EXEC_DURATION;
6957 ats->max_iterations = ATS_MAX_ITERATIONS; 7003 ats->max_iterations = ATS_MAX_ITERATIONS;
6958 ats->ats_task = GNUNET_SCHEDULER_NO_TASK; 7004 ats->ats_task = GNUNET_SCHEDULER_NO_TASK;
@@ -7006,10 +7052,15 @@ void ats_init ()
7006 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", "DUMP_SOLUTION")) 7052 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", "DUMP_SOLUTION"))
7007 ats->save_solution = GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport","DUMP_SOLUTION"); 7053 ats->save_solution = GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport","DUMP_SOLUTION");
7008 7054
7009 ats->builtin_mlp_presolver = GNUNET_NO; 7055 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", "ATS_EXEC_INTERVAL"))
7010 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", "BUILTIN_PRESOLVER")) 7056 {
7057 GNUNET_CONFIGURATION_get_value_number(cfg, "transport","ATS_EXEC_INTERVAL", &value);
7058 ats->exec_interval.rel_value = value;
7059 }
7060 if (GNUNET_CONFIGURATION_have_value(cfg, "transport", "ATS_MIN_INTERVAL"))
7011 { 7061 {
7012 ats->builtin_mlp_presolver = GNUNET_CONFIGURATION_get_value_yesno (cfg, "transport","BUILTIN_PRESOLVER"); 7062 GNUNET_CONFIGURATION_get_value_number(cfg, "transport","ATS_MIN_INTERVAL", &value);
7063 ats->min_delta.rel_value = value;
7013 } 7064 }
7014 7065
7015 ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats); 7066 ats->ats_task = GNUNET_SCHEDULER_add_now(&ats_schedule_calculation, ats);
@@ -7145,7 +7196,7 @@ run (void *cls,
7145 if (peerinfo == NULL) 7196 if (peerinfo == NULL)
7146 { 7197 {
7147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 7198 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
7148 _("Could not access PEERINFO service. Exiting.\n")); 7199 _("Could not access PEERINFO service. Exiting.\n"));
7149 GNUNET_SCHEDULER_shutdown (); 7200 GNUNET_SCHEDULER_shutdown ();
7150 if (stats != NULL) 7201 if (stats != NULL)
7151 { 7202 {