diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-06-14 06:34:16 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-06-14 06:34:16 +0000 |
commit | b88f9b616ad8efbb395dd006d214172723e51e00 (patch) | |
tree | 51f4300e0dbdf233b97b9bd6bb55ac64a38173c4 /src/ats/gnunet-service-ats-solver_proportional.c | |
parent | cba2bb763757f21c0559b4a2a9cbd4bcf372d13d (diff) | |
download | gnunet-b88f9b616ad8efbb395dd006d214172723e51e00.tar.gz gnunet-b88f9b616ad8efbb395dd006d214172723e51e00.zip |
changes
Diffstat (limited to 'src/ats/gnunet-service-ats-solver_proportional.c')
-rw-r--r-- | src/ats/gnunet-service-ats-solver_proportional.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/ats/gnunet-service-ats-solver_proportional.c b/src/ats/gnunet-service-ats-solver_proportional.c index fc03390b0..9b197b21b 100644 --- a/src/ats/gnunet-service-ats-solver_proportional.c +++ b/src/ats/gnunet-service-ats-solver_proportional.c | |||
@@ -208,7 +208,8 @@ | |||
208 | #define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 208 | #define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
209 | #define PREF_AGING_FACTOR 0.95 | 209 | #define PREF_AGING_FACTOR 0.95 |
210 | 210 | ||
211 | #define DEFAULT_PREFERENCE 1.0 | 211 | #define DEFAULT_REL_PREFERENCE 1.0 |
212 | #define DEFAULT_ABS_PREFERENCE 0.0 | ||
212 | #define MIN_UPDATE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 213 | #define MIN_UPDATE_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
213 | 214 | ||
214 | 215 | ||
@@ -520,7 +521,7 @@ update_quota_per_network (struct GAS_PROPORTIONAL_Handle *s, | |||
520 | { | 521 | { |
521 | t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); | 522 | t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); |
522 | if (NULL == t) | 523 | if (NULL == t) |
523 | total_prefs += DEFAULT_PREFERENCE; | 524 | total_prefs += DEFAULT_REL_PREFERENCE; |
524 | else | 525 | else |
525 | { | 526 | { |
526 | total_prefs += (*t); | 527 | total_prefs += (*t); |
@@ -534,7 +535,7 @@ update_quota_per_network (struct GAS_PROPORTIONAL_Handle *s, | |||
534 | cur_pref = 0.0; | 535 | cur_pref = 0.0; |
535 | t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); | 536 | t = GNUNET_CONTAINER_multihashmap_get (s->prefs, &cur->addr->peer.hashPubKey); |
536 | if (NULL == t) | 537 | if (NULL == t) |
537 | cur_pref = DEFAULT_PREFERENCE; | 538 | cur_pref = DEFAULT_REL_PREFERENCE; |
538 | else | 539 | else |
539 | cur_pref = (*t); | 540 | cur_pref = (*t); |
540 | assigned_quota_in = min_bw + ((cur_pref / total_prefs) * remaining_quota_in); | 541 | assigned_quota_in = min_bw + ((cur_pref / total_prefs) * remaining_quota_in); |
@@ -960,7 +961,7 @@ recalculate_preferences (struct PreferencePeer *p) | |||
960 | /* For this client: for all preferences, except TERMINATOR */ | 961 | /* For this client: for all preferences, except TERMINATOR */ |
961 | for (kind = GNUNET_ATS_PREFERENCE_END + 1 ; kind < GNUNET_ATS_PreferenceCount; kind ++) | 962 | for (kind = GNUNET_ATS_PREFERENCE_END + 1 ; kind < GNUNET_ATS_PreferenceCount; kind ++) |
962 | { | 963 | { |
963 | /* Recalcalculate total preference for this quality kind over all peers*/ | 964 | /* Recalcalculate total preference for this kind of quality over all peers*/ |
964 | c_cur->f_total[kind] = 0; | 965 | c_cur->f_total[kind] = 0; |
965 | for (p_cur = c_cur->p_head; NULL != p_cur; p_cur = p_cur->next) | 966 | for (p_cur = c_cur->p_head; NULL != p_cur; p_cur = p_cur->next) |
966 | c_cur->f_total[kind] += p_cur->f[kind]; | 967 | c_cur->f_total[kind] += p_cur->f[kind]; |
@@ -977,7 +978,7 @@ recalculate_preferences (struct PreferencePeer *p) | |||
977 | if (0.0 == c_cur->f_total[kind]) | 978 | if (0.0 == c_cur->f_total[kind]) |
978 | { | 979 | { |
979 | /* No one has preference, so set default preference */ | 980 | /* No one has preference, so set default preference */ |
980 | p_cur->f_rel[kind] = DEFAULT_PREFERENCE; | 981 | p_cur->f_rel[kind] = DEFAULT_REL_PREFERENCE; |
981 | } | 982 | } |
982 | else | 983 | else |
983 | { | 984 | { |
@@ -1090,13 +1091,15 @@ preference_aging (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1090 | /* Aging absolute values: */ | 1091 | /* Aging absolute values: */ |
1091 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) | 1092 | for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) |
1092 | { | 1093 | { |
1093 | if (p->f[i] > 1.0) | 1094 | if (p->f[i] > DEFAULT_REL_PREFERENCE) |
1094 | { | 1095 | { |
1095 | backup = p->f[i]; | 1096 | backup = p->f[i]; |
1096 | p->f[i] *= PREF_AGING_FACTOR; | 1097 | p->f[i] *= PREF_AGING_FACTOR; |
1097 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Aged preference for peer `%s' from %.3f to %.3f\n", | 1098 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Aged preference for peer `%s' from %.3f to %.3f\n", |
1098 | GNUNET_i2s (&p->id), backup, p->f[i]); | 1099 | GNUNET_i2s (&p->id), backup, p->f[i]); |
1099 | } | 1100 | } |
1101 | else | ||
1102 | p->f[i] = DEFAULT_REL_PREFERENCE; | ||
1100 | } | 1103 | } |
1101 | /* Updating relative value */ | 1104 | /* Updating relative value */ |
1102 | t = GNUNET_CONTAINER_multihashmap_get (p->s->prefs, &p->id.hashPubKey); | 1105 | t = GNUNET_CONTAINER_multihashmap_get (p->s->prefs, &p->id.hashPubKey); |
@@ -1185,9 +1188,9 @@ GAS_simplistic_address_change_preference (void *solver, | |||
1185 | { | 1188 | { |
1186 | /* Default value per peer absolut preference for a quality: | 1189 | /* Default value per peer absolut preference for a quality: |
1187 | * No value set, so absolute preference 0 */ | 1190 | * No value set, so absolute preference 0 */ |
1188 | p_cur->f[i] = 0.0; | 1191 | p_cur->f[i] = DEFAULT_ABS_PREFERENCE; |
1189 | /* Default value per peer relative preference for a quality: 1.0 */ | 1192 | /* Default value per peer relative preference for a quality: 1.0 */ |
1190 | p_cur->f_rel[i] = DEFAULT_PREFERENCE; | 1193 | p_cur->f_rel[i] = DEFAULT_REL_PREFERENCE; |
1191 | } | 1194 | } |
1192 | p_cur->aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, &preference_aging, p_cur); | 1195 | p_cur->aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL, &preference_aging, p_cur); |
1193 | GNUNET_CONTAINER_DLL_insert (c_cur->p_head, c_cur->p_tail, p_cur); | 1196 | GNUNET_CONTAINER_DLL_insert (c_cur->p_head, c_cur->p_tail, p_cur); |