35 #define LOG(kind, ...) GNUNET_log_from (kind, "ats-preferences", __VA_ARGS__)
40 #define PREF_AGING_INTERVAL GNUNET_TIME_relative_multiply ( \
41 GNUNET_TIME_UNIT_SECONDS, 10)
47 #define PREF_AGING_FACTOR 0.95
54 #define PREF_EPSILON 0.01
231 for (c_cur =
pc_head; NULL != c_cur; c_cur = c_cur->
next)
237 "Total relative preference for peer `%s' for `%s' is %.3f\n",
355 "Aging preference for peer `%s'\n",
368 ac->values_to_update++;
395 ac.values_to_update = 0;
396 for (
ac.cur_client =
pc_head; NULL !=
ac.cur_client;
ac.cur_client =
402 if (
ac.values_to_update > 0)
405 "Rescheduling aging task due to %u elements remaining to age\n",
406 ac.values_to_update);
415 "No values to age left, not rescheduling aging task\n");
454 uc->pc->f_abs_sum[
uc->kind] += p_cur->
f_abs[
uc->kind];
478 "Client has relative preference for %s for peer `%s' of %.3f\n",
509 "Client has sum of total preferences for %s of %.3f\n",
569 "Client changes preference for peer `%s' for `%s' to %.2f\n",
575 for (c_cur =
pc_head; NULL != c_cur; c_cur = c_cur->
next)
576 if (client == c_cur->
client)
630 p_cur->
f_abs[kind] += score_abs;
656 nump = ntohl (
msg->num_preferences);
658 "Received PREFERENCE_CHANGE message for peer `%s'\n",
661 "# preference change requests processed",
666 for (uint32_t i = 0; i < nump; i++)
706 while (NULL != (
pc = next_pc))
755 for (c_cur =
pc_head; NULL != c_cur; c_cur = c_cur->
next)
struct GNUNET_MessageHeader * msg
automatic transport selection messages
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static struct GNUNET_MQ_Envelope * ac
Handle to current GNUNET_PEERINFO_add_peer() operation.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
static char * rp
Relying party.
ats service address management
void GAS_plugin_solver_unlock()
Resume instant solving, we are done with the bulk state updates.
void GAS_plugin_solver_lock()
Stop instant solving, there are many state updates happening in bulk right now.
void GAS_plugin_notify_preference_changed(const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, double pref_rel)
The preference changed for a peer, update solver.
ats service plugin management
static int update_rel_sum(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Compute updated relative score for each peer based on the current absolute score given by this client...
#define PREF_AGING_FACTOR
By which factor do we age preferences expressed during each PREF_AGING_INTERVAL?
#define PREF_EPSILON
What is the lowest threshold up to which preference values are aged, and below which we consider them...
static void update_relative_values_for_peer(const struct GNUNET_PeerIdentity *id, enum GNUNET_ATS_PreferenceKind kind)
Update the total relative preference for a peer by summing up the relative preferences all clients ha...
void GAS_preference_client_disconnect(struct GNUNET_SERVICE_Client *client)
A performance client disconnected.
static int free_peer(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free a peer's struct PeerRelative.
static int age_values(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Age preference values of the given peer.
#define PREF_AGING_INTERVAL
How frequently do we age preference values?
void GAS_preference_init()
Initialize preferences subsystem.
static int sum_relative_preferences(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Add the relative preference for the kind given to the closure.
static void preference_aging(void *cls)
Reduce absolute preferences since they got old.
static struct PeerRelative defvalues
Default values, returned as our preferences if we do not have any preferences expressed for a peer.
static struct GNUNET_SCHEDULER_Task * aging_task
Handle for task we run periodically to age preferences over time.
static struct GNUNET_CONTAINER_MultiPeerMap * preference_peers
Hashmap to store peer information for preference normalization.
void GAS_preference_done()
Shutdown preferences subsystem.
static void update_preference(struct GNUNET_SERVICE_Client *client, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, float score_abs)
Update the absolute preference and calculate the new relative preference value.
void GAS_handle_preference_change(struct GNUNET_SERVICE_Client *client, const struct ChangePreferenceMessage *msg)
Handle 'preference change' messages from clients.
static int update_iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
The relative preferences of one of the clients have changed, update the global preferences for the gi...
static int free_preference(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Free struct PreferencePeer entry in map.
static int update_abs_sum(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Compute updated absolute score for the client based on the current absolute scores for each peer.
const double * GAS_preference_get_by_peer(void *cls, const struct GNUNET_PeerIdentity *id)
Get the normalized preference values for a specific peer or the default values if.
static void recalculate_relative_preferences(struct PreferenceClient *c, enum GNUNET_ATS_PreferenceKind kind)
Recalculate preference for a specific ATS property.
static struct PreferenceClient * pc_head
Clients in DLL: head.
static struct PreferenceClient * pc_tail
Clients in DLL: tail.
manage preferences expressed by clients
#define DEFAULT_ABS_PREFERENCE
Default preference value we assume if we know nothing.
#define DEFAULT_REL_PREFERENCE
Default relative preference value we assume if we know nothing.
ats service, inbound bandwidth reservation management
static struct GNUNET_FS_UnindexContext * uc
static struct GNUNET_OS_Process * p
Helper process we started.
const char * GNUNET_ATS_print_preference_type(enum GNUNET_ATS_PreferenceKind type)
Convert an enum GNUNET_ATS_PreferenceType to a string.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
@ GNUNET_ATS_PREFERENCE_END
End of preference list.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multipeermap_get_multiple(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Closure for age_values().
unsigned int values_to_update
Counter of values remaining to update, incremented for each value changed (to a new non-zero value).
struct PreferenceClient * cur_client
Client we are currently aging values for.
Client to ATS: I have a performance preference for a peer.
Internal representation of the hash map.
struct GNUNET_MQ_Envelope * next
Messages are stored in a linked list.
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Handle to a client that is connected to a service.
Relative preferences for a peer.
unsigned int num_clients
Number of clients that are expressing a preference for this peer.
double f_rel[GNUNET_ATS_PREFERENCE_END]
Array of relative preference values, to be indexed by an enum GNUNET_ATS_PreferenceKind.
Preference client, as in a client that expressed preferences for peers.
struct GNUNET_SERVICE_Client * client
Client handle.
struct PreferenceClient * prev
Previous in client peer list.
struct PreferenceClient * next
Next in client list.
double f_abs_sum[GNUNET_ATS_PREFERENCE_END]
Array of sums of absolute preferences for all peers as expressed by this client.
struct GNUNET_CONTAINER_MultiPeerMap * peer2pref
Mapping peer identities to struct PreferencePeer entry for the respective peer.
Preference information per peer and client.
struct PreferencePeer * prev
Previous in DLL of preference entries for the same client.
double f_abs[GNUNET_ATS_PREFERENCE_END]
Absolute preference values for all preference types as expressed by this client for this peer.
struct PreferencePeer * next
Next in DLL of preference entries for the same client.
double f_rel[GNUNET_ATS_PREFERENCE_END]
Relative preference values for all preference types, normalized in [0..1] based on how the respective...
Closure for sum_relative_preferences().
double f_rel_total
Where to accumulate the result.
enum GNUNET_ATS_PreferenceKind kind
Which kind of preference value are we adding up?
Closure for update_rel_sum() and update_abs_sum().
struct PreferenceClient * pc
Preference client with the sum of all absolute scores.
enum GNUNET_ATS_PreferenceKind kind
Which kind are we updating?
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.