aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-08 22:46:45 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-08 22:46:45 +0000
commit03a39827ef721653ad9509ce12173bd674592caf (patch)
treefded13687ea0b725c3a61e9f00ac979797ddd8f0 /src
parentdc2ca2186e69be1e24e864251bd6e17e40236d9c (diff)
downloadgnunet-03a39827ef721653ad9509ce12173bd674592caf.tar.gz
gnunet-03a39827ef721653ad9509ce12173bd674592caf.zip
-updating comments
Diffstat (limited to 'src')
-rw-r--r--src/ats/plugin_ats_proportional.c194
1 files changed, 15 insertions, 179 deletions
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c
index bacb57e02..d65cbb289 100644
--- a/src/ats/plugin_ats_proportional.c
+++ b/src/ats/plugin_ats_proportional.c
@@ -17,7 +17,6 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19 */
20
21/** 20/**
22 * @file ats/plugin_ats_proportional.c 21 * @file ats/plugin_ats_proportional.c
23 * @brief ATS proportional solver 22 * @brief ATS proportional solver
@@ -30,189 +29,24 @@
30#include "gnunet_ats_service.h" 29#include "gnunet_ats_service.h"
31#include "gnunet-service-ats_addresses.h" 30#include "gnunet-service-ats_addresses.h"
32 31
33#define PROP_STABILITY_FACTOR 1.25
34
35
36#define LOG(kind,...) GNUNET_log_from (kind, "ats-proportional",__VA_ARGS__) 32#define LOG(kind,...) GNUNET_log_from (kind, "ats-proportional",__VA_ARGS__)
37 33
38
39/** 34/**
40 * 35 * How much do we value stability over adaptation by default. A low
41 * NOTE: Do not change this documentation. This documentation is based 36 * value (close to 1.0) means we adapt as soon as possible, a larger
42 * on gnunet.org:/vcs/fsnsg/ats-paper.git/tech-doku/ats-tech-guide.tex 37 * value means that we have to have the respective factor of an
43 * use build_txt.sh to generate plaintext output 38 * advantage (or delay) before we adapt and sacrifice stability.
44 *
45 * ATS addresses : proportional solver
46 *
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
61 *
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 *
76 * preference changes
77 *
78 * 3.1 Data structures used
79 *
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.
87 *
88 * 3.2 Initializing
89 *
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.
93 *
94 * 3.3 Adding an address
95 *
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.
99 *
100 * 3.4 Updating an address
101 *
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.
124 *
125 * 3.5 Deleting an address
126 *
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
130 * network.
131 *
132 * 3.6 Requesting addresses
133 *
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.
149 *
150 * 3.7 Choosing addresses
151 *
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
170 * latency
171 *
172 * 3.8 Changing preferences
173 *
174 * 3.9 Shutdown
175 *
176 * During shutdown all network entries and aging processes are
177 * destroyed and freed.
178 *
179 *
180 * OLD DOCUMENTATION
181 *
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.
185 *
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
189 * callback.
190 *
191 * - Initialization
192 *
193 *
194 *
195 *
196 * For each peer only a single is selected and marked as "active" in the address
197 * struct.
198 *
199 * E.g.:
200 *
201 * You have the networks WAN and LAN and quotas
202 * WAN_TOTAL_IN, WAN_TOTAL_OUT
203 * LAN_TOTAL_IN, LAN_TOTAL_OUT
204 *
205 * If you have x addresses in the network segment LAN, the quotas are
206 * QUOTA_PER_ADDRESS = LAN_TOTAL_OUT / x
207 *
208 * Quotas are automatically recalculated and reported back when addresses are
209 * - requested
210 *
211 */ 39 */
40#define PROP_STABILITY_FACTOR 1.25
41
212 42
213/** 43/**
214 * Default value to assume for the proportionality factor, 44 * Default value to assume for the proportionality factor, if none is
215 * if none is given in the configuration. 45 * given in the configuration. This factor determines how strong the
46 * bandwidth allocation will orient itself on the application
47 * preferences. A lower factor means a more balanced bandwidth
48 * distribution while a larger number means a distribution more in
49 * line with application (bandwidth) preferences.
216 */ 50 */
217#define PROPORTIONALITY_FACTOR 2.0 51#define PROPORTIONALITY_FACTOR 2.0
218 52
@@ -1050,6 +884,8 @@ GAS_proportional_change_preference (void *solver,
1050{ 884{
1051 struct GAS_PROPORTIONAL_Handle *s = solver; 885 struct GAS_PROPORTIONAL_Handle *s = solver;
1052 886
887 if (GNUNET_ATS_PREFERENCE_BANDWIDTH != kind)
888 return; /* we do not care */
1053 distribute_bandwidth_in_network (s, 889 distribute_bandwidth_in_network (s,
1054 NULL); 890 NULL);
1055} 891}
@@ -1172,7 +1008,7 @@ GAS_proportional_bulk_stop (void *solver)
1172 * 1008 *
1173 * @param solver solver handle 1009 * @param solver solver handle
1174 * @param address the address 1010 * @param address the address
1175 * @param type the ATSI type in HBO 1011 * @param type the ATSI type
1176 * @param abs_value the absolute value of the property 1012 * @param abs_value the absolute value of the property
1177 * @param rel_value the normalized value 1013 * @param rel_value the normalized value
1178 */ 1014 */