2 This file is part of GNUnet.
3 (C) 2011-2014 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file ats/plugin_ats_proportional.c
23 * @brief ATS proportional solver
24 * @author Matthias Wachs
25 * @author Christian Grothoff
28 #include "gnunet_statistics_service.h"
29 #include "gnunet_ats_plugin.h"
30 #include "gnunet_ats_service.h"
31 #include "gnunet-service-ats_addresses.h"
33 #define PROP_STABILITY_FACTOR 1.25
36 #define LOG(kind,...) GNUNET_log_from (kind, "ats-proportional",__VA_ARGS__)
41 * NOTE: Do not change this documentation. This documentation is based
42 * on gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex
43 * use build_txt.sh to generate plaintext output
45 * ATS addresses : proportional solver
47 * The proportional solver ("proportional") distributes the available
48 * bandwidth fair over all the addresses influenced by the
49 * preference values. For each available network type an in- and
50 * outbound quota is configured and the bandwidth available in
51 * these networks is distributed over the addresses. The solver
52 * first assigns every addresses the minimum amount of bandwidth
53 * #GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT and then distributes the
54 * remaining bandwidth available according to the preference
55 * values. For each peer only a single address gets bandwidth
56 * assigned and only one address marked as active. The most
57 * important functionality for the solver is implemented in: *
58 * find_address_it is an hashmap iterator returning the prefered
59 * address for an peer * update_quota_per_network distributes
60 * available bandwidth for a network over active addresses
62 * Changes to addresses automatically have an impact on the the
63 * bandwidth assigned to other addresses in the same network since
64 * the solver distributes the remaining bandwidth over the
65 * addresses in the network. When changes to the addresses occur,
66 * the solver first performs the changes, like adding or deleting
67 * addresses, and then updates bandwidth assignment for the
68 * affected network. Bandwidth assignment is only recalculated on
69 * demand when an address is requested by a client for a peer or
70 * when the addresses available have changed or an address changed
71 * the network it is located in. When the bandwidth assignment has
72 * changed the callback is called with the new bandwidth
73 * assignments. The bandwidth distribution for a network is
74 * recalculated due to: * address suggestion requests * address
75 * deletions * address switching networks during address update *
78 * 3.1 Data structures used
80 * For each ATS network (e.g. WAN, LAN, loopback) a struct Network
81 * is used to specify network related information as total adresses
82 * and active addresses in this network and the configured in- and
83 * outbound quota. Each network also contains a list of addresses
84 * added to the solver located in this network. The proportional
85 * solver uses the addresses' solver_information field to store the
86 * proportional network it belongs to for each address.
90 * When the proportional solver is initialized the solver creates a
91 * new solver handle and initializes the network structures with
92 * the quotas passed from addresses and returns the handle solver.
94 * 3.3 Adding an address
96 * When a new address is added to the solver using s_add, a lookup
97 * for the network for this address is done and the address is
98 * enqueued in in the linked list of the network.
100 * 3.4 Updating an address
102 * The main purpose of address updates is to update the ATS
103 * information for addresse selection. Important for the proportional
104 * solver is when an address switches network it is located
105 * in. This is common because addresses added by transport's
106 * validation mechanism are commonly located in
107 * #GNUNET_ATS_NET_UNSPECIFIED. Addresses in validation are located
108 * in this network type and only if a connection is successful on
109 * return of payload data transport switches to the real network
110 * the address is located in. When an address changes networks it
111 * is first of all removed from the old network using the solver
112 * API function #GAS_proportional_address_delete() and the network in
113 * the address struct is updated. A lookup for the respective new
114 * proportional network is done and stored in the addresse's
115 * solver_information field. Next the address is re-added to the
116 * solver using the solver API function
117 * #GAS_proportional_address_add(). If the address was marked as in
118 * active, the solver checks if bandwidth is available in the
119 * network and if yes sets the address to active and updates the
120 * bandwidth distribution in this network. If no bandwidth is
121 * available it sets the bandwidth for this address to 0 and tries
122 * to suggest an alternative address. If an alternative address was
123 * found, addresses' callback is called for this address.
125 * 3.5 Deleting an address
127 * When an address is removed from the solver, it removes the
128 * respective address from the network and if the address was
129 * marked as active, it updates the bandwidth distribution for this
132 * 3.6 Requesting addresses
134 * When an address is requested for a peer the solver performs a
135 * lookup for the peer entry in addresses address hashmap and
136 * selects the best address. The selection of the most suitable
137 * address is done in the find_address_it hashmap iterator
138 * described in detail in section 3.7. If no address is returned,
139 * no address can be suggested at the moment. If the address
140 * returned is marked as active, the solver can return this
141 * address. If the address is not marked as active, the solver
142 * checks if another address belongign to this peer is marked as
143 * active and marks the address as inactive, updates the bandwidth
144 * for this address to 0, call the bandwidth changed callback for
145 * this address due to the change and updates quota assignment for
146 * the addresse's network. the now in-active address is belonging
147 * to. The solver marks the new address as active and updates the
148 * bandwidth assignment for this network.
150 * 3.7 Choosing addresses
152 * Choosing the best possible address for suggestion is done by
153 * iterating over all addresses of a peer stored in addresses'
154 * hashmap and using the hashmap iterator find_address_it to select
155 * the best available address. Several checks are done when an
156 * address is selected. First if this address is currently blocked
157 * by addresses from being suggested. An address is blocked for the
158 * duration of #ATS_BLOCKING_DELTA when it is suggested to
159 * transport. Next it is checked if at least
160 * #GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT bytes bandwidth is available
161 * in the addresse's network, because suggesting an address without
162 * bandwidth does not make sense. This also ensures that all active
163 * addresses in this network get at least the minimum amount of
164 * bandwidth assigned. In the next step the solver ensures that for
165 * tcp connections inbound connections are prefered over outbound
166 * connections. In the next stet the solver ensures that
167 * connections are prefered in the following order: * connections
168 * are already established and have bandwidth assigned *
169 * connections with a shorter distance * connectes have a shorter
172 * 3.8 Changing preferences
176 * During shutdown all network entries and aging processes are
177 * destroyed and freed.
182 * This solver assigns in and outbound bandwidth equally for all
183 * addresses in specific network type (WAN, LAN) based on configured
184 * in and outbound quota for this network.
186 * The solver is notified by addresses about changes to the addresses
187 * and recalculates the bandwith assigned if required. The solver
188 * notifies addresses by calling the GAS_bandwidth_changed_cb
196 * For each peer only a single is selected and marked as "active" in the address
201 * You have the networks WAN and LAN and quotas
202 * WAN_TOTAL_IN, WAN_TOTAL_OUT
203 * LAN_TOTAL_IN, LAN_TOTAL_OUT
205 * If you have x addresses in the network segment LAN, the quotas are
206 * QUOTA_PER_ADDRESS = LAN_TOTAL_OUT / x
208 * Quotas are automatically recalculated and reported back when addresses are
213 #define PROPORTIONALITY_FACTOR 2.0
216 * A handle for the proportional solver
218 struct GAS_PROPORTIONAL_Handle
222 * Our execution environment.
224 struct GNUNET_ATS_PluginEnvironment *env;
227 * Hashmap containing all valid addresses
229 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
232 * Pending address requests
234 struct GNUNET_CONTAINER_MultiPeerMap *requests;
242 * Number of changes while solver was locked
247 * Total number of addresses for solver
249 unsigned int total_addresses;
252 * Number of active addresses for solver
254 unsigned int active_addresses;
259 struct Network *network_entries;
264 unsigned int network_count;
267 * Proportionality factor
274 double stability_factor;
278 * Representation of a network
285 enum GNUNET_ATS_Network_Type type;
288 * Network description
293 * Total inbound quota
295 unsigned long long total_quota_in;
298 * Total outbound quota
300 unsigned long long total_quota_out;
303 * Number of active addresses for this network
305 unsigned int active_addresses;
308 * Number of total addresses for this network
310 unsigned int total_addresses;
313 * String for statistics total addresses
318 * String for statistics active addresses
323 * Linked list of addresses in this network: head
325 struct AddressWrapper *head;
328 * Linked list of addresses in this network: tail
330 struct AddressWrapper *tail;
334 * Address information stored in the solver
336 struct AddressSolverInformation
339 * Network scope this address is in
341 struct Network *network;
346 uint32_t calculated_quota_in;
351 uint32_t calculated_quota_out;
354 * When was this address activated
356 struct GNUNET_TIME_Absolute activated;
361 * Wrapper for addresses to store them in network's linked list
363 struct AddressWrapper
368 struct AddressWrapper *next;
373 struct AddressWrapper *prev;
378 struct ATS_Address *addr;
383 * Function used to unload the plugin.
385 * @param cls return value from #libgnunet_plugin_ats_proportional_init()
388 libgnunet_plugin_ats_proportional_done (void *cls)
390 struct GNUNET_ATS_SolverFunctions *sf = cls;
391 struct GAS_PROPORTIONAL_Handle *s = sf->cls;
392 struct AddressWrapper *cur;
393 struct AddressWrapper *next;
396 for (c = 0; c < s->network_count; c++)
398 if (s->network_entries[c].total_addresses > 0)
400 LOG(GNUNET_ERROR_TYPE_DEBUG,
401 "Had %u addresses for network `%s' not deleted during shutdown\n",
402 s->network_entries[c].total_addresses, s->network_entries[c].desc);
406 if (s->network_entries[c].active_addresses > 0)
408 LOG(GNUNET_ERROR_TYPE_DEBUG,
409 "Had %u active addresses for network `%s' not deleted during shutdown\n",
410 s->network_entries[c].active_addresses, s->network_entries[c].desc);
414 next = s->network_entries[c].head;
415 while (NULL != (cur = next))
418 GNUNET_CONTAINER_DLL_remove(s->network_entries[c].head,
419 s->network_entries[c].tail, cur);
420 GNUNET_free_non_null (cur->addr->solver_information);
423 GNUNET_free(s->network_entries[c].stat_total);
424 GNUNET_free(s->network_entries[c].stat_active);
426 if (s->total_addresses > 0)
428 LOG(GNUNET_ERROR_TYPE_DEBUG,
429 "Had %u addresses not deleted during shutdown\n", s->total_addresses);
432 if (s->active_addresses > 0)
434 LOG(GNUNET_ERROR_TYPE_DEBUG,
435 "Had %u active addresses not deleted during shutdown\n",
436 s->active_addresses);
439 GNUNET_free (s->network_entries);
440 GNUNET_CONTAINER_multipeermap_destroy (s->requests);
447 * Test if bandwidth is available in this network to add an additional address
449 * @param net the network type to update
450 * @return #GNUNET_YES or #GNUNET_NO
453 is_bandwidth_available_in_network (struct Network *net)
455 GNUNET_assert(NULL != net);
456 unsigned int na = net->active_addresses + 1;
457 uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
458 if (((net->total_quota_in / na) > min_bw)
459 && ((net->total_quota_out / na) > min_bw))
461 LOG(GNUNET_ERROR_TYPE_DEBUG,
462 "Enough bandwidth available for %u active addresses in network `%s'\n",
467 LOG(GNUNET_ERROR_TYPE_DEBUG,
468 "Not enough bandwidth available for %u active addresses in network `%s'\n",
475 * Update bandwidth assigned to peers in this network
477 * @param s the solver handle
478 * @param net the network type to update
482 distribute_bandwidth (struct GAS_PROPORTIONAL_Handle *s,
485 struct AddressSolverInformation *asi;
486 struct AddressWrapper *cur_address;
487 unsigned long long remaining_quota_in = 0;
488 unsigned long long quota_out_used = 0;
489 unsigned long long remaining_quota_out = 0;
490 unsigned long long quota_in_used = 0;
492 uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
493 double relative_peer_prefence;
494 double sum_relative_peer_prefences; /* Important: has to be double not float due to precision */
495 double cur_pref; /* Important: has to be double not float due to precision */
498 const double *peer_relative_prefs = NULL; /* Important: has to be double not float due to precision */
500 uint32_t assigned_quota_in = 0;
501 uint32_t assigned_quota_out = 0;
504 LOG (GNUNET_ERROR_TYPE_INFO,
505 "Recalculate quota for network type `%s' for %u addresses (in/out): %llu/%llu \n",
507 net->active_addresses,
509 net->total_quota_in);
511 if (net->active_addresses == 0)
513 return; /* no addresses to update */
517 * Assign every peer in network minimum Bandwidth
518 * Distribute bandwidth left according to preference
521 if ((net->active_addresses * min_bw) > net->total_quota_in)
526 if ((net->active_addresses * min_bw) > net->total_quota_out)
532 remaining_quota_in = net->total_quota_in - (net->active_addresses * min_bw);
533 remaining_quota_out = net->total_quota_out - (net->active_addresses * min_bw);
534 LOG(GNUNET_ERROR_TYPE_DEBUG, "Remaining bandwidth : (in/out): %llu/%llu \n",
535 remaining_quota_in, remaining_quota_out);
536 sum_relative_peer_prefences = 0.0;
538 /* Calculate sum of relative preference for active addresses in this network */
540 for (cur_address = net->head; NULL != cur_address; cur_address = cur_address->next)
542 if (GNUNET_YES != cur_address->addr->active)
545 GNUNET_assert( NULL != (peer_relative_prefs = s->env->get_preferences (s->env->cls,
546 &cur_address->addr->peer)));
547 relative_peer_prefence = 0.0;
548 relative_peer_prefence += peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH];
549 sum_relative_peer_prefences += relative_peer_prefence;
553 if (count_addresses != net->active_addresses)
556 LOG (GNUNET_ERROR_TYPE_WARNING,
557 "%s: Counted %u active addresses, but network says to have %u active addresses\n",
558 net->desc, count_addresses, net->active_addresses);
559 for (cur_address = net->head; NULL != cur_address; cur_address = cur_address->next)
561 if (GNUNET_YES != cur_address->addr->active)
564 LOG (GNUNET_ERROR_TYPE_WARNING,
565 "Active: `%s' `%s' length %u\n",
566 GNUNET_i2s (&cur_address->addr->peer),
567 cur_address->addr->plugin,
568 cur_address->addr->addr_len);
572 LOG (GNUNET_ERROR_TYPE_INFO,
573 "Total relative preference %.3f for %u addresses in network %s\n",
574 sum_relative_peer_prefences, net->active_addresses, net->desc);
576 for (cur_address = net->head; NULL != cur_address; cur_address = cur_address->next)
578 if (GNUNET_YES == cur_address->addr->active)
580 GNUNET_assert( NULL != (peer_relative_prefs =
581 s->env->get_preferences (s->env->cls,
582 &cur_address->addr->peer)));
584 cur_pref = peer_relative_prefs[GNUNET_ATS_PREFERENCE_BANDWIDTH];
585 total_weight = net->active_addresses +
586 s->prop_factor * sum_relative_peer_prefences;
587 peer_weight = (1.0 + (s->prop_factor * cur_pref));
589 assigned_quota_in = min_bw
590 + ((peer_weight / total_weight) * remaining_quota_in);
591 assigned_quota_out = min_bw
592 + ((peer_weight / total_weight) * remaining_quota_out);
594 LOG (GNUNET_ERROR_TYPE_INFO,
595 "New quota for peer `%s' with weight (cur/total) %.3f/%.3f (in/out): %llu / %llu\n",
596 GNUNET_i2s (&cur_address->addr->peer), peer_weight, total_weight,
597 assigned_quota_in, assigned_quota_out);
601 assigned_quota_in = 0;
602 assigned_quota_out = 0;
605 quota_in_used += assigned_quota_in;
606 quota_out_used += assigned_quota_out;
607 /* Prevent overflow due to rounding errors */
608 if (assigned_quota_in > UINT32_MAX)
609 assigned_quota_in = UINT32_MAX;
610 if (assigned_quota_out > UINT32_MAX)
611 assigned_quota_out = UINT32_MAX;
613 /* Compare to current bandwidth assigned */
614 asi = cur_address->addr->solver_information;
615 asi->calculated_quota_in = assigned_quota_in;
616 asi->calculated_quota_out = assigned_quota_out;
618 LOG(GNUNET_ERROR_TYPE_DEBUG,
619 "Total bandwidth assigned is (in/out): %llu /%llu\n", quota_in_used,
621 if (quota_out_used > net->total_quota_out + 1) /* +1 is required due to rounding errors */
623 LOG(GNUNET_ERROR_TYPE_ERROR,
624 "Total outbound bandwidth assigned is larger than allowed (used/allowed) for %u active addresses: %llu / %llu\n",
625 net->active_addresses, quota_out_used, net->total_quota_out);
627 if (quota_in_used > net->total_quota_in + 1) /* +1 is required due to rounding errors */
629 LOG(GNUNET_ERROR_TYPE_ERROR,
630 "Total inbound bandwidth assigned is larger than allowed (used/allowed) for %u active addresses: %llu / %llu\n",
631 net->active_addresses, quota_in_used, net->total_quota_in);
637 * Context for finding the best address* Linked list of addresses in this network: head
639 struct FindBestAddressCtx
644 struct GAS_PROPORTIONAL_Handle *s;
647 * The currently best address
649 struct ATS_Address *best;
654 * Find index of a ATS property type in the array.
657 find_property_index (uint32_t type)
659 int existing_types[] = GNUNET_ATS_QualityProperties;
662 for (c = 0; c < GNUNET_ATS_QualityPropertiesCount; c++)
663 if (existing_types[c] == type)
665 return GNUNET_SYSERR;
670 * Find a "good" address to use for a peer by iterating over the addresses for this peer.
671 * If we already have an existing address, we stick to it.
672 * Otherwise, we pick by lowest distance and then by lowest latency.
674 * @param cls the `struct FindBestAddressCtx *' where we store the result
676 * @param value another `struct ATS_Address*` to consider using
677 * @return #GNUNET_OK (continue to iterate)
680 find_best_address_it (void *cls,
681 const struct GNUNET_PeerIdentity *key,
684 struct FindBestAddressCtx *ctx = cls;
685 struct ATS_Address *current = value;
686 struct ATS_Address *current_best = current;
687 struct AddressSolverInformation *asi;
688 struct GNUNET_TIME_Relative active_time;
689 struct GNUNET_TIME_Relative min_active_time;
690 const double *norm_prop_cur;
691 const double *norm_prop_best;
693 double best_distance;
699 asi = current->solver_information;
706 if (GNUNET_NO == is_bandwidth_available_in_network (asi->network))
708 return GNUNET_OK; /* There's no bandwidth available in this network */
711 if (NULL != ctx->best)
713 /* Compare current addresses with denominated 'best' address */
714 current_best = ctx->best;
718 /* We do not have a 'best' address so take this address */
719 LOG (GNUNET_ERROR_TYPE_DEBUG,
720 "Setting initial address %p\n",
722 current_best = current;
726 if (GNUNET_YES == current->active)
728 GNUNET_assert (asi->activated.abs_value_us != GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us);
729 active_time = GNUNET_TIME_absolute_get_duration (asi->activated);
730 min_active_time.rel_value_us = ((double) GNUNET_TIME_UNIT_SECONDS.rel_value_us) *
731 ctx->s->stability_factor;
732 if (active_time.rel_value_us <= min_active_time.rel_value_us)
734 /* Keep active address for stability reasons */
740 /* Now compare ATS information */
741 norm_prop_cur = ctx->s->env->get_property (ctx->s->env->cls,
743 index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
744 cur_distance = norm_prop_cur[index];
745 index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
746 cur_delay = norm_prop_cur[index];
748 norm_prop_best = ctx->s->env->get_property (ctx->s->env->cls,
750 index = find_property_index (GNUNET_ATS_QUALITY_NET_DISTANCE);
751 best_distance = norm_prop_best[index];
752 index = find_property_index (GNUNET_ATS_QUALITY_NET_DELAY);
753 best_delay = norm_prop_best[index];
755 /* user shorter distance */
756 if (cur_distance < best_distance)
758 if (GNUNET_NO == ctx->best->active)
760 current_best = current; /* Use current */
762 else if ((best_distance / cur_distance) > ctx->s->stability_factor)
764 /* Best and active address performs worse */
765 current_best = current;
770 /* Use current best */
771 current_best = ctx->best;
774 /* User connection with less delay */
775 if (cur_delay < best_delay)
778 if (GNUNET_NO == ctx->best->active)
780 current_best = current; /* Use current */
782 else if ((best_delay / cur_delay) > ctx->s->stability_factor)
784 /* Best and active address performs worse */
785 current_best = current;
790 /* Use current best */
791 current_best = ctx->best;
795 ctx->best = current_best;
801 * Find the currently best address for a peer from the set of addresses available
802 * or return NULL of no address is available
804 * @param s the proportional handle
805 * @param addresses the address hashmap
806 * @param id the peer id
807 * @return the address or NULL
810 get_best_address (struct GAS_PROPORTIONAL_Handle *s,
811 struct GNUNET_CONTAINER_MultiPeerMap *addresses,
812 const struct GNUNET_PeerIdentity *id)
814 struct FindBestAddressCtx fba_ctx;
818 GNUNET_CONTAINER_multipeermap_get_multiple (addresses,
820 &find_best_address_it,
827 * Hashmap Iterator to find current active address for peer
829 * @param cls last active address
830 * @param key peer's key
831 * @param value address to check
832 * @return #GNUNET_NO on double active address else #GNUNET_YES;
835 get_active_address_it (void *cls,
836 const struct GNUNET_PeerIdentity *key,
839 struct ATS_Address **dest = cls;
840 struct ATS_Address *aa = (struct ATS_Address *) value;
842 LOG (GNUNET_ERROR_TYPE_INFO,
843 "Checking address %p\n", aa);
845 if (GNUNET_YES == aa->active)
847 LOG (GNUNET_ERROR_TYPE_INFO,
848 "Address %p is active\n", aa);
851 /* should never happen */
852 LOG (GNUNET_ERROR_TYPE_ERROR,
853 "Multiple active addresses for peer `%s'\n",
854 GNUNET_i2s (&aa->peer));
866 * Find current active address for peer
868 * @param solver the solver handle
869 * @param addresses the address set
870 * @param peer the peer
871 * @return active address or NULL
873 static struct ATS_Address *
874 get_active_address (void *solver,
875 const struct GNUNET_CONTAINER_MultiPeerMap * addresses,
876 const struct GNUNET_PeerIdentity *peer)
878 static struct ATS_Address *dest;
881 GNUNET_CONTAINER_multipeermap_get_multiple (addresses, peer,
882 &get_active_address_it,
889 * Lookup network struct by type
891 * @param s the solver handle
892 * @param type the network type
893 * @return the network struct
895 static struct Network *
896 get_network (struct GAS_PROPORTIONAL_Handle *s,
897 enum GNUNET_ATS_Network_Type type)
899 if (type >= s->env->network_count)
904 return &s->network_entries[type];
909 * Increase address count in network
911 * @param s the solver handle
912 * @param net the network type
913 * @param total increase total addresses
914 * @param active increase active addresses
917 address_increment (struct GAS_PROPORTIONAL_Handle *s,
922 if (GNUNET_YES == total)
924 s->total_addresses++;
925 net->total_addresses++;
926 GNUNET_STATISTICS_update (s->env->stats,
927 "# ATS addresses total", 1, GNUNET_NO);
928 GNUNET_STATISTICS_update (s->env->stats,
929 net->stat_total, 1, GNUNET_NO);
931 if (GNUNET_YES == active)
933 net->active_addresses++;
934 s->active_addresses++;
935 GNUNET_STATISTICS_update (s->env->stats,
936 "# ATS active addresses total", 1,
938 GNUNET_STATISTICS_update (s->env->stats,
939 net->stat_active, 1, GNUNET_NO);
946 * Decrease address count in network
948 * @param s the solver handle
949 * @param net the network type
950 * @param total decrease total addresses
951 * @param active decrease active addresses
954 addresse_decrement (struct GAS_PROPORTIONAL_Handle *s,
961 if (GNUNET_YES == total)
963 if (s->total_addresses < 1)
970 s->total_addresses--;
971 GNUNET_STATISTICS_update (s->env->stats,
972 "# ATS addresses total", -1,
975 if (net->total_addresses < 1)
982 net->total_addresses--;
983 GNUNET_STATISTICS_update (s->env->stats,
984 net->stat_total, -1, GNUNET_NO);
988 if (GNUNET_YES == active)
990 if (net->active_addresses < 1)
997 net->active_addresses--;
998 GNUNET_STATISTICS_update (s->env->stats,
999 net->stat_active, -1, GNUNET_NO);
1001 if (s->active_addresses < 1)
1004 res = GNUNET_SYSERR;
1008 s->active_addresses--;
1009 GNUNET_STATISTICS_update (s->env->stats,
1010 "# ATS addresses total", -1,
1019 * Compares addresses
1021 * @param a address a
1022 * @param b address b
1023 * @return GNUNET_YES if equal, GNUNET_NO else
1026 address_eq (struct ATS_Address *a, struct ATS_Address *b)
1028 GNUNET_assert (NULL != a);
1029 GNUNET_assert (NULL != b);
1030 if (0 != strcmp(a->plugin, b->plugin))
1032 if (a->addr_len != b->addr_len)
1034 if (0 != memcmp (a->addr, b->addr, b->addr_len))
1036 if (a->session_id != b->session_id)
1043 * Notify bandwidth changes to addresses
1045 * @param s solver handle
1046 * @param net the network to propagate changes in
1049 propagate_bandwidth (struct GAS_PROPORTIONAL_Handle *s,
1050 struct Network *net)
1052 struct AddressWrapper *cur;
1053 struct AddressSolverInformation *asi;
1055 for (cur = net->head; NULL != cur; cur = cur->next)
1057 asi = cur->addr->solver_information;
1058 if ( (cur->addr->assigned_bw_in != asi->calculated_quota_in) ||
1059 (cur->addr->assigned_bw_out != asi->calculated_quota_out) )
1061 cur->addr->assigned_bw_in = asi->calculated_quota_in;
1062 cur->addr->assigned_bw_out = asi->calculated_quota_out;
1064 /* Reset for next iteration */
1065 asi->calculated_quota_in = 0;
1066 asi->calculated_quota_out = 0;
1067 LOG (GNUNET_ERROR_TYPE_DEBUG,
1068 "Bandwidth for %s address %p for peer `%s' changed to %u/%u\n",
1069 (GNUNET_NO == cur->addr->active) ? "inactive" : "active",
1071 GNUNET_i2s (&cur->addr->peer),
1072 cur->addr->assigned_bw_in,
1073 cur->addr->assigned_bw_out);
1075 /* Notify on change */
1076 if ((GNUNET_YES == cur->addr->active))
1078 s->env->bandwidth_changed_cb (s->env->cls,
1087 * Distribibute bandwidth
1089 * @param s the solver handle
1090 * @param n the network, can be NULL for all network
1093 distribute_bandwidth_in_network (struct GAS_PROPORTIONAL_Handle *s,
1096 if (GNUNET_YES == s->bulk_lock)
1104 LOG (GNUNET_ERROR_TYPE_INFO,
1105 "Redistributing bandwidth in network %s with %u active and %u total addresses\n",
1106 GNUNET_ATS_print_network_type(n->type),
1107 n->active_addresses, n->total_addresses);
1109 if (NULL != s->env->info_cb)
1110 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_START,
1111 GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
1114 distribute_bandwidth(s, n);
1116 if (NULL != s->env->info_cb)
1117 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_STOP,
1118 GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
1119 if (NULL != s->env->info_cb)
1120 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
1121 GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
1123 /* Do propagation */
1124 propagate_bandwidth (s, n);
1126 if (NULL != s->env->info_cb)
1127 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
1128 GAS_STAT_SUCCESS, GAS_INFO_PROP_SINGLE);
1133 if (NULL != s->env->info_cb)
1134 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_START,
1135 GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
1136 for (i = 0; i < s->network_count; i++)
1139 distribute_bandwidth(s, &s->network_entries[i]);
1142 if (NULL != s->env->info_cb)
1143 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_STOP,
1144 GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
1145 if (NULL != s->env->info_cb)
1146 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START,
1147 GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
1148 for (i = 0; i < s->network_count; i++)
1150 /* Do propagation */
1151 propagate_bandwidth(s, &s->network_entries[i]);
1153 if (NULL != s->env->info_cb)
1154 s->env->info_cb(s->env->cls, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP,
1155 GAS_STAT_SUCCESS, GAS_INFO_PROP_ALL);
1161 * Update active address for a peer:
1162 * Check if active address exists and what the best address is, if addresses
1163 * are different switch
1165 * @param s solver handle
1166 * @param peer the peer to check
1167 * return the new address or NULL if no update was performed
1169 static struct ATS_Address *
1170 update_active_address (struct GAS_PROPORTIONAL_Handle *s,
1171 const struct GNUNET_PeerIdentity *peer)
1173 struct ATS_Address *best_address;
1174 struct ATS_Address *current_address;
1175 struct AddressSolverInformation *asi;
1176 struct Network *net;
1178 LOG (GNUNET_ERROR_TYPE_INFO,
1179 "Updating active address for peer `%s'\n",
1182 /* Find active address */
1183 current_address = get_active_address (s,
1187 LOG (GNUNET_ERROR_TYPE_INFO,
1188 "Peer `%s' has active address %p\n",
1192 /* Find best address */
1193 best_address = get_best_address (s,
1196 LOG (GNUNET_ERROR_TYPE_INFO,
1197 "Peer `%s' has best address %p\n",
1201 if (NULL != current_address)
1203 if ( (NULL == best_address) ||
1204 ( (NULL != best_address) &&
1205 (GNUNET_NO == address_eq (current_address,
1208 /* We switch to a new address (or to none),
1209 mark old address as inactive */
1210 LOG (GNUNET_ERROR_TYPE_INFO,
1211 "Disabling previous %s address %p for peer `%s'\n",
1212 (GNUNET_NO == current_address->active) ? "inactive" : "active",
1216 asi = current_address->solver_information;
1217 GNUNET_assert (NULL != asi);
1220 asi->activated = GNUNET_TIME_UNIT_ZERO_ABS;
1221 current_address->active = GNUNET_NO; /* No active any longer */
1222 current_address->assigned_bw_in = 0; /* no bandwidth assigned */
1223 current_address->assigned_bw_out = 0; /* no bandwidth assigned */
1225 if (GNUNET_SYSERR == addresse_decrement (s, net, GNUNET_NO, GNUNET_YES))
1228 /* Update network of previous address */
1229 distribute_bandwidth_in_network (s, net);
1231 if (NULL == best_address)
1233 /* We previously had an active address, but now we cannot suggest one
1234 * Therefore we have to disconnect the peer */
1235 LOG (GNUNET_ERROR_TYPE_INFO,
1236 "Disconnecting peer `%s' with previous address %p\n",
1239 s->env->bandwidth_changed_cb (s->env->cls,
1243 if (NULL == best_address)
1245 LOG (GNUNET_ERROR_TYPE_INFO,
1246 "Cannot suggest address for peer `%s'\n",
1251 LOG (GNUNET_ERROR_TYPE_INFO,
1252 "Suggesting new address %p for peer `%s'\n",
1256 if ( (NULL != current_address) &&
1257 (GNUNET_YES == address_eq (best_address, current_address)) )
1259 GNUNET_break (GNUNET_NO != current_address->active);
1260 return best_address; /* Same same */
1263 asi = best_address->solver_information;
1264 GNUNET_assert (NULL != asi);
1267 /* Mark address as active */
1268 asi->activated = GNUNET_TIME_absolute_get ();
1269 best_address->active = GNUNET_YES;
1270 address_increment (s, net, GNUNET_NO, GNUNET_YES);
1271 LOG (GNUNET_ERROR_TYPE_INFO,
1272 "Address %p for peer `%s' is now active\n",
1275 /* Distribute bandwidth */
1276 distribute_bandwidth_in_network (s, net);
1277 return best_address;
1282 * Changes the preferences for a peer in the problem
1284 * @param solver the solver handle
1285 * @param peer the peer to change the preference for
1286 * @param kind the kind to change the preference
1287 * @param pref_rel the normalized preference value for this kind over all clients
1290 GAS_proportional_address_change_preference (void *solver,
1291 const struct GNUNET_PeerIdentity *peer,
1292 enum GNUNET_ATS_PreferenceKind kind,
1295 struct GAS_PROPORTIONAL_Handle *s = solver;
1296 struct ATS_Address *best_address;
1297 struct ATS_Address *active_address;
1298 struct AddressSolverInformation *asi;
1301 GNUNET_CONTAINER_multipeermap_contains (s->requests, peer))
1302 return; /* Peer is not requested */
1304 /* This peer is requested, find best address */
1305 active_address = get_active_address (s, s->addresses, peer);
1306 best_address = update_active_address (s, peer);
1308 if ((NULL != best_address) && ((NULL != active_address) &&
1309 (GNUNET_YES == address_eq (active_address, best_address))))
1311 asi = best_address->solver_information;
1312 GNUNET_assert (NULL != asi);
1314 /* We sticked to the same address, therefore redistribute */
1315 distribute_bandwidth_in_network (s, asi->network);
1321 * Get application feedback for a peer
1323 * @param solver the solver handle
1324 * @param application the application
1325 * @param peer the peer to change the preference for
1326 * @param scope the time interval for this feedback: [now - scope .. now]
1327 * @param kind the kind to change the preference
1328 * @param score the score
1331 GAS_proportional_address_preference_feedback (void *solver,
1332 struct GNUNET_SERVER_Client *application,
1333 const struct GNUNET_PeerIdentity *peer,
1334 const struct GNUNET_TIME_Relative scope,
1335 enum GNUNET_ATS_PreferenceKind kind,
1338 struct GAS_PROPORTIONAL_Handle *s = solver;
1340 GNUNET_assert(NULL != peer);
1341 GNUNET_assert(NULL != s);
1346 * Get the preferred address for a specific peer
1348 * @param solver the solver handle
1349 * @param peer the identity of the peer
1350 * @return best address
1352 static const struct ATS_Address *
1353 GAS_proportional_get_preferred_address (void *solver,
1354 const struct GNUNET_PeerIdentity *peer)
1356 struct GAS_PROPORTIONAL_Handle *s = solver;
1357 const struct ATS_Address *best_address;
1359 /* Add to list of pending requests */
1361 GNUNET_CONTAINER_multipeermap_contains (s->requests, peer))
1363 GNUNET_assert (GNUNET_OK ==
1364 GNUNET_CONTAINER_multipeermap_put (s->requests,
1367 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1368 LOG (GNUNET_ERROR_TYPE_INFO,
1369 "Start suggesting addresses for peer `%s'\n",
1373 best_address = update_active_address (s, peer);
1374 if (s->bulk_lock > 0)
1375 return NULL; /* Do not suggest since bulk lock is pending */
1377 return best_address;
1382 * Stop notifying about address and bandwidth changes for this peer
1384 * @param solver the solver handle
1385 * @param peer the peer
1388 GAS_proportional_stop_get_preferred_address (void *solver,
1389 const struct GNUNET_PeerIdentity *peer)
1391 struct GAS_PROPORTIONAL_Handle *s = solver;
1392 struct ATS_Address *cur;
1393 struct AddressSolverInformation *asi;
1394 struct Network *cur_net;
1397 GNUNET_CONTAINER_multipeermap_contains (s->requests, peer))
1399 GNUNET_assert (GNUNET_OK ==
1400 GNUNET_CONTAINER_multipeermap_remove (s->requests,
1403 LOG (GNUNET_ERROR_TYPE_INFO,
1404 "Stop suggesting addresses for peer `%s'\n",
1408 cur = get_active_address (s,
1413 LOG (GNUNET_ERROR_TYPE_INFO,
1414 "Disabling %s address %p for peer `%s'\n",
1415 (GNUNET_NO == cur->active) ? "inactive" : "active",
1417 GNUNET_i2s (&cur->peer));
1419 /* Disabling current address */
1420 asi = cur->solver_information;
1421 cur_net = asi->network ;
1422 asi->activated = GNUNET_TIME_UNIT_ZERO_ABS;
1423 cur->active = GNUNET_NO; /* No active any longer */
1424 cur->assigned_bw_in = 0; /* no bandwidth assigned */
1425 cur->assigned_bw_out = 0; /* no bandwidth assigned */
1427 if (GNUNET_SYSERR ==
1428 addresse_decrement (s, cur_net, GNUNET_NO, GNUNET_YES))
1431 distribute_bandwidth_in_network (s, cur_net);
1437 * Remove an address from the solver
1439 * @param solver the solver handle
1440 * @param address the address to remove
1441 * @param session_only delete only session not whole address
1444 GAS_proportional_address_delete (void *solver,
1445 struct ATS_Address *address,
1448 struct GAS_PROPORTIONAL_Handle *s = solver;
1449 struct Network *net;
1450 struct AddressWrapper *aw;
1451 struct AddressSolverInformation *asi;
1453 /* Remove an adress completely, we have to:
1454 * - Remove from specific network
1455 * - Decrease number of total addresses
1457 * - decrease number of active addreses
1460 asi = address->solver_information;
1469 if (GNUNET_NO == session_only)
1471 LOG (GNUNET_ERROR_TYPE_INFO,
1472 "Deleting %s address %p for peer `%s' from network `%s' (total: %u/ active: %u)\n",
1473 (GNUNET_NO == address->active) ? "inactive" : "active",
1475 GNUNET_i2s (&address->peer),
1477 net->total_addresses,
1478 net->active_addresses);
1480 /* Remove address */
1481 addresse_decrement (s, net, GNUNET_YES, GNUNET_NO);
1482 for (aw = net->head; NULL != aw; aw = aw->next)
1484 if (aw->addr == address)
1492 GNUNET_CONTAINER_DLL_remove (net->head,
1499 /* Remove session only: remove if active and update */
1500 LOG (GNUNET_ERROR_TYPE_INFO,
1501 "Deleting %s session %p for peer `%s' from network `%s' (total: %u/ active: %u)\n",
1502 (GNUNET_NO == address->active) ? "inactive" : "active",
1504 GNUNET_i2s (&address->peer),
1506 net->total_addresses,
1507 net->active_addresses);
1510 if (GNUNET_YES == address->active)
1512 /* Address was active, remove from network and update quotas*/
1513 address->active = GNUNET_NO;
1514 address->assigned_bw_in = 0;
1515 address->assigned_bw_out = 0;
1516 asi->calculated_quota_in = 0;
1517 asi->calculated_quota_out = 0;
1519 if (GNUNET_SYSERR ==
1520 addresse_decrement (s, net, GNUNET_NO, GNUNET_YES))
1522 distribute_bandwidth_in_network (s, net);
1525 update_active_address (s, &address->peer))
1527 /* No alternative address found, disconnect peer */
1528 LOG (GNUNET_ERROR_TYPE_INFO,
1529 "Disconnecting peer `%s' after deleting previous address %p\n",
1530 GNUNET_i2s (&address->peer),
1532 s->env->bandwidth_changed_cb (s->env->cls,
1536 if (GNUNET_NO == session_only)
1538 GNUNET_free_non_null (address->solver_information);
1539 address->solver_information = NULL;
1542 LOG (GNUNET_ERROR_TYPE_INFO,
1543 "After deleting address now total %u and active %u addresses in network `%s'\n",
1544 net->total_addresses,
1545 net->active_addresses,
1551 * Start a bulk operation
1553 * @param solver the solver
1556 GAS_proportional_bulk_start (void *solver)
1558 struct GAS_PROPORTIONAL_Handle *s = solver;
1560 LOG (GNUNET_ERROR_TYPE_DEBUG,
1561 "Locking solver for bulk operation ...\n");
1562 GNUNET_assert (NULL != solver);
1568 * Bulk operation done
1571 GAS_proportional_bulk_stop (void *solver)
1573 struct GAS_PROPORTIONAL_Handle *s = solver;
1575 LOG (GNUNET_ERROR_TYPE_DEBUG,
1576 "Unlocking solver from bulk operation ...\n");
1577 if (s->bulk_lock < 1)
1583 if ((0 == s->bulk_lock) && (0 < s->bulk_requests))
1585 LOG(GNUNET_ERROR_TYPE_INFO, "No lock pending, recalculating\n");
1586 distribute_bandwidth_in_network (s, NULL);
1587 s->bulk_requests = 0;
1593 * Add a new single address to a network
1595 * @param solver the solver Handle
1596 * @param address the address to add
1597 * @param network network type of this address
1600 GAS_proportional_address_add (void *solver,
1601 struct ATS_Address *address,
1606 * Transport properties for this address have changed
1608 * @param solver solver handle
1609 * @param address the address
1610 * @param type the ATSI type in HBO
1611 * @param abs_value the absolute value of the property
1612 * @param rel_value the normalized value
1615 GAS_proportional_address_property_changed (void *solver,
1616 struct ATS_Address *address,
1621 struct GAS_PROPORTIONAL_Handle *s = solver;
1623 struct AddressSolverInformation *asi;
1624 struct ATS_Address *best_address;
1625 struct ATS_Address *active_address;
1627 asi = address->solver_information;
1641 LOG(GNUNET_ERROR_TYPE_INFO,
1642 "Property `%s' for peer `%s' address %p changed to %.2f \n",
1643 GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer),
1644 address, rel_value);
1646 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer))
1647 return; /* Peer is not requested */
1649 /* This peer is requested, find active and best address */
1650 active_address = get_active_address(s, s->addresses, &address->peer);
1651 best_address = update_active_address (s,
1654 if ((NULL != best_address) && ((NULL != active_address) &&
1655 (GNUNET_YES == address_eq (active_address, best_address))))
1657 asi = best_address->solver_information;
1658 GNUNET_assert (NULL != asi);
1660 /* We sticked to the same address, therefore redistribute */
1661 distribute_bandwidth_in_network (s, asi->network);
1667 * Add a new single address to a network
1669 * @param solver the solver Handle
1670 * @param address the address to add
1671 * @param network network type of this address
1674 GAS_proportional_address_add (void *solver,
1675 struct ATS_Address *address,
1676 enum GNUNET_ATS_Network_Type network)
1678 struct GAS_PROPORTIONAL_Handle *s = solver;
1679 struct Network *net;
1680 struct AddressWrapper *aw;
1681 struct AddressSolverInformation *asi;
1683 net = get_network (s, network);
1687 LOG (GNUNET_ERROR_TYPE_ERROR,
1688 "Unknown network %u `%s' for new address %p for peer `%s'\n",
1690 GNUNET_ATS_print_network_type (network),
1692 GNUNET_i2s (&address->peer));
1696 aw = GNUNET_new (struct AddressWrapper);
1698 GNUNET_CONTAINER_DLL_insert(net->head, net->tail, aw);
1699 address_increment (s, net, GNUNET_YES, GNUNET_NO);
1701 asi = GNUNET_new (struct AddressSolverInformation);
1703 asi->calculated_quota_in = 0;
1704 asi->calculated_quota_out = 0;
1705 aw->addr->solver_information = asi;
1707 LOG(GNUNET_ERROR_TYPE_INFO,
1708 "Adding new address %p for peer `%s', now total %u and active %u addresses in network `%s'\n",
1709 address, GNUNET_i2s(&address->peer), net->total_addresses, net->active_addresses, net->desc);
1711 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (s->requests, &address->peer))
1712 return; /* Peer is not requested */
1714 /* This peer is requested, find best address */
1715 update_active_address (s, &address->peer);
1721 * Function invoked when the plugin is loaded.
1723 * @param[in,out] cls the `struct GNUNET_ATS_PluginEnvironment *` to use;
1724 * modified to return the API functions (ugh).
1725 * @return the `struct GAS_PROPORTIONAL_Handle` to pass as a closure
1728 libgnunet_plugin_ats_proportional_init (void *cls)
1730 static struct GNUNET_ATS_SolverFunctions sf;
1731 struct GNUNET_ATS_PluginEnvironment *env = cls;
1732 struct GAS_PROPORTIONAL_Handle *s;
1733 struct Network * cur;
1737 GNUNET_assert (NULL != env);
1738 GNUNET_assert (NULL != env->cfg);
1739 GNUNET_assert (NULL != env->bandwidth_changed_cb);
1740 GNUNET_assert (NULL != env->get_preferences);
1741 GNUNET_assert (NULL != env->get_property);
1743 s = GNUNET_new (struct GAS_PROPORTIONAL_Handle);
1746 sf.s_add = &GAS_proportional_address_add;
1747 sf.s_address_update_property = &GAS_proportional_address_property_changed;
1748 sf.s_get = &GAS_proportional_get_preferred_address;
1749 sf.s_get_stop = &GAS_proportional_stop_get_preferred_address;
1750 sf.s_pref = &GAS_proportional_address_change_preference;
1751 sf.s_feedback = &GAS_proportional_address_preference_feedback;
1752 sf.s_del = &GAS_proportional_address_delete;
1753 sf.s_bulk_start = &GAS_proportional_bulk_start;
1754 sf.s_bulk_stop = &GAS_proportional_bulk_stop;
1756 s->network_entries = GNUNET_malloc (env->network_count * sizeof (struct Network));
1759 s->active_addresses = 0;
1760 s->total_addresses = 0;
1761 s->bulk_lock = GNUNET_NO;
1762 s->addresses = env->addresses;
1763 s->requests = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
1765 s->stability_factor = PROP_STABILITY_FACTOR;
1766 if (GNUNET_SYSERR !=
1767 GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
1768 "PROP_STABILITY_FACTOR", &f_tmp))
1770 if ((f_tmp < 1.0) || (f_tmp > 2.0))
1772 LOG (GNUNET_ERROR_TYPE_ERROR,
1773 _("Invalid %s configuration %f \n"),
1774 "PROP_STABILITY_FACTOR",
1779 s->stability_factor = f_tmp;
1780 LOG (GNUNET_ERROR_TYPE_INFO,
1781 "Using %s of %.3f\n",
1782 "PROP_STABILITY_FACTOR", f_tmp);
1786 s->prop_factor = PROPORTIONALITY_FACTOR;
1787 if (GNUNET_SYSERR !=
1788 GNUNET_CONFIGURATION_get_value_float (env->cfg, "ats",
1789 "PROP_PROPORTIONALITY_FACTOR",
1794 LOG (GNUNET_ERROR_TYPE_ERROR,
1795 _("Invalid %s configuration %f \n"),
1796 "PROP_PROPORTIONALITY_FACTOR", f_tmp);
1800 s->prop_factor = f_tmp;
1801 LOG (GNUNET_ERROR_TYPE_INFO,
1802 "Using %s of %.3f\n",
1803 "PROP_PROPORTIONALITY_FACTOR", f_tmp);
1807 for (c = 0; c < env->network_count; c++)
1809 cur = &s->network_entries[c];
1811 cur->total_quota_in = env->in_quota[c];
1812 cur->total_quota_out = env->out_quota[c];
1813 cur->desc = GNUNET_ATS_print_network_type (c);
1814 GNUNET_asprintf (&cur->stat_total,
1815 "# ATS addresses %s total",
1817 GNUNET_asprintf (&cur->stat_active,
1818 "# ATS active addresses %s total",
1820 LOG (GNUNET_ERROR_TYPE_INFO,
1821 "Added network %u `%s' (%llu/%llu)\n",
1824 cur->total_quota_in,
1825 cur->total_quota_out);
1831 /* end of plugin_ats_proportional.c */