return GNUNET_YES;
}
+
/**
* Summary context
*/
struct GAS_Addresses_Handle *ah;
};
-#if 0
static int
-eval_preference_relativity (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
+find_active_address (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
{
- struct RelativityContext *rc = cls;
+ struct ATS_Address **res = cls;
struct ATS_Address *addr = obj;
- int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType ;
- int c;
- const double *preferences;
if (GNUNET_YES == addr->active)
- {
- preferences = get_preferences_cb (rc->ah->env.get_preference_cls, id);
- for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
- {
- if (prefs[c] == GNUNET_ATS_PREFERENCE_END)
- continue;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Preference for peer `%s' type %s: %f\n",
- GNUNET_i2s (id), GNUNET_ATS_print_preference_type(prefs[c]),
- preferences[c]);
- }
- }
+ (*res) = addr;
- return GNUNET_OK;
+ if (NULL != (*res))
+ return GNUNET_NO;
+ else
+ return GNUNET_YES;
}
-#endif
-
/**
* Evaluate current bandwidth assignment
/* Variable related to utilization */
struct SummaryContext sum;
+ struct ATS_Address *active_address;
int network_count;
/* Variables for preferences */
int prefs[GNUNET_ATS_PreferenceCount] = GNUNET_ATS_PreferenceType;
double pref_val;
+ double prop_val;
+ const double *norm_values;
+ double prefs_fulfill[GNUNET_ATS_PreferenceCount];
+ int prefs_clients[GNUNET_ATS_PreferenceCount];
+ int rels;
GNUNET_assert (NULL != ah);
GNUNET_assert (NULL != ah->addresses);
if (GNUNET_YES == request_active)
requests_fulfilled ++;
requests_pending ++;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer `%s': pending requests, %s\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s': %u pending requests, %s\n",
GNUNET_i2s (&cur->id),
+ requests_pending,
(GNUNET_YES == request_active) ? "active adress" : "no active address");
}
quality_requests_fulfilled = 0.0;
include_requests = GNUNET_NO;
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u pending requests, %u requests fullfilled\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u pending requests, %u requests fullfilled\n",
requests_pending, requests_fulfilled);
/* 2) How well is bandwidth utilized? */
quality_bandwidth_utilization[c] = (((float)sum.bandwidth_out_assigned[c] / ah->env.out_quota[c]) +
((float)sum.bandwidth_in_assigned[c] / ah->env.in_quota[c])) / 2;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Utilization for network `%s': %f\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Utilization for network `%s': %f\n",
GNUNET_ATS_print_network_type(ah->env.networks[c]),
quality_bandwidth_utilization[c]);
if (sum.addresses_in_network[c] > 0)
}
else
{
- for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next)
+ for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
{
- /* V metrics*/
- for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
- {
+ prefs_fulfill[c] = 0.0;
+ prefs_clients[c] = 0;
+ }
- if (prefs[c] == GNUNET_ATS_PREFERENCE_END)
- continue;
- pref_val = -1.0;
- pref_val = GAS_normalization_get_preferences_by_client (pcur->client, prefs[c]);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "normalized pref for client %p == %.3f\n",
- pcur->client, pref_val);
- if (-1.0 == pref_val)
+ for (cur = ah->pending_requests_head; NULL != cur; cur = cur->next)
+ {
+ active_address = NULL;
+ GNUNET_CONTAINER_multipeermap_get_multiple (ah->addresses,
+ &cur->id, &find_active_address, &active_address);
+
+ for (pcur = ah->preference_clients_head; NULL != pcur; pcur = pcur->next)
+ {
+ for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
{
- GNUNET_break (0);
- continue;
+ if (prefs[c] == GNUNET_ATS_PREFERENCE_END)
+ continue;
+ pref_val = -1.0;
+ pref_val = GAS_normalization_get_preferences_by_client (pcur->client, &cur->id, prefs[c]);
+ if (-1.0 == pref_val)
+ {
+ GNUNET_break (0);
+ continue;
+ }
+
+ if (DEFAULT_REL_PREFERENCE == pref_val)
+ {
+ /* Default preference value */
+ continue;
+ }
+
+ if (NULL != active_address)
+ {
+ norm_values = GAS_normalization_get_properties (active_address);
+ prop_val = norm_values[c];
+ if ((norm_values[c] <= 1.0) || (norm_values[c] >= 2.0))
+ prop_val = DEFAULT_REL_QUALITY;
+ }
+ else
+ {
+ prop_val = DEFAULT_REL_QUALITY;
+ }
+
+ /* We now have preference values [1..2] and properties [1..2] */
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u Client %p, Peer %s Property %s: pref: %.3f prop %.3f \n",
+ c,
+ pcur->client,
+ GNUNET_i2s (&cur->id),
+ GNUNET_ATS_print_preference_type(prefs[c]),
+ pref_val,
+ prop_val);
+
+ prefs_fulfill[c] += (pref_val * prop_val) / 2;
+ prefs_clients[c] ++;
}
}
}
+ rels = 0;
+ for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+ {
+ if (0 < prefs_clients[c])
+ {
+ prefs_fulfill[c] /= prefs_clients[c];
+ rels ++;
+ quality_application_requirements += prefs_fulfill[c];
+ }
+ }
+ if (rels > 0)
+ quality_application_requirements /= rels;
+ else
+ quality_application_requirements = 0.0;
+
include_requirements = GNUNET_YES;
}
/* GUQ */
else
guq = 0.0;
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Requests fulfilled %.3f bandwidth utilized %.3f application preferences met %.3f => %.3f\n",
quality_requests_fulfilled,
quality_bandwidth_utilization_total,
GNUNET_free(mode_str);
}
- load_quotas (cfg, quotas_in, quotas_out, GNUNET_ATS_NetworkTypeCount);
+ load_quotas (cfg, quotas_out, quotas_in, GNUNET_ATS_NetworkTypeCount);
ah->env.info_cb = &solver_info_cb;
ah->env.info_cb_cls = ah;
ah->env.bandwidth_changed_cb = &bandwidth_changed_cb;