commit eb8276f4974f4a09547954a4aa70b4a48c138648
parent fe56554d28b2e277cde55f6146a54ce158340405
Author: Matthias Wachs <wachs@net.in.tum.de>
Date: Mon, 3 Feb 2014 08:56:56 +0000
documentation and random generator
Diffstat:
4 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/src/ats-tests/ats-testing-log.c b/src/ats-tests/ats-testing-log.c
@@ -577,7 +577,7 @@ GNUNET_ATS_TEST_logging_write_to_file (struct LoggingHandle *l,
/**
* Log all data now
*
- * @param llogging handle to use
+ * @param l logging handle to use
*/
void
GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
@@ -799,12 +799,12 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l)
* @param log_frequency the logging frequency
* @param testname the testname
* @param masters the master peers used for benchmarking
- * @oaram num_master the number of master peers
+ * @param num_masters the number of master peers
* @return the logging handle or NULL on error
*/
struct LoggingHandle *
-GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency,
- char * testname, struct BenchmarkPeer *masters, int num_masters)
+GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
+ char *testname, struct BenchmarkPeer *masters, int num_masters)
{
struct LoggingHandle *l;
int c_m;
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
@@ -40,9 +40,9 @@ get_delay (struct TrafficGenerator *tg)
long long int cur_rate;
long long int delta_rate;
-
delay.rel_value_us = 0;
+ /* Calculate the current transmission rate based on the type of traffic */
switch (tg->type) {
case GNUNET_ATS_TEST_TG_CONSTANT:
if (UINT32_MAX == tg->base_rate)
@@ -58,14 +58,14 @@ get_delay (struct TrafficGenerator *tg)
cur_rate = tg->base_rate + delta_rate;
break;
case GNUNET_ATS_TEST_TG_RANDOM:
- GNUNET_break (0);
+ cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ tg->max_rate - tg->base_rate);
break;
case GNUNET_ATS_TEST_TG_SINUS:
time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us;
delta_rate = (tg->max_rate - tg->base_rate) *
sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us);
- //fprintf (stderr, "delta_rate %i\n", delta_rate);
cur_rate = tg->base_rate + delta_rate;
break;
default:
@@ -73,7 +73,12 @@ get_delay (struct TrafficGenerator *tg)
break;
}
+ /* Calculate the delay for the next message based on the current delay */
delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Current rate is %u, calculated delay is %u \n",
+ cur_rate, delay.rel_value_us);
return delay;
}
@@ -269,8 +274,14 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
* Generate between the source master and the partner and send traffic with a
* maximum rate.
*
+ * @param src traffic source
+ * @param dest traffic partner
+ * @param type type of traffic to generate
* @param base_rate traffic base rate to send data with
* @param max_rate traffic maximum rate to send data with
+ * @param period duration of a period of traffic generation (~ 1/frequency)
+ * @param duration how long to generate traffic
+ * @return the traffic generator
*/
struct TrafficGenerator *
GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
@@ -540,6 +540,19 @@ void
GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p);
+/**
+ * Generate between the source master and the partner and send traffic with a
+ * maximum rate.
+ *
+ * @param src traffic source
+ * @param dest traffic partner
+ * @param type type of traffic to generate
+ * @param base_rate traffic base rate to send data with
+ * @param max_rate traffic maximum rate to send data with
+ * @param period duration of a period of traffic generation (~ 1/frequency)
+ * @param duration how long to generate traffic
+ * @return the traffic generator
+ */
struct TrafficGenerator *
GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
struct BenchmarkPartner *dest,
@@ -597,7 +610,7 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l);
/**
* Log all data now
*
- * @param llogging handle to use
+ * @param l logging handle to use
*/
void
GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l);
diff --git a/src/ats-tests/gnunet-ats-sim.c b/src/ats-tests/gnunet-ats-sim.c
@@ -208,28 +208,41 @@ static void topology_setup_done (void *cls,
for (c_s = 0; c_s < e->num_slaves; c_s++)
{
/* Generate maximum traffic to all peers */
- /*
+ /* Example: Generate traffic with constant 10,000 Bytes/s
GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
&masters[c_m].partners[c_s],
GNUNET_ATS_TEST_TG_CONSTANT,
10000,
GNUNET_TIME_UNIT_FOREVER_REL);
*/
- /*
+ /* Example: Generate traffic with an increasing rate from 1000 to 2000
+ * Bytes/s with in a minute
GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
&masters[c_m].partners[c_s],
GNUNET_ATS_TEST_TG_LINEAR,
- 100,
- 200,
+ 1000,
+ 2000,
GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_FOREVER_REL);
*/
+ /* Example: Generate traffic with a random rate between 1000 to 2000
+ * Bytes/s
+ GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
+ &masters[c_m].partners[c_s],
+ GNUNET_ATS_TEST_TG_RANDOM,
+ 1000,
+ 2000,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ GNUNET_TIME_UNIT_FOREVER_REL);
+ */
+ /* Example: Generate traffic with a sinus form, a base rate of
+ * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */
GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
&masters[c_m].partners[c_s],
GNUNET_ATS_TEST_TG_SINUS,
1000,
- 1500,
- GNUNET_TIME_UNIT_SECONDS,
+ 2000,
+ GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_FOREVER_REL);
}
}