aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-02-03 08:56:56 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-02-03 08:56:56 +0000
commiteb8276f4974f4a09547954a4aa70b4a48c138648 (patch)
tree797c8838d1432b20adb720c73b7cd99b877a00bc /src/ats-tests
parentfe56554d28b2e277cde55f6146a54ce158340405 (diff)
downloadgnunet-eb8276f4974f4a09547954a4aa70b4a48c138648.tar.gz
gnunet-eb8276f4974f4a09547954a4aa70b4a48c138648.zip
documentation and random generator
Diffstat (limited to 'src/ats-tests')
-rw-r--r--src/ats-tests/ats-testing-log.c8
-rw-r--r--src/ats-tests/ats-testing-traffic.c17
-rw-r--r--src/ats-tests/ats-testing.h15
-rw-r--r--src/ats-tests/gnunet-ats-sim.c25
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
index 847f81492..01dc7148e 100644
--- 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,
577/** 577/**
578 * Log all data now 578 * Log all data now
579 * 579 *
580 * @param llogging handle to use 580 * @param l logging handle to use
581 */ 581 */
582void 582void
583GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l) 583GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l)
@@ -799,12 +799,12 @@ GNUNET_ATS_TEST_logging_clean_up (struct LoggingHandle *l)
799 * @param log_frequency the logging frequency 799 * @param log_frequency the logging frequency
800 * @param testname the testname 800 * @param testname the testname
801 * @param masters the master peers used for benchmarking 801 * @param masters the master peers used for benchmarking
802 * @oaram num_master the number of master peers 802 * @param num_masters the number of master peers
803 * @return the logging handle or NULL on error 803 * @return the logging handle or NULL on error
804 */ 804 */
805struct LoggingHandle * 805struct LoggingHandle *
806GNUNET_ATS_TEST_logging_start (struct GNUNET_TIME_Relative log_frequency, 806GNUNET_ATS_TEST_logging_start(struct GNUNET_TIME_Relative log_frequency,
807 char * testname, struct BenchmarkPeer *masters, int num_masters) 807 char *testname, struct BenchmarkPeer *masters, int num_masters)
808{ 808{
809 struct LoggingHandle *l; 809 struct LoggingHandle *l;
810 int c_m; 810 int c_m;
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c
index 4d5abb1d1..67f85eb3c 100644
--- 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)
40 long long int cur_rate; 40 long long int cur_rate;
41 long long int delta_rate; 41 long long int delta_rate;
42 42
43
44 delay.rel_value_us = 0; 43 delay.rel_value_us = 0;
45 44
45 /* Calculate the current transmission rate based on the type of traffic */
46 switch (tg->type) { 46 switch (tg->type) {
47 case GNUNET_ATS_TEST_TG_CONSTANT: 47 case GNUNET_ATS_TEST_TG_CONSTANT:
48 if (UINT32_MAX == tg->base_rate) 48 if (UINT32_MAX == tg->base_rate)
@@ -58,14 +58,14 @@ get_delay (struct TrafficGenerator *tg)
58 cur_rate = tg->base_rate + delta_rate; 58 cur_rate = tg->base_rate + delta_rate;
59 break; 59 break;
60 case GNUNET_ATS_TEST_TG_RANDOM: 60 case GNUNET_ATS_TEST_TG_RANDOM:
61 GNUNET_break (0); 61 cur_rate = tg->base_rate + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
62 tg->max_rate - tg->base_rate);
62 break; 63 break;
63 case GNUNET_ATS_TEST_TG_SINUS: 64 case GNUNET_ATS_TEST_TG_SINUS:
64 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start); 65 time_delta = GNUNET_TIME_absolute_get_duration(tg->time_start);
65 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us; 66 time_delta.rel_value_us = time_delta.rel_value_us % tg->duration_period.rel_value_us;
66 delta_rate = (tg->max_rate - tg->base_rate) * 67 delta_rate = (tg->max_rate - tg->base_rate) *
67 sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us); 68 sin ( (2 * M_PI) / ((double) tg->duration_period.rel_value_us) * time_delta.rel_value_us);
68 //fprintf (stderr, "delta_rate %i\n", delta_rate);
69 cur_rate = tg->base_rate + delta_rate; 69 cur_rate = tg->base_rate + delta_rate;
70 break; 70 break;
71 default: 71 default:
@@ -73,7 +73,12 @@ get_delay (struct TrafficGenerator *tg)
73 break; 73 break;
74 } 74 }
75 75
76 /* Calculate the delay for the next message based on the current delay */
76 delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate; 77 delay.rel_value_us = GNUNET_TIME_UNIT_SECONDS.rel_value_us * TEST_MESSAGE_SIZE / cur_rate;
78
79 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
80 "Current rate is %u, calculated delay is %u \n",
81 cur_rate, delay.rel_value_us);
77 return delay; 82 return delay;
78} 83}
79 84
@@ -269,8 +274,14 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p)
269 * Generate between the source master and the partner and send traffic with a 274 * Generate between the source master and the partner and send traffic with a
270 * maximum rate. 275 * maximum rate.
271 * 276 *
277 * @param src traffic source
278 * @param dest traffic partner
279 * @param type type of traffic to generate
272 * @param base_rate traffic base rate to send data with 280 * @param base_rate traffic base rate to send data with
273 * @param max_rate traffic maximum rate to send data with 281 * @param max_rate traffic maximum rate to send data with
282 * @param period duration of a period of traffic generation (~ 1/frequency)
283 * @param duration how long to generate traffic
284 * @return the traffic generator
274 */ 285 */
275struct TrafficGenerator * 286struct TrafficGenerator *
276GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, 287GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
diff --git a/src/ats-tests/ats-testing.h b/src/ats-tests/ats-testing.h
index 2b4bf3f12..7d543e328 100644
--- a/src/ats-tests/ats-testing.h
+++ b/src/ats-tests/ats-testing.h
@@ -540,6 +540,19 @@ void
540GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p); 540GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p);
541 541
542 542
543/**
544 * Generate between the source master and the partner and send traffic with a
545 * maximum rate.
546 *
547 * @param src traffic source
548 * @param dest traffic partner
549 * @param type type of traffic to generate
550 * @param base_rate traffic base rate to send data with
551 * @param max_rate traffic maximum rate to send data with
552 * @param period duration of a period of traffic generation (~ 1/frequency)
553 * @param duration how long to generate traffic
554 * @return the traffic generator
555 */
543struct TrafficGenerator * 556struct TrafficGenerator *
544GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, 557GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src,
545 struct BenchmarkPartner *dest, 558 struct BenchmarkPartner *dest,
@@ -597,7 +610,7 @@ GNUNET_ATS_TEST_logging_stop (struct LoggingHandle *l);
597/** 610/**
598 * Log all data now 611 * Log all data now
599 * 612 *
600 * @param llogging handle to use 613 * @param l logging handle to use
601 */ 614 */
602void 615void
603GNUNET_ATS_TEST_logging_now (struct LoggingHandle *l); 616GNUNET_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
index 1e969689a..7ed667d23 100644
--- 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,
208 for (c_s = 0; c_s < e->num_slaves; c_s++) 208 for (c_s = 0; c_s < e->num_slaves; c_s++)
209 { 209 {
210 /* Generate maximum traffic to all peers */ 210 /* Generate maximum traffic to all peers */
211 /* 211 /* Example: Generate traffic with constant 10,000 Bytes/s
212 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], 212 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
213 &masters[c_m].partners[c_s], 213 &masters[c_m].partners[c_s],
214 GNUNET_ATS_TEST_TG_CONSTANT, 214 GNUNET_ATS_TEST_TG_CONSTANT,
215 10000, 215 10000,
216 GNUNET_TIME_UNIT_FOREVER_REL); 216 GNUNET_TIME_UNIT_FOREVER_REL);
217 */ 217 */
218 /* 218 /* Example: Generate traffic with an increasing rate from 1000 to 2000
219 * Bytes/s with in a minute
219 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], 220 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
220 &masters[c_m].partners[c_s], 221 &masters[c_m].partners[c_s],
221 GNUNET_ATS_TEST_TG_LINEAR, 222 GNUNET_ATS_TEST_TG_LINEAR,
222 100, 223 1000,
223 200, 224 2000,
224 GNUNET_TIME_UNIT_MINUTES, 225 GNUNET_TIME_UNIT_MINUTES,
225 GNUNET_TIME_UNIT_FOREVER_REL); 226 GNUNET_TIME_UNIT_FOREVER_REL);
226 */ 227 */
228 /* Example: Generate traffic with a random rate between 1000 to 2000
229 * Bytes/s
230 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
231 &masters[c_m].partners[c_s],
232 GNUNET_ATS_TEST_TG_RANDOM,
233 1000,
234 2000,
235 GNUNET_TIME_UNIT_FOREVER_REL,
236 GNUNET_TIME_UNIT_FOREVER_REL);
237 */
238 /* Example: Generate traffic with a sinus form, a base rate of
239 * 1000 Bytes/s, an amplitude of (max-base), and a period of 1 minute */
227 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m], 240 GNUNET_ATS_TEST_generate_traffic_start (&masters[c_m],
228 &masters[c_m].partners[c_s], 241 &masters[c_m].partners[c_s],
229 GNUNET_ATS_TEST_TG_SINUS, 242 GNUNET_ATS_TEST_TG_SINUS,
230 1000, 243 1000,
231 1500, 244 2000,
232 GNUNET_TIME_UNIT_SECONDS, 245 GNUNET_TIME_UNIT_MINUTES,
233 GNUNET_TIME_UNIT_FOREVER_REL); 246 GNUNET_TIME_UNIT_FOREVER_REL);
234 } 247 }
235 } 248 }