From: Matthias Wachs Date: Mon, 3 Feb 2014 09:10:13 +0000 (+0000) Subject: additional check for sinus generator X-Git-Tag: initial-import-from-subversion-38251~4840 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bafb0bbfb1ac82c87cd11b482ef6e3b547637d08;p=oweals%2Fgnunet.git additional check for sinus generator --- 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) break; case GNUNET_ATS_TEST_TG_LINEAR: time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); + /* Calculate point of time in the current period */ time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; + delta_rate = ((double) time_delta.rel_value_us / tg->duration_period.rel_value_us) * (tg->max_rate - tg->base_rate); cur_rate = tg->base_rate + delta_rate; @@ -63,7 +65,14 @@ get_delay (struct TrafficGenerator *tg) break; case GNUNET_ATS_TEST_TG_SINUS: time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); + /* Calculate point of time in the current period */ time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; + if ((tg->max_rate - tg->base_rate) < tg->base_rate) + { + /* This will cause an underflow for second half of sinus period, + * will be detected in general when experiments are loaded */ + GNUNET_break (0); + } delta_rate = (tg->max_rate - tg->base_rate) * sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us); cur_rate = tg->base_rate + delta_rate;