32 #define LOG(kind, ...) GNUNET_log_from (kind, "ats-proportional", __VA_ARGS__) 40 #define PROP_STABILITY_FACTOR 1.25 51 #define PROPORTIONALITY_FACTOR 2.0 222 "No bandwidth available in network\n");
243 for (aw = net->
head; NULL != aw; aw = aw->
next)
267 unsigned long long remaining_quota_in;
268 unsigned long long quota_out_used;
269 unsigned long long remaining_quota_out;
270 unsigned long long quota_in_used;
272 double sum_relative_peer_prefences;
275 const double *peer_relative_prefs;
278 "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n",
301 sum_relative_peer_prefences = 0.0;
303 for (aw = net->
head; NULL != aw; aw = aw->
next)
309 sum_relative_peer_prefences
317 "%s: Counted %u active addresses, expected %u active addresses\n",
325 "Total relative preference %.3f for %u addresses in network %s\n",
326 sum_relative_peer_prefences,
334 "Proportionally distributable bandwidth (in/out): %llu/%llu\n",
336 remaining_quota_out);
345 for (aw = net->
head; NULL != aw; aw = aw->
next)
361 + (peer_weight / total_weight)
362 * remaining_quota_in;
364 + (peer_weight / total_weight)
365 * remaining_quota_out;
368 "New quotas for peer `%s' with weight (cur/total) %.3f/%.3f (in/out) are: %u/%u\n",
378 "Total bandwidth assigned is (in/out): %llu /%llu\n",
382 GNUNET_break (quota_out_used <= net->total_quota_out + 1);
383 GNUNET_break (quota_in_used <= net->total_quota_in + 1);
399 for (cur = net->
head; NULL != cur; cur = cur->
next)
434 "Redistributing bandwidth in network %s with %u active and %u total addresses\n",
463 "Redistributing bandwidth in all %u networks\n",
529 double best_distance;
540 if ((NULL != ctx->
best) &&
577 if (NULL == ctx->
best)
591 if (cur_distance < best_distance)
606 if (cur_delay < best_delay)
668 "# ATS addresses total",
742 unsigned int con_min;
747 if (NULL != best_address)
751 if (current_address == best_address)
753 if (NULL != current_address)
760 "Disabling previous active address for peer `%s'\n",
768 if ((NULL == best_address) ||
772 if (NULL == best_address)
779 "Disconnecting peer `%s'.\n",
786 if (NULL == best_address)
790 "Cannot suggest address for peer `%s'\n",
796 "Selecting new address %p for peer `%s'\n",
805 "# ATS active addresses total",
813 "Address %p for peer `%s' is now active\n",
824 con_min = UINT32_MAX;
947 "Locking solver for bulk operation ...\n");
964 "Unlocking solver from bulk operation ...\n");
975 "No lock pending, recalculating\n");
1029 "# ATS addresses total",
1041 "Added new address for `%s', now total %u and active %u addresses in network `%s'\n",
1069 "Deleting %s address for peer `%s' from network `%s' (total: %u/active: %u)\n",
1096 "After deleting address now total %u and active %u addresses in network `%s'\n",
1136 "PROP_STABILITY_FACTOR",
1139 if ((f_tmp < 1.0) || (f_tmp > 2.0))
1142 _ (
"Invalid %s configuration %f \n"),
1143 "PROP_STABILITY_FACTOR",
1150 "Using %s of %.3f\n",
1151 "PROP_STABILITY_FACTOR",
1159 "PROP_PROPORTIONALITY_FACTOR",
1165 _ (
"Invalid %s configuration %f\n"),
1166 "PROP_PROPORTIONALITY_FACTOR",
1173 "Using %s of %.3f\n",
1174 "PROP_PROPORTIONALITY_FACTOR",
1189 "# ATS addresses %s total",
1192 "# ATS active addresses %s total",
1195 "Added network %u `%s' (%llu/%llu)\n",
1224 while (NULL != (cur = next))
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
GAS_solver_stop_get_preferred_address s_get_stop
Tell solver stop notifying ATS about changes for this peers.
unsigned int total_addresses
Number of total addresses for this network.
After the problem was finished, start notifications about changes to addresses.
A handle for the proportional solver.
static int count_addresses(void *cls, const struct GNUNET_HELLO_Address *address, struct GNUNET_TIME_Absolute expiration)
Address iterator that counts the remaining addresses.
struct ATS_Address * best
The currently best address.
GAS_solver_address_add s_add
Add a new address for a peer to the solver.
struct GNUNET_TIME_Absolute activated
When was this address activated.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct AddressWrapper * next
Next in DLL.
uint64_t rel_value_us
The actual value.
The proportional solver had to recalculate for a single network.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
unsigned long long total_quota_out
Total outbound quota.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint32_t calculated_quota_out
Outbound quota.
int active
Is this the active address for this peer?
static void GAS_proportional_feedback(void *solver, struct GNUNET_SERVICE_Client *application, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TIME_Relative scope, enum GNUNET_ATS_PreferenceKind kind, double score)
Get application feedback for a peer.
GAS_get_preferences get_preferences
ATS addresses function to obtain preference values.
#define PROPORTIONALITY_FACTOR
Default value to assume for the proportionality factor, if none is given in the configuration.
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
Address information stored for the proportional solver in the solver_information member of struct GNU...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
The proportional solver had to recalculate for all networks.
#define GNUNET_TIME_UNIT_SECONDS
One second.
static void address_decrement_active(struct GAS_PROPORTIONAL_Handle *s, struct Network *net)
Decrease number of active addresses in network.
void * libgnunet_plugin_ats_proportional_done(void *cls)
Function used to unload the plugin.
const char * desc
Network description.
static void GAS_proportional_start_get_address(void *solver, const struct GNUNET_PeerIdentity *peer)
Get the preferred address for a specific peer.
GAS_solver_address_feedback_preference s_feedback
Give feedback about the current assignment.
static void GAS_proportional_change_preference(void *solver, const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, double pref_rel)
The preferences for a peer in the problem changed.
GAS_solver_address_property_changed s_address_update_property
Update the properties of an address in the solver.
#define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT
Bandwidth (in/out) to assume initially (before either peer has communicated any particular preference...
double prop_factor
Proportionality factor.
static struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap to store addresses.
#define PROP_STABILITY_FACTOR
How much do we value stability over adaptation by default.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GAS_PROPORTIONAL_Handle * s
The solver handle.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct Network * network
Network scope this address is in.
char * stat_active
String for statistics active addresses.
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
static void update_active_address(struct GAS_PROPORTIONAL_Handle *s, struct ATS_Address *current_address, const struct GNUNET_PeerIdentity *peer)
Update active address for a peer.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
struct GNUNET_STATISTICS_Handle * stats
Statistics handle to be used by the solver.
Handle to a client that is connected to a service.
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
A solution iteration has been started.
static char * value
Value of the record to add/remove.
static void propagate_bandwidth(struct GAS_PROPORTIONAL_Handle *s, struct Network *net)
Notify ATS service of bandwidth changes to addresses.
struct AddressWrapper * prev
Previous in DLL.
struct GNUNET_ATS_PluginEnvironment * env
Our execution environment.
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
GAS_solver_address_delete s_del
Delete an address in the solver.
static void distribute_bandwidth_in_network(struct GAS_PROPORTIONAL_Handle *s, struct Network *n)
Distribute bandwidth.
static int all_require_connectivity(struct GAS_PROPORTIONAL_Handle *s, struct Network *net, unsigned int con)
Test if all peers in this network require connectivity at level at least con.
Representation of a network.
struct AddressWrapper * head
Linked list of addresses in this network: head.
struct ATS_Address * get_best_address(struct GAS_PROPORTIONAL_Handle *s, struct GNUNET_CONTAINER_MultiPeerMap *addresses, const struct GNUNET_PeerIdentity *id)
Find the currently best address for a peer from the set of addresses available or return NULL of no a...
static int find_best_address_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Find a "good" address to use for a peer by iterating over the addresses for this peer.
Internal representation of the hash map.
unsigned int bulk_requests
Number of changes made while solver was locked.
uint32_t calculated_quota_in
Inbound quota.
void * cls
Closure to pass to all solver functions in this struct.
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
void * libgnunet_plugin_ats_proportional_init(void *cls)
Function invoked when the plugin is loaded.
static void GAS_proportional_address_delete(void *solver, struct ATS_Address *address)
Remove an address from the solver.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
static void GAS_proportional_address_property_changed(void *solver, struct ATS_Address *address)
Transport properties for this address have changed.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
char * stat_total
String for statistics total addresses.
enum GNUNET_NetworkType type
ATS network type.
static int get_active_address_it(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Address map iterator to find current active address for peer.
static void distribute_bandwidth(struct GAS_PROPORTIONAL_Handle *s, struct Network *net)
Update bandwidth assigned to peers in this network.
Address with additional information.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
unsigned long long total_quota_in
Total inbound quota.
void * solver_information
Solver-specific information for this address.
struct GNUNET_MQ_Envelope * env
unsigned int active_addresses
Number of active addresses for solver.
void * cls
Closure to pass to all callbacks in this struct.
ats service address management
struct Network * network_entries
Networks array.
GAS_solver_get_preferred_address s_get
Tell solver to notify ATS if the address to use changes for a specific peer using the bandwidth chang...
unsigned long long in_quota[6]
Array of configured inbound quotas Order according to networks in network array.
A solution iteration has been finished.
GAS_solver_bulk_start s_bulk_start
Start a bulk operation.
The identity of the host (wraps the signing key of the peer).
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
static void GAS_proportional_bulk_start(void *solver)
Start a bulk operation.
static struct ATS_Address * get_active_address(struct GAS_PROPORTIONAL_Handle *s, const struct GNUNET_PeerIdentity *peer)
Find current active address for peer.
static void GAS_proportional_bulk_stop(void *solver)
Bulk operation done.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
static int is_bandwidth_available_in_network(struct Network *net, int extra)
Test if bandwidth is available in this network to add an additional address.
static void GAS_proportional_address_add(void *solver, struct ATS_Address *address, uint32_t network)
Add a new single address to a network.
static void GAS_proportional_stop_get_address(void *solver, const struct GNUNET_PeerIdentity *peer)
Stop notifying about address and bandwidth changes for this peer.
Automatic transport selection and outbound bandwidth determination.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle to be used by the solver.
GAS_solver_information_callback info_cb
Callback for solver to call with status information, can be NULL.
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
Context for finding the best address* Linked list of addresses in this network: head.
struct GAS_NormalizationInfo norm_delay
Normalized delay information for this address.
unsigned long long out_quota[6]
Array of configured outbound quotas Order according to networks in network array. ...
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
struct ATS_Address * addr
The address.
Time for absolute times used by GNUnet, in microseconds.
struct AddressWrapper * tail
Linked list of addresses in this network: tail.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap containing all addresses available.
The ATS plugin will pass a pointer to a struct of this type as to the initialization function of the ...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_float(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, float *number)
Get a configuration value that should be a floating point number.
GAS_solver_bulk_stop s_bulk_stop
Bulk operation done.
unsigned int bulk_lock
Bulk lock counter.
static char * address
GNS address for this phone.
GAS_bandwidth_changed_cb bandwidth_changed_cb
ATS addresses callback to be notified about bandwidth assignment changes.
After the problem was finished, notifications about changes to addresses are done.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
double norm
Normalized values from queue to a range of values [1.0...2.0].
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.
unsigned int active_addresses
Number of active addresses for this network.
unsigned int network_count
Number of networks available, size of the out_quota and in_quota arrays.
double stability_factor
Stability factor.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GAS_NormalizationInfo norm_distance
Normalized distance information for this address.
#define GNUNET_free(ptr)
Wrapper around free.
GAS_get_connectivity get_connectivity
ATS addresses function to obtain preference values.
Time for relative time used by GNUnet, in microseconds.