aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-03 09:58:18 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-03 09:58:18 +0000
commitc25e21e16f0079b94b4ee71240013e16b425240d (patch)
treecceded3c132bd620c4b8ae3c8532e6a8fcc889cd /src/ats-tests
parent2debb60e6a2c3cafab0c9095944d316672a8b4a0 (diff)
downloadgnunet-c25e21e16f0079b94b4ee71240013e16b425240d.tar.gz
gnunet-c25e21e16f0079b94b4ee71240013e16b425240d.zip
safety checks
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/ats-testing-experiment.c12
-rw-r--r--src/ats-tests/ats-testing-traffic.c13
-rw-r--r--src/ats-tests/experiments/test.exp2
3 files changed, 24 insertions, 3 deletions
diff --git a/src/ats-tests/ats-testing-experiment.c b/src/ats-tests/ats-testing-experiment.c
index 1ab1342c5..80f30d9f0 100644
--- a/src/ats-tests/ats-testing-experiment.c
+++ b/src/ats-tests/ats-testing-experiment.c
@@ -256,6 +256,18 @@ load_episode (struct Experiment *e, struct Episode *cur,
256 } 256 }
257 } 257 }
258 258
259 /* Safety checks */
260 if ((GNUNET_ATS_TEST_TG_LINEAR == o->tg_type) ||
261 (GNUNET_ATS_TEST_TG_SINUS == o->tg_type))
262 {
263 if ((o->max_rate - o->base_rate) > o->base_rate)
264 {
265 /* This will cause an underflow */
266 GNUNET_break (0);
267 }
268 fprintf (stderr, "Selected max rate and base rate cannot be used for desired traffic form!\n");
269 }
270
259 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",
260 op_counter, cur->id, print_op (o->type), o->src_id, 272 op_counter, cur->id, print_op (o->type), o->src_id,
261 o->dest_id, type, o->base_rate, o->max_rate, 273 o->dest_id, type, o->base_rate, o->max_rate,
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
index 1bd31cc26..0938f79f4 100644
--- a/src/ats-tests/ats-testing-traffic.c
+++ b/src/ats-tests/ats-testing-traffic.c
@@ -54,9 +54,13 @@ get_delay (struct TrafficGenerator *tg)
54 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); 54 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
55 /* Calculate point of time in the current period */ 55 /* Calculate point of time in the current period */
56 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; 56 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us;
57
58 delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) * 57 delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) *
59 (tg->max_rate - tg->base_rate); 58 (tg->max_rate - tg->base_rate);
59 if ((tg->max_rate - tg->base_rate) > tg->base_rate)
60 {
61 /* This will cause an underflow */
62 GNUNET_break (0);
63 }
60 cur_rate = tg->base_rate + delta_rate; 64 cur_rate = tg->base_rate + delta_rate;
61 break; 65 break;
62 case GNUNET_ATS_TEST_TG_RANDOM: 66 case GNUNET_ATS_TEST_TG_RANDOM:
@@ -67,7 +71,7 @@ get_delay (struct TrafficGenerator *tg)
67 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); 71 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
68 /* Calculate point of time in the current period */ 72 /* Calculate point of time in the current period */
69 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; 73 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us;
70 if ((tg->max_rate - tg->base_rate) < tg->base_rate) 74 if ((tg->max_rate - tg->base_rate) > tg->base_rate)
71 { 75 {
72 /* This will cause an underflow for second half of sinus period, 76 /* This will cause an underflow for second half of sinus period,
73 * will be detected in general when experiments are loaded */ 77 * will be detected in general when experiments are loaded */
@@ -82,6 +86,11 @@ get_delay (struct TrafficGenerator *tg)
82 break; 86 break;
83 } 87 }
84 88
89 if (cur_rate < 0)
90 {
91 cur_rate = 0;
92 }
93
85 /* Calculate the delay for the next message based on the current delay */ 94 /* Calculate the delay for the next message based on the current delay */
86 delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate; 95 delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate;
87 96
diff --git a/src/ats-tests/experiments/test.exp b/src/ats-tests/experiments/test.exp
index 3ecfc63d4..b70cb7550 100644
--- a/src/ats-tests/experiments/test.exp
+++ b/src/ats-tests/experiments/test.exp
@@ -21,7 +21,7 @@ op-1-dest = 2
21op-1-type = sinus 21op-1-type = sinus
22op-1-period = 1 s 22op-1-period = 1 s
23op-1-base-rate= 10000 23op-1-base-rate= 10000
24op-1-max-rate = 20000 24op-1-max-rate = 15000
25 25
26op-2-operation = set_rate 26op-2-operation = set_rate
27op-2-src = 0 27op-2-src = 0