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