struct GNUNET_PeerIdentity id;
};
+ /**
+ * Pending Address suggestion requests
+ */
+ struct GAS_Addresses_Preference_Clients
+ {
+ /**
+ * Next in DLL
+ */
+ struct GAS_Addresses_Preference_Clients *next;
+
+ /**
+ * Previous in DLL
+ */
+ struct GAS_Addresses_Preference_Clients *prev;
+
+ /**
+ * Peer ID
+ */
+ void *client;
+ };
+
/**
* Handle for ATS address component
*/
*/
int running;
+ /**
+ * Preferences clients
+ */
+ int pref_clients;
+
/**
* Configured ATS solver
*/
*/
struct GAS_Addresses_Suggestion_Requests *pending_requests_tail;
+ /**
+ * Address suggestion requests DLL head
+ */
+ struct GAS_Addresses_Preference_Clients *preference_clients_head;
+
+ /**
+ * Address suggestion requests DLL head
+ */
+ struct GAS_Addresses_Preference_Clients *preference_clients_tail;
+
/**
* Solver functions
*/
* @param plugin_name plugin
* @param plugin_addr address
* @param plugin_addr_len address length
+ * @param local_address_info additional local info for the address
* @param session_id session
* @return the ATS_Address
*/
static struct ATS_Address *
-create_address (const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id)
+create_address (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id)
{
struct ATS_Address *aa = NULL;
int c1;
memcpy (&aa[1], plugin_addr, plugin_addr_len);
aa->plugin = GNUNET_strdup (plugin_name);
aa->session_id = session_id;
+ aa->local_address_info = local_address_info;
aa->active = GNUNET_NO;
aa->used = GNUNET_NO;
aa->solver_information = NULL;
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @return an ATS_address or NULL
*/
static struct ATS_Address *
find_exact_address (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id)
{
struct ATS_Address *aa;
struct ATS_Address *ea;
aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
- session_id);
+ local_address_info, session_id);
/* Get existing address or address with session == 0 */
ea = find_equivalent_address (handle, peer, aa);
return ea;
}
+/**
+ * Function allowing the solver to obtain normalized preference
+ * values from solver
+ *
+ * @param cls unused
+ * @param id the peer to return the normalized properties for
+ * @return array of double values with |GNUNET_ATS_PreferenceCount| elements
+ */
+const double *
+get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
+{
+ return GAS_normalization_get_preferences_by_peer (id);
+}
+
+/**
+ * Function allowing the solver to obtain normalized property
+ * values for an address from solver
+ *
+ * @param cls unused
+ * @param address the address
+ * @return array of double values with |GNUNET_ATS_QualityPropertiesCount| elements
+ */
+const double *
+get_property_cb (void *cls, const struct ATS_Address *address)
+{
+ return GAS_normalization_get_properties ((struct ATS_Address *) address);
+}
+
/**
* Extract an ATS performance info from an address
*
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @param atsi performance information for this address
* @param atsi_count number of performance information contained
*/
void
GAS_addresses_add (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct ATS_Address *new_address;
struct ATS_Address *existing_address;
GNUNET_assert(NULL != handle->addresses);
new_address = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
- session_id);
+ local_address_info, session_id);
atsi_delta = NULL;
disassemble_ats_information (new_address, atsi, atsi_count, &atsi_delta,
&atsi_delta_count);
if (existing_address == NULL )
{
/* Add a new address */
+ new_address->t_added = GNUNET_TIME_absolute_get();
+ new_address->t_last_activity = GNUNET_TIME_absolute_get();
GNUNET_assert(
GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (handle->addresses,
peer,
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"Adding new address %p for peer `%s', length %u, session id %u, %s\n",
- new_address, GNUNET_i2s (peer), plugin_addr_len, session_id,
+ new_address,
+ GNUNET_i2s (peer),
+ plugin_addr_len, session_id,
GNUNET_ATS_print_network_type (addr_net));
/* Tell solver about new address */
GNUNET_i2s (peer), existing_address, session_id,
GNUNET_ATS_print_network_type (addr_net));
/* We have an address without an session, update this address */
+ existing_address->t_added = GNUNET_TIME_absolute_get();
+ existing_address->t_last_activity = GNUNET_TIME_absolute_get();
atsi_delta = NULL;
atsi_delta_count = 0;
if (GNUNET_YES
&& (addr_net != ntohl (atsi_delta[c1].value)))
{
/* Network type changed */
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Address for peer `%s' %p changed from network %s to %s\n",
GNUNET_i2s (peer), existing_address,
GNUNET_ATS_print_network_type (addr_net),
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @param atsi performance information for this address
* @param atsi_count number of performance information contained
*/
void
GAS_addresses_update (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Information *atsi,
+ uint32_t atsi_count)
{
struct ATS_Address *aa;
struct GNUNET_ATS_Information *atsi_delta;
/* Get existing address */
aa = find_exact_address (handle, peer, plugin_name, plugin_addr,
- plugin_addr_len, session_id);
+ plugin_addr_len, local_address_info, session_id);
if (aa == NULL )
- {
- /* GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Tried to update unknown address for peer `%s' `%s' session id %u\n", */
- /* GNUNET_i2s (peer), plugin_name, session_id); */
- /* GNUNET_break (0); */
return;
- }
-
if (NULL == aa->solver_information)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "Tried to update unknown address for peer `%s' `%s' session id %u\n",
- GNUNET_i2s (peer), plugin_name, session_id);
return;
- }
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s' address \n",
"ADDRESS UPDATE", GNUNET_i2s (peer), aa);
/* Update address */
+ aa->t_last_activity = GNUNET_TIME_absolute_get();
if (session_id != aa->session_id)
{
/* Session changed */
GNUNET_break(0);
return GNUNET_OK;
}
-
- if (aa->addr_len == 0)
+ if (GNUNET_HELLO_ADDRESS_INFO_INBOUND ==
+ (aa->local_address_info && GNUNET_HELLO_ADDRESS_INFO_INBOUND))
{
/* Inbound connection died, delete full address */
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
*/
void
GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id)
+ const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id)
{
struct ATS_Address *ea;
struct DestroyContext dc;
/* Get existing address */
ea = find_exact_address (handle, peer, plugin_name, plugin_addr,
- plugin_addr_len, session_id);
+ plugin_addr_len, local_address_info, session_id);
if (ea == NULL )
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Tried to destroy unknown address for peer `%s' `%s' session id %u\n",
GNUNET_i2s (peer), plugin_name, session_id);
return;
}
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' for peer `%s' address %p session %u\n", "ADDRESS DESTROY",
GNUNET_i2s (peer), ea, session_id);
GNUNET_break(0 < strlen (plugin_name));
dc.handle = handle;
dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
- session_id);
+ local_address_info, session_id);
GNUNET_CONTAINER_multipeermap_get_multiple (handle->addresses,
peer,
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
* @param plugin_addr_len length of the plugin address
+ * @param local_address_info the local address for the address
* @param session_id session id, can be 0
* @param in_use GNUNET_YES if GNUNET_NO
* @return GNUNET_SYSERR on failure (address unknown ...)
int
GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
+ const void *plugin_addr, size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
int in_use)
{
struct ATS_Address *ea;
return GNUNET_SYSERR;
ea = find_exact_address (handle, peer, plugin_name, plugin_addr,
- plugin_addr_len, session_id);
+ plugin_addr_len, local_address_info, session_id);
if (NULL == ea)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
"Trying to set unknown address `%s' `%s' `%u' to %s \n",
GNUNET_i2s (peer), plugin_name, session_id,
(GNUNET_NO == in_use) ? "NO" : "YES");
if (ea->used == in_use)
{
GNUNET_break(0);
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
"Address in use called multiple times for peer `%s': %s -> %s \n",
GNUNET_i2s (peer), (GNUNET_NO == ea->used) ? "NO" : "YES",
(GNUNET_NO == in_use) ? "NO" : "YES");
/* Tell solver about update */
ea->used = in_use;
+ ea->t_last_activity = GNUNET_TIME_absolute_get();
handle->env.sf.s_address_update_inuse (handle->solver, ea, ea->used);
return GNUNET_OK;
}
if (NULL == cur)
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"No address requests pending for peer `%s', cannot remove!\n",
GNUNET_i2s (peer));
return;
struct GAS_Addresses_Suggestion_Requests *cur = handle->pending_requests_head;
struct ATS_Address *aa;
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Received `%s' for peer `%s'\n",
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received `%s' for peer `%s'\n",
"REQUEST ADDRESS", GNUNET_i2s (peer));
if (GNUNET_NO == handle->running)
}
if (NULL == cur)
{
- cur = GNUNET_malloc (sizeof (struct GAS_Addresses_Suggestion_Requests));
+ cur = GNUNET_new (struct GAS_Addresses_Suggestion_Requests);
cur->id = (*peer);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Adding new address suggestion request for `%s'\n",
aa, GNUNET_i2s (peer));
GAS_scheduling_transmit_address_suggestion (peer, aa->plugin, aa->addr,
- aa->addr_len, aa->session_id, aa->atsi, aa->atsi_count,
+ aa->addr_len, aa->local_address_info, aa->session_id,
+ aa->atsi, aa->atsi_count,
aa->assigned_bw_out, aa->assigned_bw_in);
aa->block_interval = GNUNET_TIME_relative_add (aa->block_interval,
}
-
static int
-eval_count_active_it (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
+eval_count_active_it (void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ void *obj)
{
int *request_fulfilled = cls;
struct ATS_Address *addr = obj;
return GNUNET_YES;
}
-struct SummaryContext {
+
+/**
+ * Summary context
+ */
+struct SummaryContext
+{
+ /**
+ * Sum of the utilized inbound bandwidth per network
+ */
unsigned long long bandwidth_in_assigned[GNUNET_ATS_NetworkTypeCount];
+
+ /**
+ * Sum of the utilized outbound bandwidth per network
+ */
unsigned long long bandwidth_out_assigned[GNUNET_ATS_NetworkTypeCount];
+
+ /**
+ * Sum addresses within a network
+ */
unsigned int addresses_in_network[GNUNET_ATS_NetworkTypeCount];
};
static int
eval_sum_bw_used (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
{
+ struct SummaryContext *ctx = cls;
struct ATS_Address *addr = obj;
int networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
int net;
- struct SummaryContext *ctx = cls;
-
int c;
if (GNUNET_YES == addr->active)
ctx->bandwidth_out_assigned[c] += ntohl (addr->assigned_bw_out.value__);
}
}
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Active address in %s with (in/out) %llu/%llu Bps\n",
- GNUNET_ATS_print_network_type(net),
- ntohl (addr->assigned_bw_in.value__),
- ntohl (addr->assigned_bw_out.value__));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Active address in %s with (in/out) %u/%u Bps\n",
+ GNUNET_ATS_print_network_type (net),
+ (unsigned int) ntohl (addr->assigned_bw_in.value__),
+ (unsigned int) ntohl (addr->assigned_bw_out.value__));
}
return GNUNET_OK;
}
+/**
+ * Summary context
+ */
+struct RelativityContext
+{
+
+ struct GAS_Addresses_Handle *ah;
+};
+
+
+static int
+find_active_address (void *cls, const struct GNUNET_PeerIdentity *id, void *obj)
+{
+ struct ATS_Address **res = cls;
+ struct ATS_Address *addr = obj;
+
+ if (GNUNET_YES == addr->active)
+ (*res) = addr;
+
+ if (NULL != (*res))
+ return GNUNET_NO;
+ else
+ return GNUNET_YES;
+}
+
/**
* Evaluate current bandwidth assignment
*
GAS_addresses_evaluate_assignment (struct GAS_Addresses_Handle *ah)
{
struct GAS_Addresses_Suggestion_Requests *cur;
+ struct GAS_Addresses_Preference_Clients *pcur;
int c;
float quality_requests_fulfilled = 0.0;
/* 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)
}
/* 3) How well does selection match application requirements */
- /* TODO */
- include_requirements = GNUNET_NO;
+ if (0 == ah->pref_clients)
+ {
+ include_requirements = 0;
+ }
+ else
+ {
+ for (c = 0; c < GNUNET_ATS_PreferenceCount; c++)
+ {
+ prefs_fulfill[c] = 0.0;
+ prefs_clients[c] = 0;
+ }
+ 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++)
+ {
+ if (prefs[c] == GNUNET_ATS_PREFERENCE_END)
+ continue;
+ 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 = 1;
+ }
/* GUQ */
if (include_requests + include_utilization + include_requirements > 0)
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,
ah->env.sf.s_address_update_property (ah->solver, address, type, 0, prop_rel);
}
-/**
- * Function allowing the solver to obtain normalized preference
- * values from solver
- *
- * @param cls unused
- * @param id the peer to return the normalized properties for
- * @return array of double values with |GNUNET_ATS_PreferenceCount| elements
- */
-const double *
-get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
+static struct GAS_Addresses_Preference_Clients *
+find_preference_client (struct GAS_Addresses_Handle *handle, void *client)
{
- return GAS_normalization_get_preferences (id);
+ struct GAS_Addresses_Preference_Clients *cur;
+
+ for (cur = handle->preference_clients_head; NULL != cur; cur = cur->next)
+ {
+ if (cur->client == client)
+ return cur;
+ }
+ return NULL;
}
/**
- * Function allowing the solver to obtain normalized property
- * values for an address from solver
+ * A performance client disconnected
*
- * @param cls unused
- * @param address the address
- * @return array of double values with |GNUNET_ATS_QualityPropertiesCount| elements
+ * @param handle address handle
+ * @param client the client
*/
-const double *
-get_property_cb (void *cls, const struct ATS_Address *address)
+
+void
+GAS_addresses_preference_client_disconnect (struct GAS_Addresses_Handle *handle,
+ void *client)
{
- return GAS_normalization_get_properties ((struct ATS_Address *) address);
+ struct GAS_Addresses_Preference_Clients * pc;
+ if (NULL != (pc = find_preference_client (handle, client)))
+ {
+ GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head,
+ handle->preference_clients_tail, pc);
+ GNUNET_free (pc);
+ GNUNET_assert (handle->pref_clients > 0);
+ handle->pref_clients --;
+ GNUNET_STATISTICS_set (handle->stat, "# active performance clients", handle->pref_clients, GNUNET_NO);
+ }
+ GAS_normalization_preference_client_disconnect (client);
}
/**
* @param score_abs the new preference score
*/
void
-GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
+GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle,
void *client, const struct GNUNET_PeerIdentity *peer,
enum GNUNET_ATS_PreferenceKind kind, float score_abs)
{
+ struct GAS_Addresses_Preference_Clients * pc;
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' for peer `%s' for client %p\n", "CHANGE PREFERENCE",
GNUNET_i2s (peer), client);
GNUNET_CONTAINER_multipeermap_contains (handle->addresses,
peer))
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' for unknown peer `%s' from client %p\n",
"CHANGE PREFERENCE", GNUNET_i2s (peer), client);
return;
}
+ if (NULL == find_preference_client (handle, client))
+ {
+ pc = GNUNET_new (struct GAS_Addresses_Preference_Clients);
+ pc->client = client;
+ GNUNET_CONTAINER_DLL_insert (handle->preference_clients_head,
+ handle->preference_clients_tail, pc);
+ handle->pref_clients ++;
+ GNUNET_STATISTICS_set (handle->stat, "# active performance clients", handle->pref_clients, GNUNET_NO);
+ }
+
handle->env.sf.s_bulk_start (handle->solver);
/* Tell normalization about change, normalization will call callback if preference changed */
GAS_normalization_normalize_preference (client, peer, kind, score_abs);
GNUNET_CONTAINER_multipeermap_contains (handle->addresses,
peer))
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' for unknown peer `%s' from client %p\n",
"PREFERENCE FEEDBACK", GNUNET_i2s (peer), application);
return;
}
if (NULL == cur)
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Nobody is interested in peer `%s' :(\n",
- GNUNET_i2s (&address->peer));
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "Nobody is interested in peer `%s' :(\n",
+ GNUNET_i2s (&address->peer));
return;
}
if ((0 == ntohl (address->assigned_bw_in.value__))
&& (0 == ntohl (address->assigned_bw_out.value__)))
{
- GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Telling transport to disconnect peer `%s'\n",
- GNUNET_i2s (&address->peer));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Telling transport to disconnect peer `%s'\n",
+ GNUNET_i2s (&address->peer));
}
else
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Sending bandwidth update for peer `%s': %llu %llu\n",
- GNUNET_i2s (&address->peer), address->assigned_bw_out,
- address->assigned_bw_out);
+ "Sending bandwidth update for peer `%s': %u %u\n",
+ GNUNET_i2s (&address->peer),
+ (unsigned int) ntohl (address->assigned_bw_out.value__),
+ (unsigned int) ntohl (address->assigned_bw_out.value__));
}
/* *Notify scheduling clients about suggestion */
GAS_scheduling_transmit_address_suggestion (&address->peer, address->plugin,
- address->addr, address->addr_len, address->session_id, address->atsi,
+ address->addr, address->addr_len, address->local_address_info,
+ address->session_id, address->atsi,
address->atsi_count, address->assigned_bw_out, address->assigned_bw_in);
}
+
/**
* Initialize address subsystem. The addresses subsystem manages the addresses
* known and current performance information. It has a solver component
char *plugin_short;
int c;
- ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle));
+ ah = GNUNET_new (struct GAS_Addresses_Handle);
ah->running = GNUNET_NO;
ah->stat = (struct GNUNET_STATISTICS_Handle *) stats;
/* Initialize the addresses database */
ah->addresses = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
+ ah->pref_clients = 0;
GNUNET_assert(NULL != ah->addresses);
/* Figure out configured solution method */
- plugin_short = NULL;
if (GNUNET_SYSERR
== GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str))
{
for (c = 0; c < strlen (mode_str); c++)
mode_str[c] = toupper (mode_str[c]);
if (0 == strcmp (mode_str, "PROPORTIONAL"))
- {
ah->ats_mode = MODE_PROPORTIONAL;
- plugin_short = "proportional";
- }
else if (0 == strcmp (mode_str, "MLP"))
{
ah->ats_mode = MODE_MLP;
- plugin_short = "mlp";
#if !HAVE_LIBGLPK
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"Assignment method `%s' configured, but GLPK is not available, please install \n",
mode_str);
ah->ats_mode = MODE_PROPORTIONAL;
- plugin_short = "proportional";
#endif
}
else if (0 == strcmp (mode_str, "RIL"))
- {
ah->ats_mode = MODE_RIL;
- plugin_short = "ril";
- }
else
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
"Invalid resource assignment method `%s' configured, using proportional approach\n",
mode_str);
ah->ats_mode = MODE_PROPORTIONAL;
- plugin_short = "proportional";
}
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;
ah->env.in_quota[c] = quotas_in[c];
}
+ switch (ah->ats_mode) {
+ case MODE_PROPORTIONAL:
+ plugin_short = "proportional";
+ break;
+ case MODE_MLP:
+ plugin_short = "mlp";
+ break;
+ case MODE_RIL:
+ plugin_short = "ril";
+ break;
+ default:
+ plugin_short = NULL;
+ break;
+ }
GNUNET_asprintf (&ah->plugin, "libgnunet_plugin_ats_%s", plugin_short);
GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Initializing solver `%s '`%s'\n"), plugin_short, ah->plugin);
if (NULL == (ah->solver = GNUNET_PLUGIN_load (ah->plugin, &ah->env)))
GAS_addresses_done (struct GAS_Addresses_Handle *handle)
{
struct GAS_Addresses_Suggestion_Requests *cur;
+ struct GAS_Addresses_Preference_Clients *pcur;
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Shutting down addresses\n");
GNUNET_assert(NULL != handle);
GNUNET_free(cur);
}
+ while (NULL != (pcur = handle->preference_clients_head))
+ {
+ GNUNET_CONTAINER_DLL_remove (handle->preference_clients_head,
+ handle->preference_clients_tail, pcur);
+ GNUNET_assert (handle->pref_clients > 0);
+ handle->pref_clients --;
+ GNUNET_STATISTICS_set (handle->stat, "# active performance clients", handle->pref_clients, GNUNET_NO);
+ GNUNET_free (pcur);
+ }
+
GNUNET_PLUGIN_unload (handle->plugin, handle->solver);
GNUNET_free (handle->plugin);
GNUNET_free(handle);