aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_ats.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/transport/gnunet-service-transport_ats.h
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
downloadgnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz
gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip
indentation
Diffstat (limited to 'src/transport/gnunet-service-transport_ats.h')
-rw-r--r--src/transport/gnunet-service-transport_ats.h273
1 files changed, 129 insertions, 144 deletions
diff --git a/src/transport/gnunet-service-transport_ats.h b/src/transport/gnunet-service-transport_ats.h
index 5226c24df..d1d789b5f 100644
--- a/src/transport/gnunet-service-transport_ats.h
+++ b/src/transport/gnunet-service-transport_ats.h
@@ -68,10 +68,8 @@ struct ATS_mechanism;
68struct ATS_peer; 68struct ATS_peer;
69 69
70typedef void (*GNUNET_TRANSPORT_ATS_AddressNotification) 70typedef void (*GNUNET_TRANSPORT_ATS_AddressNotification)
71 (struct ATS_peer **peers, 71 (struct ATS_peer ** peers,
72 int * c_p, 72 int *c_p, struct ATS_mechanism ** mechanisms, int *c_m);
73 struct ATS_mechanism ** mechanisms,
74 int * c_m );
75 73
76typedef void (*GNUNET_TRANSPORT_ATS_ResultCallback) (void); 74typedef void (*GNUNET_TRANSPORT_ATS_ResultCallback) (void);
77 75
@@ -119,192 +117,192 @@ struct ATS_internals
119 * result of last GLPK run 117 * result of last GLPK run
120 * 5 == OPTIMAL 118 * 5 == OPTIMAL
121 */ 119 */
122 int solution; 120 int solution;
123 121
124 /** 122 /**
125 * Ressource costs or quality metrics changed 123 * Ressource costs or quality metrics changed
126 * update problem before solving 124 * update problem before solving
127 */ 125 */
128 int modified_resources; 126 int modified_resources;
129 127
130 /** 128 /**
131 * Ressource costs or quality metrics changed, update matrix 129 * Ressource costs or quality metrics changed, update matrix
132 * update problem before solving 130 * update problem before solving
133 */ 131 */
134 int modified_quality; 132 int modified_quality;
135 133
136 /** 134 /**
137 * Peers have connected or disconnected 135 * Peers have connected or disconnected
138 * problem has to be recreated 136 * problem has to be recreated
139 */ 137 */
140 int recreate_problem; 138 int recreate_problem;
141 139
142 /** 140 /**
143 * Was the available basis invalid and we needed to rerun simplex? 141 * Was the available basis invalid and we needed to rerun simplex?
144 */ 142 */
145 int simplex_rerun_required; 143 int simplex_rerun_required;
146 144
147 /** 145 /**
148 * is problem currently valid and can it be solved 146 * is problem currently valid and can it be solved
149 */ 147 */
150 int valid; 148 int valid;
151 149
152 /** 150 /**
153 * Number of transport mechanisms in the problem 151 * Number of transport mechanisms in the problem
154 */ 152 */
155 int c_mechs; 153 int c_mechs;
156 154
157 /** 155 /**
158 * Number of transport mechanisms in the problem 156 * Number of transport mechanisms in the problem
159 */ 157 */
160 int c_peers; 158 int c_peers;
161 159
162 /** 160 /**
163 * row index where quality related rows start 161 * row index where quality related rows start
164 */ 162 */
165 int begin_qm; 163 int begin_qm;
166 164
167 /** 165 /**
168 * row index where quality related rows end 166 * row index where quality related rows end
169 */ 167 */
170 int end_qm; 168 int end_qm;
171 169
172 /** 170 /**
173 * row index where ressource cost related rows start 171 * row index where ressource cost related rows start
174 */ 172 */
175 int begin_cr; 173 int begin_cr;
176 174
177 /** 175 /**
178 * row index where ressource cost related rows end 176 * row index where ressource cost related rows end
179 */ 177 */
180 int end_cr; 178 int end_cr;
181 179
182 /** 180 /**
183 * column index for objective function value d 181 * column index for objective function value d
184 */ 182 */
185 int col_d; 183 int col_d;
186 184
187 /** 185 /**
188 * column index for objective function value u 186 * column index for objective function value u
189 */ 187 */
190 int col_u; 188 int col_u;
191 189
192 /** 190 /**
193 * column index for objective function value r 191 * column index for objective function value r
194 */ 192 */
195 int col_r; 193 int col_r;
196 194
197 /** 195 /**
198 * column index for objective function value quality metrics 196 * column index for objective function value quality metrics
199 */ 197 */
200 int col_qm; 198 int col_qm;
201 199
202 /** 200 /**
203 * column index for objective function value cost ressources 201 * column index for objective function value cost ressources
204 */ 202 */
205 int col_cr; 203 int col_cr;
206}; 204};
207 205
208struct ATS_Handle 206struct ATS_Handle
209{ 207{
210 /* 208 /*
211 * Callback functions 209 * Callback functions
212 */ 210 */
213 211
214 GNUNET_TRANSPORT_ATS_AddressNotification addr_notification; 212 GNUNET_TRANSPORT_ATS_AddressNotification addr_notification;
215 213
216 GNUNET_TRANSPORT_ATS_ResultCallback result_cb; 214 GNUNET_TRANSPORT_ATS_ResultCallback result_cb;
217 215
218 216
219 /** 217 /**
220 * Statistics handle 218 * Statistics handle
221 */ 219 */
222 struct GNUNET_STATISTICS_Handle *stats; 220 struct GNUNET_STATISTICS_Handle *stats;
223 221
224 /** 222 /**
225 * Maximum execution time per calculation 223 * Maximum execution time per calculation
226 */ 224 */
227 struct GNUNET_TIME_Relative max_exec_duration; 225 struct GNUNET_TIME_Relative max_exec_duration;
228 226
229 /** 227 /**
230 * GLPK (MLP) problem object 228 * GLPK (MLP) problem object
231 */ 229 */
232#if HAVE_LIBGLPK 230#if HAVE_LIBGLPK
233 231
234 glp_prob *prob; 232 glp_prob *prob;
235#else 233#else
236 void * prob; 234 void *prob;
237#endif 235#endif
238 236
239 /** 237 /**
240 * Internal information state of the GLPK problem 238 * Internal information state of the GLPK problem
241 */ 239 */
242 struct ATS_internals internal; 240 struct ATS_internals internal;
243 241
244 /** 242 /**
245 * mechanisms used in current problem 243 * mechanisms used in current problem
246 * needed for problem modification 244 * needed for problem modification
247 */ 245 */
248 struct ATS_mechanism * mechanisms; 246 struct ATS_mechanism *mechanisms;
249 247
250 /** 248 /**
251 * peers used in current problem 249 * peers used in current problem
252 * needed for problem modification 250 * needed for problem modification
253 */ 251 */
254 struct ATS_peer * peers; 252 struct ATS_peer *peers;
255 253
256 /** 254 /**
257 * State of the MLP problem 255 * State of the MLP problem
258 * value of ATS_problem_state 256 * value of ATS_problem_state
259 * 257 *
260 */ 258 */
261 int state; 259 int state;
262 260
263 /** 261 /**
264 * number of successful executions 262 * number of successful executions
265 */ 263 */
266 int successful_executions; 264 int successful_executions;
267 265
268 /** 266 /**
269 * number with an invalid result 267 * number with an invalid result
270 */ 268 */
271 int invalid_executions; 269 int invalid_executions;
272 270
273 /** 271 /**
274 * Maximum number of LP iterations per calculation 272 * Maximum number of LP iterations per calculation
275 */ 273 */
276 int max_iterations; 274 int max_iterations;
277 275
278 276
279 /* 277 /*
280 * ATS configuration 278 * ATS configuration
281 */ 279 */
282 280
283 281
284 /** 282 /**
285 * Diversity weight 283 * Diversity weight
286 */ 284 */
287 double D; 285 double D;
288 286
289 /** 287 /**
290 * Utility weight 288 * Utility weight
291 */ 289 */
292 double U; 290 double U;
293 291
294 /** 292 /**
295 * Relativity weight 293 * Relativity weight
296 */ 294 */
297 double R; 295 double R;
298 296
299 /** 297 /**
300 * Minimum bandwidth per peer 298 * Minimum bandwidth per peer
301 */ 299 */
302 int v_b_min; 300 int v_b_min;
303 301
304 /** 302 /**
305 * Minimum number of connections per peer 303 * Minimum number of connections per peer
306 */ 304 */
307 int v_n_min; 305 int v_n_min;
308 306
309 307
310 /** 308 /**
@@ -315,104 +313,104 @@ struct ATS_Handle
315 /** 313 /**
316 * Dump problem to a file? 314 * Dump problem to a file?
317 */ 315 */
318 int save_mlp; 316 int save_mlp;
319 317
320 /** 318 /**
321 * Dump solution to a file 319 * Dump solution to a file
322 */ 320 */
323 int save_solution; 321 int save_solution;
324 322
325 /** 323 /**
326 * Dump solution when minimum peers: 324 * Dump solution when minimum peers:
327 */ 325 */
328 int dump_min_peers; 326 int dump_min_peers;
329 327
330 /** 328 /**
331 * Dump solution when minimum addresses: 329 * Dump solution when minimum addresses:
332 */ 330 */
333 int dump_min_addr; 331 int dump_min_addr;
334 332
335 /** 333 /**
336 * Dump solution overwrite file: 334 * Dump solution overwrite file:
337 */ 335 */
338 int dump_overwrite; 336 int dump_overwrite;
339}; 337};
340 338
341struct ATS_mechanism 339struct ATS_mechanism
342{ 340{
343 struct ATS_mechanism * prev; 341 struct ATS_mechanism *prev;
344 struct ATS_mechanism * next; 342 struct ATS_mechanism *next;
345 struct ForeignAddressList * addr; 343 struct ForeignAddressList *addr;
346 struct ATS_quality_entry * quality; 344 struct ATS_quality_entry *quality;
347 struct ATS_ressource_entry * ressources; 345 struct ATS_ressource_entry *ressources;
348 struct TransportPlugin * plugin; 346 struct TransportPlugin *plugin;
349 struct ATS_peer * peer; 347 struct ATS_peer *peer;
350 int col_index; 348 int col_index;
351 int id; 349 int id;
352 struct ATS_ressource_cost * rc; 350 struct ATS_ressource_cost *rc;
353}; 351};
354 352
355struct ATS_peer 353struct ATS_peer
356{ 354{
357 struct GNUNET_PeerIdentity peer; 355 struct GNUNET_PeerIdentity peer;
358 356
359 struct ATS_mechanism * m_head; 357 struct ATS_mechanism *m_head;
360 struct ATS_mechanism * m_tail; 358 struct ATS_mechanism *m_tail;
361 359
362 /* preference value f */ 360 /* preference value f */
363 double f; 361 double f;
364 362
365 //struct NeighbourList * n; 363 //struct NeighbourList * n;
366}; 364};
367 365
368struct ATS_ressource 366struct ATS_ressource
369{ 367{
370 /* index in ressources array */ 368 /* index in ressources array */
371 int index; 369 int index;
372 /* depending ATSi parameter to calculcate limits */ 370 /* depending ATSi parameter to calculcate limits */
373 int atis_index; 371 int atis_index;
374 /* cfg option to load limits */ 372 /* cfg option to load limits */
375 char * cfg_param; 373 char *cfg_param;
376 /* lower bound */ 374 /* lower bound */
377 double c_min; 375 double c_min;
378 /* upper bound */ 376 /* upper bound */
379 double c_max; 377 double c_max;
380 378
381 /* cofficients for the specific plugins */ 379 /* cofficients for the specific plugins */
382 double c_unix; 380 double c_unix;
383 double c_tcp; 381 double c_tcp;
384 double c_udp; 382 double c_udp;
385 double c_http; 383 double c_http;
386 double c_https; 384 double c_https;
387 double c_wlan; 385 double c_wlan;
388 double c_default; 386 double c_default;
389}; 387};
390 388
391 389
392struct ATS_ressource_entry 390struct ATS_ressource_entry
393{ 391{
394 /* index in ressources array */ 392 /* index in ressources array */
395 int index; 393 int index;
396 /* depending ATSi parameter to calculcate limits */ 394 /* depending ATSi parameter to calculcate limits */
397 int atis_index; 395 int atis_index;
398 /* lower bound */ 396 /* lower bound */
399 double c; 397 double c;
400}; 398};
401 399
402 400
403struct ATS_quality_metric 401struct ATS_quality_metric
404{ 402{
405 int index; 403 int index;
406 int atis_index; 404 int atis_index;
407 char * name; 405 char *name;
408}; 406};
409 407
410struct ATS_quality_entry 408struct ATS_quality_entry
411{ 409{
412 int index; 410 int index;
413 int atsi_index; 411 int atsi_index;
414 uint32_t values[3]; 412 uint32_t values[3];
415 int current; 413 int current;
416}; 414};
417 415
418/* 416/*
@@ -420,12 +418,11 @@ struct ATS_quality_entry
420 */ 418 */
421 419
422 420
423static struct ATS_ressource ressources[] = 421static struct ATS_ressource ressources[] = {
424{ 422 /* FIXME: the coefficients for the specific plugins */
425 /* FIXME: the coefficients for the specific plugins */ 423 {1, 7, "LAN_BW_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 1, 1, 2, 2, 1, 3},
426 {1, 7, "LAN_BW_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 1, 1, 2, 2, 1, 3}, 424 {2, 7, "WAN_BW_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 1, 1, 2, 2, 2, 3},
427 {2, 7, "WAN_BW_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 1, 1, 2, 2, 2, 3}, 425 {3, 4, "WLAN_ENERGY_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 0, 0, 0, 0, 2, 1}
428 {3, 4, "WLAN_ENERGY_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 0, 0, 0, 0, 2, 1}
429/* 426/*
430 {4, 4, "COST_ENERGY_CONSUMPTION", VERY_BIG_DOUBLE_VALUE}, 427 {4, 4, "COST_ENERGY_CONSUMPTION", VERY_BIG_DOUBLE_VALUE},
431 {5, 5, "COST_CONNECT", VERY_BIG_DOUBLE_VALUE}, 428 {5, 5, "COST_CONNECT", VERY_BIG_DOUBLE_VALUE},
@@ -439,8 +436,7 @@ static struct ATS_ressource ressources[] =
439 * ATS quality metrics 436 * ATS quality metrics
440 */ 437 */
441 438
442static struct ATS_quality_metric qm[] = 439static struct ATS_quality_metric qm[] = {
443{
444 {1, 1028, "QUALITY_NET_DISTANCE"}, 440 {1, 1028, "QUALITY_NET_DISTANCE"},
445 {2, 1034, "QUALITY_NET_DELAY"}, 441 {2, 1034, "QUALITY_NET_DELAY"},
446}; 442};
@@ -451,61 +447,50 @@ static struct ATS_quality_metric qm[] =
451/* 447/*
452 * ATS functions 448 * ATS functions
453 */ 449 */
454struct ATS_Handle * 450struct ATS_Handle *ats_init (double D,
455ats_init (double D, 451 double U,
456 double U, 452 double R,
457 double R, 453 int v_b_min,
458 int v_b_min, 454 int v_n_min,
459 int v_n_min, 455 int max_iterations,
460 int max_iterations, 456 struct GNUNET_TIME_Relative max_duration,
461 struct GNUNET_TIME_Relative max_duration, 457 GNUNET_TRANSPORT_ATS_AddressNotification
462 GNUNET_TRANSPORT_ATS_AddressNotification address_not, 458 address_not,
463 GNUNET_TRANSPORT_ATS_ResultCallback res_cb); 459 GNUNET_TRANSPORT_ATS_ResultCallback res_cb);
464 460
465void 461void ats_shutdown (struct ATS_Handle *ats);
466ats_shutdown (struct ATS_Handle * ats);
467 462
468void 463void ats_delete_problem (struct ATS_Handle *ats);
469ats_delete_problem (struct ATS_Handle * ats);
470 464
471int 465int
472ats_create_problem (struct ATS_Handle *ats, 466ats_create_problem (struct ATS_Handle *ats,
473 struct ATS_internals *stat, 467 struct ATS_internals *stat,
474 struct ATS_peer *peers, 468 struct ATS_peer *peers,
475 int c_p, 469 int c_p, struct ATS_mechanism *mechanisms, int c_m);
476 struct ATS_mechanism *mechanisms,
477 int c_m);
478 470
479void ats_modify_problem_state (struct ATS_Handle * ats, 471void ats_modify_problem_state (struct ATS_Handle *ats,
480 enum ATS_problem_state s); 472 enum ATS_problem_state s);
481 473
482void 474void ats_calculate_bandwidth_distribution (struct ATS_Handle *ats);
483ats_calculate_bandwidth_distribution (struct ATS_Handle * ats);
484 475
485void 476void
486ats_solve_problem (struct ATS_Handle * ats, 477ats_solve_problem (struct ATS_Handle *ats,
487 unsigned int max_it, 478 unsigned int max_it,
488 unsigned int max_dur, 479 unsigned int max_dur,
489 unsigned int c_peers, 480 unsigned int c_peers,
490 unsigned int c_mechs, 481 unsigned int c_mechs, struct ATS_internals *stat);
491 struct ATS_internals *stat);
492 482
493int 483int ats_evaluate_results (int result, int solution, char *problem);
494ats_evaluate_results (int result,
495 int solution,
496 char * problem);
497 484
498void 485void ats_update_problem_qm (struct ATS_Handle *ats);
499ats_update_problem_qm (struct ATS_Handle * ats);
500 486
501void 487void ats_update_problem_cr (struct ATS_Handle *ats);
502ats_update_problem_cr (struct ATS_Handle * ats);
503 488
504 489
505void 490void
506ats_set_logging_options (struct ATS_Handle * ats, 491ats_set_logging_options (struct ATS_Handle *ats,
507 struct GNUNET_STATISTICS_Handle *stats, 492 struct GNUNET_STATISTICS_Handle *stats,
508 const struct GNUNET_CONFIGURATION_Handle *cfg); 493 const struct GNUNET_CONFIGURATION_Handle *cfg);
509 494
510#endif 495#endif
511/* end of file gnunet-service-transport_ats.h */ 496/* end of file gnunet-service-transport_ats.h */