diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-31 13:06:12 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-31 13:06:12 +0000 |
commit | 1542ca5c49f27ebaa5331d9954e7539b4fda0b72 (patch) | |
tree | 06a7890cbe3c6db829ee383953c8e7285d21dbb5 /src/ats-tests/ats-testing-traffic.c | |
parent | 7a2cc6b993a9d12ef2876e2fd7eb48a4fa50a525 (diff) | |
download | gnunet-1542ca5c49f27ebaa5331d9954e7539b4fda0b72.tar.gz gnunet-1542ca5c49f27ebaa5331d9954e7539b4fda0b72.zip |
constant traffic generator
Diffstat (limited to 'src/ats-tests/ats-testing-traffic.c')
-rw-r--r-- | src/ats-tests/ats-testing-traffic.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c index ecee76816..21e9723b6 100644 --- a/src/ats-tests/ats-testing-traffic.c +++ b/src/ats-tests/ats-testing-traffic.c | |||
@@ -32,6 +32,28 @@ static struct TrafficGenerator *tg_tail; | |||
32 | 32 | ||
33 | extern struct GNUNET_ATS_TEST_Topology *top; | 33 | extern struct GNUNET_ATS_TEST_Topology *top; |
34 | 34 | ||
35 | static struct GNUNET_TIME_Relative | ||
36 | get_delay (struct TrafficGenerator *tg) | ||
37 | { | ||
38 | struct GNUNET_TIME_Relative delay; | ||
39 | delay.rel_value_us = 0; | ||
40 | |||
41 | switch (tg->type) { | ||
42 | case GNUNET_ATS_TEST_TG_CONSTANT: | ||
43 | if (UINT32_MAX == tg->rate) | ||
44 | delay.rel_value_us = 0; | ||
45 | else if (tg->rate <= TEST_MESSAGE_SIZE) | ||
46 | delay.rel_value_us = (GNUNET_TIME_UNIT_SECONDS.rel_value_us); | ||
47 | else | ||
48 | delay.rel_value_us = (GNUNET_TIME_UNIT_SECONDS.rel_value_us / (tg->rate / TEST_MESSAGE_SIZE)); | ||
49 | break; | ||
50 | default: | ||
51 | return delay; | ||
52 | break; | ||
53 | } | ||
54 | return delay; | ||
55 | } | ||
56 | |||
35 | static size_t | 57 | static size_t |
36 | send_ping_ready_cb (void *cls, size_t size, void *buf) | 58 | send_ping_ready_cb (void *cls, size_t size, void *buf) |
37 | { | 59 | { |
@@ -86,7 +108,8 @@ send_ping_ready_cb (void *cls, size_t size, void *buf) | |||
86 | GNUNET_break (0); | 108 | GNUNET_break (0); |
87 | return TEST_MESSAGE_SIZE; | 109 | return TEST_MESSAGE_SIZE; |
88 | } | 110 | } |
89 | p->tg->next_ping_transmission = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), p->tg->delta); | 111 | p->tg->next_ping_transmission = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), |
112 | get_delay (p->tg)); | ||
90 | 113 | ||
91 | return TEST_MESSAGE_SIZE; | 114 | return TEST_MESSAGE_SIZE; |
92 | } | 115 | } |
@@ -209,15 +232,16 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | |||
209 | } | 232 | } |
210 | } | 233 | } |
211 | 234 | ||
235 | |||
212 | /** | 236 | /** |
213 | * Generate between the source master and the partner and send traffic with a | 237 | * Generate between the source master and the partner and send traffic with a |
214 | * maximum rate. | 238 | * maximum rate. |
215 | * | 239 | * |
216 | */ | 240 | */ |
217 | |||
218 | struct TrafficGenerator * | 241 | struct TrafficGenerator * |
219 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 242 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |
220 | struct BenchmarkPartner *dest, | 243 | struct BenchmarkPartner *dest, |
244 | enum TrafficGeneratorType type, | ||
221 | unsigned int rate, | 245 | unsigned int rate, |
222 | struct GNUNET_TIME_Relative duration) | 246 | struct GNUNET_TIME_Relative duration) |
223 | { | 247 | { |
@@ -232,15 +256,10 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | |||
232 | 256 | ||
233 | tg = GNUNET_new (struct TrafficGenerator); | 257 | tg = GNUNET_new (struct TrafficGenerator); |
234 | GNUNET_CONTAINER_DLL_insert (tg_head, tg_tail, tg); | 258 | GNUNET_CONTAINER_DLL_insert (tg_head, tg_tail, tg); |
259 | tg->type = type; | ||
235 | tg->src = src; | 260 | tg->src = src; |
236 | tg->dest = dest; | 261 | tg->dest = dest; |
237 | tg->rate = rate; | 262 | tg->rate = rate; |
238 | if (UINT32_MAX == rate) | ||
239 | tg->delta.rel_value_us = 0; | ||
240 | else if (rate <= TEST_MESSAGE_SIZE) | ||
241 | tg->delta.rel_value_us = (GNUNET_TIME_UNIT_SECONDS.rel_value_us); | ||
242 | else | ||
243 | tg->delta.rel_value_us = (GNUNET_TIME_UNIT_SECONDS.rel_value_us / (rate / TEST_MESSAGE_SIZE)); | ||
244 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; | 263 | tg->next_ping_transmission = GNUNET_TIME_UNIT_FOREVER_ABS; |
245 | 264 | ||
246 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 265 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |