diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 12:36:25 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 12:36:25 +0000 |
commit | 23c87f2aea815cbd6078ab75b5b8fe8cf8f6ee31 (patch) | |
tree | af24b05a1b2f4a2829ee044b7e7c7161df6e9989 /src/ats-tests/ats-testing-experiment.c | |
parent | c25e21e16f0079b94b4ee71240013e16b425240d (diff) | |
download | gnunet-23c87f2aea815cbd6078ab75b5b8fe8cf8f6ee31.tar.gz gnunet-23c87f2aea815cbd6078ab75b5b8fe8cf8f6ee31.zip |
various fixes
Diffstat (limited to 'src/ats-tests/ats-testing-experiment.c')
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 103 |
1 files changed, 76 insertions, 27 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c index 80f30d9f0..764d7fb84 100644 --- a/src/ats-tests/ats-testing-experiment.c +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -64,8 +64,8 @@ free_experiment (struct Experiment *e) | |||
64 | { | 64 | { |
65 | struct Episode *cur; | 65 | struct Episode *cur; |
66 | struct Episode *next; | 66 | struct Episode *next; |
67 | struct Operation *cur_o; | 67 | struct GNUNET_ATS_TEST_Operation *cur_o; |
68 | struct Operation *next_o; | 68 | struct GNUNET_ATS_TEST_Operation *next_o; |
69 | 69 | ||
70 | next = e->start; | 70 | next = e->start; |
71 | for (cur = next; NULL != cur; cur = next) | 71 | for (cur = next; NULL != cur; cur = next) |
@@ -90,7 +90,7 @@ static int | |||
90 | load_episode (struct Experiment *e, struct Episode *cur, | 90 | load_episode (struct Experiment *e, struct Episode *cur, |
91 | struct GNUNET_CONFIGURATION_Handle *cfg) | 91 | struct GNUNET_CONFIGURATION_Handle *cfg) |
92 | { | 92 | { |
93 | struct Operation *o; | 93 | struct GNUNET_ATS_TEST_Operation *o; |
94 | char *sec_name; | 94 | char *sec_name; |
95 | char *op_name; | 95 | char *op_name; |
96 | char *op; | 96 | char *op; |
@@ -106,9 +106,10 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
106 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | 106 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, |
107 | sec_name, op_name, &op)) | 107 | sec_name, op_name, &op)) |
108 | { | 108 | { |
109 | GNUNET_free (op_name); | ||
109 | break; | 110 | break; |
110 | } | 111 | } |
111 | o = GNUNET_new (struct Operation); | 112 | o = GNUNET_new (struct GNUNET_ATS_TEST_Operation); |
112 | /* operations = set_rate, start_send, stop_send, set_preference */ | 113 | /* operations = set_rate, start_send, stop_send, set_preference */ |
113 | if (0 == strcmp (op, "start_send")) | 114 | if (0 == strcmp (op, "start_send")) |
114 | { | 115 | { |
@@ -179,13 +180,9 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
179 | GNUNET_free (op_name); | 180 | GNUNET_free (op_name); |
180 | 181 | ||
181 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); | 182 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); |
182 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg, | 183 | if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, |
183 | sec_name, op_name, &type)) | 184 | sec_name, op_name, &type)) && |
184 | { | 185 | (STOP_SEND != o->type)) |
185 | break; | ||
186 | } | ||
187 | |||
188 | if (STOP_SEND != o->type) | ||
189 | { | 186 | { |
190 | /* Load arguments for set_rate, start_send, set_preference */ | 187 | /* Load arguments for set_rate, start_send, set_preference */ |
191 | if (0 == strcmp (type, "constant")) | 188 | if (0 == strcmp (type, "constant")) |
@@ -208,6 +205,7 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
208 | { | 205 | { |
209 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", | 206 | fprintf (stderr, "Invalid type %u `%s' in episode %u\n", |
210 | op_counter, op, cur->id); | 207 | op_counter, op, cur->id); |
208 | GNUNET_free (type); | ||
211 | GNUNET_free (op); | 209 | GNUNET_free (op); |
212 | GNUNET_free (op_name); | 210 | GNUNET_free (op_name); |
213 | return GNUNET_SYSERR; | 211 | return GNUNET_SYSERR; |
@@ -221,6 +219,7 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
221 | { | 219 | { |
222 | fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", | 220 | fprintf (stderr, "Missing base rate in operation %u `%s' in episode %u\n", |
223 | op_counter, op, cur->id); | 221 | op_counter, op, cur->id); |
222 | GNUNET_free (type); | ||
224 | GNUNET_free (op); | 223 | GNUNET_free (op); |
225 | GNUNET_free (op_name); | 224 | GNUNET_free (op_name); |
226 | return GNUNET_SYSERR; | 225 | return GNUNET_SYSERR; |
@@ -238,22 +237,23 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
238 | { | 237 | { |
239 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | 238 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", |
240 | op_counter, op, cur->id); | 239 | op_counter, op, cur->id); |
240 | GNUNET_free (type); | ||
241 | GNUNET_free (op_name); | ||
241 | GNUNET_free (op); | 242 | GNUNET_free (op); |
242 | return GNUNET_SYSERR; | 243 | return GNUNET_SYSERR; |
243 | } | 244 | } |
244 | } | 245 | } |
245 | GNUNET_free (op_name); | 246 | GNUNET_free (op_name); |
246 | 247 | ||
248 | /* Get period */ | ||
249 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | ||
250 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
251 | sec_name, op_name, &o->period)) | ||
247 | { | 252 | { |
248 | /* Get period */ | 253 | o->period = cur->duration; |
249 | GNUNET_asprintf(&op_name, "op-%u-period", op_counter); | ||
250 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
251 | sec_name, op_name, &o->period)) | ||
252 | { | ||
253 | o->period = cur->duration; | ||
254 | } | ||
255 | GNUNET_free (op_name); | ||
256 | } | 254 | } |
255 | GNUNET_free (op_name); | ||
256 | |||
257 | } | 257 | } |
258 | 258 | ||
259 | /* Safety checks */ | 259 | /* Safety checks */ |
@@ -270,9 +270,13 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
270 | 270 | ||
271 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | 271 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", |
272 | op_counter, cur->id, print_op (o->type), o->src_id, | 272 | op_counter, cur->id, print_op (o->type), o->src_id, |
273 | o->dest_id, type, o->base_rate, o->max_rate, | 273 | o->dest_id, (NULL != type) ? type : "", |
274 | o->base_rate, o->max_rate, | ||
274 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | 275 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); |
275 | 276 | ||
277 | GNUNET_free_non_null (type); | ||
278 | GNUNET_free (op); | ||
279 | |||
276 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); | 280 | GNUNET_CONTAINER_DLL_insert (cur->head,cur->tail, o); |
277 | op_counter++; | 281 | op_counter++; |
278 | } | 282 | } |
@@ -351,32 +355,77 @@ timeout_experiment (void *cls, const struct GNUNET_SCHEDULER_TaskContext* tc) | |||
351 | } | 355 | } |
352 | 356 | ||
353 | static void | 357 | static void |
354 | enforce_start_send (struct Operation *op) | 358 | enforce_start_send (struct GNUNET_ATS_TEST_Operation *op) |
355 | { | 359 | { |
356 | GNUNET_break (0); | 360 | GNUNET_break (0); |
357 | } | 361 | } |
358 | 362 | ||
359 | static void | 363 | static void |
360 | enforce_stop_send (struct Operation *op) | 364 | enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) |
361 | { | 365 | { |
362 | GNUNET_break (0); | 366 | struct BenchmarkPartner *p; |
367 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
368 | if (NULL == p) | ||
369 | { | ||
370 | GNUNET_break (0); | ||
371 | return; | ||
372 | } | ||
373 | |||
374 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
375 | |||
376 | if (NULL != p->tg) | ||
377 | { | ||
378 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); | ||
379 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); | ||
380 | p->tg = NULL; | ||
381 | } | ||
382 | |||
383 | |||
363 | } | 384 | } |
364 | 385 | ||
365 | static void | 386 | static void |
366 | enforce_set_rate (struct Operation *op) | 387 | enforce_set_rate (struct GNUNET_ATS_TEST_Operation *op) |
367 | { | 388 | { |
368 | GNUNET_break (0); | 389 | struct BenchmarkPeer *peer; |
390 | struct BenchmarkPartner *partner; | ||
391 | |||
392 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
393 | if (NULL == peer) | ||
394 | { | ||
395 | GNUNET_break (0); | ||
396 | return; | ||
397 | } | ||
398 | |||
399 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
400 | if (NULL == partner) | ||
401 | { | ||
402 | GNUNET_break (0); | ||
403 | return; | ||
404 | } | ||
405 | |||
406 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
407 | |||
408 | if (NULL != partner->tg) | ||
409 | { | ||
410 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); | ||
411 | GNUNET_ATS_TEST_generate_traffic_stop(partner->tg); | ||
412 | partner->tg = NULL; | ||
413 | } | ||
414 | |||
415 | partner->tg = GNUNET_ATS_TEST_generate_traffic_start(peer, partner, | ||
416 | op->tg_type, op->base_rate, op->max_rate, op->period, | ||
417 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
369 | } | 418 | } |
370 | 419 | ||
371 | static void | 420 | static void |
372 | enforce_set_preference (struct Operation *op) | 421 | enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op) |
373 | { | 422 | { |
374 | GNUNET_break (0); | 423 | GNUNET_break (0); |
375 | } | 424 | } |
376 | 425 | ||
377 | static void enforce_episode (struct Episode *ep) | 426 | static void enforce_episode (struct Episode *ep) |
378 | { | 427 | { |
379 | struct Operation *cur; | 428 | struct GNUNET_ATS_TEST_Operation *cur; |
380 | for (cur = ep->head; NULL != cur; cur = cur->next) | 429 | for (cur = ep->head; NULL != cur; cur = cur->next) |
381 | { | 430 | { |
382 | 431 | ||