[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33175 - in gnunet/src/ats: . experiments
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33175 - in gnunet/src/ats: . experiments |
Date: |
Tue, 6 May 2014 17:50:20 +0200 |
Author: wachs
Date: 2014-05-06 17:50:20 +0200 (Tue, 06 May 2014)
New Revision: 33175
Modified:
gnunet/src/ats/ats.conf.in
gnunet/src/ats/experiments/example.exp
gnunet/src/ats/experiments/set_preference.exp
gnunet/src/ats/gnunet-ats-solver-eval.c
gnunet/src/ats/gnunet-service-ats_normalization.c
gnunet/src/ats/gnunet-service-ats_normalization.h
gnunet/src/ats/plugin_ats_mlp.c
gnunet/src/ats/plugin_ats_proportional.c
Log:
- refine preference calculcations to reflect all clients
- refining bandwidth distribution in a network
- adding a configurable factor to better respect preferences
Modified: gnunet/src/ats/ats.conf.in
===================================================================
--- gnunet/src/ats/ats.conf.in 2014-05-06 15:07:52 UTC (rev 33174)
+++ gnunet/src/ats/ats.conf.in 2014-05-06 15:50:20 UTC (rev 33175)
@@ -32,6 +32,11 @@
BLUETOOTH_QUOTA_OUT = 128 KiB
# ATS options
+# Proportional specific settings
+# How proportional to preferences is bandwidth distribution in a network
+# 1: Fair with respect to addresses without preferences
+# > 1: The bigger, the more respect is payed to preferences
+PROP_PROPORTIONALITY_FACTOR = 4
# MLP specific settings
# MLP defaults
Modified: gnunet/src/ats/experiments/example.exp
===================================================================
--- gnunet/src/ats/experiments/example.exp 2014-05-06 15:07:52 UTC (rev
33174)
+++ gnunet/src/ats/experiments/example.exp 2014-05-06 15:50:20 UTC (rev
33175)
@@ -1,10 +1,11 @@
[experiment]
- name = test
- max_duration = 15 s
- log_freq = 1000 ms
- cfg_file = experiments/gnunet_ats_sim_default.conf
-
-
+name = test
+max_duration = 15 s
+log_freq = 1000 ms
+cfg_file = experiments/gnunet_ats_sim_default.conf
+log_output_dir = data/
+log_append_time_stamp = no
+
[episode-0]
# Setup addresses
Modified: gnunet/src/ats/experiments/set_preference.exp
===================================================================
--- gnunet/src/ats/experiments/set_preference.exp 2014-05-06 15:07:52 UTC
(rev 33174)
+++ gnunet/src/ats/experiments/set_preference.exp 2014-05-06 15:50:20 UTC
(rev 33175)
@@ -1,23 +1,24 @@
# Example setting up two peers
[experiment]
- name = test
- max_duration = 15 s
- log_freq = 1000 ms
- cfg_file = experiments/gnunet_ats_sim_default.conf
-
-
+name = test
+max_duration = 15 s
+log_freq = 1000 ms
+log_prefix = set_preference
+cfg_file = experiments/gnunet_ats_sim_default.conf
+
[episode-0]
# Setup addresses
# operations = address_add, address_del, start_set_property,
stop_set_property,
# start_set_preference, stop_preference, start_request, stop_request
-duration = 5 s
+duration = 2 s
+
op-0-operation = address_add
op-0-address-id = 0
op-0-peer-id = 0
op-0-address-session = 0
-op-0-address-network = 0
+op-0-address-network = lan
op-0-address = 0_0_test
op-0-plugin = test
@@ -25,7 +26,7 @@
op-1-address-id = 1
op-1-peer-id = 1
op-1-address-session = 0
-op-1-address-network = 0
+op-1-address-network = lan
op-1-address = 1_1_test
op-1-plugin = test
@@ -37,18 +38,18 @@
[episode-1]
# Set delay
-duration = 1 s
+duration = 10 s
op-0-operation = start_set_preference
op-0-address-id = 0
op-0-peer-id = 0
op-0-client-id = 1
# constant, linear, sinus, random
-op-0-gen-type = constant
-op-0-base-rate= 10000
+op-0-gen-type = linear
+op-0-base-rate= 1000
op-0-max-rate = 10000
-op-0-period = 1000 ms
-op-0-frequency = 1000 ms
+op-0-period = 10 s
+op-0-frequency = 500 ms
# BANDWIDTH, LATENCY
op-0-pref = BANDWIDTH
@@ -58,12 +59,13 @@
op-1-peer-id = 1
op-1-client-id = 1
# constant, linear, sinus, random
-op-1-gen-type = linear
-op-1-base-rate= 10000
-op-1-max-rate = 20000
-op-1-period = 1000 ms
-op-1-frequency = 100 ms
-op-1-prop = DELAY
+op-1-gen-type = constant
+op-1-base-rate= 1000
+op-1-max-rate = 1000
+op-1-period = 10 s
+op-1-frequency = 500 ms
+# BANDWIDTH, LATENCY
+op-1-pref = BANDWIDTH
[episode-2]
# Shutdown
Modified: gnunet/src/ats/gnunet-ats-solver-eval.c
===================================================================
--- gnunet/src/ats/gnunet-ats-solver-eval.c 2014-05-06 15:07:52 UTC (rev
33174)
+++ gnunet/src/ats/gnunet-ats-solver-eval.c 2014-05-06 15:50:20 UTC (rev
33175)
@@ -2452,7 +2452,7 @@
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
"name", &e->name))
{
- fprintf (stderr, "Invalid %s", "name");
+ fprintf (stderr, "Invalid %s \n", "name");
free_experiment (e);
return NULL;
}
@@ -2462,7 +2462,7 @@
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment",
"log_prefix", &e->log_prefix))
{
- fprintf (stderr, "Invalid %s", "name");
+ fprintf (stderr, "Invalid %s \n", "log_prefix");
free_experiment (e);
return NULL;
}
@@ -2490,7 +2490,7 @@
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg,
"experiment",
"cfg_file", &e->cfg_file))
{
- fprintf (stderr, "Invalid %s", "cfg_file");
+ fprintf (stderr, "Invalid %s \n", "cfg_file");
free_experiment (e);
return NULL;
}
@@ -2500,7 +2500,7 @@
e->cfg = GNUNET_CONFIGURATION_create();
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (e->cfg, e->cfg_file))
{
- fprintf (stderr, "Invalid configuration %s", "cfg_file");
+ fprintf (stderr, "Invalid configuration %s \n", "cfg_file");
free_experiment (e);
return NULL;
}
@@ -2510,7 +2510,7 @@
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment",
"log_freq", &e->log_freq))
{
- fprintf (stderr, "Invalid %s", "log_freq");
+ fprintf (stderr, "Invalid %s \n", "log_freq");
free_experiment (e);
return NULL;
}
Modified: gnunet/src/ats/gnunet-service-ats_normalization.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.c 2014-05-06 15:07:52 UTC
(rev 33174)
+++ gnunet/src/ats/gnunet-service-ats_normalization.c 2014-05-06 15:50:20 UTC
(rev 33175)
@@ -53,11 +53,16 @@
void *client;
/**
- * Total preference for this peer
+ * Array of sum of absolute preferences for this client
*/
double f_abs_sum[GNUNET_ATS_PreferenceCount];
/**
+ * Array of sum of relative preferences for this client
+ */
+ double f_rel_sum[GNUNET_ATS_PreferenceCount];
+
+ /**
* List of peer preferences for this client
*/
@@ -98,15 +103,18 @@
struct GNUNET_PeerIdentity id;
/**
- * Absolute preference values
+ * Absolute preference values for all preference types
*/
double f_abs[GNUNET_ATS_PreferenceCount];
/**
- * Relative preference values
+ * Relative preference values for all preference types
*/
double f_rel[GNUNET_ATS_PreferenceCount];
+ /**
+ * Absolute point of time of next aging process
+ */
struct GNUNET_TIME_Absolute next_aging[GNUNET_ATS_PreferenceCount];
};
@@ -127,6 +135,20 @@
};
/**
+ * Quality Normalization
+ */
+struct Property
+{
+ uint32_t prop_type;
+ uint32_t atsi_type;
+ uint32_t min;
+ uint32_t max;
+};
+
+struct Property properties[GNUNET_ATS_QualityPropertiesCount];
+
+
+/**
* Callback to call on changing preference values
*/
static GAS_Normalization_preference_changed_cb pref_changed_cb;
@@ -184,128 +206,110 @@
* @param kind the kind
* @return the new relative preference
*/
-static double
-update_peers (struct GNUNET_PeerIdentity *id,
- enum GNUNET_ATS_PreferenceKind kind)
+static void
+update_relative_values_for_peer (const struct GNUNET_PeerIdentity *id,
+ enum GNUNET_ATS_PreferenceKind kind, struct PeerRelative *rp)
{
struct PreferenceClient *c_cur;
struct PreferencePeer *p_cur;
- struct PeerRelative *rp;
double f_rel_total;
+ double f_rel_sum;
double backup;
- unsigned int count;
+ unsigned int peer_count;
+ f_rel_sum = 0.0;
f_rel_total = 0.0;
- count = 0;
+ peer_count = 0;
/* For all clients */
for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next)
{
- /* Find peer with id */
+ /* For peer entries with this id */
for (p_cur = c_cur->p_head; NULL != p_cur; p_cur = p_cur->next)
{
+ f_rel_sum += p_cur->f_rel[kind];
if (0 == memcmp (id, &p_cur->id, sizeof(struct GNUNET_PeerIdentity)))
- break;
+ {
+ peer_count ++;
+ f_rel_total += p_cur->f_rel[kind];
+ }
+
}
- if (NULL != p_cur)
- {
- /* Found peer with id */
- f_rel_total += p_cur->f_rel[kind];
- count++;
- }
}
- /* Find a client */
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "%u clients have a total relative preference for peer `%s''s `%s' of
%.3f\n",
- count, GNUNET_i2s (id), GNUNET_ATS_print_preference_type (kind),
- f_rel_total);
- if (NULL != (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers, id)))
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "%u clients have a total relative preference for peer `%s' `%s' of %.3f
and for %s in total %.3f\n",
+ peer_count, GNUNET_i2s (id),
+ GNUNET_ATS_print_preference_type (kind),
+ f_rel_total,
+ GNUNET_ATS_print_preference_type (kind),
+ f_rel_sum);
+
+ /* Find entry for the peer containing relative values in the hashmap */
+ if (NULL != rp)
{
backup = rp->f_rel[kind];
- if (0 < count)
- {
- rp->f_rel[kind] = f_rel_total / count;
- }
+ if (f_rel_sum > 0)
+ rp->f_rel[kind] = f_rel_total / f_rel_sum;
else
{
+ /* No client had any preferences for this type and any peer */
rp->f_rel[kind] = DEFAULT_REL_PREFERENCE;
}
}
- else
- {
- return DEFAULT_REL_PREFERENCE;
- }
if ((backup != rp->f_rel[kind]) && (NULL != pref_changed_cb))
{
pref_changed_cb (pref_changed_cb_cls, &rp->id, kind, rp->f_rel[kind]);
}
-
- return rp->f_rel[kind];
}
/**
* Recalculate preference for a specific ATS property
*
* @param c the preference client
- * @param p the peer
* @param kind the preference kind
* @return the result
*/
-static double
-recalculate_rel_preferences (struct PreferenceClient *c,
- struct PreferencePeer *p, enum GNUNET_ATS_PreferenceKind kind)
+static void
+recalculate_relative_preferences (struct PreferenceClient *c, enum
GNUNET_ATS_PreferenceKind kind)
{
struct PreferencePeer *p_cur;
- struct PeerRelative *rp;
- double backup;
- double res;
- double ret;
- /* For this client: sum preferences to total preference */
- c->f_abs_sum[kind] = 0;
+ /* For this client: sum of absolute preference values for this preference */
+ c->f_abs_sum[kind] = 0.0;
+ /* For this client: sum of relative preference values for this preference
+ *
+ * Note: this value should also be 1.0, but:
+ * if no preferences exist due to aging, this value can be 0.0
+ * and the client can be removed */
+ c->f_rel_sum[kind] = 0.0;
+
for (p_cur = c->p_head; NULL != p_cur; p_cur = p_cur->next)
c->f_abs_sum[kind] += p_cur->f_abs[kind];
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Client %p has total preference for %s of %.3f\n", c->client,
- GNUNET_ATS_print_preference_type (kind), c->f_abs_sum[kind]);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %p has sum of total preferences for %s of %.3f\n",
+ c->client, GNUNET_ATS_print_preference_type (kind), c->f_abs_sum[kind]);
- ret = DEFAULT_REL_PREFERENCE;
/* For all peers: calculate relative preference */
for (p_cur = c->p_head; NULL != p_cur; p_cur = p_cur->next)
{
/* Calculate relative preference for specific kind */
- backup = p_cur->f_rel[kind];
- if (DEFAULT_ABS_PREFERENCE == c->f_abs_sum[kind])
- /* No peer has a preference for this property,
- * so set default preference */
- p_cur->f_rel[kind] = DEFAULT_REL_PREFERENCE;
- else
- p_cur->f_rel[kind] = (c->f_abs_sum[kind] + p_cur->f_abs[kind])
- / c->f_abs_sum[kind];
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Client %p: peer `%s' has relative preference for %s of %.3f\n",
- c->client, GNUNET_i2s (&p_cur->id),
- GNUNET_ATS_print_preference_type (kind), p_cur->f_rel[kind]);
+ /* Every application has a preference for each peer between
+ * [0 .. 1] in relative values
+ * and [0 .. inf] in absolute values */
+ p_cur->f_rel[kind] = p_cur->f_abs[kind] / c->f_abs_sum[kind];
+ c->f_rel_sum[kind] += p_cur->f_rel[kind];
- if (p_cur->f_rel[kind] != backup)
- {
- /* Value changed, recalculate */
- res = update_peers (&p_cur->id, kind);
- if (0 == memcmp (&p->id, &p_cur->id, sizeof(struct GNUNET_PeerIdentity)))
- ret = res;
- }
- else
- {
- /* Value did not chang, return old value*/
- GNUNET_assert(
- NULL != (rp = GNUNET_CONTAINER_multipeermap_get (preference_peers,
&p->id)));
- ret = rp->f_rel[kind];
- }
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %p has relative preference for %s for peer `%s' of %.3f\n",
+ c->client,
+ GNUNET_ATS_print_preference_type (kind),
+ GNUNET_i2s (&p_cur->id),
+ p_cur->f_rel[kind]);
}
- return ret;
+
}
/**
@@ -316,8 +320,8 @@
* @param score_abs the absolute value
* @return the new relative preference value
*/
-static double
-update_preference (struct PreferenceClient *c, struct PreferencePeer *p,
+static void
+update_abs_preference (struct PreferenceClient *c, struct PreferencePeer *p,
enum GNUNET_ATS_PreferenceKind kind, float score_abs)
{
double score = score_abs;
@@ -327,7 +331,8 @@
{
case GNUNET_ATS_PREFERENCE_BANDWIDTH:
case GNUNET_ATS_PREFERENCE_LATENCY:
- p->f_abs[kind] = (p->f_abs[kind] + score) / 2;
+ p->f_abs[kind] = score;
+ /* p->f_abs[kind] = (p->f_abs[kind] + score) / 2; */
p->next_aging[kind] = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get
(),
PREF_AGING_INTERVAL);
break;
@@ -336,9 +341,34 @@
default:
break;
}
- return recalculate_rel_preferences (c, p, kind);
}
+static int update_iterator (void *cls,
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
+{
+ enum GNUNET_ATS_PreferenceKind *kind = cls;
+ update_relative_values_for_peer (key, (*kind), (struct PeerRelative *)
value);
+ return GNUNET_OK;
+}
+
+static void
+run_preference_update (struct PreferenceClient *c_cur,
+ struct PreferencePeer *p_cur,enum GNUNET_ATS_PreferenceKind kind,
+ float score_abs)
+{
+ double old_value;
+
+ /* Update relative value */
+ old_value = p_cur->f_rel[kind];
+ recalculate_relative_preferences (c_cur, kind);
+ if (p_cur->f_rel[kind] == old_value)
+ return;
+
+ /* Relative preference value changed, recalculate for all peers */
+ GNUNET_CONTAINER_multipeermap_iterate (preference_peers, &update_iterator,
&kind);
+}
+
/**
* Reduce absolute preferences since they got old
*
@@ -373,15 +403,19 @@
backup = p->f_abs[i];
if (p->f_abs[i] > DEFAULT_ABS_PREFERENCE)
p->f_abs[i] *= PREF_AGING_FACTOR;
+
if (p->f_abs[i] <= DEFAULT_ABS_PREFERENCE + PREF_EPSILON)
p->f_abs[i] = DEFAULT_ABS_PREFERENCE;
- if ((p->f_abs[i] != DEFAULT_ABS_PREFERENCE)
- && (backup != p->f_abs[i]))
+
+ if ( (p->f_abs[i] != DEFAULT_ABS_PREFERENCE) &&
+ (backup != p->f_abs[i]) )
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Aged preference for peer `%s' from %.3f to %.3f\n",
GNUNET_i2s (&p->id), backup, p->f_abs[i]);
- recalculate_rel_preferences (p->client, p, i);
+
+ run_preference_update(cur_client, p, i, p->f_abs[i]);
+
p->next_aging[i] = GNUNET_TIME_absolute_add (
GNUNET_TIME_absolute_get (), PREF_AGING_INTERVAL);
values_to_update++;
@@ -408,27 +442,31 @@
/**
* Normalize an updated preference value
*
- * @param src the client with this preference
+ * @param client the client with this preference
* @param peer the peer to change the preference for
* @param kind the kind to change the preference
* @param score_abs the normalized score
*/
void
-GAS_normalization_normalize_preference (void *src,
+GAS_normalization_normalize_preference (void *client,
const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind
kind,
float score_abs)
{
struct PreferenceClient *c_cur;
struct PreferencePeer *p_cur;
struct PeerRelative *r_cur;
+ double old_value;
int i;
- GNUNET_assert(NULL != src);
+ GNUNET_assert(NULL != client);
GNUNET_assert(NULL != peer);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "Client %p changes preference for peer `%s' for `%s' to %.2f\n", src,
- GNUNET_i2s (peer), GNUNET_ATS_print_preference_type (kind), score_abs);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %p changes preference for peer `%s' for `%s' to %.2f\n",
+ client,
+ GNUNET_i2s (peer),
+ GNUNET_ATS_print_preference_type (kind),
+ score_abs);
if (kind >= GNUNET_ATS_PreferenceCount)
{
@@ -439,16 +477,22 @@
/* Find preference client */
for (c_cur = pc_head; NULL != c_cur; c_cur = c_cur->next)
{
- if (src == c_cur->client)
+ if (client == c_cur->client)
break;
}
/* Not found: create new preference client */
if (NULL == c_cur)
{
c_cur = GNUNET_new (struct PreferenceClient);
- c_cur->client = src;
+ c_cur->client = client;
+ for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
+ {
+ c_cur->f_abs_sum[i] = DEFAULT_ABS_PREFERENCE;
+ c_cur->f_rel_sum[i] = DEFAULT_REL_PREFERENCE;
+ }
+
GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, c_cur);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding new client %p \n", c_cur);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding new client %p \n", c_cur);
}
/* Find entry for peer */
@@ -464,32 +508,42 @@
p_cur->id = (*peer);
for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
{
- /* Default value per peer absolut preference for a quality:
- * No value set, so absolute preference 0 */
+ /* Default value per peer absolute preference for a preference: 0 */
p_cur->f_abs[i] = DEFAULT_ABS_PREFERENCE;
/* Default value per peer relative preference for a quality: 1.0 */
p_cur->f_rel[i] = DEFAULT_REL_PREFERENCE;
p_cur->next_aging[i] = GNUNET_TIME_UNIT_FOREVER_ABS;
}
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer %p for client %p \n",
+ p_cur, c_cur);
GNUNET_CONTAINER_DLL_insert(c_cur->p_head, c_cur->p_tail, p_cur);
}
+ /* Create struct for peer */
if (NULL == GNUNET_CONTAINER_multipeermap_get (preference_peers, peer))
{
r_cur = GNUNET_new (struct PeerRelative);
r_cur->id = (*peer);
for (i = 0; i < GNUNET_ATS_PreferenceCount; i++)
r_cur->f_rel[i] = DEFAULT_REL_PREFERENCE;
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (preference_peers,
&r_cur->id, r_cur,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_assert(
+ GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (preference_peers,
+ &r_cur->id, r_cur,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
+ /* Update absolute value */
+ old_value = p_cur->f_abs[kind];
+ update_abs_preference (c_cur, p_cur, kind, score_abs);
+ if (p_cur->f_abs[kind] == old_value)
+ return;
+
+ run_preference_update (c_cur, p_cur, kind, score_abs);
+
+ /* Start aging task */
if (GNUNET_SCHEDULER_NO_TASK == aging_task)
aging_task = GNUNET_SCHEDULER_add_delayed (PREF_AGING_INTERVAL,
&preference_aging, NULL );
- update_preference (c_cur, p_cur, kind, score_abs);
}
/**
@@ -576,21 +630,7 @@
return norm_values;
}
-
/**
- * Quality Normalization
- */
-struct Property
-{
- uint32_t prop_type;
- uint32_t atsi_type;
- uint32_t min;
- uint32_t max;
-};
-
-struct Property properties[GNUNET_ATS_QualityPropertiesCount];
-
-/**
* Normalize a specific ATS type with the values in queue
* @param address the address
* @param atsi the ats information
Modified: gnunet/src/ats/gnunet-service-ats_normalization.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.h 2014-05-06 15:07:52 UTC
(rev 33174)
+++ gnunet/src/ats/gnunet-service-ats_normalization.h 2014-05-06 15:50:20 UTC
(rev 33175)
@@ -29,9 +29,9 @@
#define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10)
#define PREF_AGING_FACTOR 0.95
-#define PREF_EPSILON 0.1
+#define PREF_EPSILON 0.01
-#define DEFAULT_REL_PREFERENCE 1.0
+#define DEFAULT_REL_PREFERENCE 0.0
#define DEFAULT_ABS_PREFERENCE 0.0
#define DEFAULT_REL_QUALITY 1.0
Modified: gnunet/src/ats/plugin_ats_mlp.c
===================================================================
--- gnunet/src/ats/plugin_ats_mlp.c 2014-05-06 15:07:52 UTC (rev 33174)
+++ gnunet/src/ats/plugin_ats_mlp.c 2014-05-06 15:50:20 UTC (rev 33175)
@@ -1681,7 +1681,7 @@
int c;
preferences = mlp->get_preferences (mlp->get_preferences_cls, peer);
- res = 0.0;
+ res = 1.0;
for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
{
if (c != GNUNET_ATS_PREFERENCE_END)
Modified: gnunet/src/ats/plugin_ats_proportional.c
===================================================================
--- gnunet/src/ats/plugin_ats_proportional.c 2014-05-06 15:07:52 UTC (rev
33174)
+++ gnunet/src/ats/plugin_ats_proportional.c 2014-05-06 15:50:20 UTC (rev
33175)
@@ -203,13 +203,8 @@
*
*/
-#define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10)
-#define PREF_AGING_FACTOR 0.95
+#define PROPORTIONALITY_FACTOR 2.0
-#define DEFAULT_REL_PREFERENCE 1.0
-#define DEFAULT_ABS_PREFERENCE 0.0
-#define MIN_UPDATE_INTERVAL GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10)
-
/**
* A handle for the proportional solver
*/
@@ -292,6 +287,10 @@
*/
unsigned int network_count;
+ /**
+ * Proportionality factor
+ */
+ double prop_factor;
};
/**
@@ -400,6 +399,7 @@
struct GAS_PROPORTIONAL_Handle *s;
struct Network * cur;
char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
+ unsigned long long prop_factor;
int c;
GNUNET_assert (NULL != env);
@@ -440,6 +440,23 @@
s->addresses = env->addresses;
s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
+ if (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_number(s->env->cfg,
"ats",
+ "PROP_PROPORTIONALITY_FACTOR", &prop_factor))
+ {
+ if (prop_factor > 1)
+ s->prop_factor = (double) prop_factor;
+ else
+ {
+ GNUNET_break (0);
+ s->prop_factor = PROPORTIONALITY_FACTOR;
+ }
+ }
+ else
+ s->prop_factor = PROPORTIONALITY_FACTOR;
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Using proportionality factor %.0f\n",
+ s->prop_factor);
+
+
for (c = 0; c < env->network_count; c++)
{
cur = &s->network_entries[c];
@@ -557,18 +574,21 @@
struct Network *net, struct ATS_Address *address_except)
{
struct AddressSolverInformation *asi;
- struct AddressWrapper *cur;
+ struct AddressWrapper *cur_address;
unsigned long long remaining_quota_in = 0;
unsigned long long quota_out_used = 0;
unsigned long long remaining_quota_out = 0;
unsigned long long quota_in_used = 0;
+ int count_addresses;
uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- double peer_prefs;
- double total_prefs; /* Important: has to be double not float due to
precision */
+ double relative_peer_prefence;
+ double sum_relative_peer_prefences; /* Important: has to be double not float
due to precision */
double cur_pref; /* Important: has to be double not float due to precision */
- const double *t = NULL; /* Important: has to be double not float due to
precision */
- int c;
+ double peer_weight;
+ double total_weight;
+ const double *peer_relative_prefs = NULL; /* Important: has to be double not
float due to precision */
+
unsigned long long assigned_quota_in = 0;
unsigned long long assigned_quota_out = 0;
@@ -603,49 +623,49 @@
remaining_quota_out = net->total_quota_out - (net->active_addresses *
min_bw);
LOG(GNUNET_ERROR_TYPE_DEBUG, "Remaining bandwidth : (in/out): %llu/%llu \n",
remaining_quota_in, remaining_quota_out);
- total_prefs = 0.0;
- for (cur = net->head; NULL != cur; cur = cur->next)
+ sum_relative_peer_prefences = 0.0;
+
+ /* Calculate sum of relative preference for active addresses in this network
*/
+ count_addresses = 0;
+ for (cur_address = net->head; NULL != cur_address; cur_address =
cur_address->next)
{
- if (GNUNET_YES == cur->addr->active)
- {
- GNUNET_assert(
- NULL != (t = s->get_preferences (s->get_preferences_cls,
&cur->addr->peer)));
+ if (GNUNET_YES != cur_address->addr->active)
+ continue;
- peer_prefs = 0.0;
- for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
- {
- if (c != GNUNET_ATS_PREFERENCE_END)
- {
- //fprintf (stderr, "VALUE[%u] %s %.3f \n", c, GNUNET_i2s
(&cur->addr->peer), t[c]);
- peer_prefs += t[c];
- }
- }
- total_prefs += (peer_prefs / (GNUNET_ATS_PreferenceCount - 1));
- }
+ GNUNET_assert( NULL != (peer_relative_prefs = s->get_preferences
(s->get_preferences_cls,
+ &cur_address->addr->peer)));
+ relative_peer_prefence = 0.0;
+ relative_peer_prefence +=
peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH];
+ sum_relative_peer_prefences += relative_peer_prefence;
+ count_addresses ++;
}
- for (cur = net->head; NULL != cur; cur = cur->next)
+
+ GNUNET_assert (count_addresses == net->active_addresses);
+
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "Total relative preference %.3f for %u addresses in network %s\n",
+ sum_relative_peer_prefences, net->active_addresses, net->desc);
+
+ for (cur_address = net->head; NULL != cur_address; cur_address =
cur_address->next)
{
- if (GNUNET_YES == cur->addr->active)
+ if (GNUNET_YES == cur_address->addr->active)
{
- cur_pref = 0.0;
- GNUNET_assert(
- NULL != (t = s->get_preferences (s->get_preferences_cls,
&cur->addr->peer)));
+ GNUNET_assert( NULL != (peer_relative_prefs =
+ s->get_preferences (s->get_preferences_cls,
&cur_address->addr->peer)));
- for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
- {
- if (c != GNUNET_ATS_PREFERENCE_END)
- cur_pref += t[c];
- }
- cur_pref /= 2;
+ cur_pref = peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH];
+ total_weight = net->active_addresses +
+ s->prop_factor * sum_relative_peer_prefences;
+ peer_weight = (1.0 + (s->prop_factor * cur_pref));
assigned_quota_in = min_bw
- + ((cur_pref / total_prefs) * remaining_quota_in);
+ + ((peer_weight / total_weight) * remaining_quota_in);
assigned_quota_out = min_bw
- + ((cur_pref / total_prefs) * remaining_quota_out);
+ + ((peer_weight / total_weight) * remaining_quota_out);
LOG (GNUNET_ERROR_TYPE_INFO,
- "New quota for peer `%s' with preference (cur/total) %.3f/%.3f
(in/out): %llu / %llu\n",
- GNUNET_i2s (&cur->addr->peer), cur_pref, total_prefs,
+ "New quota for peer `%s' with weight (cur/total) %.3f/%.3f (in/out):
%llu / %llu\n",
+ GNUNET_i2s (&cur_address->addr->peer), peer_weight, total_weight,
assigned_quota_in, assigned_quota_out);
}
else
@@ -663,7 +683,7 @@
assigned_quota_out = UINT32_MAX;
/* Compare to current bandwidth assigned */
- asi = cur->addr->solver_information;
+ asi = cur_address->addr->solver_information;
asi->calculated_quota_in_NBO = htonl (assigned_quota_in);
asi->calculated_quota_out_NBO = htonl (assigned_quota_out);
}
@@ -1140,13 +1160,11 @@
GNUNET_assert(peer != NULL);
/* Add to list of pending requests */
- if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests,
- peer))
+ if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, peer))
{
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (s->requests,
- peer, NULL,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_assert(
+ GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (s->requests, peer,
NULL,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
}
/* Get address with: stick to current address, lower distance, lower latency
*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33175 - in gnunet/src/ats: . experiments,
gnunet <=