diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 08:56:56 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-03 08:56:56 +0000 |
commit | eb8276f4974f4a09547954a4aa70b4a48c138648 (patch) | |
tree | 797c8838d1432b20adb720c73b7cd99b877a00bc /src/ats-tests/ats-testing-traffic.c | |
parent | fe56554d28b2e277cde55f6146a54ce158340405 (diff) | |
download | gnunet-eb8276f4974f4a09547954a4aa70b4a48c138648.tar.gz gnunet-eb8276f4974f4a09547954a4aa70b4a48c138648.zip |
documentation and random generator
Diffstat (limited to 'src/ats-tests/ats-testing-traffic.c')
-rw-r--r-- | src/ats-tests/ats-testing-traffic.c | 17 |
1 files changed, 14 insertions, 3 deletions
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 | */ |
275 | struct TrafficGenerator * | 286 | struct TrafficGenerator * |
276 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 287 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |