diff options
Diffstat (limited to 'src/ats-tests/ats-testing-experiment.c')
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 1088 |
1 files changed, 570 insertions, 518 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c index db5f411dd..676021926 100644 --- a/src/ats-tests/ats-testing-experiment.c +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -28,35 +28,35 @@ | |||
28 | #include "ats-testing.h" | 28 | #include "ats-testing.h" |
29 | 29 | ||
30 | const char * | 30 | const char * |
31 | print_op(enum OperationType op) | 31 | print_op (enum OperationType op) |
32 | { | 32 | { |
33 | switch (op) | 33 | switch (op) |
34 | { | 34 | { |
35 | case START_SEND: | 35 | case START_SEND: |
36 | return "START_SEND"; | 36 | return "START_SEND"; |
37 | 37 | ||
38 | case STOP_SEND: | 38 | case STOP_SEND: |
39 | return "STOP_SEND"; | 39 | return "STOP_SEND"; |
40 | 40 | ||
41 | case START_PREFERENCE: | 41 | case START_PREFERENCE: |
42 | return "START_PREFERENCE"; | 42 | return "START_PREFERENCE"; |
43 | 43 | ||
44 | case STOP_PREFERENCE: | 44 | case STOP_PREFERENCE: |
45 | return "STOP_PREFERENCE"; | 45 | return "STOP_PREFERENCE"; |
46 | 46 | ||
47 | default: | 47 | default: |
48 | break; | 48 | break; |
49 | } | 49 | } |
50 | return ""; | 50 | return ""; |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | static struct Experiment * | 54 | static struct Experiment * |
55 | create_experiment() | 55 | create_experiment () |
56 | { | 56 | { |
57 | struct Experiment *e; | 57 | struct Experiment *e; |
58 | 58 | ||
59 | e = GNUNET_new(struct Experiment); | 59 | e = GNUNET_new (struct Experiment); |
60 | e->name = NULL; | 60 | e->name = NULL; |
61 | e->num_masters = 0; | 61 | e->num_masters = 0; |
62 | e->num_slaves = 0; | 62 | e->num_slaves = 0; |
@@ -66,7 +66,7 @@ create_experiment() | |||
66 | } | 66 | } |
67 | 67 | ||
68 | static void | 68 | static void |
69 | free_experiment(struct Experiment *e) | 69 | free_experiment (struct Experiment *e) |
70 | { | 70 | { |
71 | struct Episode *cur; | 71 | struct Episode *cur; |
72 | struct Episode *next; | 72 | struct Episode *next; |
@@ -75,28 +75,28 @@ free_experiment(struct Experiment *e) | |||
75 | 75 | ||
76 | next = e->start; | 76 | next = e->start; |
77 | for (cur = next; NULL != cur; cur = next) | 77 | for (cur = next; NULL != cur; cur = next) |
78 | { | 78 | { |
79 | next = cur->next; | 79 | next = cur->next; |
80 | 80 | ||
81 | next_o = cur->head; | 81 | next_o = cur->head; |
82 | for (cur_o = next_o; NULL != cur_o; cur_o = next_o) | 82 | for (cur_o = next_o; NULL != cur_o; cur_o = next_o) |
83 | { | 83 | { |
84 | next_o = cur_o->next; | 84 | next_o = cur_o->next; |
85 | GNUNET_free(cur_o); | 85 | GNUNET_free (cur_o); |
86 | } | ||
87 | GNUNET_free(cur); | ||
88 | } | 86 | } |
87 | GNUNET_free (cur); | ||
88 | } | ||
89 | 89 | ||
90 | GNUNET_free_non_null(e->name); | 90 | GNUNET_free_non_null (e->name); |
91 | GNUNET_free_non_null(e->cfg_file); | 91 | GNUNET_free_non_null (e->cfg_file); |
92 | GNUNET_free(e); | 92 | GNUNET_free (e); |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | static int | 96 | static int |
97 | load_episode(struct Experiment *e, | 97 | load_episode (struct Experiment *e, |
98 | struct Episode *cur, | 98 | struct Episode *cur, |
99 | struct GNUNET_CONFIGURATION_Handle *cfg) | 99 | struct GNUNET_CONFIGURATION_Handle *cfg) |
100 | { | 100 | { |
101 | struct GNUNET_ATS_TEST_Operation *o; | 101 | struct GNUNET_ATS_TEST_Operation *o; |
102 | char *sec_name; | 102 | char *sec_name; |
@@ -106,272 +106,297 @@ load_episode(struct Experiment *e, | |||
106 | char *pref; | 106 | char *pref; |
107 | int op_counter = 0; | 107 | int op_counter = 0; |
108 | 108 | ||
109 | fprintf(stderr, "Parsing episode %u\n", cur->id); | 109 | fprintf (stderr, "Parsing episode %u\n", cur->id); |
110 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); | 110 | GNUNET_asprintf (&sec_name, "episode-%u", cur->id); |
111 | 111 | ||
112 | while (1) | 112 | while (1) |
113 | { | ||
114 | /* Load operation */ | ||
115 | GNUNET_asprintf (&op_name, "op-%u-operation", op_counter); | ||
116 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
117 | sec_name, | ||
118 | op_name, &op)) | ||
113 | { | 119 | { |
114 | /* Load operation */ | 120 | GNUNET_free (op_name); |
115 | GNUNET_asprintf(&op_name, "op-%u-operation", op_counter); | 121 | break; |
116 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | 122 | } |
117 | sec_name, op_name, &op)) | 123 | o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); |
118 | { | 124 | /* operations = set_rate, start_send, stop_send, set_preference */ |
119 | GNUNET_free(op_name); | 125 | if (0 == strcmp (op, "start_send")) |
120 | break; | 126 | { |
121 | } | 127 | o->type = START_SEND; |
122 | o = GNUNET_new(struct GNUNET_ATS_TEST_Operation); | 128 | } |
123 | /* operations = set_rate, start_send, stop_send, set_preference */ | 129 | else if (0 == strcmp (op, "stop_send")) |
124 | if (0 == strcmp(op, "start_send")) | 130 | { |
125 | { | 131 | o->type = STOP_SEND; |
126 | o->type = START_SEND; | 132 | } |
127 | } | 133 | else if (0 == strcmp (op, "start_preference")) |
128 | else if (0 == strcmp(op, "stop_send")) | 134 | { |
129 | { | 135 | o->type = START_PREFERENCE; |
130 | o->type = STOP_SEND; | 136 | } |
131 | } | 137 | else if (0 == strcmp (op, "stop_preference")) |
132 | else if (0 == strcmp(op, "start_preference")) | 138 | { |
133 | { | 139 | o->type = STOP_PREFERENCE; |
134 | o->type = START_PREFERENCE; | 140 | } |
135 | } | 141 | else |
136 | else if (0 == strcmp(op, "stop_preference")) | 142 | { |
137 | { | 143 | fprintf (stderr, "Invalid operation %u `%s' in episode %u\n", |
138 | o->type = STOP_PREFERENCE; | 144 | op_counter, op, cur->id); |
139 | } | 145 | GNUNET_free (op); |
146 | GNUNET_free (op_name); | ||
147 | GNUNET_free (o); | ||
148 | GNUNET_free (sec_name); | ||
149 | return GNUNET_SYSERR; | ||
150 | } | ||
151 | GNUNET_free (op_name); | ||
152 | |||
153 | /* Get source */ | ||
154 | GNUNET_asprintf (&op_name, "op-%u-src", op_counter); | ||
155 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
156 | sec_name, | ||
157 | op_name, | ||
158 | &o->src_id)) | ||
159 | { | ||
160 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
161 | op_counter, op, cur->id); | ||
162 | GNUNET_free (op); | ||
163 | GNUNET_free (op_name); | ||
164 | GNUNET_free (o); | ||
165 | GNUNET_free (sec_name); | ||
166 | return GNUNET_SYSERR; | ||
167 | } | ||
168 | if (o->src_id > (e->num_masters - 1)) | ||
169 | { | ||
170 | fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | ||
171 | o->src_id, op_counter, op, cur->id); | ||
172 | GNUNET_free (op); | ||
173 | GNUNET_free (op_name); | ||
174 | GNUNET_free (o); | ||
175 | GNUNET_free (sec_name); | ||
176 | return GNUNET_SYSERR; | ||
177 | } | ||
178 | GNUNET_free (op_name); | ||
179 | |||
180 | /* Get destination */ | ||
181 | GNUNET_asprintf (&op_name, "op-%u-dest", op_counter); | ||
182 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
183 | sec_name, | ||
184 | op_name, | ||
185 | &o->dest_id)) | ||
186 | { | ||
187 | fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n", | ||
188 | op_counter, op, cur->id); | ||
189 | GNUNET_free (op); | ||
190 | GNUNET_free (op_name); | ||
191 | GNUNET_free (o); | ||
192 | GNUNET_free (sec_name); | ||
193 | return GNUNET_SYSERR; | ||
194 | } | ||
195 | if (o->dest_id > (e->num_slaves - 1)) | ||
196 | { | ||
197 | fprintf (stderr, | ||
198 | "Invalid destination %llu in operation %u `%s' in episode %u\n", | ||
199 | o->dest_id, op_counter, op, cur->id); | ||
200 | GNUNET_free (op); | ||
201 | GNUNET_free (op_name); | ||
202 | GNUNET_free (o); | ||
203 | GNUNET_free (sec_name); | ||
204 | return GNUNET_SYSERR; | ||
205 | } | ||
206 | GNUNET_free (op_name); | ||
207 | |||
208 | GNUNET_asprintf (&op_name, "op-%u-type", op_counter); | ||
209 | if ((GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string (cfg, | ||
210 | sec_name, | ||
211 | op_name, | ||
212 | &type)) && | ||
213 | (STOP_SEND != o->type) && | ||
214 | (STOP_PREFERENCE != o->type)) | ||
215 | { | ||
216 | /* Load arguments for set_rate, start_send, set_preference */ | ||
217 | if (0 == strcmp (type, "constant")) | ||
218 | { | ||
219 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
220 | } | ||
221 | else if (0 == strcmp (type, "linear")) | ||
222 | { | ||
223 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
224 | } | ||
225 | else if (0 == strcmp (type, "sinus")) | ||
226 | { | ||
227 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
228 | } | ||
229 | else if (0 == strcmp (type, "random")) | ||
230 | { | ||
231 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
232 | } | ||
140 | else | 233 | else |
234 | { | ||
235 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | ||
236 | op_counter, op, cur->id); | ||
237 | GNUNET_free (type); | ||
238 | GNUNET_free (op); | ||
239 | GNUNET_free (op_name); | ||
240 | GNUNET_free (sec_name); | ||
241 | GNUNET_free (o); | ||
242 | return GNUNET_SYSERR; | ||
243 | } | ||
244 | GNUNET_free (op_name); | ||
245 | |||
246 | /* Get base rate */ | ||
247 | GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter); | ||
248 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
249 | sec_name, | ||
250 | op_name, | ||
251 | &o->base_rate)) | ||
252 | { | ||
253 | fprintf (stderr, | ||
254 | "Missing base rate in operation %u `%s' in episode %u\n", | ||
255 | op_counter, op, cur->id); | ||
256 | GNUNET_free (type); | ||
257 | GNUNET_free (op); | ||
258 | GNUNET_free (op_name); | ||
259 | GNUNET_free (sec_name); | ||
260 | GNUNET_free (o); | ||
261 | return GNUNET_SYSERR; | ||
262 | } | ||
263 | GNUNET_free (op_name); | ||
264 | |||
265 | /* Get max rate */ | ||
266 | GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter); | ||
267 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | ||
268 | sec_name, | ||
269 | op_name, | ||
270 | &o->max_rate)) | ||
271 | { | ||
272 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
273 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
274 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
141 | { | 275 | { |
142 | fprintf(stderr, "Invalid operation %u `%s' in episode %u\n", | 276 | fprintf (stderr, |
143 | op_counter, op, cur->id); | 277 | "Missing max rate in operation %u `%s' in episode %u\n", |
144 | GNUNET_free(op); | 278 | op_counter, op, cur->id); |
145 | GNUNET_free(op_name); | 279 | GNUNET_free (type); |
146 | GNUNET_free(o); | 280 | GNUNET_free (op_name); |
147 | GNUNET_free(sec_name); | 281 | GNUNET_free (op); |
282 | GNUNET_free (o); | ||
283 | GNUNET_free (sec_name); | ||
148 | return GNUNET_SYSERR; | 284 | return GNUNET_SYSERR; |
149 | } | 285 | } |
150 | GNUNET_free(op_name); | 286 | } |
151 | 287 | GNUNET_free (op_name); | |
152 | /* Get source */ | 288 | |
153 | GNUNET_asprintf(&op_name, "op-%u-src", op_counter); | 289 | /* Get period */ |
154 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | 290 | GNUNET_asprintf (&op_name, "op-%u-period", op_counter); |
155 | sec_name, op_name, &o->src_id)) | 291 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, |
292 | sec_name, | ||
293 | op_name, | ||
294 | &o->period)) | ||
295 | { | ||
296 | o->period = cur->duration; | ||
297 | } | ||
298 | GNUNET_free (op_name); | ||
299 | |||
300 | if (START_PREFERENCE == o->type) | ||
301 | { | ||
302 | /* Get frequency */ | ||
303 | GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter); | ||
304 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
305 | sec_name, | ||
306 | op_name, | ||
307 | &o->frequency)) | ||
156 | { | 308 | { |
157 | fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", | 309 | fprintf (stderr, |
158 | op_counter, op, cur->id); | 310 | "Missing frequency in operation %u `%s' in episode %u\n", |
159 | GNUNET_free(op); | 311 | op_counter, op, cur->id); |
160 | GNUNET_free(op_name); | 312 | GNUNET_free (type); |
161 | GNUNET_free(o); | 313 | GNUNET_free (op_name); |
162 | GNUNET_free(sec_name); | 314 | GNUNET_free (op); |
315 | GNUNET_free (o); | ||
316 | GNUNET_free (sec_name); | ||
163 | return GNUNET_SYSERR; | 317 | return GNUNET_SYSERR; |
164 | } | 318 | } |
165 | if (o->src_id > (e->num_masters - 1)) | 319 | GNUNET_free (op_name); |
320 | |||
321 | /* Get preference */ | ||
322 | GNUNET_asprintf (&op_name, "op-%u-pref", op_counter); | ||
323 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
324 | sec_name, | ||
325 | op_name, | ||
326 | &pref)) | ||
166 | { | 327 | { |
167 | fprintf(stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", | 328 | fprintf (stderr, |
168 | o->src_id, op_counter, op, cur->id); | 329 | "Missing preference in operation %u `%s' in episode %u\n", |
169 | GNUNET_free(op); | 330 | op_counter, op, cur->id); |
170 | GNUNET_free(op_name); | 331 | GNUNET_free (type); |
171 | GNUNET_free(o); | 332 | GNUNET_free (op_name); |
172 | GNUNET_free(sec_name); | 333 | GNUNET_free (op); |
334 | GNUNET_free_non_null (pref); | ||
335 | GNUNET_free (o); | ||
336 | GNUNET_free (sec_name); | ||
173 | return GNUNET_SYSERR; | 337 | return GNUNET_SYSERR; |
174 | } | 338 | } |
175 | GNUNET_free(op_name); | ||
176 | 339 | ||
177 | /* Get destination */ | 340 | if (0 == strcmp (pref, "bandwidth")) |
178 | GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); | 341 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; |
179 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | 342 | else if (0 == strcmp (pref, "latency")) |
180 | sec_name, op_name, &o->dest_id)) | 343 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; |
344 | else | ||
181 | { | 345 | { |
182 | fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", | 346 | fprintf (stderr, |
183 | op_counter, op, cur->id); | 347 | "Invalid preference in operation %u `%s' in episode %u\n", |
184 | GNUNET_free(op); | 348 | op_counter, op, cur->id); |
185 | GNUNET_free(op_name); | 349 | GNUNET_free (type); |
186 | GNUNET_free(o); | 350 | GNUNET_free (op_name); |
187 | GNUNET_free(sec_name); | 351 | GNUNET_free (op); |
352 | GNUNET_free_non_null (pref); | ||
353 | GNUNET_free (o); | ||
354 | GNUNET_free (sec_name); | ||
188 | return GNUNET_SYSERR; | 355 | return GNUNET_SYSERR; |
189 | } | 356 | } |
190 | if (o->dest_id > (e->num_slaves - 1)) | 357 | GNUNET_free (pref); |
191 | { | 358 | GNUNET_free (op_name); |
192 | fprintf(stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n", | 359 | } |
193 | o->dest_id, op_counter, op, cur->id); | 360 | } |
194 | GNUNET_free(op); | ||
195 | GNUNET_free(op_name); | ||
196 | GNUNET_free(o); | ||
197 | GNUNET_free(sec_name); | ||
198 | return GNUNET_SYSERR; | ||
199 | } | ||
200 | GNUNET_free(op_name); | ||
201 | |||
202 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); | ||
203 | if ((GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, | ||
204 | sec_name, op_name, &type)) && | ||
205 | (STOP_SEND != o->type) && | ||
206 | (STOP_PREFERENCE != o->type)) | ||
207 | { | ||
208 | /* Load arguments for set_rate, start_send, set_preference */ | ||
209 | if (0 == strcmp(type, "constant")) | ||
210 | { | ||
211 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; | ||
212 | } | ||
213 | else if (0 == strcmp(type, "linear")) | ||
214 | { | ||
215 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; | ||
216 | } | ||
217 | else if (0 == strcmp(type, "sinus")) | ||
218 | { | ||
219 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; | ||
220 | } | ||
221 | else if (0 == strcmp(type, "random")) | ||
222 | { | ||
223 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | fprintf(stderr, "Invalid type %u `%s' in episode %u\n", | ||
228 | op_counter, op, cur->id); | ||
229 | GNUNET_free(type); | ||
230 | GNUNET_free(op); | ||
231 | GNUNET_free(op_name); | ||
232 | GNUNET_free(sec_name); | ||
233 | GNUNET_free(o); | ||
234 | return GNUNET_SYSERR; | ||
235 | } | ||
236 | GNUNET_free(op_name); | ||
237 | |||
238 | /* Get base rate */ | ||
239 | GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter); | ||
240 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
241 | sec_name, op_name, &o->base_rate)) | ||
242 | { | ||
243 | fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n", | ||
244 | op_counter, op, cur->id); | ||
245 | GNUNET_free(type); | ||
246 | GNUNET_free(op); | ||
247 | GNUNET_free(op_name); | ||
248 | GNUNET_free(sec_name); | ||
249 | GNUNET_free(o); | ||
250 | return GNUNET_SYSERR; | ||
251 | } | ||
252 | GNUNET_free(op_name); | ||
253 | |||
254 | /* Get max rate */ | ||
255 | GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter); | ||
256 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, | ||
257 | sec_name, op_name, &o->max_rate)) | ||
258 | { | ||
259 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
260 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || | ||
261 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
262 | { | ||
263 | fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n", | ||
264 | op_counter, op, cur->id); | ||
265 | GNUNET_free(type); | ||
266 | GNUNET_free(op_name); | ||
267 | GNUNET_free(op); | ||
268 | GNUNET_free(o); | ||
269 | GNUNET_free(sec_name); | ||
270 | return GNUNET_SYSERR; | ||
271 | } | ||
272 | } | ||
273 | GNUNET_free(op_name); | ||
274 | |||
275 | /* Get period */ | ||
276 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | ||
277 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
278 | sec_name, op_name, &o->period)) | ||
279 | { | ||
280 | o->period = cur->duration; | ||
281 | } | ||
282 | GNUNET_free(op_name); | ||
283 | |||
284 | if (START_PREFERENCE == o->type) | ||
285 | { | ||
286 | /* Get frequency */ | ||
287 | GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); | ||
288 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | ||
289 | sec_name, op_name, &o->frequency)) | ||
290 | { | ||
291 | fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n", | ||
292 | op_counter, op, cur->id); | ||
293 | GNUNET_free(type); | ||
294 | GNUNET_free(op_name); | ||
295 | GNUNET_free(op); | ||
296 | GNUNET_free(o); | ||
297 | GNUNET_free(sec_name); | ||
298 | return GNUNET_SYSERR; | ||
299 | } | ||
300 | GNUNET_free(op_name); | ||
301 | |||
302 | /* Get preference */ | ||
303 | GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); | ||
304 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | ||
305 | sec_name, op_name, &pref)) | ||
306 | { | ||
307 | fprintf(stderr, "Missing preference in operation %u `%s' in episode %u\n", | ||
308 | op_counter, op, cur->id); | ||
309 | GNUNET_free(type); | ||
310 | GNUNET_free(op_name); | ||
311 | GNUNET_free(op); | ||
312 | GNUNET_free_non_null(pref); | ||
313 | GNUNET_free(o); | ||
314 | GNUNET_free(sec_name); | ||
315 | return GNUNET_SYSERR; | ||
316 | } | ||
317 | |||
318 | if (0 == strcmp(pref, "bandwidth")) | ||
319 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | ||
320 | else if (0 == strcmp(pref, "latency")) | ||
321 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | ||
322 | else | ||
323 | { | ||
324 | fprintf(stderr, "Invalid preference in operation %u `%s' in episode %u\n", | ||
325 | op_counter, op, cur->id); | ||
326 | GNUNET_free(type); | ||
327 | GNUNET_free(op_name); | ||
328 | GNUNET_free(op); | ||
329 | GNUNET_free_non_null(pref); | ||
330 | GNUNET_free(o); | ||
331 | GNUNET_free(sec_name); | ||
332 | return GNUNET_SYSERR; | ||
333 | } | ||
334 | GNUNET_free(pref); | ||
335 | GNUNET_free(op_name); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | /* Safety checks */ | ||
340 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || | ||
341 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
342 | { | ||
343 | if ((o->max_rate - o->base_rate) > o->base_rate) | ||
344 | { | ||
345 | /* This will cause an underflow */ | ||
346 | GNUNET_break(0); | ||
347 | } | ||
348 | fprintf(stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); | ||
349 | } | ||
350 | |||
351 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) | ||
352 | fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | ||
353 | op_counter, cur->id, print_op(o->type), o->src_id, | ||
354 | o->dest_id, (NULL != type) ? type : "", | ||
355 | o->base_rate, o->max_rate, | ||
356 | GNUNET_STRINGS_relative_time_to_string(o->period, GNUNET_YES)); | ||
357 | else | ||
358 | fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | ||
359 | op_counter, cur->id, print_op(o->type), o->src_id, o->dest_id); | ||
360 | |||
361 | GNUNET_free_non_null(type); | ||
362 | GNUNET_free(op); | ||
363 | 361 | ||
364 | GNUNET_CONTAINER_DLL_insert(cur->head, cur->tail, o); | 362 | /* Safety checks */ |
365 | op_counter++; | 363 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
364 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) | ||
365 | { | ||
366 | if ((o->max_rate - o->base_rate) > o->base_rate) | ||
367 | { | ||
368 | /* This will cause an underflow */ | ||
369 | GNUNET_break (0); | ||
370 | } | ||
371 | fprintf (stderr, | ||
372 | "Selected max rate and base rate cannot be used for desired traffic form!\n"); | ||
366 | } | 373 | } |
367 | GNUNET_free(sec_name); | 374 | |
375 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) | ||
376 | fprintf (stderr, | ||
377 | "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | ||
378 | op_counter, cur->id, print_op (o->type), o->src_id, | ||
379 | o->dest_id, (NULL != type) ? type : "", | ||
380 | o->base_rate, o->max_rate, | ||
381 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | ||
382 | else | ||
383 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | ||
384 | op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id); | ||
385 | |||
386 | GNUNET_free_non_null (type); | ||
387 | GNUNET_free (op); | ||
388 | |||
389 | GNUNET_CONTAINER_DLL_insert (cur->head, cur->tail, o); | ||
390 | op_counter++; | ||
391 | } | ||
392 | GNUNET_free (sec_name); | ||
368 | 393 | ||
369 | return GNUNET_OK; | 394 | return GNUNET_OK; |
370 | } | 395 | } |
371 | 396 | ||
372 | 397 | ||
373 | static int | 398 | static int |
374 | load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | 399 | load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) |
375 | { | 400 | { |
376 | int e_counter = 0; | 401 | int e_counter = 0; |
377 | char *sec_name; | 402 | char *sec_name; |
@@ -382,380 +407,407 @@ load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
382 | e_counter = 0; | 407 | e_counter = 0; |
383 | last = NULL; | 408 | last = NULL; |
384 | while (1) | 409 | while (1) |
410 | { | ||
411 | GNUNET_asprintf (&sec_name, "episode-%u", e_counter); | ||
412 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
413 | sec_name, | ||
414 | "duration", | ||
415 | &e_duration)) | ||
385 | { | 416 | { |
386 | GNUNET_asprintf(&sec_name, "episode-%u", e_counter); | 417 | GNUNET_free (sec_name); |
387 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | 418 | break; |
388 | sec_name, "duration", &e_duration)) | 419 | } |
389 | { | ||
390 | GNUNET_free(sec_name); | ||
391 | break; | ||
392 | } | ||
393 | |||
394 | cur = GNUNET_new(struct Episode); | ||
395 | cur->duration = e_duration; | ||
396 | cur->id = e_counter; | ||
397 | |||
398 | if (GNUNET_OK != load_episode(e, cur, cfg)) | ||
399 | { | ||
400 | GNUNET_free(sec_name); | ||
401 | GNUNET_free(cur); | ||
402 | return GNUNET_SYSERR; | ||
403 | } | ||
404 | |||
405 | fprintf(stderr, "Found episode %u with duration %s \n", | ||
406 | e_counter, | ||
407 | GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES)); | ||
408 | 420 | ||
409 | /* Update experiment */ | 421 | cur = GNUNET_new (struct Episode); |
410 | e->num_episodes++; | 422 | cur->duration = e_duration; |
411 | e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); | 423 | cur->id = e_counter; |
412 | /* Put in linked list */ | ||
413 | if (NULL == last) | ||
414 | e->start = cur; | ||
415 | else | ||
416 | last->next = cur; | ||
417 | 424 | ||
418 | GNUNET_free(sec_name); | 425 | if (GNUNET_OK != load_episode (e, cur, cfg)) |
419 | e_counter++; | 426 | { |
420 | last = cur; | 427 | GNUNET_free (sec_name); |
428 | GNUNET_free (cur); | ||
429 | return GNUNET_SYSERR; | ||
421 | } | 430 | } |
431 | |||
432 | fprintf (stderr, "Found episode %u with duration %s \n", | ||
433 | e_counter, | ||
434 | GNUNET_STRINGS_relative_time_to_string (cur->duration, | ||
435 | GNUNET_YES)); | ||
436 | |||
437 | /* Update experiment */ | ||
438 | e->num_episodes++; | ||
439 | e->total_duration = GNUNET_TIME_relative_add (e->total_duration, | ||
440 | cur->duration); | ||
441 | /* Put in linked list */ | ||
442 | if (NULL == last) | ||
443 | e->start = cur; | ||
444 | else | ||
445 | last->next = cur; | ||
446 | |||
447 | GNUNET_free (sec_name); | ||
448 | e_counter++; | ||
449 | last = cur; | ||
450 | } | ||
422 | return e_counter; | 451 | return e_counter; |
423 | } | 452 | } |
424 | 453 | ||
425 | 454 | ||
426 | static void | 455 | static void |
427 | timeout_experiment(void *cls) | 456 | timeout_experiment (void *cls) |
428 | { | 457 | { |
429 | struct Experiment *e = cls; | 458 | struct Experiment *e = cls; |
430 | 459 | ||
431 | e->experiment_timeout_task = NULL; | 460 | e->experiment_timeout_task = NULL; |
432 | fprintf(stderr, "Experiment timeout!\n"); | 461 | fprintf (stderr, "Experiment timeout!\n"); |
433 | 462 | ||
434 | if (NULL != e->episode_timeout_task) | 463 | if (NULL != e->episode_timeout_task) |
435 | { | 464 | { |
436 | GNUNET_SCHEDULER_cancel(e->episode_timeout_task); | 465 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); |
437 | e->episode_timeout_task = NULL; | 466 | e->episode_timeout_task = NULL; |
438 | } | 467 | } |
439 | 468 | ||
440 | e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), | 469 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time), |
441 | GNUNET_SYSERR); | 470 | GNUNET_SYSERR); |
442 | } | 471 | } |
443 | 472 | ||
444 | 473 | ||
445 | static void | 474 | static void |
446 | enforce_start_send(struct GNUNET_ATS_TEST_Operation *op) | 475 | enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) |
447 | { | 476 | { |
448 | struct BenchmarkPeer *peer; | 477 | struct BenchmarkPeer *peer; |
449 | struct BenchmarkPartner *partner; | 478 | struct BenchmarkPartner *partner; |
450 | 479 | ||
451 | peer = GNUNET_ATS_TEST_get_peer(op->src_id); | 480 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); |
452 | if (NULL == peer) | 481 | if (NULL == peer) |
453 | { | 482 | { |
454 | GNUNET_break(0); | 483 | GNUNET_break (0); |
455 | return; | 484 | return; |
456 | } | 485 | } |
457 | 486 | ||
458 | partner = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); | 487 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
459 | if (NULL == partner) | 488 | if (NULL == partner) |
460 | { | 489 | { |
461 | GNUNET_break(0); | 490 | GNUNET_break (0); |
462 | return; | 491 | return; |
463 | } | 492 | } |
464 | 493 | ||
465 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | 494 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
466 | 495 | ||
467 | if (NULL != partner->tg) | 496 | if (NULL != partner->tg) |
468 | { | 497 | { |
469 | fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", op->src_id, op->dest_id); | 498 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", |
470 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); | 499 | op->src_id, op->dest_id); |
471 | partner->tg = NULL; | 500 | GNUNET_ATS_TEST_generate_traffic_stop (partner->tg); |
472 | } | 501 | partner->tg = NULL; |
473 | 502 | } | |
474 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, | 503 | |
475 | op->gen_type, op->base_rate, op->max_rate, op->period, | 504 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start (peer, partner, |
476 | GNUNET_TIME_UNIT_FOREVER_REL); | 505 | op->gen_type, |
506 | op->base_rate, | ||
507 | op->max_rate, | ||
508 | op->period, | ||
509 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
477 | } | 510 | } |
478 | 511 | ||
479 | static void | 512 | static void |
480 | enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op) | 513 | enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) |
481 | { | 514 | { |
482 | struct BenchmarkPartner *p; | 515 | struct BenchmarkPartner *p; |
483 | 516 | ||
484 | p = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); | 517 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
485 | if (NULL == p) | 518 | if (NULL == p) |
486 | { | 519 | { |
487 | GNUNET_break(0); | 520 | GNUNET_break (0); |
488 | return; | 521 | return; |
489 | } | 522 | } |
490 | 523 | ||
491 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | 524 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
492 | 525 | ||
493 | if (NULL != p->tg) | 526 | if (NULL != p->tg) |
494 | { | 527 | { |
495 | fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", | 528 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", |
496 | op->src_id, op->dest_id); | 529 | op->src_id, op->dest_id); |
497 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); | 530 | GNUNET_ATS_TEST_generate_traffic_stop (p->tg); |
498 | p->tg = NULL; | 531 | p->tg = NULL; |
499 | } | 532 | } |
500 | } | 533 | } |
501 | 534 | ||
502 | 535 | ||
503 | static void | 536 | static void |
504 | enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op) | 537 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) |
505 | { | 538 | { |
506 | struct BenchmarkPeer *peer; | 539 | struct BenchmarkPeer *peer; |
507 | struct BenchmarkPartner *partner; | 540 | struct BenchmarkPartner *partner; |
508 | 541 | ||
509 | peer = GNUNET_ATS_TEST_get_peer(op->src_id); | 542 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); |
510 | if (NULL == peer) | 543 | if (NULL == peer) |
511 | { | 544 | { |
512 | GNUNET_break(0); | 545 | GNUNET_break (0); |
513 | return; | 546 | return; |
514 | } | 547 | } |
515 | 548 | ||
516 | partner = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); | 549 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
517 | if (NULL == partner) | 550 | if (NULL == partner) |
518 | { | 551 | { |
519 | GNUNET_break(0); | 552 | GNUNET_break (0); |
520 | return; | 553 | return; |
521 | } | 554 | } |
522 | 555 | ||
523 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | 556 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
524 | 557 | ||
525 | if (NULL != partner->pg) | 558 | if (NULL != partner->pg) |
526 | { | 559 | { |
527 | fprintf(stderr, "Stopping traffic between master %llu slave %llu\n", | 560 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", |
528 | op->src_id, op->dest_id); | 561 | op->src_id, op->dest_id); |
529 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); | 562 | GNUNET_ATS_TEST_generate_preferences_stop (partner->pg); |
530 | partner->pg = NULL; | 563 | partner->pg = NULL; |
531 | } | 564 | } |
532 | 565 | ||
533 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, | 566 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start (peer, partner, |
534 | op->gen_type, op->base_rate, op->max_rate, op->period, op->frequency, | 567 | op->gen_type, |
535 | op->pref_type); | 568 | op->base_rate, |
569 | op->max_rate, | ||
570 | op->period, | ||
571 | op->frequency, | ||
572 | op->pref_type); | ||
536 | } | 573 | } |
537 | 574 | ||
538 | static void | 575 | static void |
539 | enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op) | 576 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) |
540 | { | 577 | { |
541 | struct BenchmarkPartner *p; | 578 | struct BenchmarkPartner *p; |
542 | 579 | ||
543 | p = GNUNET_ATS_TEST_get_partner(op->src_id, op->dest_id); | 580 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); |
544 | if (NULL == p) | 581 | if (NULL == p) |
545 | { | 582 | { |
546 | GNUNET_break(0); | 583 | GNUNET_break (0); |
547 | return; | 584 | return; |
548 | } | 585 | } |
549 | 586 | ||
550 | fprintf(stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); | 587 | fprintf (stderr, "Found master %llu slave %llu\n", op->src_id, op->dest_id); |
551 | 588 | ||
552 | if (NULL != p->pg) | 589 | if (NULL != p->pg) |
553 | { | 590 | { |
554 | fprintf(stderr, "Stopping preference between master %llu slave %llu\n", | 591 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", |
555 | op->src_id, op->dest_id); | 592 | op->src_id, op->dest_id); |
556 | GNUNET_ATS_TEST_generate_preferences_stop(p->pg); | 593 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); |
557 | p->pg = NULL; | 594 | p->pg = NULL; |
558 | } | 595 | } |
559 | } | 596 | } |
560 | 597 | ||
561 | static void enforce_episode(struct Episode *ep) | 598 | static void enforce_episode (struct Episode *ep) |
562 | { | 599 | { |
563 | struct GNUNET_ATS_TEST_Operation *cur; | 600 | struct GNUNET_ATS_TEST_Operation *cur; |
564 | 601 | ||
565 | for (cur = ep->head; NULL != cur; cur = cur->next) | 602 | for (cur = ep->head; NULL != cur; cur = cur->next) |
603 | { | ||
604 | fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | ||
605 | print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate); | ||
606 | switch (cur->type) | ||
566 | { | 607 | { |
567 | fprintf(stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", | 608 | case START_SEND: |
568 | print_op(cur->type), cur->src_id, cur->dest_id, cur->base_rate); | 609 | enforce_start_send (cur); |
569 | switch (cur->type) | 610 | break; |
570 | { | ||
571 | case START_SEND: | ||
572 | enforce_start_send(cur); | ||
573 | break; | ||
574 | 611 | ||
575 | case STOP_SEND: | 612 | case STOP_SEND: |
576 | enforce_stop_send(cur); | 613 | enforce_stop_send (cur); |
577 | break; | 614 | break; |
578 | 615 | ||
579 | case START_PREFERENCE: | 616 | case START_PREFERENCE: |
580 | enforce_start_preference(cur); | 617 | enforce_start_preference (cur); |
581 | break; | 618 | break; |
582 | 619 | ||
583 | case STOP_PREFERENCE: | 620 | case STOP_PREFERENCE: |
584 | enforce_stop_preference(cur); | 621 | enforce_stop_preference (cur); |
585 | break; | 622 | break; |
586 | 623 | ||
587 | default: | 624 | default: |
588 | break; | 625 | break; |
589 | } | ||
590 | } | 626 | } |
627 | } | ||
591 | } | 628 | } |
592 | 629 | ||
593 | 630 | ||
594 | static void | 631 | static void |
595 | timeout_episode(void *cls) | 632 | timeout_episode (void *cls) |
596 | { | 633 | { |
597 | struct Experiment *e = cls; | 634 | struct Experiment *e = cls; |
598 | 635 | ||
599 | e->episode_timeout_task = NULL; | 636 | e->episode_timeout_task = NULL; |
600 | if (NULL != e->ep_done_cb) | 637 | if (NULL != e->ep_done_cb) |
601 | e->ep_done_cb(e->cur); | 638 | e->ep_done_cb (e->cur); |
602 | 639 | ||
603 | /* Scheduling next */ | 640 | /* Scheduling next */ |
604 | e->cur = e->cur->next; | 641 | e->cur = e->cur->next; |
605 | if (NULL == e->cur) | 642 | if (NULL == e->cur) |
643 | { | ||
644 | /* done */ | ||
645 | fprintf (stderr, "Last episode done!\n"); | ||
646 | if (NULL != e->experiment_timeout_task) | ||
606 | { | 647 | { |
607 | /* done */ | 648 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); |
608 | fprintf(stderr, "Last episode done!\n"); | 649 | e->experiment_timeout_task = NULL; |
609 | if (NULL != e->experiment_timeout_task) | ||
610 | { | ||
611 | GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); | ||
612 | e->experiment_timeout_task = NULL; | ||
613 | } | ||
614 | e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK); | ||
615 | return; | ||
616 | } | 650 | } |
617 | 651 | e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time), | |
618 | fprintf(stderr, "Running episode %u with timeout %s\n", | 652 | GNUNET_OK); |
619 | e->cur->id, | 653 | return; |
620 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); | 654 | } |
621 | enforce_episode(e->cur); | 655 | |
622 | 656 | fprintf (stderr, "Running episode %u with timeout %s\n", | |
623 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, | 657 | e->cur->id, |
624 | &timeout_episode, e); | 658 | GNUNET_STRINGS_relative_time_to_string (e->cur->duration, |
659 | GNUNET_YES)); | ||
660 | enforce_episode (e->cur); | ||
661 | |||
662 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, | ||
663 | &timeout_episode, e); | ||
625 | } | 664 | } |
626 | 665 | ||
627 | 666 | ||
628 | void | 667 | void |
629 | GNUNET_ATS_TEST_experimentation_run(struct Experiment *e, | 668 | GNUNET_ATS_TEST_experimentation_run (struct Experiment *e, |
630 | GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, | 669 | GNUNET_ATS_TESTING_EpisodeDoneCallback |
631 | GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) | 670 | ep_done_cb, |
671 | GNUNET_ATS_TESTING_ExperimentDoneCallback | ||
672 | e_done_cb) | ||
632 | { | 673 | { |
633 | fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name, | 674 | fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name, |
634 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); | 675 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, |
676 | GNUNET_YES)); | ||
635 | e->e_done_cb = e_done_cb; | 677 | e->e_done_cb = e_done_cb; |
636 | e->ep_done_cb = ep_done_cb; | 678 | e->ep_done_cb = ep_done_cb; |
637 | e->start_time = GNUNET_TIME_absolute_get(); | 679 | e->start_time = GNUNET_TIME_absolute_get (); |
638 | 680 | ||
639 | /* Start total time out */ | 681 | /* Start total time out */ |
640 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed(e->max_duration, | 682 | e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration, |
641 | &timeout_experiment, e); | 683 | &timeout_experiment, |
684 | e); | ||
642 | 685 | ||
643 | /* Start */ | 686 | /* Start */ |
644 | e->cur = e->start; | 687 | e->cur = e->start; |
645 | fprintf(stderr, "Running episode %u with timeout %s\n", | 688 | fprintf (stderr, "Running episode %u with timeout %s\n", |
646 | e->cur->id, | 689 | e->cur->id, |
647 | GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); | 690 | GNUNET_STRINGS_relative_time_to_string (e->cur->duration, |
648 | enforce_episode(e->cur); | 691 | GNUNET_YES)); |
649 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, | 692 | enforce_episode (e->cur); |
650 | &timeout_episode, e); | 693 | e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration, |
694 | &timeout_episode, e); | ||
651 | } | 695 | } |
652 | 696 | ||
653 | 697 | ||
654 | struct Experiment * | 698 | struct Experiment * |
655 | GNUNET_ATS_TEST_experimentation_load(const char *filename) | 699 | GNUNET_ATS_TEST_experimentation_load (const char *filename) |
656 | { | 700 | { |
657 | struct Experiment *e; | 701 | struct Experiment *e; |
658 | struct GNUNET_CONFIGURATION_Handle *cfg; | 702 | struct GNUNET_CONFIGURATION_Handle *cfg; |
659 | 703 | ||
660 | e = NULL; | 704 | e = NULL; |
661 | 705 | ||
662 | cfg = GNUNET_CONFIGURATION_create(); | 706 | cfg = GNUNET_CONFIGURATION_create (); |
663 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename)) | 707 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename)) |
664 | { | 708 | { |
665 | fprintf(stderr, "Failed to load `%s'\n", filename); | 709 | fprintf (stderr, "Failed to load `%s'\n", filename); |
666 | GNUNET_CONFIGURATION_destroy(cfg); | 710 | GNUNET_CONFIGURATION_destroy (cfg); |
667 | return NULL; | 711 | return NULL; |
668 | } | 712 | } |
669 | 713 | ||
670 | e = create_experiment(); | 714 | e = create_experiment (); |
671 | 715 | ||
672 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", | 716 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "experiment", |
673 | "name", &e->name)) | 717 | "name", &e->name)) |
674 | { | 718 | { |
675 | fprintf(stderr, "Invalid %s", "name"); | 719 | fprintf (stderr, "Invalid %s", "name"); |
676 | free_experiment(e); | 720 | free_experiment (e); |
677 | return NULL; | 721 | return NULL; |
678 | } | 722 | } |
679 | else | 723 | else |
680 | fprintf(stderr, "Experiment name: `%s'\n", e->name); | 724 | fprintf (stderr, "Experiment name: `%s'\n", e->name); |
681 | 725 | ||
682 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment", | 726 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg, |
683 | "cfg_file", &e->cfg_file)) | 727 | "experiment", |
684 | { | 728 | "cfg_file", |
685 | fprintf(stderr, "Invalid %s", "cfg_file"); | 729 | &e->cfg_file)) |
686 | free_experiment(e); | 730 | { |
687 | return NULL; | 731 | fprintf (stderr, "Invalid %s", "cfg_file"); |
688 | } | 732 | free_experiment (e); |
733 | return NULL; | ||
734 | } | ||
689 | else | 735 | else |
690 | fprintf(stderr, "Experiment name: `%s'\n", e->cfg_file); | 736 | fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file); |
691 | 737 | ||
692 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | 738 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment", |
693 | "masters", &e->num_masters)) | 739 | "masters", |
694 | { | 740 | &e->num_masters)) |
695 | fprintf(stderr, "Invalid %s", "masters"); | 741 | { |
696 | free_experiment(e); | 742 | fprintf (stderr, "Invalid %s", "masters"); |
697 | return NULL; | 743 | free_experiment (e); |
698 | } | 744 | return NULL; |
745 | } | ||
699 | else | 746 | else |
700 | fprintf(stderr, "Experiment masters: `%llu'\n", | 747 | fprintf (stderr, "Experiment masters: `%llu'\n", |
701 | e->num_masters); | 748 | e->num_masters); |
702 | 749 | ||
703 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | 750 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment", |
704 | "slaves", &e->num_slaves)) | 751 | "slaves", |
705 | { | 752 | &e->num_slaves)) |
706 | fprintf(stderr, "Invalid %s", "slaves"); | 753 | { |
707 | free_experiment(e); | 754 | fprintf (stderr, "Invalid %s", "slaves"); |
708 | return NULL; | 755 | free_experiment (e); |
709 | } | 756 | return NULL; |
757 | } | ||
710 | else | 758 | else |
711 | fprintf(stderr, "Experiment slaves: `%llu'\n", | 759 | fprintf (stderr, "Experiment slaves: `%llu'\n", |
712 | e->num_slaves); | 760 | e->num_slaves); |
713 | 761 | ||
714 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 762 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment", |
715 | "log_freq", &e->log_freq)) | 763 | "log_freq", |
716 | { | 764 | &e->log_freq)) |
717 | fprintf(stderr, "Invalid %s", "log_freq"); | 765 | { |
718 | free_experiment(e); | 766 | fprintf (stderr, "Invalid %s", "log_freq"); |
719 | return NULL; | 767 | free_experiment (e); |
720 | } | 768 | return NULL; |
769 | } | ||
721 | else | 770 | else |
722 | fprintf(stderr, "Experiment logging frequency: `%s'\n", | 771 | fprintf (stderr, "Experiment logging frequency: `%s'\n", |
723 | GNUNET_STRINGS_relative_time_to_string(e->log_freq, GNUNET_YES)); | 772 | GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES)); |
724 | 773 | ||
725 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 774 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment", |
726 | "max_duration", &e->max_duration)) | 775 | "max_duration", |
727 | { | 776 | &e->max_duration)) |
728 | fprintf(stderr, "Invalid %s", "max_duration"); | 777 | { |
729 | free_experiment(e); | 778 | fprintf (stderr, "Invalid %s", "max_duration"); |
730 | return NULL; | 779 | free_experiment (e); |
731 | } | 780 | return NULL; |
781 | } | ||
732 | else | 782 | else |
733 | fprintf(stderr, "Experiment duration: `%s'\n", | 783 | fprintf (stderr, "Experiment duration: `%s'\n", |
734 | GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); | 784 | GNUNET_STRINGS_relative_time_to_string (e->max_duration, |
785 | GNUNET_YES)); | ||
735 | 786 | ||
736 | load_episodes(e, cfg); | 787 | load_episodes (e, cfg); |
737 | fprintf(stderr, "Loaded %u episodes with total duration %s\n", | 788 | fprintf (stderr, "Loaded %u episodes with total duration %s\n", |
738 | e->num_episodes, | 789 | e->num_episodes, |
739 | GNUNET_STRINGS_relative_time_to_string(e->total_duration, GNUNET_YES)); | 790 | GNUNET_STRINGS_relative_time_to_string (e->total_duration, |
791 | GNUNET_YES)); | ||
740 | 792 | ||
741 | GNUNET_CONFIGURATION_destroy(cfg); | 793 | GNUNET_CONFIGURATION_destroy (cfg); |
742 | return e; | 794 | return e; |
743 | } | 795 | } |
744 | 796 | ||
745 | void | 797 | void |
746 | GNUNET_ATS_TEST_experimentation_stop(struct Experiment *e) | 798 | GNUNET_ATS_TEST_experimentation_stop (struct Experiment *e) |
747 | { | 799 | { |
748 | if (NULL != e->experiment_timeout_task) | 800 | if (NULL != e->experiment_timeout_task) |
749 | { | 801 | { |
750 | GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); | 802 | GNUNET_SCHEDULER_cancel (e->experiment_timeout_task); |
751 | e->experiment_timeout_task = NULL; | 803 | e->experiment_timeout_task = NULL; |
752 | } | 804 | } |
753 | if (NULL != e->episode_timeout_task) | 805 | if (NULL != e->episode_timeout_task) |
754 | { | 806 | { |
755 | GNUNET_SCHEDULER_cancel(e->episode_timeout_task); | 807 | GNUNET_SCHEDULER_cancel (e->episode_timeout_task); |
756 | e->episode_timeout_task = NULL; | 808 | e->episode_timeout_task = NULL; |
757 | } | 809 | } |
758 | free_experiment(e); | 810 | free_experiment (e); |
759 | } | 811 | } |
760 | 812 | ||
761 | /* end of file ats-testing-experiment.c*/ | 813 | /* end of file ats-testing-experiment.c*/ |