2 This file is part of GNUnet.
3 (C) 2009 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 transport/transport_ats.h
23 * @brief common internal definitions for transport service's ats code
24 * @author Matthias Wachs
26 #ifndef TRANSPORT_ATS_H
27 #define TRANSPORT_ATS_H
30 #include "gnunet_constants.h"
31 #include "gnunet_scheduler_lib.h"
32 #include "gnunet_statistics_service.h"
33 #include "gnunet_time_lib.h"
44 #define DEBUG_ATS GNUNET_NO
45 #define VERBOSE_ATS GNUNET_NO
48 /* Minimum time between to calculations*/
49 #define ATS_MIN_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 15)
50 #define ATS_EXEC_INTERVAL GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30)
51 #define ATS_MAX_EXEC_DURATION GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 3)
52 #define ATS_MAX_ITERATIONS INT_MAX
54 #define ATS_DEFAULT_D 1.0
55 #define ATS_DEFAULT_U 1.0
56 #define ATS_DEFAULT_R 1.0
57 #define ATS_DEFAULT_B_MIN 64000
58 #define ATS_DEFAULT_N_MIN 10
60 #define VERY_BIG_DOUBLE_VALUE 100000000000LL
70 typedef void (*GNUNET_TRANSPORT_ATS_AddressNotification)
71 (struct ATS_peer **peers,
73 struct ATS_mechanism ** mechanisms,
76 typedef void (*GNUNET_TRANSPORT_ATS_ResultCallback) (void);
78 enum ATS_problem_state
86 * Problem quality properties were modified
88 ATS_QUALITY_UPDATED = 1,
91 * Problem ressource properties were modified
96 * Problem quality and ressource properties were modified
98 ATS_QUALITY_COST_UPDATED = 3,
101 * Problem is modified and needs to be completely recalculated
102 * due to e.g. connecting or disconnecting peers
107 * Problem is unmodified
113 * ATS data structures
119 * result of last GLPK run
125 * Ressource costs or quality metrics changed
126 * update problem before solving
128 int modified_resources;
131 * Ressource costs or quality metrics changed, update matrix
132 * update problem before solving
134 int modified_quality;
137 * Peers have connected or disconnected
138 * problem has to be recreated
140 int recreate_problem;
143 * Was the available basis invalid and we needed to rerun simplex?
145 int simplex_rerun_required;
148 * is problem currently valid and can it be solved
153 * Number of transport mechanisms in the problem
158 * Number of transport mechanisms in the problem
163 * row index where quality related rows start
168 * row index where quality related rows end
173 * row index where ressource cost related rows start
178 * row index where ressource cost related rows end
183 * column index for objective function value d
188 * column index for objective function value u
193 * column index for objective function value r
198 * column index for objective function value quality metrics
203 * column index for objective function value cost ressources
214 GNUNET_TRANSPORT_ATS_AddressNotification addr_notification;
216 GNUNET_TRANSPORT_ATS_ResultCallback result_cb;
219 * Maximum execution time per calculation
221 struct GNUNET_TIME_Relative max_exec_duration;
224 * GLPK (MLP) problem object
234 * Internal information state of the GLPK problem
236 struct ATS_internals internal;
239 * mechanisms used in current problem
240 * needed for problem modification
242 struct ATS_mechanism * mechanisms;
245 * peers used in current problem
246 * needed for problem modification
248 struct ATS_peer * peers;
251 * State of the MLP problem
252 * value of ATS_problem_state
258 * number of successful executions
260 int successful_executions;
263 * number with an invalid result
265 int invalid_executions;
268 * Maximum number of LP iterations per calculation
294 * Minimum bandwidth per peer
299 * Minimum number of connections per peer
305 * Logging related variables
310 * Dump problem to a file?
315 * Dump solution to a file
320 * Dump solution when minimum peers:
325 * Dump solution when minimum addresses:
330 * Dump solution overwrite file:
337 struct ATS_mechanism * prev;
338 struct ATS_mechanism * next;
339 struct ForeignAddressList * addr;
340 struct ATS_quality_entry * quality;
341 struct ATS_ressource_entry * ressources;
342 struct TransportPlugin * plugin;
343 struct ATS_peer * peer;
346 struct ATS_ressource_cost * rc;
351 struct GNUNET_PeerIdentity peer;
353 struct ATS_mechanism * m_head;
354 struct ATS_mechanism * m_tail;
356 /* preference value f */
359 //struct NeighbourList * n;
364 /* index in ressources array */
366 /* depending ATSi parameter to calculcate limits */
368 /* cfg option to load limits */
375 /* cofficients for the specific plugins */
386 struct ATS_ressource_entry
388 /* index in ressources array */
390 /* depending ATSi parameter to calculcate limits */
397 struct ATS_quality_metric
404 struct ATS_quality_entry
417 static struct ATS_ressource ressources[] =
419 /* FIXME: the coefficients for the specific plugins */
420 {1, 7, "LAN_BW_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 1, 1, 2, 2, 1, 3},
421 {2, 7, "WAN_BW_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 1, 1, 2, 2, 2, 3},
422 {3, 4, "WLAN_ENERGY_LIMIT", 0, VERY_BIG_DOUBLE_VALUE, 0, 0, 0, 0, 0, 2, 1}
424 {4, 4, "COST_ENERGY_CONSUMPTION", VERY_BIG_DOUBLE_VALUE},
425 {5, 5, "COST_CONNECT", VERY_BIG_DOUBLE_VALUE},
426 {6, 6, "COST_BANDWITH_AVAILABLE", VERY_BIG_DOUBLE_VALUE},
427 {7, 7, "COST_NETWORK_OVERHEAD", VERY_BIG_DOUBLE_VALUE},*/
430 #define available_ressources (sizeof(ressources)/sizeof(*ressources))
433 * ATS quality metrics
436 static struct ATS_quality_metric qm[] =
438 {1, 1028, "QUALITY_NET_DISTANCE"},
439 {2, 1034, "QUALITY_NET_DELAY"},
442 #define available_quality_metrics (sizeof(qm)/sizeof(*qm))
455 struct GNUNET_TIME_Relative max_duration,
456 GNUNET_TRANSPORT_ATS_AddressNotification address_not,
457 GNUNET_TRANSPORT_ATS_ResultCallback res_cb);
460 ats_shutdown (struct ATS_Handle * ats);
463 ats_delete_problem (struct ATS_Handle * ats);
466 ats_create_problem (struct ATS_Handle *ats,
467 struct ATS_internals *stat,
468 struct ATS_peer *peers,
470 struct ATS_mechanism *mechanisms,
473 void ats_modify_problem_state (struct ATS_Handle * ats,
474 enum ATS_problem_state s);
477 ats_calculate_bandwidth_distribution (struct ATS_Handle * ats,
478 struct GNUNET_STATISTICS_Handle *stats);
481 ats_solve_problem (struct ATS_Handle * ats,
483 unsigned int max_dur,
484 unsigned int c_peers,
485 unsigned int c_mechs,
486 struct ATS_internals *stat);
489 ats_evaluate_results (int result,
494 ats_update_problem_qm (struct ATS_Handle * ats);
497 ats_update_problem_cr (struct ATS_Handle * ats);
501 ats_set_logging_options (struct ATS_Handle * ats,
502 int minimum_addresses,
509 /* end of file transport_ats.h */