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;
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;