[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35150 - in gnunet/src: ats include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35150 - in gnunet/src: ats include |
Date: |
Sun, 8 Feb 2015 14:04:27 +0100 |
Author: grothoff
Date: 2015-02-08 14:04:27 +0100 (Sun, 08 Feb 2015)
New Revision: 35150
Modified:
gnunet/src/ats/gnunet-ats-solver-eval.c
gnunet/src/ats/gnunet-service-ats_addresses.c
gnunet/src/ats/gnunet-service-ats_normalization.c
gnunet/src/ats/gnunet-service-ats_normalization.h
gnunet/src/ats/gnunet-service-ats_plugins.c
gnunet/src/ats/gnunet-service-ats_plugins.h
gnunet/src/ats/plugin_ats_mlp.c
gnunet/src/ats/plugin_ats_proportional.c
gnunet/src/ats/plugin_ats_ril.c
gnunet/src/include/gnunet_ats_plugin.h
Log:
simplify normalization logic, also have clients access norm array of address
directly
Modified: gnunet/src/ats/gnunet-ats-solver-eval.c
===================================================================
--- gnunet/src/ats/gnunet-ats-solver-eval.c 2015-02-08 11:46:36 UTC (rev
35149)
+++ gnunet/src/ats/gnunet-ats-solver-eval.c 2015-02-08 13:04:27 UTC (rev
35150)
@@ -87,8 +87,6 @@
static void
end_now ();
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address);
static char *
print_generator_type (enum GeneratorType g)
@@ -140,23 +138,9 @@
}
-static struct TestAddress *
-find_address_by_ats_address (struct TestPeer *p, const struct ATS_Address
*addr)
-{
- struct TestAddress *cur;
- for (cur = p->addr_head; NULL != cur; cur = cur->next)
- if ((0 == strcmp(cur->ats_addr->plugin, addr->plugin)) &&
- (cur->ats_addr->addr_len == addr->addr_len) &&
- (0 == memcmp (cur->ats_addr->addr, addr->addr, addr->addr_len)))
- return cur;
- return NULL;
-}
-
-
/**
* Logging
*/
-
void
GNUNET_ATS_solver_logging_now (struct LoggingHandle *l)
{
@@ -660,13 +644,12 @@
pg->set_task = GNUNET_SCHEDULER_add_delayed (pg->frequency,
&set_prop_task, pg);
-
}
+
/**
* Set ats_property to 0 to find all pgs
*/
-
static struct PropertyGenerator *
find_prop_gen (unsigned int peer, unsigned int address,
uint32_t ats_property)
@@ -786,7 +769,6 @@
}
-
/**
* Stop all preferences generators
*/
@@ -1033,7 +1015,8 @@
GNUNET_free (pg);
}
-struct TestAddress*
+
+static struct TestAddress*
find_active_address (struct TestPeer *p)
{
struct TestAddress *cur;
@@ -1043,6 +1026,7 @@
return NULL;
}
+
/**
* Generate between the source master and the partner and set property with a
* value depending on the generator.
@@ -1129,14 +1113,12 @@
if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us !=
feedback_frequency.rel_value_us)
{
struct TestAddress * addr = find_active_address(p);
- const double *properties = get_property_cb (NULL, addr->ats_addr);
pg->last_assigned_bw_in = p->assigned_bw_in;
pg->last_assigned_bw_out = p->assigned_bw_out;
pg->feedback_bw_in_acc = 0;
pg->feedback_bw_out_acc = 0;
-
- pg->last_delay_value = properties[GNUNET_ATS_QUALITY_NET_DELAY];
+ pg->last_delay_value = addr->prop_norm[GNUNET_ATS_QUALITY_NET_DELAY];
pg->feedback_delay_acc = 0;
pg->feedback_last_bw_update = GNUNET_TIME_absolute_get();
@@ -1172,8 +1154,7 @@
/**
* Experiments
*/
-
-const char *
+static const char *
print_op (enum OperationType op)
{
switch (op) {
@@ -1199,6 +1180,7 @@
return "";
}
+
static struct Experiment *
create_experiment ()
{
@@ -1210,6 +1192,7 @@
return e;
}
+
static void
free_experiment (struct Experiment *e)
{
@@ -1368,6 +1351,7 @@
return GNUNET_OK;
}
+
static int
load_op_del_address (struct GNUNET_ATS_TEST_Operation *o,
struct Episode *e,
@@ -1447,6 +1431,7 @@
return GNUNET_OK;
}
+
static enum GNUNET_ATS_Property
parse_preference_string (const char * str)
{
@@ -1457,8 +1442,9 @@
if (0 == strcmp(str, props[c]))
return c;
return 0;
-};
+}
+
static int
load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o,
struct Episode *e,
@@ -1628,6 +1614,7 @@
return GNUNET_OK;
}
+
static int
load_op_stop_set_preference (struct GNUNET_ATS_TEST_Operation *o,
struct Episode *e,
@@ -3028,25 +3015,6 @@
}
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address)
-{
- struct TestPeer *p;
- struct TestAddress *a;
-
- if (GNUNET_YES == opt_disable_normalization)
- {
- p = find_peer_by_pid (&address->peer);
- if (NULL == p)
- return NULL;
- a = find_address_by_ats_address (p, address);
- return a->prop_abs;
- }
- return GAS_normalization_get_properties (NULL,
- address);
-}
-
-
struct SolverHandle *
GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
{
@@ -3081,7 +3049,6 @@
sh->env.addresses = sh->addresses;
sh->env.bandwidth_changed_cb = &solver_bandwidth_changed_cb;
sh->env.get_preferences = &get_preferences_cb;
- sh->env.get_property = &get_property_cb;
sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
sh->env.info_cb = &solver_info_cb;
sh->env.network_count = GNUNET_ATS_NetworkTypeCount;
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2015-02-08 11:46:36 UTC
(rev 35149)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2015-02-08 13:04:27 UTC
(rev 35150)
@@ -412,6 +412,7 @@
for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++)
{
aa->atsin[c1].avg_queue_index = 0;
+ aa->atsin[c1].norm = DEFAULT_REL_QUALITY;
for (c2 = 0; c2 < GAS_normalization_queue_length; c2++)
aa->atsin[c1].atsi_abs[c2] = GNUNET_ATS_VALUE_UNDEFINED;
}
Modified: gnunet/src/ats/gnunet-service-ats_normalization.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.c 2015-02-08 11:46:36 UTC
(rev 35149)
+++ gnunet/src/ats/gnunet-service-ats_normalization.c 2015-02-08 13:04:27 UTC
(rev 35150)
@@ -27,6 +27,7 @@
* FIXME: rename to 'properties'!? merge with addresses!?
*/
#include "platform.h"
+#include <float.h>
#include "gnunet_ats_service.h"
#include "gnunet-service-ats_addresses.h"
#include "gnunet-service-ats_normalization.h"
@@ -36,7 +37,7 @@
/**
- * Quality Normalization
+ * Range information for normalization of quality properties.
*/
struct Property
{
@@ -46,9 +47,9 @@
uint32_t prop_type;
/**
- * Corresponding enum value. FIXME: type?
+ * Corresponding enum value of the respective quality property.
*/
- uint32_t atsi_type;
+ enum GNUNET_ATS_Property atsi_type;
/**
* Minimum value we see for this property across all addresses.
@@ -63,80 +64,34 @@
/**
- * Range information for all properties we see.
+ * Range information for all quality properties we see.
*/
static struct Property properties[GNUNET_ATS_QualityPropertiesCount];
-/**
- * Get the normalized properties values for a specific peer or
- * the default values if no normalized values are available.
- *
- * @param cls ignored
- * @param address the address
- * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind
- */
-const double *
-GAS_normalization_get_properties (void *cls,
- const struct ATS_Address *address)
-{
- static double norm_values[GNUNET_ATS_QualityPropertiesCount];
- unsigned int i;
- for (i = 0; i < GNUNET_ATS_QualityPropertiesCount; i++)
- {
- if ((address->atsin[i].norm >= 1.0) && (address->atsin[i].norm <= 2.0))
- norm_values[i] = address->atsin[i].norm;
- else
- norm_values[i] = DEFAULT_REL_QUALITY;
- }
- return norm_values;
-}
-
-
/**
- * Normalize a specific ATS type with the values in queue.
+ * Add the value from @a atsi to the running average of the
+ * given @a ni quality property.
*
- * @param address the address
+ * @param ni normalization information to update
* @param atsi the ats information
- * @return the new average or #GNUNET_ATS_VALUE_UNDEFINED
*/
-static uint32_t
-property_average (struct ATS_Address *address,
+static void
+property_average (struct GAS_NormalizationInfo *ni,
const struct GNUNET_ATS_Information *atsi)
{
- struct GAS_NormalizationInfo *ni;
- uint32_t current_type;
uint32_t current_val;
uint32_t res;
uint64_t sum;
uint32_t count;
unsigned int c1;
- unsigned int index;
- unsigned int props[] = GNUNET_ATS_QualityProperties;
- /* Average the values of this property */
- current_type = ntohl (atsi->type);
current_val = ntohl (atsi->value);
-
- for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++)
- {
- if (current_type == props[c1])
- break;
- }
- if (c1 == GNUNET_ATS_QualityPropertiesCount)
- {
- GNUNET_break(0);
- return GNUNET_ATS_VALUE_UNDEFINED;
- }
- index = c1;
-
- ni = &address->atsin[index];
- ni->atsi_abs[ni->avg_queue_index] = current_val;
- ni->avg_queue_index++;
+ GNUNET_assert (GNUNET_ATS_VALUE_UNDEFINED != current_val);
+ ni->atsi_abs[ni->avg_queue_index++] = current_val;
if (GAS_normalization_queue_length == ni->avg_queue_index)
ni->avg_queue_index = 0;
-
count = 0;
sum = 0;
for (c1 = 0; c1 < GAS_normalization_queue_length; c1++)
@@ -144,26 +99,12 @@
if (GNUNET_ATS_VALUE_UNDEFINED != ni->atsi_abs[c1])
{
count++;
- if (GNUNET_ATS_VALUE_UNDEFINED > (sum + ni->atsi_abs[c1]))
- sum += ni->atsi_abs[c1];
- else
- {
- sum = GNUNET_ATS_VALUE_UNDEFINED - 1;
- GNUNET_break(0);
- }
+ sum += ni->atsi_abs[c1];
}
}
- GNUNET_assert(0 != count);
+ GNUNET_assert (0 != count);
res = sum / count;
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "New average of `%s' created by adding %u from %u elements: %u\n",
- GNUNET_ATS_print_property_type (current_type),
- current_val,
- count,
- res,
- sum);
ni->avg = res;
- return res;
}
@@ -190,8 +131,9 @@
/**
- * Function called on X to find the minimum and maximum
- * values for a given property.
+ * Function called for all addresses and peers to find the minimum and
+ * maximum (averaged) values for a given quality property. Given
+ * those, we can then calculate the normalized score.
*
* @param cls the `struct FindMinMaxCtx`
* @param h which peer are we looking at (ignored)
@@ -220,34 +162,34 @@
*
* @param cls the `struct Property` with details on the
* property and its global range
- * @param h which peer are we looking at (ignored)
- * @param k the address for that peer, from where we get
+ * @param key which peer are we looking at (ignored)
+ * @param value the address for that peer, from where we get
* the original value and where we write the
* normalized value
* @return #GNUNET_OK (continue to iterate)
*/
static int
normalize_address (void *cls,
- const struct GNUNET_PeerIdentity *h,
- void *k)
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct Property *p = cls;
- struct ATS_Address *address = k;
+ struct ATS_Address *address = value;
double delta;
- double backup;
+ double update;
uint32_t avg_value;
- backup = address->atsin[p->prop_type].norm;
avg_value = address->atsin[p->prop_type].avg;
delta = p->max - p->min;
- /* max - 2 * min + avg_value / max - min */
- if (0 != delta)
- address->atsin[p->prop_type].norm = (delta + (avg_value - p->min)) /
(delta);
+ /* max - 2 * min + avg_value / (max - min) */
+ if (delta > DBL_EPSILON)
+ update = DEFAULT_REL_QUALITY + (avg_value - p->min) / delta;
else
- address->atsin[p->prop_type].norm = DEFAULT_REL_QUALITY;
+ update = DEFAULT_REL_QUALITY;
- if (backup == address->atsin[p->prop_type].norm)
+ if (update == address->atsin[p->prop_type].norm)
return GNUNET_OK;
+ address->atsin[p->prop_type].norm = update;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Normalize `%s' address %p's '%s' with value %u to range [%u..%u] =
%.3f\n",
@@ -258,84 +200,31 @@
p->min,
p->max,
address->atsin[p->prop_type].norm);
- GAS_normalized_property_changed (address,
- p->atsi_type,
- address->atsin[p->prop_type].norm);
return GNUNET_OK;
}
/**
- * Normalize @a avg_value to a range of values between [1.0, 2.0]
- * based on min/max values currently known.
+ * Notify about change in normalized property.
*
- * @param p the property
- * @param address the address
- * @param avg_value the value to normalize
+ * @param cls the `struct Property` with details on the
+ * property and its global range
+ * @param key which peer are we looking at (ignored)
+ * @param value the address for that peer
+ * @return #GNUNET_OK (continue to iterate)
*/
-static void
-property_normalize (struct Property *p,
- struct ATS_Address *address,
- uint32_t avg_value)
+static int
+notify_change (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
- struct FindMinMaxCtx find_ctx;
- int addr_count;
- int limits_changed;
+ struct Property *p = cls;
+ struct ATS_Address *address = value;
- find_ctx.p = p;
- find_ctx.max = 0;
- find_ctx.min = UINT32_MAX;
- addr_count = GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
- &find_min_max_it,
- &find_ctx);
- if (0 == addr_count)
- {
- GNUNET_break(0);
- return;
- }
-
- limits_changed = GNUNET_NO;
- if (find_ctx.max != p->max)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Normalizing %s: new maximum %u -> recalculate all values\n",
- GNUNET_ATS_print_property_type (p->atsi_type),
- find_ctx.max);
- p->max = find_ctx.max;
- limits_changed = GNUNET_YES;
- }
-
- if ((find_ctx.min != p->min) && (find_ctx.min < p->max))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Normalizing %s: new minimum %u -> recalculate all values\n",
- GNUNET_ATS_print_property_type (p->atsi_type),
- find_ctx.min,
- find_ctx.max);
- p->min = find_ctx.min;
- limits_changed = GNUNET_YES;
- }
- else if (find_ctx.min == p->max)
- {
- /* Only one value, so minimum has to be 0 */
- p->min = 0;
- }
-
- /* Normalize the values of this property */
- if (GNUNET_NO == limits_changed)
- {
- /* normalize just this address */
- normalize_address (p,
- &address->peer,
- address);
- }
- else
- {
- /* limits changed, normalize all addresses */
- GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
- &normalize_address,
- p);
- }
+ GAS_normalized_property_changed (address,
+ p->atsi_type,
+ address->atsin[p->prop_type].norm);
+ return GNUNET_OK;
}
@@ -351,12 +240,12 @@
const struct GNUNET_ATS_Information
*atsi,
uint32_t atsi_count)
{
- struct Property *cur_prop;
unsigned int c1;
unsigned int c2;
uint32_t current_type;
- uint32_t current_val;
- unsigned int existing_properties[] = GNUNET_ATS_QualityProperties;
+ uint32_t old;
+ struct FindMinMaxCtx find_ctx;
+ int range_changed;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Updating %u elements for peer `%s'\n",
@@ -368,30 +257,64 @@
current_type = ntohl (atsi[c1].type);
for (c2 = 0; c2 < GNUNET_ATS_QualityPropertiesCount; c2++)
- {
- /* Check if type is valid */
- if (current_type == existing_properties[c2])
+ if (current_type == properties[c2].atsi_type)
break;
- }
if (GNUNET_ATS_QualityPropertiesCount == c2)
{
- /* Invalid property, continue with next element */
+ /* Not a quality property, continue with next element */
continue;
}
- /* Averaging */
- current_val = property_average (address, &atsi[c1]);
- if (GNUNET_ATS_VALUE_UNDEFINED == current_val)
+ /* Calculate running average */
+ old = address->atsin[c2].avg;
+ property_average (&address->atsin[c2],
+ &atsi[c1]);
+ if (old == address->atsin[c2].avg)
+ continue; /* no change */
+ range_changed = GNUNET_NO;
+ if ( (old == properties[c2].min) ||
+ (old == properties[c2].max) ||
+ (address->atsin[c2].avg < properties[c2].min) ||
+ (address->atsin[c2].avg > properties[c2].max) )
{
- GNUNET_break(0);
- continue;
+ /* need to re-calculate min/max range, as it may have changed */
+ find_ctx.p = &properties[c2];
+ find_ctx.max = 0;
+ find_ctx.min = UINT32_MAX;
+ if (0 ==
+ GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
+ &find_min_max_it,
+ &find_ctx))
+ {
+ GNUNET_break(0);
+ continue;
+ }
+ if ( (find_ctx.min != properties[c2].min) ||
+ (find_ctx.max != properties[c2].max) )
+ {
+ properties[c2].min = find_ctx.min;
+ properties[c2].max = find_ctx.max;
+ /* limits changed, (re)normalize all addresses */
+ range_changed = GNUNET_YES;
+ }
}
+ if (GNUNET_YES == range_changed)
+ GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
+ &normalize_address,
+ &properties[c2]);
+ else
+ normalize_address (&properties[c2],
+ &address->peer,
+ address);
+ /* after all peers have been updated, notify about changes */
+ if (GNUNET_YES == range_changed)
+ GNUNET_CONTAINER_multipeermap_iterate (GSA_addresses,
+ ¬ify_change,
+ &properties[c2]);
+ else
+ notify_change (&properties[c2],
+ &address->peer,
+ address);
- /* Normalizing */
- /* Check min, max */
- cur_prop = &properties[c2];
- property_normalize (cur_prop,
- address,
- current_val);
}
GAS_plugin_solver_unlock ();
}
@@ -404,7 +327,7 @@
GAS_normalization_start ()
{
unsigned int c1;
- unsigned int existing_properties[] = GNUNET_ATS_QualityProperties;
+ const unsigned int existing_properties[] = GNUNET_ATS_QualityProperties;
for (c1 = 0; c1 < GNUNET_ATS_QualityPropertiesCount; c1++)
{
Modified: gnunet/src/ats/gnunet-service-ats_normalization.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.h 2015-02-08 11:46:36 UTC
(rev 35149)
+++ gnunet/src/ats/gnunet-service-ats_normalization.h 2015-02-08 13:04:27 UTC
(rev 35150)
@@ -35,19 +35,6 @@
/**
- * Get the normalized properties values for a specific peer or
- * the default values if no normalized values are available.
- *
- * @param cls ignored
- * @param address the address
- * @return pointer to the values, can be indexed with GNUNET_ATS_PreferenceKind
- */
-const double *
-GAS_normalization_get_properties (void *cls,
- const struct ATS_Address *address);
-
-
-/**
* Update and normalize a @a atsi performance information
*
* @param address the address to update
Modified: gnunet/src/ats/gnunet-service-ats_plugins.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-08 11:46:36 UTC (rev
35149)
+++ gnunet/src/ats/gnunet-service-ats_plugins.c 2015-02-08 13:04:27 UTC (rev
35150)
@@ -78,7 +78,7 @@
*/
void
GAS_normalized_property_changed (struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
double prop_rel)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -432,7 +432,6 @@
env.info_cb = &solver_info_cb;
env.bandwidth_changed_cb = &bandwidth_changed_cb;
env.get_preferences = &GAS_normalization_get_preferences_by_peer;
- env.get_property = &GAS_normalization_get_properties;
env.cfg = cfg;
env.stats = GSA_stats;
env.addresses = GSA_addresses;
Modified: gnunet/src/ats/gnunet-service-ats_plugins.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_plugins.h 2015-02-08 11:46:36 UTC (rev
35149)
+++ gnunet/src/ats/gnunet-service-ats_plugins.h 2015-02-08 13:04:27 UTC (rev
35150)
@@ -73,7 +73,7 @@
*/
void
GAS_normalized_property_changed (struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
double prop_rel);
Modified: gnunet/src/ats/plugin_ats_mlp.c
===================================================================
--- gnunet/src/ats/plugin_ats_mlp.c 2015-02-08 11:46:36 UTC (rev 35149)
+++ gnunet/src/ats/plugin_ats_mlp.c 2015-02-08 13:04:27 UTC (rev 35150)
@@ -960,9 +960,8 @@
struct ATS_Peer *peer;
struct MLP_information *mlpi;
char *name;
- const double *props;
+ double prop;
double cur_bigm;
-
uint32_t addr_net;
uint32_t addr_net_index;
unsigned long long max_quota;
@@ -1111,15 +1110,21 @@
/* For all quality metrics, set quality of this address */
if (GNUNET_YES == mlp->opt_dbg_optimize_quality)
{
- props = mlp->env->get_property (mlp->env->cls, address);
for (c = 0; c < mlp->pv.m_q; c++)
{
- if ((props[c] < 1.0) && (props[c] > 2.0))
+ prop = address->atsin[c].norm;
+ if ((prop < 1.0) && (prop > 2.0))
{
- fprintf (stderr, "PROP == %.3f \t ", props[c]);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "PROP == %.3f \t ",
+ prop);
GNUNET_break (0);
}
- mlp_create_problem_set_value (p, p->r_q[c], mlpi->c_b, props[c],
__LINE__);
+ mlp_create_problem_set_value (p,
+ p->r_q[c],
+ mlpi->c_b,
+ prop,
+ __LINE__);
}
}
}
@@ -1911,7 +1916,7 @@
static void
GAS_mlp_address_property_changed (void *solver,
struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
uint32_t abs_value,
double rel_value)
{
Modified: gnunet/src/ats/plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/plugin_ats_proportional.c 2015-02-08 11:46:36 UTC (rev
35149)
+++ gnunet/src/ats/plugin_ats_proportional.c 2015-02-08 13:04:27 UTC (rev
35150)
@@ -687,8 +687,6 @@
struct AddressSolverInformation *asi;
struct GNUNET_TIME_Relative active_time;
struct GNUNET_TIME_Relative min_active_time;
- const double *norm_prop_cur;
- const double *norm_prop_best;
double best_delay;
double best_distance;
double cur_delay;
@@ -738,20 +736,13 @@
}
/* Now compare ATS information */
- norm_prop_cur = ctx->s->env->get_property (ctx->s->env->cls,
- current);
index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
- cur_distance = norm_prop_cur[index];
+ cur_distance = current->atsin[index].norm;
+ best_distance = ctx->best->atsin[index].norm;
index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
- cur_delay = norm_prop_cur[index];
+ cur_delay = current->atsin[index].norm;
+ best_delay = ctx->best->atsin[index].norm;
- norm_prop_best = ctx->s->env->get_property (ctx->s->env->cls,
- ctx->best);
- index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
- best_distance = norm_prop_best[index];
- index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
- best_delay = norm_prop_best[index];
-
/* user shorter distance */
if (cur_distance < best_distance)
{
@@ -1614,7 +1605,7 @@
static void
GAS_proportional_address_property_changed (void *solver,
struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
uint32_t abs_value,
double rel_value)
{
@@ -1738,7 +1729,6 @@
GNUNET_assert (NULL != env->cfg);
GNUNET_assert (NULL != env->bandwidth_changed_cb);
GNUNET_assert (NULL != env->get_preferences);
- GNUNET_assert (NULL != env->get_property);
s = GNUNET_new (struct GAS_PROPORTIONAL_Handle);
s->env = env;
Modified: gnunet/src/ats/plugin_ats_ril.c
===================================================================
--- gnunet/src/ats/plugin_ats_ril.c 2015-02-08 11:46:36 UTC (rev 35149)
+++ gnunet/src/ats/plugin_ats_ril.c 2015-02-08 13:04:27 UTC (rev 35150)
@@ -2375,14 +2375,14 @@
*
* @param solver solver handle
* @param address the address
- * @param type the ATSI type in HBO
+ * @param type the ATSI type
* @param abs_value the absolute value of the property
* @param rel_value the normalized value
*/
static void
GAS_ril_address_property_changed (void *solver,
struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
uint32_t abs_value,
double rel_value)
{
@@ -2583,14 +2583,14 @@
char *string;
float f_tmp;
- LOG(GNUNET_ERROR_TYPE_DEBUG, "API_init() Initializing RIL solver\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "API_init() Initializing RIL solver\n");
- GNUNET_assert(NULL != env);
- GNUNET_assert(NULL != env->cfg);
- GNUNET_assert(NULL != env->stats);
- GNUNET_assert(NULL != env->bandwidth_changed_cb);
- GNUNET_assert(NULL != env->get_preferences);
- GNUNET_assert(NULL != env->get_property);
+ GNUNET_assert (NULL != env);
+ GNUNET_assert (NULL != env->cfg);
+ GNUNET_assert (NULL != env->stats);
+ GNUNET_assert (NULL != env->bandwidth_changed_cb);
+ GNUNET_assert (NULL != env->get_preferences);
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number(env->cfg, "ats",
"RIL_RBF_DIVISOR", &solver->parameters.rbf_divisor))
{
Modified: gnunet/src/include/gnunet_ats_plugin.h
===================================================================
--- gnunet/src/include/gnunet_ats_plugin.h 2015-02-08 11:46:36 UTC (rev
35149)
+++ gnunet/src/include/gnunet_ats_plugin.h 2015-02-08 13:04:27 UTC (rev
35150)
@@ -134,7 +134,7 @@
typedef void
(*GAS_solver_address_property_changed) (void *solver,
struct ATS_Address *address,
- uint32_t type,
+ enum GNUNET_ATS_Property type,
uint32_t abs_value,
double rel_value);
@@ -402,20 +402,6 @@
/**
- * Callback to call from solver to obtain transport properties for an
- * address
- *
- * @param cls the cls
- * @param address the address
- * @return carry of double values containing the preferences with
- * GNUNET_ATS_PreferenceCount elements
- */
-typedef const double *
-(*GAS_get_properties) (void *cls,
- const struct ATS_Address *address);
-
-
-/**
* The ATS plugin will pass a pointer to a struct
* of this type as to the initialization function
* of the ATS plugins.
@@ -453,11 +439,6 @@
GAS_get_preferences get_preferences;
/**
- * ATS addresses function to obtain property values
- */
- GAS_get_properties get_property;
-
- /**
* Callback for solver to call with status information,
* can be NULL
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35150 - in gnunet/src: ats include,
gnunet <=