diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 22:31:19 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 22:31:19 +0000 |
commit | 6dd86aa09f9eff39fcca73bcca12b3eb34f1bc1d (patch) | |
tree | 041e8cde4d37f318ccaae4b512882c54b49286fe /src/ats-tests/ats-testing-experiment.c | |
parent | 0558cdeaee9f5b2021279b8106e9f907021c45cd (diff) | |
download | gnunet-6dd86aa09f9eff39fcca73bcca12b3eb34f1bc1d.tar.gz gnunet-6dd86aa09f9eff39fcca73bcca12b3eb34f1bc1d.zip |
enforcing preferences
Diffstat (limited to 'src/ats-tests/ats-testing-experiment.c')
-rw-r--r-- | src/ats-tests/ats-testing-experiment.c | 137 |
1 files changed, 126 insertions, 11 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c index 4db1758cb..ae92b58c2 100644 --- a/src/ats-tests/ats-testing-experiment.c +++ b/src/ats-tests/ats-testing-experiment.c | |||
@@ -35,8 +35,10 @@ print_op (enum OperationType op) | |||
35 | return "START_SEND"; | 35 | return "START_SEND"; |
36 | case STOP_SEND: | 36 | case STOP_SEND: |
37 | return "STOP_SEND"; | 37 | return "STOP_SEND"; |
38 | case SET_PREFERENCE: | 38 | case START_PREFERENCE: |
39 | return "SET_PREFERENCE"; | 39 | return "START_PREFERENCE"; |
40 | case STOP_PREFERENCE: | ||
41 | return "STOP_PREFERENCE"; | ||
40 | default: | 42 | default: |
41 | break; | 43 | break; |
42 | } | 44 | } |
@@ -93,6 +95,7 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
93 | char *op_name; | 95 | char *op_name; |
94 | char *op; | 96 | char *op; |
95 | char *type; | 97 | char *type; |
98 | char *pref; | ||
96 | int op_counter = 0; | 99 | int op_counter = 0; |
97 | fprintf (stderr, "Parsing episode %u\n",cur->id); | 100 | fprintf (stderr, "Parsing episode %u\n",cur->id); |
98 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); | 101 | GNUNET_asprintf(&sec_name, "episode-%u", cur->id); |
@@ -117,9 +120,13 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
117 | { | 120 | { |
118 | o->type = STOP_SEND; | 121 | o->type = STOP_SEND; |
119 | } | 122 | } |
120 | else if (0 == strcmp (op, "set_preference")) | 123 | else if (0 == strcmp (op, "start_preference")) |
121 | { | 124 | { |
122 | o->type = SET_PREFERENCE; | 125 | o->type = START_PREFERENCE; |
126 | } | ||
127 | else if (0 == strcmp (op, "stop_preference")) | ||
128 | { | ||
129 | o->type = STOP_PREFERENCE; | ||
123 | } | 130 | } |
124 | else | 131 | else |
125 | { | 132 | { |
@@ -176,7 +183,7 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
176 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); | 183 | GNUNET_asprintf(&op_name, "op-%u-type", op_counter); |
177 | if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, | 184 | if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg, |
178 | sec_name, op_name, &type)) && | 185 | sec_name, op_name, &type)) && |
179 | (STOP_SEND != o->type)) | 186 | ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type))) |
180 | { | 187 | { |
181 | /* Load arguments for set_rate, start_send, set_preference */ | 188 | /* Load arguments for set_rate, start_send, set_preference */ |
182 | if (0 == strcmp (type, "constant")) | 189 | if (0 == strcmp (type, "constant")) |
@@ -247,6 +254,55 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
247 | o->period = cur->duration; | 254 | o->period = cur->duration; |
248 | } | 255 | } |
249 | GNUNET_free (op_name); | 256 | GNUNET_free (op_name); |
257 | |||
258 | if (START_PREFERENCE == o->type) | ||
259 | { | ||
260 | /* Get frequency */ | ||
261 | GNUNET_asprintf(&op_name, "op-%u-frequency", op_counter); | ||
262 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (cfg, | ||
263 | sec_name, op_name, &o->frequency)) | ||
264 | { | ||
265 | fprintf (stderr, "Missing frequency in operation %u `%s' in episode %u\n", | ||
266 | op_counter, op, cur->id); | ||
267 | GNUNET_free (type); | ||
268 | GNUNET_free (op_name); | ||
269 | GNUNET_free (op); | ||
270 | return GNUNET_SYSERR; | ||
271 | } | ||
272 | GNUNET_free (op_name); | ||
273 | |||
274 | /* Get preference */ | ||
275 | GNUNET_asprintf(&op_name, "op-%u-pref", op_counter); | ||
276 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (cfg, | ||
277 | sec_name, op_name, &pref)) | ||
278 | { | ||
279 | fprintf (stderr, "Missing preference in operation %u `%s' in episode %u\n", | ||
280 | op_counter, op, cur->id); | ||
281 | GNUNET_free (type); | ||
282 | GNUNET_free (op_name); | ||
283 | GNUNET_free (op); | ||
284 | GNUNET_free_non_null (pref); | ||
285 | return GNUNET_SYSERR; | ||
286 | } | ||
287 | |||
288 | if (0 == strcmp(pref, "bandwidth")) | ||
289 | o->pref_type = GNUNET_ATS_PREFERENCE_BANDWIDTH; | ||
290 | else if (0 == strcmp(pref, "latency")) | ||
291 | o->pref_type = GNUNET_ATS_PREFERENCE_LATENCY; | ||
292 | else | ||
293 | { | ||
294 | fprintf (stderr, "Invalid preference in operation %u `%s' in episode %u\n", | ||
295 | op_counter, op, cur->id); | ||
296 | GNUNET_free (type); | ||
297 | GNUNET_free (op_name); | ||
298 | GNUNET_free (op); | ||
299 | GNUNET_free (pref); | ||
300 | GNUNET_free_non_null (pref); | ||
301 | return GNUNET_SYSERR; | ||
302 | } | ||
303 | GNUNET_free (pref); | ||
304 | GNUNET_free (op_name); | ||
305 | } | ||
250 | } | 306 | } |
251 | 307 | ||
252 | /* Safety checks */ | 308 | /* Safety checks */ |
@@ -261,11 +317,15 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
261 | fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); | 317 | fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n"); |
262 | } | 318 | } |
263 | 319 | ||
264 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | 320 | if ((START_SEND == o->type) || (START_PREFERENCE == o->type)) |
321 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu] == %s, %llu -> %llu in %s\n", | ||
265 | op_counter, cur->id, print_op (o->type), o->src_id, | 322 | op_counter, cur->id, print_op (o->type), o->src_id, |
266 | o->dest_id, (NULL != type) ? type : "", | 323 | o->dest_id, (NULL != type) ? type : "", |
267 | o->base_rate, o->max_rate, | 324 | o->base_rate, o->max_rate, |
268 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); | 325 | GNUNET_STRINGS_relative_time_to_string (o->period, GNUNET_YES)); |
326 | else | ||
327 | fprintf (stderr, "Found operation %u in episode %u: %s [%llu]->[%llu]\n", | ||
328 | op_counter, cur->id, print_op (o->type), o->src_id, o->dest_id); | ||
269 | 329 | ||
270 | GNUNET_free_non_null (type); | 330 | GNUNET_free_non_null (type); |
271 | GNUNET_free (op); | 331 | GNUNET_free (op); |
@@ -396,7 +456,8 @@ enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) | |||
396 | 456 | ||
397 | if (NULL != p->tg) | 457 | if (NULL != p->tg) |
398 | { | 458 | { |
399 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n",op->src_id, op->dest_id); | 459 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", |
460 | op->src_id, op->dest_id); | ||
400 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); | 461 | GNUNET_ATS_TEST_generate_traffic_stop(p->tg); |
401 | p->tg = NULL; | 462 | p->tg = NULL; |
402 | } | 463 | } |
@@ -404,9 +465,60 @@ enforce_stop_send (struct GNUNET_ATS_TEST_Operation *op) | |||
404 | 465 | ||
405 | 466 | ||
406 | static void | 467 | static void |
407 | enforce_set_preference (struct GNUNET_ATS_TEST_Operation *op) | 468 | enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) |
408 | { | 469 | { |
409 | GNUNET_break (0); | 470 | struct BenchmarkPeer *peer; |
471 | struct BenchmarkPartner *partner; | ||
472 | |||
473 | peer = GNUNET_ATS_TEST_get_peer (op->src_id); | ||
474 | if (NULL == peer) | ||
475 | { | ||
476 | GNUNET_break (0); | ||
477 | return; | ||
478 | } | ||
479 | |||
480 | partner = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
481 | if (NULL == partner) | ||
482 | { | ||
483 | GNUNET_break (0); | ||
484 | return; | ||
485 | } | ||
486 | |||
487 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
488 | |||
489 | if (NULL != partner->pg) | ||
490 | { | ||
491 | fprintf (stderr, "Stopping traffic between master %llu slave %llu\n", | ||
492 | op->src_id, op->dest_id); | ||
493 | GNUNET_ATS_TEST_generate_preferences_stop(partner->pg); | ||
494 | partner->pg = NULL; | ||
495 | } | ||
496 | |||
497 | partner->pg = GNUNET_ATS_TEST_generate_preferences_start(peer, partner, | ||
498 | op->tg_type, op->base_rate, op->max_rate, op->period, op->frequency, | ||
499 | op->pref_type); | ||
500 | } | ||
501 | |||
502 | static void | ||
503 | enforce_stop_preference (struct GNUNET_ATS_TEST_Operation *op) | ||
504 | { | ||
505 | struct BenchmarkPartner *p; | ||
506 | p = GNUNET_ATS_TEST_get_partner (op->src_id, op->dest_id); | ||
507 | if (NULL == p) | ||
508 | { | ||
509 | GNUNET_break (0); | ||
510 | return; | ||
511 | } | ||
512 | |||
513 | fprintf (stderr, "Found master %llu slave %llu\n",op->src_id, op->dest_id); | ||
514 | |||
515 | if (NULL != p->pg) | ||
516 | { | ||
517 | fprintf (stderr, "Stopping preference between master %llu slave %llu\n", | ||
518 | op->src_id, op->dest_id); | ||
519 | GNUNET_ATS_TEST_generate_preferences_stop (p->pg); | ||
520 | p->pg = NULL; | ||
521 | } | ||
410 | } | 522 | } |
411 | 523 | ||
412 | static void enforce_episode (struct Episode *ep) | 524 | static void enforce_episode (struct Episode *ep) |
@@ -424,8 +536,11 @@ static void enforce_episode (struct Episode *ep) | |||
424 | case STOP_SEND: | 536 | case STOP_SEND: |
425 | enforce_stop_send (cur); | 537 | enforce_stop_send (cur); |
426 | break; | 538 | break; |
427 | case SET_PREFERENCE: | 539 | case START_PREFERENCE: |
428 | enforce_set_preference (cur); | 540 | enforce_start_preference (cur); |
541 | break; | ||
542 | case STOP_PREFERENCE: | ||
543 | enforce_stop_preference (cur); | ||
429 | break; | 544 | break; |
430 | default: | 545 | default: |
431 | break; | 546 | break; |