summaryrefslogtreecommitdiff
path: root/src/ats-tests/gnunet-solver-eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats-tests/gnunet-solver-eval.c')
-rw-r--r--src/ats-tests/gnunet-solver-eval.c1147
1 files changed, 593 insertions, 554 deletions
diff --git a/src/ats-tests/gnunet-solver-eval.c b/src/ats-tests/gnunet-solver-eval.c
index b5e00bd6f..bc6a3c435 100644
--- a/src/ats-tests/gnunet-solver-eval.c
+++ b/src/ats-tests/gnunet-solver-eval.c
@@ -34,35 +34,35 @@
34 * Experiments 34 * Experiments
35 */ 35 */
36const char * 36const char *
37print_op(enum OperationType op) 37print_op (enum OperationType op)
38{ 38{
39 switch (op) 39 switch (op)
40 { 40 {
41 case START_SEND: 41 case START_SEND:
42 return "START_SEND"; 42 return "START_SEND";
43 43
44 case STOP_SEND: 44 case STOP_SEND:
45 return "STOP_SEND"; 45 return "STOP_SEND";
46 46
47 case START_PREFERENCE: 47 case START_PREFERENCE:
48 return "START_PREFERENCE"; 48 return "START_PREFERENCE";
49 49
50 case STOP_PREFERENCE: 50 case STOP_PREFERENCE:
51 return "STOP_PREFERENCE"; 51 return "STOP_PREFERENCE";
52 52
53 default: 53 default:
54 break; 54 break;
55 } 55 }
56 return ""; 56 return "";
57} 57}
58 58
59 59
60static struct Experiment * 60static struct Experiment *
61create_experiment() 61create_experiment ()
62{ 62{
63 struct Experiment *e; 63 struct Experiment *e;
64 64
65 e = GNUNET_new(struct Experiment); 65 e = GNUNET_new (struct Experiment);
66 e->name = NULL; 66 e->name = NULL;
67 e->num_masters = 0; 67 e->num_masters = 0;
68 e->num_slaves = 0; 68 e->num_slaves = 0;
@@ -73,7 +73,7 @@ create_experiment()
73 73
74 74
75static void 75static void
76free_experiment(struct Experiment *e) 76free_experiment (struct Experiment *e)
77{ 77{
78 struct Episode *cur; 78 struct Episode *cur;
79 struct Episode *next; 79 struct Episode *next;
@@ -82,28 +82,28 @@ free_experiment(struct Experiment *e)
82 82
83 next = e->start; 83 next = e->start;
84 for (cur = next; NULL != cur; cur = next) 84 for (cur = next; NULL != cur; cur = next)
85 { 85 {
86 next = cur->next; 86 next = cur->next;
87 87
88 next_o = cur->head; 88 next_o = cur->head;
89 for (cur_o = next_o; NULL != cur_o; cur_o = next_o) 89 for (cur_o = next_o; NULL != cur_o; cur_o = next_o)
90 { 90 {
91 next_o = cur_o->next; 91 next_o = cur_o->next;
92 GNUNET_free(cur_o); 92 GNUNET_free (cur_o);
93 }
94 GNUNET_free(cur);
95 } 93 }
94 GNUNET_free (cur);
95 }
96 96
97 GNUNET_free_non_null(e->name); 97 GNUNET_free_non_null (e->name);
98 GNUNET_free_non_null(e->cfg_file); 98 GNUNET_free_non_null (e->cfg_file);
99 GNUNET_free(e); 99 GNUNET_free (e);
100} 100}
101 101
102 102
103static int 103static int
104load_episode(struct Experiment *e, 104load_episode (struct Experiment *e,
105 struct Episode *cur, 105 struct Episode *cur,
106 struct GNUNET_CONFIGURATION_Handle *cfg) 106 struct GNUNET_CONFIGURATION_Handle *cfg)
107{ 107{
108 struct GNUNET_ATS_TEST_Operation *o; 108 struct GNUNET_ATS_TEST_Operation *o;
109 char *sec_name; 109 char *sec_name;
@@ -113,284 +113,303 @@ load_episode(struct Experiment *e,
113 char *pref; 113 char *pref;
114 int op_counter = 0; 114 int op_counter = 0;
115 115
116 fprintf(stderr, "Parsing episode %u\n", cur->id); 116 fprintf (stderr, "Parsing episode %u\n", cur->id);
117 GNUNET_asprintf(&sec_name, "episode-%u", cur->id); 117 GNUNET_asprintf (&sec_name, "episode-%u", cur->id);
118 118
119 while (1) 119 while (1)
120 {
121 /* Load operation */
122 GNUNET_asprintf (&op_name, "op-%u-operation", op_counter);
123 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
124 sec_name,
125 op_name, &op))
120 { 126 {
121 /* Load operation */ 127 GNUNET_free (op_name);
122 GNUNET_asprintf(&op_name, "op-%u-operation", op_counter); 128 break;
123 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, 129 }
124 sec_name, op_name, &op)) 130 o = GNUNET_new (struct GNUNET_ATS_TEST_Operation);
125 { 131 /* operations = set_rate, start_send, stop_send, set_preference */
126 GNUNET_free(op_name); 132 if (0 == strcmp (op, "start_send"))
127 break; 133 {
128 } 134 o->type = START_SEND;
129 o = GNUNET_new(struct GNUNET_ATS_TEST_Operation); 135 }
130 /* operations = set_rate, start_send, stop_send, set_preference */ 136 else if (0 == strcmp (op, "stop_send"))
131 if (0 == strcmp(op, "start_send")) 137 {
132 { 138 o->type = STOP_SEND;
133 o->type = START_SEND; 139 }
134 } 140 else if (0 == strcmp (op, "start_preference"))
135 else if (0 == strcmp(op, "stop_send")) 141 {
136 { 142 o->type = START_PREFERENCE;
137 o->type = STOP_SEND; 143 }
138 } 144 else if (0 == strcmp (op, "stop_preference"))
139 else if (0 == strcmp(op, "start_preference")) 145 {
140 { 146 o->type = STOP_PREFERENCE;
141 o->type = START_PREFERENCE; 147 }
142 } 148 else
143 else if (0 == strcmp(op, "stop_preference")) 149 {
144 { 150 fprintf (stderr, "Invalid operation %u `%s' in episode %u\n",
145 o->type = STOP_PREFERENCE; 151 op_counter, op, cur->id);
146 } 152 GNUNET_free (op);
153 GNUNET_free (op_name);
154 GNUNET_free (sec_name);
155 GNUNET_free (o);
156 return GNUNET_SYSERR;
157 }
158 GNUNET_free (op_name);
159
160 /* Get source */
161 GNUNET_asprintf (&op_name, "op-%u-src", op_counter);
162 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
163 sec_name,
164 op_name,
165 &o->src_id))
166 {
167 fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
168 op_counter, op, cur->id);
169 GNUNET_free (op);
170 GNUNET_free (op_name);
171 GNUNET_free (sec_name);
172 GNUNET_free (o);
173 return GNUNET_SYSERR;
174 }
175 if (o->src_id > (e->num_masters - 1))
176 {
177 fprintf (stderr, "Invalid src %llu in operation %u `%s' in episode %u\n",
178 o->src_id, op_counter, op, cur->id);
179 GNUNET_free (op);
180 GNUNET_free (op_name);
181 GNUNET_free (sec_name);
182 GNUNET_free (o);
183 return GNUNET_SYSERR;
184 }
185 GNUNET_free (op_name);
186
187 /* Get destination */
188 GNUNET_asprintf (&op_name, "op-%u-dest", op_counter);
189 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
190 sec_name,
191 op_name,
192 &o->dest_id))
193 {
194 fprintf (stderr, "Missing src in operation %u `%s' in episode %u\n",
195 op_counter, op, cur->id);
196 GNUNET_free (op);
197 GNUNET_free (op_name);
198 GNUNET_free (sec_name);
199 GNUNET_free (o);
200 return GNUNET_SYSERR;
201 }
202 if (o->dest_id > (e->num_slaves - 1))
203 {
204 fprintf (stderr,
205 "Invalid destination %llu in operation %u `%s' in episode %u\n",
206 o->dest_id,
207 op_counter,
208 op,
209 cur->id);
210 GNUNET_free (op);
211 GNUNET_free (op_name);
212 GNUNET_free (sec_name);
213 GNUNET_free (o);
214 return GNUNET_SYSERR;
215 }
216 GNUNET_free (op_name);
217
218 GNUNET_asprintf (&op_name, "op-%u-type", op_counter);
219 if ((GNUNET_SYSERR !=
220 GNUNET_CONFIGURATION_get_value_string (cfg,
221 sec_name,
222 op_name,
223 &type)) &&
224 (STOP_SEND != o->type) &&
225 (STOP_PREFERENCE != o->type))
226 {
227 /* Load arguments for set_rate, start_send, set_preference */
228 if (0 == strcmp (type, "constant"))
229 {
230 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
231 }
232 else if (0 == strcmp (type, "linear"))
233 {
234 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
235 }
236 else if (0 == strcmp (type, "sinus"))
237 {
238 o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
239 }
240 else if (0 == strcmp (type, "random"))
241 {
242 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
243 }
147 else 244 else
245 {
246 fprintf (stderr, "Invalid type %u `%s' in episode %u\n",
247 op_counter, op, cur->id);
248 GNUNET_free (type);
249 GNUNET_free (op);
250 GNUNET_free (op_name);
251 GNUNET_free (sec_name);
252 GNUNET_free (o);
253 return GNUNET_SYSERR;
254 }
255 GNUNET_free (op_name);
256
257 /* Get base rate */
258 GNUNET_asprintf (&op_name, "op-%u-base-rate", op_counter);
259 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
260 sec_name,
261 op_name,
262 &o->base_rate))
263 {
264 fprintf (stderr,
265 "Missing base rate in operation %u `%s' in episode %u\n",
266 op_counter, op, cur->id);
267 GNUNET_free (type);
268 GNUNET_free (op);
269 GNUNET_free (op_name);
270 GNUNET_free (sec_name);
271 GNUNET_free (o);
272 return GNUNET_SYSERR;
273 }
274 GNUNET_free (op_name);
275
276 /* Get max rate */
277 GNUNET_asprintf (&op_name, "op-%u-max-rate", op_counter);
278 if (GNUNET_SYSERR ==
279 GNUNET_CONFIGURATION_get_value_number (cfg,
280 sec_name,
281 op_name,
282 &o->max_rate))
283 {
284 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
285 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
286 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
148 { 287 {
149 fprintf(stderr, "Invalid operation %u `%s' in episode %u\n", 288 fprintf (stderr,
150 op_counter, op, cur->id); 289 "Missing max rate in operation %u `%s' in episode %u\n",
151 GNUNET_free(op); 290 op_counter, op, cur->id);
152 GNUNET_free(op_name); 291 GNUNET_free (type);
153 GNUNET_free(sec_name); 292 GNUNET_free (op_name);
154 GNUNET_free(o); 293 GNUNET_free (op);
294 GNUNET_free (sec_name);
295 GNUNET_free (o);
155 return GNUNET_SYSERR; 296 return GNUNET_SYSERR;
156 } 297 }
157 GNUNET_free(op_name); 298 }
158 299 GNUNET_free (op_name);
159 /* Get source */ 300
160 GNUNET_asprintf(&op_name, "op-%u-src", op_counter); 301 /* Get period */
161 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, 302 GNUNET_asprintf (&op_name, "op-%u-period", op_counter);
162 sec_name, op_name, &o->src_id)) 303 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
304 sec_name,
305 op_name,
306 &o->period))
307 {
308 o->period = cur->duration;
309 }
310 GNUNET_free (op_name);
311
312 if (START_PREFERENCE == o->type)
313 {
314 /* Get frequency */
315 GNUNET_asprintf (&op_name, "op-%u-frequency", op_counter);
316 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
317 sec_name,
318 op_name,
319 &o->frequency))
163 { 320 {
164 fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", 321 fprintf (stderr,
165 op_counter, op, cur->id); 322 "Missing frequency in operation %u `%s' in episode %u\n",
166 GNUNET_free(op); 323 op_counter, op, cur->id);
167 GNUNET_free(op_name); 324 GNUNET_free (type);
168 GNUNET_free(sec_name); 325 GNUNET_free (op_name);
169 GNUNET_free(o); 326 GNUNET_free (op);
327 GNUNET_free (sec_name);
328 GNUNET_free (o);
170 return GNUNET_SYSERR; 329 return GNUNET_SYSERR;
171 } 330 }
172 if (o->src_id > (e->num_masters - 1)) 331 GNUNET_free (op_name);
332
333 /* Get preference */
334 GNUNET_asprintf (&op_name, "op-%u-pref", op_counter);
335 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg,
336 sec_name,
337 op_name,
338 &pref))
173 { 339 {
174 fprintf(stderr, "Invalid src %llu in operation %u `%s' in episode %u\n", 340 fprintf (stderr,
175 o->src_id, op_counter, op, cur->id); 341 "Missing preference in operation %u `%s' in episode %u\n",
176 GNUNET_free(op); 342 op_counter, op, cur->id);
177 GNUNET_free(op_name); 343 GNUNET_free (type);
178 GNUNET_free(sec_name); 344 GNUNET_free (op_name);
179 GNUNET_free(o); 345 GNUNET_free (op);
346 GNUNET_free (sec_name);
347 GNUNET_free_non_null (pref);
348 GNUNET_free (o);
180 return GNUNET_SYSERR; 349 return GNUNET_SYSERR;
181 } 350 }
182 GNUNET_free(op_name);
183 351
184 /* Get destination */ 352 if (0 == strcmp (pref, "bandwidth"))
185 GNUNET_asprintf(&op_name, "op-%u-dest", op_counter); 353 o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
186 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, 354 else if (0 == strcmp (pref, "latency"))
187 sec_name, op_name, &o->dest_id)) 355 o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
356 else
188 { 357 {
189 fprintf(stderr, "Missing src in operation %u `%s' in episode %u\n", 358 fprintf (stderr,
190 op_counter, op, cur->id); 359 "Invalid preference in operation %u `%s' in episode %u\n",
191 GNUNET_free(op); 360 op_counter,
192 GNUNET_free(op_name); 361 op,
193 GNUNET_free(sec_name); 362 cur->id);
194 GNUNET_free(o); 363 GNUNET_free (type);
364 GNUNET_free (op_name);
365 GNUNET_free (op);
366 GNUNET_free (sec_name);
367 GNUNET_free_non_null (pref);
368 GNUNET_free (o);
195 return GNUNET_SYSERR; 369 return GNUNET_SYSERR;
196 } 370 }
197 if (o->dest_id > (e->num_slaves - 1)) 371 GNUNET_free (pref);
198 { 372 GNUNET_free (op_name);
199 fprintf(stderr, 373 }
200 "Invalid destination %llu in operation %u `%s' in episode %u\n", 374 }
201 o->dest_id,
202 op_counter,
203 op,
204 cur->id);
205 GNUNET_free(op);
206 GNUNET_free(op_name);
207 GNUNET_free(sec_name);
208 GNUNET_free(o);
209 return GNUNET_SYSERR;
210 }
211 GNUNET_free(op_name);
212
213 GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
214 if ((GNUNET_SYSERR !=
215 GNUNET_CONFIGURATION_get_value_string(cfg,
216 sec_name,
217 op_name,
218 &type)) &&
219 (STOP_SEND != o->type) &&
220 (STOP_PREFERENCE != o->type))
221 {
222 /* Load arguments for set_rate, start_send, set_preference */
223 if (0 == strcmp(type, "constant"))
224 {
225 o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT;
226 }
227 else if (0 == strcmp(type, "linear"))
228 {
229 o->gen_type = GNUNET_ATS_TEST_TG_LINEAR;
230 }
231 else if (0 == strcmp(type, "sinus"))
232 {
233 o->gen_type = GNUNET_ATS_TEST_TG_SINUS;
234 }
235 else if (0 == strcmp(type, "random"))
236 {
237 o->gen_type = GNUNET_ATS_TEST_TG_RANDOM;
238 }
239 else
240 {
241 fprintf(stderr, "Invalid type %u `%s' in episode %u\n",
242 op_counter, op, cur->id);
243 GNUNET_free(type);
244 GNUNET_free(op);
245 GNUNET_free(op_name);
246 GNUNET_free(sec_name);
247 GNUNET_free(o);
248 return GNUNET_SYSERR;
249 }
250 GNUNET_free(op_name);
251
252 /* Get base rate */
253 GNUNET_asprintf(&op_name, "op-%u-base-rate", op_counter);
254 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg,
255 sec_name, op_name, &o->base_rate))
256 {
257 fprintf(stderr, "Missing base rate in operation %u `%s' in episode %u\n",
258 op_counter, op, cur->id);
259 GNUNET_free(type);
260 GNUNET_free(op);
261 GNUNET_free(op_name);
262 GNUNET_free(sec_name);
263 GNUNET_free(o);
264 return GNUNET_SYSERR;
265 }
266 GNUNET_free(op_name);
267
268 /* Get max rate */
269 GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
270 if (GNUNET_SYSERR ==
271 GNUNET_CONFIGURATION_get_value_number(cfg,
272 sec_name,
273 op_name,
274 &o->max_rate))
275 {
276 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
277 (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
278 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
279 {
280 fprintf(stderr, "Missing max rate in operation %u `%s' in episode %u\n",
281 op_counter, op, cur->id);
282 GNUNET_free(type);
283 GNUNET_free(op_name);
284 GNUNET_free(op);
285 GNUNET_free(sec_name);
286 GNUNET_free(o);
287 return GNUNET_SYSERR;
288 }
289 }
290 GNUNET_free(op_name);
291
292 /* Get period */
293 GNUNET_asprintf(&op_name, "op-%u-period", op_counter);
294 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
295 sec_name, op_name, &o->period))
296 {
297 o->period = cur->duration;
298 }
299 GNUNET_free(op_name);
300
301 if (START_PREFERENCE == o->type)
302 {
303 /* Get frequency */
304 GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter);
305 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg,
306 sec_name, op_name, &o->frequency))
307 {
308 fprintf(stderr, "Missing frequency in operation %u `%s' in episode %u\n",
309 op_counter, op, cur->id);
310 GNUNET_free(type);
311 GNUNET_free(op_name);
312 GNUNET_free(op);
313 GNUNET_free(sec_name);
314 GNUNET_free(o);
315 return GNUNET_SYSERR;
316 }
317 GNUNET_free(op_name);
318
319 /* Get preference */
320 GNUNET_asprintf(&op_name, "op-%u-pref", op_counter);
321 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg,
322 sec_name, op_name, &pref))
323 {
324 fprintf(stderr, "Missing 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(sec_name);
330 GNUNET_free_non_null(pref);
331 GNUNET_free(o);
332 return GNUNET_SYSERR;
333 }
334
335 if (0 == strcmp(pref, "bandwidth"))
336 o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH;
337 else if (0 == strcmp(pref, "latency"))
338 o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY;
339 else
340 {
341 fprintf(stderr,
342 "Invalid preference in operation %u `%s' in episode %u\n",
343 op_counter,
344 op,
345 cur->id);
346 GNUNET_free(type);
347 GNUNET_free(op_name);
348 GNUNET_free(op);
349 GNUNET_free(sec_name);
350 GNUNET_free_non_null(pref);
351 GNUNET_free(o);
352 return GNUNET_SYSERR;
353 }
354 GNUNET_free(pref);
355 GNUNET_free(op_name);
356 }
357 }
358
359 /* Safety checks */
360 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
361 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
362 {
363 if ((o->max_rate - o->base_rate) > o->base_rate)
364 {
365 /* This will cause an underflow */
366 GNUNET_break(0);
367 }
368 fprintf(stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
369 }
370
371 if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
372 fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
373 op_counter, cur->id, print_op(o->type), o->src_id,
374 o->dest_id, (NULL != type) ? type : "",
375 o->base_rate, o->max_rate,
376 GNUNET_STRINGS_relative_time_to_string(o->period, GNUNET_YES));
377 else
378 fprintf(stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
379 op_counter, cur->id, print_op(o->type), o->src_id, o->dest_id);
380
381 GNUNET_free_non_null(type);
382 GNUNET_free(op);
383 375
384 GNUNET_CONTAINER_DLL_insert(cur->head, cur->tail, o); 376 /* Safety checks */
385 op_counter++; 377 if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
378 (GNUNET_ATS_TEST_TG_SINUS == o->gen_type))
379 {
380 if ((o->max_rate - o->base_rate) > o->base_rate)
381 {
382 /* This will cause an underflow */
383 GNUNET_break (0);
384 }
385 fprintf (stderr,
386 "Selected max rate and base rate cannot be used for desired traffic form!\n");
386 } 387 }
387 GNUNET_free(sec_name); 388
389 if ((START_SEND == o->type) || (START_PREFERENCE == o->type))
390 fprintf (stderr,
391 "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n",
392 op_counter, cur->id, print_op (o->type), o->src_id,
393 o->dest_id, (NULL != type) ? type : "",
394 o->base_rate, o->max_rate,
395 GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES));
396 else
397 fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n",
398 op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id);
399
400 GNUNET_free_non_null (type);
401 GNUNET_free (op);
402
403 GNUNET_CONTAINER_DLL_insert (cur->head, cur->tail, o);
404 op_counter++;
405 }
406 GNUNET_free (sec_name);
388 407
389 return GNUNET_OK; 408 return GNUNET_OK;
390} 409}
391 410
392static int 411static int
393load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) 412load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
394{ 413{
395 int e_counter = 0; 414 int e_counter = 0;
396 char *sec_name; 415 char *sec_name;
@@ -401,68 +420,72 @@ load_episodes(struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg)
401 e_counter = 0; 420 e_counter = 0;
402 last = NULL; 421 last = NULL;
403 while (1) 422 while (1)
423 {
424 GNUNET_asprintf (&sec_name, "episode-%u", e_counter);
425 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg,
426 sec_name,
427 "duration",
428 &e_duration))
404 { 429 {
405 GNUNET_asprintf(&sec_name, "episode-%u", e_counter); 430 GNUNET_free (sec_name);
406 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, 431 break;
407 sec_name, "duration", &e_duration)) 432 }
408 {
409 GNUNET_free(sec_name);
410 break;
411 }
412
413 cur = GNUNET_new(struct Episode);
414 cur->duration = e_duration;
415 cur->id = e_counter;
416
417 if (GNUNET_OK != load_episode(e, cur, cfg))
418 {
419 GNUNET_free(sec_name);
420 GNUNET_free(cur);
421 return GNUNET_SYSERR;
422 }
423
424 fprintf(stderr, "Found episode %u with duration %s \n",
425 e_counter,
426 GNUNET_STRINGS_relative_time_to_string(cur->duration, GNUNET_YES));
427 433
428 /* Update experiment */ 434 cur = GNUNET_new (struct Episode);
429 e->num_episodes++; 435 cur->duration = e_duration;
430 e->total_duration = GNUNET_TIME_relative_add(e->total_duration, cur->duration); 436 cur->id = e_counter;
431 /* Put in linked list */
432 if (NULL == last)
433 e->start = cur;
434 else
435 last->next = cur;
436 437
437 GNUNET_free(sec_name); 438 if (GNUNET_OK != load_episode (e, cur, cfg))
438 e_counter++; 439 {
439 last = cur; 440 GNUNET_free (sec_name);
441 GNUNET_free (cur);
442 return GNUNET_SYSERR;
440 } 443 }
444
445 fprintf (stderr, "Found episode %u with duration %s \n",
446 e_counter,
447 GNUNET_STRINGS_relative_time_to_string (cur->duration,
448 GNUNET_YES));
449
450 /* Update experiment */
451 e->num_episodes++;
452 e->total_duration = GNUNET_TIME_relative_add (e->total_duration,
453 cur->duration);
454 /* Put in linked list */
455 if (NULL == last)
456 e->start = cur;
457 else
458 last->next = cur;
459
460 GNUNET_free (sec_name);
461 e_counter++;
462 last = cur;
463 }
441 return e_counter; 464 return e_counter;
442} 465}
443 466
444 467
445static void 468static void
446timeout_experiment(void *cls) 469timeout_experiment (void *cls)
447{ 470{
448 struct Experiment *e = cls; 471 struct Experiment *e = cls;
449 472
450 e->experiment_timeout_task = NULL; 473 e->experiment_timeout_task = NULL;
451 fprintf(stderr, "Experiment timeout!\n"); 474 fprintf (stderr, "Experiment timeout!\n");
452 475
453 if (NULL != e->episode_timeout_task) 476 if (NULL != e->episode_timeout_task)
454 { 477 {
455 GNUNET_SCHEDULER_cancel(e->episode_timeout_task); 478 GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
456 e->episode_timeout_task = NULL; 479 e->episode_timeout_task = NULL;
457 } 480 }
458 481
459 e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), 482 e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time),
460 GNUNET_SYSERR); 483 GNUNET_SYSERR);
461} 484}
462 485
463 486
464static void 487static void
465enforce_start_send(struct GNUNET_ATS_TEST_Operation *op) 488enforce_start_send (struct GNUNET_ATS_TEST_Operation *op)
466{ 489{
467 /* 490 /*
468 struct BenchmarkPeer *peer; 491 struct BenchmarkPeer *peer;
@@ -498,7 +521,7 @@ enforce_start_send(struct GNUNET_ATS_TEST_Operation *op)
498} 521}
499 522
500static void 523static void
501enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op) 524enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op)
502{ 525{
503 /* 526 /*
504 struct BenchmarkPartner *p; 527 struct BenchmarkPartner *p;
@@ -523,7 +546,7 @@ enforce_stop_send(struct GNUNET_ATS_TEST_Operation *op)
523 546
524 547
525static void 548static void
526enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op) 549enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op)
527{ 550{
528 /* 551 /*
529 struct BenchmarkPeer *peer; 552 struct BenchmarkPeer *peer;
@@ -560,7 +583,7 @@ enforce_start_preference(struct GNUNET_ATS_TEST_Operation *op)
560} 583}
561 584
562static void 585static void
563enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op) 586enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op)
564{ 587{
565 /* 588 /*
566 struct BenchmarkPartner *p; 589 struct BenchmarkPartner *p;
@@ -583,264 +606,281 @@ enforce_stop_preference(struct GNUNET_ATS_TEST_Operation *op)
583 */ 606 */
584} 607}
585 608
586static void enforce_episode(struct Episode *ep) 609static void enforce_episode (struct Episode *ep)
587{ 610{
588 struct GNUNET_ATS_TEST_Operation *cur; 611 struct GNUNET_ATS_TEST_Operation *cur;
589 612
590 for (cur = ep->head; NULL != cur; cur = cur->next) 613 for (cur = ep->head; NULL != cur; cur = cur->next)
614 {
615 fprintf (stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n",
616 print_op (cur->type), cur->src_id, cur->dest_id, cur->base_rate);
617 switch (cur->type)
591 { 618 {
592 fprintf(stderr, "Enforcing operation: %s [%llu]->[%llu] == %llu\n", 619 case START_SEND:
593 print_op(cur->type), cur->src_id, cur->dest_id, cur->base_rate); 620 enforce_start_send (cur);
594 switch (cur->type) 621 break;
595 {
596 case START_SEND:
597 enforce_start_send(cur);
598 break;
599 622
600 case STOP_SEND: 623 case STOP_SEND:
601 enforce_stop_send(cur); 624 enforce_stop_send (cur);
602 break; 625 break;
603 626
604 case START_PREFERENCE: 627 case START_PREFERENCE:
605 enforce_start_preference(cur); 628 enforce_start_preference (cur);
606 break; 629 break;
607 630
608 case STOP_PREFERENCE: 631 case STOP_PREFERENCE:
609 enforce_stop_preference(cur); 632 enforce_stop_preference (cur);
610 break; 633 break;
611 634
612 default: 635 default:
613 break; 636 break;
614 }
615 } 637 }
638 }
616} 639}
617 640
618 641
619static void 642static void
620timeout_episode(void *cls) 643timeout_episode (void *cls)
621{ 644{
622 struct Experiment *e = cls; 645 struct Experiment *e = cls;
623 646
624 e->episode_timeout_task = NULL; 647 e->episode_timeout_task = NULL;
625 if (NULL != e->ep_done_cb) 648 if (NULL != e->ep_done_cb)
626 e->ep_done_cb(e->cur); 649 e->ep_done_cb (e->cur);
627 650
628 /* Scheduling next */ 651 /* Scheduling next */
629 e->cur = e->cur->next; 652 e->cur = e->cur->next;
630 if (NULL == e->cur) 653 if (NULL == e->cur)
654 {
655 /* done */
656 fprintf (stderr, "Last episode done!\n");
657 if (NULL != e->experiment_timeout_task)
631 { 658 {
632 /* done */ 659 GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
633 fprintf(stderr, "Last episode done!\n"); 660 e->experiment_timeout_task = NULL;
634 if (NULL != e->experiment_timeout_task)
635 {
636 GNUNET_SCHEDULER_cancel(e->experiment_timeout_task);
637 e->experiment_timeout_task = NULL;
638 }
639 e->e_done_cb(e, GNUNET_TIME_absolute_get_duration(e->start_time), GNUNET_OK);
640 return;
641 } 661 }
642 662 e->e_done_cb (e, GNUNET_TIME_absolute_get_duration (e->start_time),
643 fprintf(stderr, "Running episode %u with timeout %s\n", 663 GNUNET_OK);
644 e->cur->id, 664 return;
645 GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); 665 }
646 enforce_episode(e->cur); 666
647 667 fprintf (stderr, "Running episode %u with timeout %s\n",
648 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, 668 e->cur->id,
649 &timeout_episode, e); 669 GNUNET_STRINGS_relative_time_to_string (e->cur->duration,
670 GNUNET_YES));
671 enforce_episode (e->cur);
672
673 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration,
674 &timeout_episode, e);
650} 675}
651 676
652 677
653void 678void
654GNUNET_ATS_solvers_experimentation_run(struct Experiment *e, 679GNUNET_ATS_solvers_experimentation_run (struct Experiment *e,
655 GNUNET_ATS_TESTING_EpisodeDoneCallback ep_done_cb, 680 GNUNET_ATS_TESTING_EpisodeDoneCallback
656 GNUNET_ATS_TESTING_ExperimentDoneCallback e_done_cb) 681 ep_done_cb,
682 GNUNET_ATS_TESTING_ExperimentDoneCallback
683 e_done_cb)
657{ 684{
658 fprintf(stderr, "Running experiment `%s' with timeout %s\n", e->name, 685 fprintf (stderr, "Running experiment `%s' with timeout %s\n", e->name,
659 GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); 686 GNUNET_STRINGS_relative_time_to_string (e->max_duration,
687 GNUNET_YES));
660 e->e_done_cb = e_done_cb; 688 e->e_done_cb = e_done_cb;
661 e->ep_done_cb = ep_done_cb; 689 e->ep_done_cb = ep_done_cb;
662 e->start_time = GNUNET_TIME_absolute_get(); 690 e->start_time = GNUNET_TIME_absolute_get ();
663 691
664 /* Start total time out */ 692 /* Start total time out */
665 e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed(e->max_duration, 693 e->experiment_timeout_task = GNUNET_SCHEDULER_add_delayed (e->max_duration,
666 &timeout_experiment, e); 694 &timeout_experiment,
695 e);
667 696
668 /* Start */ 697 /* Start */
669 e->cur = e->start; 698 e->cur = e->start;
670 fprintf(stderr, "Running episode %u with timeout %s\n", 699 fprintf (stderr, "Running episode %u with timeout %s\n",
671 e->cur->id, 700 e->cur->id,
672 GNUNET_STRINGS_relative_time_to_string(e->cur->duration, GNUNET_YES)); 701 GNUNET_STRINGS_relative_time_to_string (e->cur->duration,
673 enforce_episode(e->cur); 702 GNUNET_YES));
674 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed(e->cur->duration, 703 enforce_episode (e->cur);
675 &timeout_episode, e); 704 e->episode_timeout_task = GNUNET_SCHEDULER_add_delayed (e->cur->duration,
705 &timeout_episode, e);
676} 706}
677 707
678 708
679struct Experiment * 709struct Experiment *
680GNUNET_ATS_solvers_experimentation_load(char *filename) 710GNUNET_ATS_solvers_experimentation_load (char *filename)
681{ 711{
682 struct Experiment *e; 712 struct Experiment *e;
683 struct GNUNET_CONFIGURATION_Handle *cfg; 713 struct GNUNET_CONFIGURATION_Handle *cfg;
684 714
685 e = NULL; 715 e = NULL;
686 716
687 cfg = GNUNET_CONFIGURATION_create(); 717 cfg = GNUNET_CONFIGURATION_create ();
688 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load(cfg, filename)) 718 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, filename))
689 { 719 {
690 fprintf(stderr, "Failed to load `%s'\n", filename); 720 fprintf (stderr, "Failed to load `%s'\n", filename);
691 GNUNET_CONFIGURATION_destroy(cfg); 721 GNUNET_CONFIGURATION_destroy (cfg);
692 return NULL; 722 return NULL;
693 } 723 }
694 724
695 e = create_experiment(); 725 e = create_experiment ();
696 726
697 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, "experiment", 727 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, "experiment",
698 "name", &e->name)) 728 "name", &e->name))
699 { 729 {
700 fprintf(stderr, "Invalid %s", "name"); 730 fprintf (stderr, "Invalid %s", "name");
701 free_experiment(e); 731 free_experiment (e);
702 return NULL; 732 return NULL;
703 } 733 }
704 else 734 else
705 fprintf(stderr, "Experiment name: `%s'\n", e->name); 735 fprintf (stderr, "Experiment name: `%s'\n", e->name);
706 736
707 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename(cfg, "experiment", 737 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_filename (cfg,
708 "cfg_file", &e->cfg_file)) 738 "experiment",
709 { 739 "cfg_file",
710 fprintf(stderr, "Invalid %s", "cfg_file"); 740 &e->cfg_file))
711 free_experiment(e); 741 {
712 return NULL; 742 fprintf (stderr, "Invalid %s", "cfg_file");
713 } 743 free_experiment (e);
744 return NULL;
745 }
714 else 746 else
715 fprintf(stderr, "Experiment name: `%s'\n", e->cfg_file); 747 fprintf (stderr, "Experiment name: `%s'\n", e->cfg_file);
716 748
717 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", 749 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment",
718 "masters", &e->num_masters)) 750 "masters",
719 { 751 &e->num_masters))
720 fprintf(stderr, "Invalid %s", "masters"); 752 {
721 free_experiment(e); 753 fprintf (stderr, "Invalid %s", "masters");
722 return NULL; 754 free_experiment (e);
723 } 755 return NULL;
756 }
724 else 757 else
725 fprintf(stderr, "Experiment masters: `%llu'\n", 758 fprintf (stderr, "Experiment masters: `%llu'\n",
726 e->num_masters); 759 e->num_masters);
727 760
728 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", 761 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "experiment",
729 "slaves", &e->num_slaves)) 762 "slaves",
730 { 763 &e->num_slaves))
731 fprintf(stderr, "Invalid %s", "slaves"); 764 {
732 free_experiment(e); 765 fprintf (stderr, "Invalid %s", "slaves");
733 return NULL; 766 free_experiment (e);
734 } 767 return NULL;
768 }
735 else 769 else
736 fprintf(stderr, "Experiment slaves: `%llu'\n", 770 fprintf (stderr, "Experiment slaves: `%llu'\n",
737 e->num_slaves); 771 e->num_slaves);
738 772
739 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", 773 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment",
740 "log_freq", &e->log_freq)) 774 "log_freq",
741 { 775 &e->log_freq))
742 fprintf(stderr, "Invalid %s", "log_freq"); 776 {
743 free_experiment(e); 777 fprintf (stderr, "Invalid %s", "log_freq");
744 return NULL; 778 free_experiment (e);
745 } 779 return NULL;
780 }
746 else 781 else
747 fprintf(stderr, "Experiment logging frequency: `%s'\n", 782 fprintf (stderr, "Experiment logging frequency: `%s'\n",
748 GNUNET_STRINGS_relative_time_to_string(e->log_freq, GNUNET_YES)); 783 GNUNET_STRINGS_relative_time_to_string (e->log_freq, GNUNET_YES));
749 784
750 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", 785 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, "experiment",
751 "max_duration", &e->max_duration)) 786 "max_duration",
752 { 787 &e->max_duration))
753 fprintf(stderr, "Invalid %s", "max_duration"); 788 {
754 free_experiment(e); 789 fprintf (stderr, "Invalid %s", "max_duration");
755 return NULL; 790 free_experiment (e);
756 } 791 return NULL;
792 }
757 else 793 else
758 fprintf(stderr, "Experiment duration: `%s'\n", 794 fprintf (stderr, "Experiment duration: `%s'\n",
759 GNUNET_STRINGS_relative_time_to_string(e->max_duration, GNUNET_YES)); 795 GNUNET_STRINGS_relative_time_to_string (e->max_duration,
796 GNUNET_YES));
760 797
761 load_episodes(e, cfg); 798 load_episodes (e, cfg);
762 fprintf(stderr, "Loaded %u episodes with total duration %s\n", 799 fprintf (stderr, "Loaded %u episodes with total duration %s\n",
763 e->num_episodes, 800 e->num_episodes,
764 GNUNET_STRINGS_relative_time_to_string(e->total_duration, GNUNET_YES)); 801 GNUNET_STRINGS_relative_time_to_string (e->total_duration,
802 GNUNET_YES));
765 803
766 GNUNET_CONFIGURATION_destroy(cfg); 804 GNUNET_CONFIGURATION_destroy (cfg);
767 return e; 805 return e;
768} 806}
769 807
770void 808void
771GNUNET_ATS_solvers_experimentation_stop(struct Experiment *e) 809GNUNET_ATS_solvers_experimentation_stop (struct Experiment *e)
772{ 810{
773 if (NULL != e->experiment_timeout_task) 811 if (NULL != e->experiment_timeout_task)
774 { 812 {
775 GNUNET_SCHEDULER_cancel(e->experiment_timeout_task); 813 GNUNET_SCHEDULER_cancel (e->experiment_timeout_task);
776 e->experiment_timeout_task = NULL; 814 e->experiment_timeout_task = NULL;
777 } 815 }
778 if (NULL != e->episode_timeout_task) 816 if (NULL != e->episode_timeout_task)
779 { 817 {
780 GNUNET_SCHEDULER_cancel(e->episode_timeout_task); 818 GNUNET_SCHEDULER_cancel (e->episode_timeout_task);
781 e->episode_timeout_task = NULL; 819 e->episode_timeout_task = NULL;
782 } 820 }
783 free_experiment(e); 821 free_experiment (e);
784} 822}
785 823
786/** 824/**
787 * Solver 825 * Solver
788 */ 826 */
789 827
790struct GNUNET_ATS_TESTING_SolverHandle { 828struct GNUNET_ATS_TESTING_SolverHandle
791 char * plugin; 829{
830 char *plugin;
792 struct GNUNET_ATS_PluginEnvironment env; 831 struct GNUNET_ATS_PluginEnvironment env;
793 void *solver; 832 void *solver;
794}; 833};
795 834
796enum GNUNET_ATS_Solvers { 835enum GNUNET_ATS_Solvers
836{
797 GNUNET_ATS_SOLVER_PROPORTIONAL, 837 GNUNET_ATS_SOLVER_PROPORTIONAL,
798 GNUNET_ATS_SOLVER_MLP, 838 GNUNET_ATS_SOLVER_MLP,
799 GNUNET_ATS_SOLVER_RIL, 839 GNUNET_ATS_SOLVER_RIL,
800}; 840};
801 841
802void 842void
803GNUNET_ATS_solvers_solver_stop(struct GNUNET_ATS_TESTING_SolverHandle *sh) 843GNUNET_ATS_solvers_solver_stop (struct GNUNET_ATS_TESTING_SolverHandle *sh)
804{ 844{
805 GNUNET_PLUGIN_unload(sh->plugin, sh->solver); 845 GNUNET_PLUGIN_unload (sh->plugin, sh->solver);
806 GNUNET_free(sh->plugin); 846 GNUNET_free (sh->plugin);
807 GNUNET_free(sh); 847 GNUNET_free (sh);
808} 848}
809 849
810struct GNUNET_ATS_TESTING_SolverHandle * 850struct GNUNET_ATS_TESTING_SolverHandle *
811GNUNET_ATS_solvers_solver_start(enum GNUNET_ATS_Solvers type) 851GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type)
812{ 852{
813 struct GNUNET_ATS_TESTING_SolverHandle *sh; 853 struct GNUNET_ATS_TESTING_SolverHandle *sh;
814 char * solver_str; 854 char *solver_str;
815 855
816 switch (type) 856 switch (type)
817 { 857 {
818 case GNUNET_ATS_SOLVER_PROPORTIONAL: 858 case GNUNET_ATS_SOLVER_PROPORTIONAL:
819 solver_str = "proportional"; 859 solver_str = "proportional";
820 break; 860 break;
821 861
822 case GNUNET_ATS_SOLVER_MLP: 862 case GNUNET_ATS_SOLVER_MLP:
823 solver_str = "mlp"; 863 solver_str = "mlp";
824 break; 864 break;
825 865
826 case GNUNET_ATS_SOLVER_RIL: 866 case GNUNET_ATS_SOLVER_RIL:
827 solver_str = "ril"; 867 solver_str = "ril";
828 break; 868 break;
829 869
830 default: 870 default:
831 GNUNET_break(0); 871 GNUNET_break (0);
832 return NULL; 872 return NULL;
833 break; 873 break;
834 } 874 }
835 875
836 sh = GNUNET_new(struct GNUNET_ATS_TESTING_SolverHandle); 876 sh = GNUNET_new (struct GNUNET_ATS_TESTING_SolverHandle);
837 GNUNET_asprintf(&sh->plugin, "libgnunet_plugin_ats_%s", solver_str); 877 GNUNET_asprintf (&sh->plugin, "libgnunet_plugin_ats_%s", solver_str);
838 //sh->solver = GNUNET_PLUGIN_load (sh->plugin, &sh->env); 878 // sh->solver = GNUNET_PLUGIN_load (sh->plugin, &sh->env);
839 if (NULL == sh->solver) 879 if (NULL == sh->solver)
840 { 880 {
841 fprintf(stderr, "Failed to load solver `%s'\n", sh->plugin); 881 fprintf (stderr, "Failed to load solver `%s'\n", sh->plugin);
842 exit(1); 882 exit (1);
843 } 883 }
844 884
845 return sh; 885 return sh;
846} 886}
@@ -872,56 +912,56 @@ static int opt_plot;
872static int opt_verbose; 912static int opt_verbose;
873 913
874static void 914static void
875run(void *cls, char * const *args, const char *cfgfile, 915run (void *cls, char *const *args, const char *cfgfile,
876 const struct GNUNET_CONFIGURATION_Handle *cfg) 916 const struct GNUNET_CONFIGURATION_Handle *cfg)
877{ 917{
878 enum GNUNET_ATS_Solvers solver; 918 enum GNUNET_ATS_Solvers solver;
879 919
880 if (NULL == opt_exp_file) 920 if (NULL == opt_exp_file)
881 { 921 {
882 fprintf(stderr, "No experiment given ...\n"); 922 fprintf (stderr, "No experiment given ...\n");
883 exit(1); 923 exit (1);
884 } 924 }
885 925
886 if (NULL == opt_solver) 926 if (NULL == opt_solver)
887 { 927 {
888 fprintf(stderr, "No solver given ...\n"); 928 fprintf (stderr, "No solver given ...\n");
889 exit(1); 929 exit (1);
890 } 930 }
891 931
892 if (0 == strcmp(opt_solver, "mlp")) 932 if (0 == strcmp (opt_solver, "mlp"))
893 { 933 {
894 solver = GNUNET_ATS_SOLVER_MLP; 934 solver = GNUNET_ATS_SOLVER_MLP;
895 } 935 }
896 else if (0 == strcmp(opt_solver, "proportional")) 936 else if (0 == strcmp (opt_solver, "proportional"))
897 { 937 {
898 solver = GNUNET_ATS_SOLVER_PROPORTIONAL; 938 solver = GNUNET_ATS_SOLVER_PROPORTIONAL;
899 } 939 }
900 else if (0 == strcmp(opt_solver, "ril")) 940 else if (0 == strcmp (opt_solver, "ril"))
901 { 941 {
902 solver = GNUNET_ATS_SOLVER_RIL; 942 solver = GNUNET_ATS_SOLVER_RIL;
903 } 943 }
904 else 944 else
905 { 945 {
906 fprintf(stderr, "No solver given ..."); 946 fprintf (stderr, "No solver given ...");
907 return; 947 return;
908 } 948 }
909 949
910 /* load experiment */ 950 /* load experiment */
911 e = GNUNET_ATS_solvers_experimentation_load(opt_exp_file); 951 e = GNUNET_ATS_solvers_experimentation_load (opt_exp_file);
912 if (NULL == e) 952 if (NULL == e)
913 { 953 {
914 fprintf(stderr, "Failed to load experiment ...\n"); 954 fprintf (stderr, "Failed to load experiment ...\n");
915 return; 955 return;
916 } 956 }
917 957
918 /* load solver */ 958 /* load solver */
919 sh = GNUNET_ATS_solvers_solver_start(solver); 959 sh = GNUNET_ATS_solvers_solver_start (solver);
920 if (NULL == sh) 960 if (NULL == sh)
921 { 961 {
922 fprintf(stderr, "Failed to start solver ...\n"); 962 fprintf (stderr, "Failed to start solver ...\n");
923 return; 963 return;
924 } 964 }
925 965
926 /* start logging */ 966 /* start logging */
927 967
@@ -938,40 +978,39 @@ run(void *cls, char * const *args, const char *cfgfile,
938 * @param argv argument values 978 * @param argv argument values
939 */ 979 */
940int 980int
941main(int argc, char *argv[]) 981main (int argc, char *argv[])
942{ 982{
943 opt_exp_file = NULL; 983 opt_exp_file = NULL;
944 opt_solver = NULL; 984 opt_solver = NULL;
945 opt_log = GNUNET_NO; 985 opt_log = GNUNET_NO;
946 opt_plot = GNUNET_NO; 986 opt_plot = GNUNET_NO;
947 987
948 struct GNUNET_GETOPT_CommandLineOption options[] = 988 struct GNUNET_GETOPT_CommandLineOption options[] = {
949 { 989 GNUNET_GETOPT_option_string ('s',
950 GNUNET_GETOPT_option_string('s', 990 "solver",
951 "solver", 991 NULL,
952 NULL, 992 gettext_noop ("solver to use"),
953 gettext_noop("solver to use"), 993 &opt_solver),
954 &opt_solver), 994
955 995 GNUNET_GETOPT_option_string ('e',
956 GNUNET_GETOPT_option_string('e', 996 "experiment",
957 "experiment", 997 NULL,
958 NULL, 998 gettext_noop ("experiment to use"),
959 gettext_noop("experiment to use"), 999 &opt_exp_file),
960 &opt_exp_file), 1000
961 1001 GNUNET_GETOPT_option_flag ('e',
962 GNUNET_GETOPT_option_flag('e', 1002 "experiment",
963 "experiment", 1003 gettext_noop ("experiment to use"),
964 gettext_noop("experiment to use"), 1004 &opt_verbose),
965 &opt_verbose),
966 GNUNET_GETOPT_OPTION_END 1005 GNUNET_GETOPT_OPTION_END
967 }; 1006 };
968 1007
969 if (GNUNET_OK != 1008 if (GNUNET_OK !=
970 GNUNET_PROGRAM_run(argc, 1009 GNUNET_PROGRAM_run (argc,
971 argv, argv[0], 1010 argv, argv[0],
972 NULL, 1011 NULL,
973 options, 1012 options,
974 &run, argv[0])) 1013 &run, argv[0]))
975 return 1; 1014 return 1;
976 1015
977 return 0; 1016 return 0;