diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-05 12:52:20 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-05 12:52:20 +0000 |
commit | c55971f17dc99f9833af48e078c8f681be771cb7 (patch) | |
tree | 544fd671b67903506419c98d463d086a696e25a1 /src/ats/gnunet-ats-solver-eval.c | |
parent | 15dd8e6cc1199d611d804853e134882bf13b234a (diff) | |
download | gnunet-c55971f17dc99f9833af48e078c8f681be771cb7.tar.gz gnunet-c55971f17dc99f9833af48e078c8f681be771cb7.zip |
big ATS refactoring, no serious semantic changes should stem from this
Diffstat (limited to 'src/ats/gnunet-ats-solver-eval.c')
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 110 |
1 files changed, 15 insertions, 95 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index 58fe03e25..6bf640f21 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -26,9 +26,17 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet-ats-solver-eval.h" | 28 | #include "gnunet-ats-solver-eval.h" |
29 | #include "gnunet-service-ats_normalization.h" | ||
30 | #include "gnunet-service-ats_preferences.h" | ||
29 | 31 | ||
30 | #define BIG_M_STRING "unlimited" | 32 | #define BIG_M_STRING "unlimited" |
31 | 33 | ||
34 | /** | ||
35 | * Handle for statistics. | ||
36 | */ | ||
37 | struct GNUNET_STATISTICS_Handle *GSA_stats; | ||
38 | |||
39 | |||
32 | static struct Experiment *e; | 40 | static struct Experiment *e; |
33 | 41 | ||
34 | static struct LoggingHandle *l; | 42 | static struct LoggingHandle *l; |
@@ -36,6 +44,7 @@ static struct LoggingHandle *l; | |||
36 | static struct SolverHandle *sh; | 44 | static struct SolverHandle *sh; |
37 | 45 | ||
38 | static struct TestPeer *peer_head; | 46 | static struct TestPeer *peer_head; |
47 | |||
39 | static struct TestPeer *peer_tail; | 48 | static struct TestPeer *peer_tail; |
40 | 49 | ||
41 | static double default_properties[GNUNET_ATS_PropertyCount]; | 50 | static double default_properties[GNUNET_ATS_PropertyCount]; |
@@ -670,8 +679,7 @@ set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
670 | pg->ats_property, prop_value, prop_value); | 679 | pg->ats_property, prop_value, prop_value); |
671 | } | 680 | } |
672 | else | 681 | else |
673 | GAS_normalization_normalize_property (sh->addresses, | 682 | GAS_normalization_normalize_property (pg->test_address->ats_addr, &atsi, 1); |
674 | pg->test_address->ats_addr, &atsi, 1); | ||
675 | sh->env.sf.s_bulk_stop (sh->solver); | 683 | sh->env.sf.s_bulk_stop (sh->solver); |
676 | 684 | ||
677 | pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, | 685 | pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency, |
@@ -3040,7 +3048,8 @@ get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id) | |||
3040 | return p->pref_abs; | 3048 | return p->pref_abs; |
3041 | } | 3049 | } |
3042 | else | 3050 | else |
3043 | return GAS_normalization_get_preferences_by_peer (id); | 3051 | return GAS_normalization_get_preferences_by_peer (NULL, |
3052 | id); | ||
3044 | } | 3053 | } |
3045 | 3054 | ||
3046 | 3055 | ||
@@ -3058,96 +3067,8 @@ get_property_cb (void *cls, const struct ATS_Address *address) | |||
3058 | a = find_address_by_ats_address (p, address); | 3067 | a = find_address_by_ats_address (p, address); |
3059 | return a->prop_abs; | 3068 | return a->prop_abs; |
3060 | } | 3069 | } |
3061 | return GAS_normalization_get_properties ((struct ATS_Address *) address); | 3070 | return GAS_normalization_get_properties (NULL, |
3062 | } | 3071 | address); |
3063 | |||
3064 | |||
3065 | static void | ||
3066 | set_updated_property ( struct ATS_Address *address, uint32_t type, double prop_rel) | ||
3067 | { | ||
3068 | struct TestPeer *p; | ||
3069 | struct TestAddress *a; | ||
3070 | |||
3071 | if (NULL == (p = find_peer_by_pid (&address->peer))) | ||
3072 | { | ||
3073 | GNUNET_break (0); | ||
3074 | return; | ||
3075 | } | ||
3076 | |||
3077 | if (NULL == (a = find_address_by_ats_address (p, address))) | ||
3078 | { | ||
3079 | GNUNET_break (0); | ||
3080 | return; | ||
3081 | } | ||
3082 | a->prop_norm[type] = prop_rel; | ||
3083 | sh->env.sf.s_address_update_property (sh->solver, address, type, a->prop_abs [type], prop_rel); | ||
3084 | } | ||
3085 | |||
3086 | |||
3087 | static void | ||
3088 | normalized_property_changed_cb (void *cls, struct ATS_Address *address, | ||
3089 | uint32_t type, double prop_rel) | ||
3090 | { | ||
3091 | struct TestPeer *p; | ||
3092 | struct PreferenceGenerator *pg; | ||
3093 | struct GNUNET_TIME_Relative duration; | ||
3094 | uint32_t delta; | ||
3095 | |||
3096 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
3097 | "Normalized property %s for peer `%s' changed to %.3f \n", | ||
3098 | GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), | ||
3099 | prop_rel); | ||
3100 | |||
3101 | if (NULL != (p = find_peer_by_pid (&address->peer))) | ||
3102 | { | ||
3103 | for (pg = pref_gen_head; NULL != pg; pg = pg->next) | ||
3104 | { | ||
3105 | if (pg->peer == p->id) | ||
3106 | { | ||
3107 | duration = GNUNET_TIME_absolute_get_duration(pg->feedback_last_delay_update); | ||
3108 | delta = duration.rel_value_us * pg->last_delay_value; | ||
3109 | pg->feedback_delay_acc += delta; | ||
3110 | |||
3111 | pg->last_delay_value = prop_rel; | ||
3112 | pg->feedback_last_bw_update = GNUNET_TIME_absolute_get(); | ||
3113 | } | ||
3114 | } | ||
3115 | |||
3116 | } | ||
3117 | |||
3118 | set_updated_property (address, type, prop_rel); | ||
3119 | } | ||
3120 | |||
3121 | static void | ||
3122 | set_updated_preference (const struct GNUNET_PeerIdentity *peer, | ||
3123 | enum GNUNET_ATS_PreferenceKind kind, | ||
3124 | double pref_rel) | ||
3125 | { | ||
3126 | struct TestPeer *p; | ||
3127 | |||
3128 | if (NULL == (p = find_peer_by_pid (peer))) | ||
3129 | { | ||
3130 | GNUNET_break (0); | ||
3131 | return; | ||
3132 | } | ||
3133 | |||
3134 | p->pref_norm[kind] = pref_rel; | ||
3135 | sh->env.sf.s_pref (sh->solver, peer, kind, pref_rel); | ||
3136 | } | ||
3137 | |||
3138 | |||
3139 | static void | ||
3140 | normalized_preference_changed_cb (void *cls, | ||
3141 | const struct GNUNET_PeerIdentity *peer, | ||
3142 | enum GNUNET_ATS_PreferenceKind kind, | ||
3143 | double pref_rel) | ||
3144 | { | ||
3145 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | ||
3146 | "Normalized preference %s for peer `%s' changed to %.3f \n", | ||
3147 | GNUNET_ATS_print_preference_type (kind), GNUNET_i2s (peer), | ||
3148 | pref_rel); | ||
3149 | |||
3150 | set_updated_preference(peer, kind, pref_rel); | ||
3151 | } | 3072 | } |
3152 | 3073 | ||
3153 | 3074 | ||
@@ -3196,8 +3117,7 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) | |||
3196 | 3117 | ||
3197 | 3118 | ||
3198 | /* start normalization */ | 3119 | /* start normalization */ |
3199 | GAS_normalization_start (&normalized_preference_changed_cb, NULL, | 3120 | GAS_normalization_start (); |
3200 | &normalized_property_changed_cb, NULL ); | ||
3201 | 3121 | ||
3202 | /* load quotas */ | 3122 | /* load quotas */ |
3203 | if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg, | 3123 | if (GNUNET_ATS_NetworkTypeCount != GNUNET_ATS_solvers_load_quotas (e->cfg, |