diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 09:10:13 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 09:10:13 +0000 |
commit | bafb0bbfb1ac82c87cd11b482ef6e3b547637d08 (patch) | |
tree | 7416f3e94474c760c859923840e8cfbcf2833a55 /src/ats-tests/ats-testing-traffic.c | |
parent | eb8276f4974f4a09547954a4aa70b4a48c138648 (diff) | |
download | gnunet-bafb0bbfb1ac82c87cd11b482ef6e3b547637d08.tar.gz gnunet-bafb0bbfb1ac82c87cd11b482ef6e3b547637d08.zip |
additional check for sinus generator
Diffstat (limited to 'src/ats-tests/ats-testing-traffic.c')
-rw-r--r-- | src/ats-tests/ats-testing-traffic.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c index 67f85eb3c..1bd31cc26 100644 --- a/src/ats-tests/ats-testing-traffic.c +++ b/src/ats-tests/ats-testing-traffic.c | |||
@@ -52,7 +52,9 @@ get_delay (struct TrafficGenerator *tg) | |||
52 | break; | 52 | break; |
53 | case GNUNET_ATS_TEST_TG_LINEAR: | 53 | case GNUNET_ATS_TEST_TG_LINEAR: |
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 | 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 | |||
56 | delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) * | 58 | delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) * |
57 | (tg->max_rate - tg->base_rate); | 59 | (tg->max_rate - tg->base_rate); |
58 | cur_rate = tg->base_rate + delta_rate; | 60 | cur_rate = tg->base_rate + delta_rate; |
@@ -63,7 +65,14 @@ get_delay (struct TrafficGenerator *tg) | |||
63 | break; | 65 | break; |
64 | case GNUNET_ATS_TEST_TG_SINUS: | 66 | case GNUNET_ATS_TEST_TG_SINUS: |
65 | time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); | 67 | time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); |
68 | /* Calculate point of time in the current period */ | ||
66 | time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; | 69 | 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) | ||
71 | { | ||
72 | /* This will cause an underflow for second half of sinus period, | ||
73 | * will be detected in general when experiments are loaded */ | ||
74 | GNUNET_break (0); | ||
75 | } | ||
67 | delta_rate = (tg->max_rate - tg->base_rate) * | 76 | delta_rate = (tg->max_rate - tg->base_rate) * |
68 | sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us); | 77 | sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us); |
69 | cur_rate = tg->base_rate + delta_rate; | 78 | cur_rate = tg->base_rate + delta_rate; |