diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 07:49:32 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 07:49:32 +0000 |
commit | 0af4aedc3acedf4bbe5d1878b6ac7744f85bf0b7 (patch) | |
tree | e061786720b029184f869053416446c46f5d43c4 /src | |
parent | 1295424fe99da3cf276fe34c43a3ba05aca4e6fd (diff) | |
download | gnunet-0af4aedc3acedf4bbe5d1878b6ac7744f85bf0b7.tar.gz gnunet-0af4aedc3acedf4bbe5d1878b6ac7744f85bf0b7.zip |
enforcing correct generator type
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index d955b7c9c..b5c57bb94 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -61,6 +61,23 @@ static int res; | |||
61 | static void | 61 | static void |
62 | end_now (); | 62 | end_now (); |
63 | 63 | ||
64 | static char * | ||
65 | print_generator_type (enum GeneratorType g) | ||
66 | { | ||
67 | switch (g) { | ||
68 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
69 | return "CONSTANT"; | ||
70 | case GNUNET_ATS_TEST_TG_LINEAR: | ||
71 | return "LINEAR"; | ||
72 | case GNUNET_ATS_TEST_TG_RANDOM: | ||
73 | return "RANDOM"; | ||
74 | case GNUNET_ATS_TEST_TG_SINUS: | ||
75 | return "SINUS"; | ||
76 | default: | ||
77 | return "INVALID"; | ||
78 | break; | ||
79 | } | ||
80 | } | ||
64 | 81 | ||
65 | /** | 82 | /** |
66 | * Property Generators | 83 | * Property Generators |
@@ -454,27 +471,27 @@ GNUNET_ATS_solver_generate_preferences_start (unsigned int peer, | |||
454 | switch (type) { | 471 | switch (type) { |
455 | case GNUNET_ATS_TEST_TG_CONSTANT: | 472 | case GNUNET_ATS_TEST_TG_CONSTANT: |
456 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 473 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
457 | "Setting up constant preference generator peer [%u] address [%u] `%s' max %u Bips\n", | 474 | "Setting up %s preference generator peer [%u] address [%u] `%s' max %u Bips\n", |
458 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | 475 | print_generator_type (type), pg->peer, pg->address_id, |
476 | GNUNET_ATS_print_preference_type(kind), | ||
459 | base_value); | 477 | base_value); |
460 | break; | 478 | break; |
461 | case GNUNET_ATS_TEST_TG_LINEAR: | 479 | case GNUNET_ATS_TEST_TG_LINEAR: |
462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 480 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
463 | "Setting up linear preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bips\n", | 481 | "Setting up %s preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bips\n", |
464 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | 482 | print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), |
465 | base_value, value_rate); | 483 | base_value, value_rate); |
466 | break; | 484 | break; |
467 | case GNUNET_ATS_TEST_TG_SINUS: | 485 | case GNUNET_ATS_TEST_TG_SINUS: |
468 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 486 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
469 | "Setting up sinus preference generator peer [%u] address [%u] `%s' baserate %u Bips, amplitude %u Bps\n", | 487 | "Setting up %s preference generator peer [%u] address [%u] `%s' baserate %u Bips, amplitude %u Bps\n", |
470 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | 488 | print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), |
471 | base_value, value_rate); | 489 | base_value, value_rate); |
472 | |||
473 | break; | 490 | break; |
474 | case GNUNET_ATS_TEST_TG_RANDOM: | 491 | case GNUNET_ATS_TEST_TG_RANDOM: |
475 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 492 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
476 | "Setting up random preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bps\n", | 493 | "Setting up %s preference generator peer [%u] address [%u] `%s' min %u Bips max %u Bps\n", |
477 | pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), | 494 | print_generator_type (type), pg->peer, pg->address_id, GNUNET_ATS_print_preference_type(kind), |
478 | base_value, value_rate); | 495 | base_value, value_rate); |
479 | break; | 496 | break; |
480 | default: | 497 | default: |
@@ -811,19 +828,19 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o, | |||
811 | /* Load arguments for set_rate, start_send, set_preference */ | 828 | /* Load arguments for set_rate, start_send, set_preference */ |
812 | if (0 == strcmp (type, "constant")) | 829 | if (0 == strcmp (type, "constant")) |
813 | { | 830 | { |
814 | o->tg_type = GNUNET_ATS_TEST_TG_CONSTANT; | 831 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; |
815 | } | 832 | } |
816 | else if (0 == strcmp (type, "linear")) | 833 | else if (0 == strcmp (type, "linear")) |
817 | { | 834 | { |
818 | o->tg_type = GNUNET_ATS_TEST_TG_LINEAR; | 835 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; |
819 | } | 836 | } |
820 | else if (0 == strcmp (type, "sinus")) | 837 | else if (0 == strcmp (type, "sinus")) |
821 | { | 838 | { |
822 | o->tg_type = GNUNET_ATS_TEST_TG_SINUS; | 839 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; |
823 | } | 840 | } |
824 | else if (0 == strcmp (type, "random")) | 841 | else if (0 == strcmp (type, "random")) |
825 | { | 842 | { |
826 | o->tg_type = GNUNET_ATS_TEST_TG_RANDOM; | 843 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; |
827 | } | 844 | } |
828 | else | 845 | else |
829 | { | 846 | { |
@@ -855,9 +872,9 @@ load_op_start_set_preference (struct GNUNET_ATS_TEST_Operation *o, | |||
855 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 872 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, |
856 | sec_name, op_name, &o->max_rate)) | 873 | sec_name, op_name, &o->max_rate)) |
857 | { | 874 | { |
858 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) || | 875 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
859 | (GNUNET_ATS_TEST_TG_RANDOM == o->tg_type) || | 876 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || |
860 | (GNUNET_ATS_TEST_TG_SINUS == o->tg_type)) | 877 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) |
861 | { | 878 | { |
862 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | 879 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", |
863 | op_counter, op_name, e->id); | 880 | op_counter, op_name, e->id); |
@@ -1042,22 +1059,22 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, | |||
1042 | /* Load arguments for set_rate, start_send, set_preference */ | 1059 | /* Load arguments for set_rate, start_send, set_preference */ |
1043 | if (0 == strcmp (type, "constant")) | 1060 | if (0 == strcmp (type, "constant")) |
1044 | { | 1061 | { |
1045 | o->tg_type = GNUNET_ATS_TEST_TG_CONSTANT; | 1062 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; |
1046 | GNUNET_break (0); | 1063 | GNUNET_break (0); |
1047 | } | 1064 | } |
1048 | else if (0 == strcmp (type, "linear")) | 1065 | else if (0 == strcmp (type, "linear")) |
1049 | { | 1066 | { |
1050 | o->tg_type = GNUNET_ATS_TEST_TG_LINEAR; | 1067 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; |
1051 | GNUNET_break (0); | 1068 | GNUNET_break (0); |
1052 | } | 1069 | } |
1053 | else if (0 == strcmp (type, "sinus")) | 1070 | else if (0 == strcmp (type, "sinus")) |
1054 | { | 1071 | { |
1055 | o->tg_type = GNUNET_ATS_TEST_TG_SINUS; | 1072 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; |
1056 | GNUNET_break (0); | 1073 | GNUNET_break (0); |
1057 | } | 1074 | } |
1058 | else if (0 == strcmp (type, "random")) | 1075 | else if (0 == strcmp (type, "random")) |
1059 | { | 1076 | { |
1060 | o->tg_type = GNUNET_ATS_TEST_TG_RANDOM; | 1077 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; |
1061 | GNUNET_break (0); | 1078 | GNUNET_break (0); |
1062 | } | 1079 | } |
1063 | else | 1080 | else |
@@ -1090,9 +1107,9 @@ load_op_start_set_property(struct GNUNET_ATS_TEST_Operation *o, | |||
1090 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 1107 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, |
1091 | sec_name, op_name, &o->max_rate)) | 1108 | sec_name, op_name, &o->max_rate)) |
1092 | { | 1109 | { |
1093 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) || | 1110 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
1094 | (GNUNET_ATS_TEST_TG_RANDOM == o->tg_type) || | 1111 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || |
1095 | (GNUNET_ATS_TEST_TG_SINUS == o->tg_type)) | 1112 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) |
1096 | { | 1113 | { |
1097 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | 1114 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", |
1098 | op_counter, op_name, e->id); | 1115 | op_counter, op_name, e->id); |
@@ -1394,19 +1411,19 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
1394 | /* Load arguments for set_rate, start_send, set_preference */ | 1411 | /* Load arguments for set_rate, start_send, set_preference */ |
1395 | if (0 == strcmp (type, "constant")) | 1412 | if (0 == strcmp (type, "constant")) |
1396 | { | 1413 | { |
1397 | o->tg_type = GNUNET_ATS_TEST_TG_CONSTANT; | 1414 | o->gen_type = GNUNET_ATS_TEST_TG_CONSTANT; |
1398 | } | 1415 | } |
1399 | else if (0 == strcmp (type, "linear")) | 1416 | else if (0 == strcmp (type, "linear")) |
1400 | { | 1417 | { |
1401 | o->tg_type = GNUNET_ATS_TEST_TG_LINEAR; | 1418 | o->gen_type = GNUNET_ATS_TEST_TG_LINEAR; |
1402 | } | 1419 | } |
1403 | else if (0 == strcmp (type, "sinus")) | 1420 | else if (0 == strcmp (type, "sinus")) |
1404 | { | 1421 | { |
1405 | o->tg_type = GNUNET_ATS_TEST_TG_SINUS; | 1422 | o->gen_type = GNUNET_ATS_TEST_TG_SINUS; |
1406 | } | 1423 | } |
1407 | else if (0 == strcmp (type, "random")) | 1424 | else if (0 == strcmp (type, "random")) |
1408 | { | 1425 | { |
1409 | o->tg_type = GNUNET_ATS_TEST_TG_RANDOM; | 1426 | o->gen_type = GNUNET_ATS_TEST_TG_RANDOM; |
1410 | } | 1427 | } |
1411 | else | 1428 | else |
1412 | { | 1429 | { |
@@ -1438,9 +1455,9 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
1438 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 1455 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, |
1439 | sec_name, op_name, &o->max_rate)) | 1456 | sec_name, op_name, &o->max_rate)) |
1440 | { | 1457 | { |
1441 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) || | 1458 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
1442 | (GNUNET_ATS_TEST_TG_RANDOM == o->tg_type) || | 1459 | (GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) || |
1443 | (GNUNET_ATS_TEST_TG_SINUS == o->tg_type)) | 1460 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) |
1444 | { | 1461 | { |
1445 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", | 1462 | fprintf (stderr, "Missing max rate in operation %u `%s' in episode %u\n", |
1446 | op_counter, op, cur->id); | 1463 | op_counter, op, cur->id); |
@@ -1512,8 +1529,8 @@ load_episode (struct Experiment *e, struct Episode *cur, | |||
1512 | } | 1529 | } |
1513 | 1530 | ||
1514 | /* Safety checks */ | 1531 | /* Safety checks */ |
1515 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) || | 1532 | if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) || |
1516 | (GNUNET_ATS_TEST_TG_SINUS == o->tg_type)) | 1533 | (GNUNET_ATS_TEST_TG_SINUS == o->gen_type)) |
1517 | { | 1534 | { |
1518 | if ((o->max_rate - o->base_rate) > o->base_rate) | 1535 | if ((o->max_rate - o->base_rate) > o->base_rate) |
1519 | { | 1536 | { |
@@ -1708,9 +1725,12 @@ enforce_start_preference (struct GNUNET_ATS_TEST_Operation *op) | |||
1708 | GNUNET_free (pg); | 1725 | GNUNET_free (pg); |
1709 | } | 1726 | } |
1710 | 1727 | ||
1728 | fprintf (stderr, "ENFORECE: %s, %u\n", print_generator_type (op->gen_type), | ||
1729 | op->base_rate); | ||
1730 | |||
1711 | GNUNET_ATS_solver_generate_preferences_start (op->peer_id, | 1731 | GNUNET_ATS_solver_generate_preferences_start (op->peer_id, |
1712 | op->address_id, | 1732 | op->address_id, |
1713 | op->type, | 1733 | op->gen_type, |
1714 | op->base_rate, | 1734 | op->base_rate, |
1715 | op->max_rate, | 1735 | op->max_rate, |
1716 | op->period, | 1736 | op->period, |
@@ -1988,6 +2008,7 @@ enum GNUNET_ATS_Solvers | |||
1988 | GNUNET_ATS_SOLVER_RIL, | 2008 | GNUNET_ATS_SOLVER_RIL, |
1989 | }; | 2009 | }; |
1990 | 2010 | ||
2011 | |||
1991 | void | 2012 | void |
1992 | GNUNET_ATS_solvers_solver_stop (struct GNUNET_ATS_TESTING_SolverHandle *sh) | 2013 | GNUNET_ATS_solvers_solver_stop (struct GNUNET_ATS_TESTING_SolverHandle *sh) |
1993 | { | 2014 | { |
@@ -2483,7 +2504,8 @@ main (int argc, char *argv[]) | |||
2483 | GNUNET_GETOPT_OPTION_END | 2504 | GNUNET_GETOPT_OPTION_END |
2484 | }; | 2505 | }; |
2485 | 2506 | ||
2486 | GNUNET_PROGRAM_run (argc, argv, argv[0], NULL, options, &run, argv[0]); | 2507 | GNUNET_PROGRAM_run (argc, argv, "gnunet-ats-solver-eval", |
2508 | NULL, options, &run, argv[0]); | ||
2487 | 2509 | ||
2488 | return res; | 2510 | return res; |
2489 | } | 2511 | } |