2 This file is part of GNUnet.
3 Copyright (C) 2010-2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file ats-tests/ats-testing-experiment.c
22 * @brief ats benchmark: controlled experiment execution
23 * @author Christian Grothoff
24 * @author Matthias Wachs
26 #ifndef GNUNET_ATS_SOLVER_EVAL_H
27 #define GNUNET_ATS_SOLVER_EVAL_H
30 #include "gnunet_util_lib.h"
31 #include "gnunet_ats_plugin.h"
32 #include "gnunet_ats_service.h"
33 #include "gnunet-service-ats_addresses.h"
34 #include "gnunet-service-ats_normalization.h"
35 #include "test_ats_api_common.h"
39 GNUNET_ATS_TEST_TG_LINEAR,
40 GNUNET_ATS_TEST_TG_CONSTANT,
41 GNUNET_ATS_TEST_TG_RANDOM,
42 GNUNET_ATS_TEST_TG_SINUS
48 SOLVER_OP_ADD_ADDRESS,
49 SOLVER_OP_DEL_ADDRESS,
50 SOLVER_OP_START_SET_PROPERTY,
51 SOLVER_OP_STOP_SET_PROPERTY,
52 SOLVER_OP_START_SET_PREFERENCE,
53 SOLVER_OP_STOP_SET_PREFERENCE,
54 SOLVER_OP_START_REQUEST,
55 SOLVER_OP_STOP_REQUEST,
68 struct GNUNET_ATS_PluginEnvironment env;
73 struct GNUNET_ATS_SolverFunctions *sf;
78 struct GNUNET_CONTAINER_MultiPeerMap *addresses;
81 enum GNUNET_ATS_Solvers
83 GNUNET_ATS_SOLVER_PROPORTIONAL,
84 GNUNET_ATS_SOLVER_MLP,
85 GNUNET_ATS_SOLVER_RIL,
88 struct LoggingFileHandle
90 /* DLL list for logging time steps */
91 struct LoggingFileHandle *next;
92 struct LoggingFileHandle *prev;
95 long long unsigned int pid;
98 long long unsigned int aid;
100 struct GNUNET_DISK_FileHandle *f_hd;
104 struct LoggingTimeStep
106 struct LoggingTimeStep *prev;
107 struct LoggingTimeStep *next;
109 struct LoggingPeer *head;
110 struct LoggingPeer *tail;
112 struct GNUNET_TIME_Absolute timestamp;
113 struct GNUNET_TIME_Relative delta;
118 struct LoggingPeer *prev;
119 struct LoggingPeer *next;
121 long long unsigned int id;
122 struct GNUNET_PeerIdentity peer_id;
123 double pref_abs[GNUNET_ATS_PREFERENCE_END];
124 double pref_norm[GNUNET_ATS_PREFERENCE_END];
127 struct LoggingAddress *addr_head;
128 struct LoggingAddress *addr_tail;
131 struct LoggingAddress
133 struct LoggingAddress *next;
134 struct LoggingAddress *prev;
136 long long unsigned int aid;
139 uint32_t assigned_bw_in;
140 uint32_t assigned_bw_out;
142 double prop_abs[GNUNET_ATS_PropertyCount];
143 double prop_norm[GNUNET_ATS_PropertyCount];
149 struct TestPeer *prev;
150 struct TestPeer *next;
153 long long unsigned int id;
155 struct GNUNET_PeerIdentity peer_id;
157 double pref_abs[GNUNET_ATS_PreferenceCount];
158 double pref_norm[GNUNET_ATS_PreferenceCount];
160 uint32_t assigned_bw_in;
161 uint32_t assigned_bw_out;
163 struct TestAddress *addr_head;
164 struct TestAddress *addr_tail;
170 struct TestAddress *next;
171 struct TestAddress *prev;
173 long long unsigned int aid;
174 struct ATS_Address *ats_addr;
177 double prop_abs[GNUNET_ATS_PropertyCount];
178 double prop_norm[GNUNET_ATS_PropertyCount];
185 typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) (
188 typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e,
189 struct GNUNET_TIME_Relative duration,int success);
192 * An operation in an experiment
194 struct GNUNET_ATS_TEST_Operation
196 struct GNUNET_ATS_TEST_Operation *next;
197 struct GNUNET_ATS_TEST_Operation *prev;
199 long long unsigned int address_id;
200 long long unsigned int peer_id;
201 long long unsigned int client_id;
203 long long unsigned int address_session;
204 unsigned int address_network;
209 long long unsigned int base_rate;
210 long long unsigned int max_rate;
211 struct GNUNET_TIME_Relative period;
212 struct GNUNET_TIME_Relative frequency;
213 struct GNUNET_TIME_Relative feedback_delay;
215 enum OperationType type;
216 enum GeneratorType gen_type;
217 enum GNUNET_ATS_PreferenceKind pref_type;
218 // enum GNUNET_ATS_Property prop_type;
224 struct Episode *next;
225 struct GNUNET_TIME_Relative duration;
227 struct GNUNET_ATS_TEST_Operation *head;
228 struct GNUNET_ATS_TEST_Operation *tail;
233 struct GNUNET_SCHEDULER_Task * logging_task;
234 struct GNUNET_TIME_Relative log_freq;
236 /* DLL list for logging time steps */
237 struct LoggingTimeStep *head;
238 struct LoggingTimeStep *tail;
246 char *log_output_dir;
247 int log_append_time_stamp;
249 struct GNUNET_TIME_Relative log_freq;
250 struct GNUNET_TIME_Relative max_duration;
251 struct GNUNET_TIME_Relative total_duration;
252 struct GNUNET_TIME_Absolute start_time;
253 unsigned int num_episodes;
254 struct Episode *start;
256 struct GNUNET_CONFIGURATION_Handle *cfg;
258 struct GNUNET_SCHEDULER_Task * experiment_timeout_task;
259 struct GNUNET_SCHEDULER_Task * episode_timeout_task;
262 GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb;
263 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
266 struct PreferenceGenerator
268 struct PreferenceGenerator *prev;
269 struct PreferenceGenerator *next;
271 enum GeneratorType type;
273 long long unsigned int peer;
274 unsigned int client_id;
276 enum GNUNET_ATS_PreferenceKind kind;
280 struct GNUNET_TIME_Relative duration_period;
281 struct GNUNET_TIME_Relative frequency;
282 struct GNUNET_TIME_Relative feedback_frequency;
284 struct GNUNET_SCHEDULER_Task * set_task;
285 struct GNUNET_SCHEDULER_Task * feedback_task;
286 struct GNUNET_TIME_Absolute next_ping_transmission;
287 struct GNUNET_TIME_Absolute time_start;
291 uint32_t feedback_bw_out_acc;
292 uint32_t feedback_bw_in_acc;
293 uint32_t feedback_delay_acc;
296 double pref_latency_old;
298 struct GNUNET_TIME_Absolute feedback_last;
300 struct GNUNET_TIME_Absolute feedback_last_bw_update;
301 struct GNUNET_TIME_Absolute feedback_last_delay_update;
302 uint32_t last_assigned_bw_in;
303 uint32_t last_assigned_bw_out;
304 double last_delay_value;
309 struct PropertyGenerator
311 struct PropertyGenerator *prev;
312 struct PropertyGenerator *next;
314 enum GeneratorType type;
316 long long unsigned int peer;
317 long long unsigned int address_id;
319 struct TestPeer *test_peer;
320 struct TestAddress *test_address;
321 uint32_t ats_property;
325 struct GNUNET_TIME_Relative duration_period;
326 struct GNUNET_TIME_Relative frequency;
328 struct GNUNET_SCHEDULER_Task * set_task;
329 struct GNUNET_TIME_Absolute next_ping_transmission;
330 struct GNUNET_TIME_Absolute time_start;
333 #endif /* #ifndef GNUNET_ATS_SOLVER_EVAL_H */
334 /* end of file ats-testing.h */