aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-07-18 15:45:50 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-07-18 15:45:50 +0000
commit03f5899ccc1a4d6fdf2d1eae4be2a7cdd90c3021 (patch)
tree759fa9d5b3b4bcd236cfc1bdd7281fced308f091 /src/transport
parent555ebf304585fb4ae296cdd9388961d9b303f7e2 (diff)
downloadgnunet-03f5899ccc1a4d6fdf2d1eae4be2a7cdd90c3021.tar.gz
gnunet-03f5899ccc1a4d6fdf2d1eae4be2a7cdd90c3021.zip
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-service-transport.c31
-rw-r--r--src/transport/gnunet-service-transport_ats.c35
-rw-r--r--src/transport/gnunet-service-transport_ats.h10
3 files changed, 43 insertions, 33 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index cb73083e0..09a3ef178 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -997,7 +997,7 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i
997 fal->quality[c].values[1] = fal->quality[c].values[2]; 997 fal->quality[c].values[1] = fal->quality[c].values[2];
998 fal->quality[c].values[2] = value; 998 fal->quality[c].values[2] = value;
999 set = GNUNET_YES; 999 set = GNUNET_YES;
1000#if HAVE_GLPK 1000#if HAVE_LIBGLPK
1001 ats_modify_problem_state (ats, ATS_QUALITY_UPDATED); 1001 ats_modify_problem_state (ats, ATS_QUALITY_UPDATED);
1002#endif 1002#endif
1003 } 1003 }
@@ -1010,7 +1010,7 @@ static int update_addr_value (struct ForeignAddressList *fal, uint32_t value , i
1010 { 1010 {
1011 fal->ressources[c].c = value; 1011 fal->ressources[c].c = value;
1012 set = GNUNET_YES; 1012 set = GNUNET_YES;
1013#if HAVE_GLPK 1013#if HAVE_LIBGLPK
1014 ats_modify_problem_state (ats, ATS_COST_UPDATED); 1014 ats_modify_problem_state (ats, ATS_COST_UPDATED);
1015#endif 1015#endif
1016 } 1016 }
@@ -2510,7 +2510,7 @@ plugin_env_session_end (void *cls,
2510 } 2510 }
2511 GNUNET_free_non_null(pos->ressources); 2511 GNUNET_free_non_null(pos->ressources);
2512 GNUNET_free_non_null(pos->quality); 2512 GNUNET_free_non_null(pos->quality);
2513#if HAVE_GLPK 2513#if HAVE_LIBGLPK
2514 ats_modify_problem_state (ats, ATS_MODIFIED); 2514 ats_modify_problem_state (ats, ATS_MODIFIED);
2515#endif 2515#endif
2516 if (GNUNET_YES != pos->connected) 2516 if (GNUNET_YES != pos->connected)
@@ -2680,9 +2680,9 @@ notify_clients_connect (const struct GNUNET_PeerIdentity *peer,
2680 /* notify ats about connecting peer */ 2680 /* notify ats about connecting peer */
2681 if ((ats != NULL) && (shutdown_in_progress == GNUNET_NO)) 2681 if ((ats != NULL) && (shutdown_in_progress == GNUNET_NO))
2682 { 2682 {
2683#if HAVE_GLPK 2683#if HAVE_LIBGLPK
2684 ats_modify_problem_state(ats, ATS_MODIFIED); 2684 ats_modify_problem_state(ats, ATS_MODIFIED);
2685 ats_calculate_bandwidth_distribution (ats, stats); 2685 ats_calculate_bandwidth_distribution (ats);
2686#endif 2686#endif
2687 } 2687 }
2688 cpos = clients; 2688 cpos = clients;
@@ -2728,9 +2728,9 @@ notify_clients_disconnect (const struct GNUNET_PeerIdentity *peer)
2728 /* notify ats about connecting peer */ 2728 /* notify ats about connecting peer */
2729 if ((ats != NULL) && (shutdown_in_progress == GNUNET_NO)) 2729 if ((ats != NULL) && (shutdown_in_progress == GNUNET_NO))
2730 { 2730 {
2731#if HAVE_GLPK 2731#if HAVE_LIBGLPK
2732 ats_modify_problem_state(ats, ATS_MODIFIED); 2732 ats_modify_problem_state(ats, ATS_MODIFIED);
2733 ats_calculate_bandwidth_distribution (ats, stats); 2733 ats_calculate_bandwidth_distribution (ats);
2734#endif 2734#endif
2735 } 2735 }
2736 2736
@@ -4896,7 +4896,7 @@ disconnect_neighbour (struct NeighbourList *n, int check)
4896 n->received_pong = GNUNET_NO; 4896 n->received_pong = GNUNET_NO;
4897 notify_clients_disconnect (&n->id); 4897 notify_clients_disconnect (&n->id);
4898 } 4898 }
4899#if HAVE_GLPK 4899#if HAVE_LIBGLPK
4900 ats_modify_problem_state(ats, ATS_MODIFIED); 4900 ats_modify_problem_state(ats, ATS_MODIFIED);
4901#endif 4901#endif
4902 /* clean up all plugins, cancel connections and pending transmissions */ 4902 /* clean up all plugins, cancel connections and pending transmissions */
@@ -5428,7 +5428,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
5428 if ((ntohs(message->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ATS) && 5428 if ((ntohs(message->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ATS) &&
5429 (ntohs(message->size) == (sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t)))) 5429 (ntohs(message->size) == (sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t))))
5430 { 5430 {
5431#if HAVE_GLPK 5431#if HAVE_LIBGLPK
5432 uint32_t value = ntohl(*((uint32_t *) &message[1])); 5432 uint32_t value = ntohl(*((uint32_t *) &message[1]));
5433 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_MESSAGE_TYPE_TRANSPORT_ATS: %i \n", value); 5433 //GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GNUNET_MESSAGE_TYPE_TRANSPORT_ATS: %i \n", value);
5434 /* Force ressource and quality update */ 5434 /* Force ressource and quality update */
@@ -6322,7 +6322,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
6322 GNUNET_SCHEDULER_cancel(ats_task); 6322 GNUNET_SCHEDULER_cancel(ats_task);
6323 ats_task = GNUNET_SCHEDULER_NO_TASK; 6323 ats_task = GNUNET_SCHEDULER_NO_TASK;
6324 } 6324 }
6325#if HAVE_GLPK 6325#if HAVE_LIBGLPK
6326 if (ats != NULL) 6326 if (ats != NULL)
6327 ats_shutdown (ats); 6327 ats_shutdown (ats);
6328#endif 6328#endif
@@ -6516,8 +6516,8 @@ schedule_ats (void *cls,
6516#if DEBUG_ATS 6516#if DEBUG_ATS
6517 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Running scheduled calculation\n"); 6517 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Running scheduled calculation\n");
6518#endif 6518#endif
6519#if HAVE_GLPK 6519#if HAVE_LIBGLPK
6520 ats_calculate_bandwidth_distribution (ats, stats); 6520 ats_calculate_bandwidth_distribution (ats);
6521#endif 6521#endif
6522 last_ats_execution = GNUNET_TIME_absolute_get(); 6522 last_ats_execution = GNUNET_TIME_absolute_get();
6523 6523
@@ -6671,7 +6671,7 @@ run (void *cls,
6671 int co; 6671 int co;
6672 char * section; 6672 char * section;
6673 unsigned long long value; 6673 unsigned long long value;
6674#if HAVE_GLPK 6674#if HAVE_LIBGLPK
6675 double D = 1.0; 6675 double D = 1.0;
6676 double U = 1.0; 6676 double U = 1.0;
6677 double R = 1.0; 6677 double R = 1.0;
@@ -6720,7 +6720,7 @@ run (void *cls,
6720 } 6720 }
6721 GNUNET_free (section); 6721 GNUNET_free (section);
6722 } 6722 }
6723#if HAVE_GLPK 6723#if HAVE_LIBGLPK
6724 ats = ats_init (D, U, R, v_b_min, v_n_min, 6724 ats = ats_init (D, U, R, v_b_min, v_n_min,
6725 ATS_MAX_ITERATIONS, ATS_MAX_EXEC_DURATION, 6725 ATS_MAX_ITERATIONS, ATS_MAX_EXEC_DURATION,
6726 create_ats_information, 6726 create_ats_information,
@@ -6764,8 +6764,9 @@ run (void *cls,
6764 "transport", 6764 "transport",
6765 "ATS_MIN_INTERVAL", 6765 "ATS_MIN_INTERVAL",
6766 &ats_minimum_interval)); 6766 &ats_minimum_interval));
6767#if HAVE_GLPK 6767#if HAVE_LIBGLPK
6768 ats_set_logging_options (ats, 6768 ats_set_logging_options (ats,
6769 stats,
6769 minimum_addresses, 6770 minimum_addresses,
6770 minimum_peers, 6771 minimum_peers,
6771 overwrite_dump, 6772 overwrite_dump,
diff --git a/src/transport/gnunet-service-transport_ats.c b/src/transport/gnunet-service-transport_ats.c
index acbc3878c..d8acb534b 100644
--- a/src/transport/gnunet-service-transport_ats.c
+++ b/src/transport/gnunet-service-transport_ats.c
@@ -457,9 +457,12 @@ static void _dummy ()
457 _dummy2(); 457 _dummy2();
458} 458}
459 459
460
461
460static void _dummy2 () 462static void _dummy2 ()
461{ 463{
462 ats_modify_problem_state (NULL, 0); 464 ats_modify_problem_state (NULL, 0);
465 qm[1].atis_index = 0;
463 _dummy(); 466 _dummy();
464 int t = ATS_COST_UPDATED + ATS_MODIFIED + ATS_NEW; 467 int t = ATS_COST_UPDATED + ATS_MODIFIED + ATS_NEW;
465 t = 0; 468 t = 0;
@@ -1303,8 +1306,7 @@ void ats_update_problem_qm (struct ATS_Handle * ats)
1303 1306
1304 1307
1305void 1308void
1306ats_calculate_bandwidth_distribution (struct ATS_Handle * ats, 1309ats_calculate_bandwidth_distribution (struct ATS_Handle * ats)
1307 struct GNUNET_STATISTICS_Handle *stats)
1308{ 1310{
1309 struct GNUNET_TIME_Absolute start; 1311 struct GNUNET_TIME_Absolute start;
1310 struct GNUNET_TIME_Relative creation; 1312 struct GNUNET_TIME_Relative creation;
@@ -1401,50 +1403,50 @@ ats_calculate_bandwidth_distribution (struct ATS_Handle * ats,
1401 (ats->internal.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES", 1403 (ats->internal.simplex_rerun_required == GNUNET_NO) ? "NO" : "YES",
1402 (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID"); 1404 (ats->internal.solution == 5) ? "OPTIMAL" : "INVALID");
1403 ats->successful_executions ++; 1405 ats->successful_executions ++;
1404 GNUNET_STATISTICS_set (stats, "# ATS successful executions", 1406 GNUNET_STATISTICS_set (ats->stats, "# ATS successful executions",
1405 ats->successful_executions, 1407 ats->successful_executions,
1406 GNUNET_NO); 1408 GNUNET_NO);
1407 1409
1408 if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob==NULL)) 1410 if ((ats->internal.recreate_problem == GNUNET_YES) || (ats->prob==NULL))
1409 GNUNET_STATISTICS_set (stats, "ATS state",ATS_NEW, GNUNET_NO); 1411 GNUNET_STATISTICS_set (ats->stats, "ATS state",ATS_NEW, GNUNET_NO);
1410 else if ((ats->internal.modified_resources == GNUNET_YES) && 1412 else if ((ats->internal.modified_resources == GNUNET_YES) &&
1411 (ats->internal.modified_quality == GNUNET_NO)) 1413 (ats->internal.modified_quality == GNUNET_NO))
1412 GNUNET_STATISTICS_set (stats, "ATS state", ATS_COST_UPDATED, GNUNET_NO); 1414 GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_COST_UPDATED, GNUNET_NO);
1413 else if ((ats->internal.modified_resources == GNUNET_NO) && 1415 else if ((ats->internal.modified_resources == GNUNET_NO) &&
1414 (ats->internal.modified_quality == GNUNET_YES) && 1416 (ats->internal.modified_quality == GNUNET_YES) &&
1415 (ats->internal.simplex_rerun_required == GNUNET_NO)) 1417 (ats->internal.simplex_rerun_required == GNUNET_NO))
1416 GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_UPDATED, GNUNET_NO); 1418 GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_QUALITY_UPDATED, GNUNET_NO);
1417 else if ((ats->internal.modified_resources == GNUNET_YES) && 1419 else if ((ats->internal.modified_resources == GNUNET_YES) &&
1418 (ats->internal.modified_quality == GNUNET_YES) && 1420 (ats->internal.modified_quality == GNUNET_YES) &&
1419 (ats->internal.simplex_rerun_required == GNUNET_NO)) 1421 (ats->internal.simplex_rerun_required == GNUNET_NO))
1420 GNUNET_STATISTICS_set (stats, "ATS state", ATS_QUALITY_COST_UPDATED, GNUNET_NO); 1422 GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_QUALITY_COST_UPDATED, GNUNET_NO);
1421 else if (ats->internal.simplex_rerun_required == GNUNET_NO) 1423 else if (ats->internal.simplex_rerun_required == GNUNET_NO)
1422 GNUNET_STATISTICS_set (stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO); 1424 GNUNET_STATISTICS_set (ats->stats, "ATS state", ATS_UNMODIFIED, GNUNET_NO);
1423 } 1425 }
1424 else 1426 else
1425 { 1427 {
1426 if (ats->internal.c_peers != 0) 1428 if (ats->internal.c_peers != 0)
1427 { 1429 {
1428 ats->invalid_executions ++; 1430 ats->invalid_executions ++;
1429 GNUNET_STATISTICS_set (stats, "# ATS invalid executions", 1431 GNUNET_STATISTICS_set (ats->stats, "# ATS invalid executions",
1430 ats->invalid_executions, GNUNET_NO); 1432 ats->invalid_executions, GNUNET_NO);
1431 } 1433 }
1432 else 1434 else
1433 { 1435 {
1434 GNUNET_STATISTICS_set (stats, "# ATS successful executions", 1436 GNUNET_STATISTICS_set (ats->stats, "# ATS successful executions",
1435 ats->successful_executions, GNUNET_NO); 1437 ats->successful_executions, GNUNET_NO);
1436 } 1438 }
1437 } 1439 }
1438 1440
1439 GNUNET_STATISTICS_set (stats, 1441 GNUNET_STATISTICS_set (ats->stats,
1440 "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO); 1442 "ATS duration", solving.rel_value + creation.rel_value, GNUNET_NO);
1441 GNUNET_STATISTICS_set (stats, 1443 GNUNET_STATISTICS_set (ats->stats,
1442 "ATS mechanisms", ats->internal.c_mechs, GNUNET_NO); 1444 "ATS mechanisms", ats->internal.c_mechs, GNUNET_NO);
1443 GNUNET_STATISTICS_set (stats, 1445 GNUNET_STATISTICS_set (ats->stats,
1444 "ATS peers", ats->internal.c_peers, GNUNET_NO); 1446 "ATS peers", ats->internal.c_peers, GNUNET_NO);
1445 GNUNET_STATISTICS_set (stats, 1447 GNUNET_STATISTICS_set (ats->stats,
1446 "ATS solution", ats->internal.solution, GNUNET_NO); 1448 "ATS solution", ats->internal.solution, GNUNET_NO);
1447 GNUNET_STATISTICS_set (stats, 1449 GNUNET_STATISTICS_set (ats->stats,
1448 "ATS timestamp", start.abs_value, GNUNET_NO); 1450 "ATS timestamp", start.abs_value, GNUNET_NO);
1449 1451
1450 if ((ats->save_mlp == GNUNET_YES) && 1452 if ((ats->save_mlp == GNUNET_YES) &&
@@ -1666,6 +1668,7 @@ void ats_update_problem_cr (struct ATS_Handle * ats)
1666} 1668}
1667 1669
1668void ats_set_logging_options (struct ATS_Handle * ats, 1670void ats_set_logging_options (struct ATS_Handle * ats,
1671 struct GNUNET_STATISTICS_Handle * stats,
1669 int minimum_addresses, 1672 int minimum_addresses,
1670 int minimum_peers, 1673 int minimum_peers,
1671 int overwrite_dump, 1674 int overwrite_dump,
@@ -1674,7 +1677,7 @@ void ats_set_logging_options (struct ATS_Handle * ats,
1674{ 1677{
1675 if (ats == NULL) 1678 if (ats == NULL)
1676 return; 1679 return;
1677 1680 ats->stats = stats;
1678 ats->dump_min_addr = minimum_addresses; 1681 ats->dump_min_addr = minimum_addresses;
1679 ats->dump_min_peers = minimum_peers; 1682 ats->dump_min_peers = minimum_peers;
1680 ats->dump_overwrite = overwrite_dump; 1683 ats->dump_overwrite = overwrite_dump;
diff --git a/src/transport/gnunet-service-transport_ats.h b/src/transport/gnunet-service-transport_ats.h
index a6d8f30ba..997014e7a 100644
--- a/src/transport/gnunet-service-transport_ats.h
+++ b/src/transport/gnunet-service-transport_ats.h
@@ -215,6 +215,12 @@ struct ATS_Handle
215 215
216 GNUNET_TRANSPORT_ATS_ResultCallback result_cb; 216 GNUNET_TRANSPORT_ATS_ResultCallback result_cb;
217 217
218
219 /**
220 * Statistics handle
221 */
222 struct GNUNET_STATISTICS_Handle *stats;
223
218 /** 224 /**
219 * Maximum execution time per calculation 225 * Maximum execution time per calculation
220 */ 226 */
@@ -474,8 +480,7 @@ void ats_modify_problem_state (struct ATS_Handle * ats,
474 enum ATS_problem_state s); 480 enum ATS_problem_state s);
475 481
476void 482void
477ats_calculate_bandwidth_distribution (struct ATS_Handle * ats, 483ats_calculate_bandwidth_distribution (struct ATS_Handle * ats);
478 struct GNUNET_STATISTICS_Handle *stats);
479 484
480void 485void
481ats_solve_problem (struct ATS_Handle * ats, 486ats_solve_problem (struct ATS_Handle * ats,
@@ -499,6 +504,7 @@ ats_update_problem_cr (struct ATS_Handle * ats);
499 504
500void 505void
501ats_set_logging_options (struct ATS_Handle * ats, 506ats_set_logging_options (struct ATS_Handle * ats,
507 struct GNUNET_STATISTICS_Handle *stats,
502 int minimum_addresses, 508 int minimum_addresses,
503 int minimum_peers, 509 int minimum_peers,
504 int overwrite_dump, 510 int overwrite_dump,