1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
/*
This file is part of GNUnet.
Copyright (C) 2010-2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/**
* @file ats-tests/ats-testing-experiment.c
* @brief ats benchmark: controlled experiment execution
* @author Christian Grothoff
* @author Matthias Wachs
*/
#ifndef GNUNET_ATS_SOLVER_EVAL_H
#define GNUNET_ATS_SOLVER_EVAL_H
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_ats_plugin.h"
#include "gnunet_ats_service.h"
#include "gnunet-service-ats_addresses.h"
#include "gnunet-service-ats_normalization.h"
#include "test_ats_api_common.h"
enum GeneratorType
{
GNUNET_ATS_TEST_TG_LINEAR,
GNUNET_ATS_TEST_TG_CONSTANT,
GNUNET_ATS_TEST_TG_RANDOM,
GNUNET_ATS_TEST_TG_SINUS
};
enum OperationType
{
SOLVER_OP_ADD_ADDRESS,
SOLVER_OP_DEL_ADDRESS,
SOLVER_OP_START_SET_PROPERTY,
SOLVER_OP_STOP_SET_PROPERTY,
SOLVER_OP_START_SET_PREFERENCE,
SOLVER_OP_STOP_SET_PREFERENCE,
SOLVER_OP_START_REQUEST,
SOLVER_OP_STOP_REQUEST,
};
struct SolverHandle
{
/**
* Solver plugin name
*/
char *plugin;
/**
* Solver environment
*/
struct GNUNET_ATS_PluginEnvironment env;
/**
* Solver handle
*/
struct GNUNET_ATS_SolverFunctions *sf;
/**
* Address hashmap
*/
struct GNUNET_CONTAINER_MultiPeerMap *addresses;
};
enum GNUNET_ATS_Solvers
{
GNUNET_ATS_SOLVER_PROPORTIONAL,
GNUNET_ATS_SOLVER_MLP,
GNUNET_ATS_SOLVER_RIL,
};
struct LoggingFileHandle
{
/* DLL list for logging time steps */
struct LoggingFileHandle *next;
struct LoggingFileHandle *prev;
/* peer id */
long long unsigned int pid;
/* address id */
long long unsigned int aid;
struct GNUNET_DISK_FileHandle *f_hd;
};
struct LoggingTimeStep
{
struct LoggingTimeStep *prev;
struct LoggingTimeStep *next;
struct LoggingPeer *head;
struct LoggingPeer *tail;
struct GNUNET_TIME_Absolute timestamp;
struct GNUNET_TIME_Relative delta;
};
struct LoggingPeer
{
struct LoggingPeer *prev;
struct LoggingPeer *next;
long long unsigned int id;
struct GNUNET_PeerIdentity peer_id;
double pref_abs[GNUNET_ATS_PREFERENCE_END];
double pref_norm[GNUNET_ATS_PREFERENCE_END];
int is_requested;
struct LoggingAddress *addr_head;
struct LoggingAddress *addr_tail;
};
struct LoggingAddress
{
struct LoggingAddress *next;
struct LoggingAddress *prev;
long long unsigned int aid;
int active;
uint32_t network;
uint32_t assigned_bw_in;
uint32_t assigned_bw_out;
double prop_abs[GNUNET_ATS_PropertyCount];
double prop_norm[GNUNET_ATS_PropertyCount];
};
struct TestPeer
{
struct TestPeer *prev;
struct TestPeer *next;
long long unsigned int id;
int is_requested;
struct GNUNET_PeerIdentity peer_id;
double pref_abs[GNUNET_ATS_PreferenceCount];
double pref_norm[GNUNET_ATS_PreferenceCount];
uint32_t assigned_bw_in;
uint32_t assigned_bw_out;
struct TestAddress *addr_head;
struct TestAddress *addr_tail;
};
struct TestAddress
{
struct TestAddress *next;
struct TestAddress *prev;
long long unsigned int aid;
struct ATS_Address *ats_addr;
uint32_t network;
double prop_abs[GNUNET_ATS_PropertyCount];
double prop_norm[GNUNET_ATS_PropertyCount];
};
struct Episode;
struct Experiment;
typedef void (*GNUNET_ATS_TESTING_EpisodeDoneCallback) (
struct Episode *e);
typedef void (*GNUNET_ATS_TESTING_ExperimentDoneCallback) (struct Experiment *e,
struct GNUNET_TIME_Relative duration,int success);
/**
* An operation in an experiment
*/
struct GNUNET_ATS_TEST_Operation
{
struct GNUNET_ATS_TEST_Operation *next;
struct GNUNET_ATS_TEST_Operation *prev;
long long unsigned int address_id;
long long unsigned int peer_id;
long long unsigned int client_id;
long long unsigned int address_session;
unsigned int address_network;
char*address;
char*plugin;
long long unsigned int base_rate;
long long unsigned int max_rate;
struct GNUNET_TIME_Relative period;
struct GNUNET_TIME_Relative frequency;
struct GNUNET_TIME_Relative feedback_delay;
enum OperationType type;
enum GeneratorType gen_type;
enum GNUNET_ATS_PreferenceKind pref_type;
// enum GNUNET_ATS_Property prop_type;
};
struct Episode
{
int id;
struct Episode *next;
struct GNUNET_TIME_Relative duration;
struct GNUNET_ATS_TEST_Operation *head;
struct GNUNET_ATS_TEST_Operation *tail;
};
struct LoggingHandle
{
struct GNUNET_SCHEDULER_Task * logging_task;
struct GNUNET_TIME_Relative log_freq;
/* DLL list for logging time steps */
struct LoggingTimeStep *head;
struct LoggingTimeStep *tail;
};
struct Experiment
{
char *name;
char *log_prefix;
char *cfg_file;
char *log_output_dir;
int log_append_time_stamp;
struct GNUNET_TIME_Relative log_freq;
struct GNUNET_TIME_Relative max_duration;
struct GNUNET_TIME_Relative total_duration;
struct GNUNET_TIME_Absolute start_time;
unsigned int num_episodes;
struct Episode *start;
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_SCHEDULER_Task * experiment_timeout_task;
struct GNUNET_SCHEDULER_Task * episode_timeout_task;
struct Episode *cur;
GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb;
GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb;
};
struct PreferenceGenerator
{
struct PreferenceGenerator *prev;
struct PreferenceGenerator *next;
enum GeneratorType type;
long long unsigned int peer;
unsigned int client_id;
enum GNUNET_ATS_PreferenceKind kind;
long int base_value;
long int max_value;
struct GNUNET_TIME_Relative duration_period;
struct GNUNET_TIME_Relative frequency;
struct GNUNET_TIME_Relative feedback_frequency;
struct GNUNET_SCHEDULER_Task * set_task;
struct GNUNET_SCHEDULER_Task * feedback_task;
struct GNUNET_TIME_Absolute next_ping_transmission;
struct GNUNET_TIME_Absolute time_start;
/* Feedback */
uint32_t feedback_bw_out_acc;
uint32_t feedback_bw_in_acc;
uint32_t feedback_delay_acc;
double pref_bw_old;
double pref_latency_old;
struct GNUNET_TIME_Absolute feedback_last;
struct GNUNET_TIME_Absolute feedback_last_bw_update;
struct GNUNET_TIME_Absolute feedback_last_delay_update;
uint32_t last_assigned_bw_in;
uint32_t last_assigned_bw_out;
double last_delay_value;
};
struct PropertyGenerator
{
struct PropertyGenerator *prev;
struct PropertyGenerator *next;
enum GeneratorType type;
long long unsigned int peer;
long long unsigned int address_id;
struct TestPeer *test_peer;
struct TestAddress *test_address;
uint32_t ats_property;
long int base_value;
long int max_value;
struct GNUNET_TIME_Relative duration_period;
struct GNUNET_TIME_Relative frequency;
struct GNUNET_SCHEDULER_Task * set_task;
struct GNUNET_TIME_Absolute next_ping_transmission;
struct GNUNET_TIME_Absolute time_start;
};
#endif /* #ifndef GNUNET_ATS_SOLVER_EVAL_H */
/* end of file ats-testing.h */
|