diff options
Diffstat (limited to 'src/ats-tests/ats-testing-traffic.c')
-rw-r--r-- | src/ats-tests/ats-testing-traffic.c | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/src/ats-tests/ats-testing-traffic.c b/src/ats-tests/ats-testing-traffic.c index 06a983d5c..4d5abb1d1 100644 --- a/src/ats-tests/ats-testing-traffic.c +++ b/src/ats-tests/ats-testing-traffic.c | |||
@@ -77,6 +77,7 @@ get_delay (struct TrafficGenerator *tg) | |||
77 | return delay; | 77 | return delay; |
78 | } | 78 | } |
79 | 79 | ||
80 | |||
80 | static size_t | 81 | static size_t |
81 | send_ping_ready_cb (void *cls, size_t size, void *buf) | 82 | send_ping_ready_cb (void *cls, size_t size, void *buf) |
82 | { | 83 | { |
@@ -96,24 +97,24 @@ send_ping_ready_cb (void *cls, size_t size, void *buf) | |||
96 | return 0; | 97 | return 0; |
97 | } | 98 | } |
98 | 99 | ||
99 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n", | 100 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
100 | p->me->no, p->dest->no); | 101 | "Master [%u]: Sending PING to [%u]\n", |
101 | 102 | p->me->no, p->dest->no); | |
102 | if (top->test_core) | 103 | if (top->test_core) |
103 | { | 104 | { |
104 | if (NULL == p->cth) | 105 | if (NULL == p->cth) |
105 | { | 106 | { |
106 | GNUNET_break (0); | 107 | GNUNET_break (0); |
107 | } | 108 | } |
108 | p->cth = NULL; | 109 | p->cth = NULL; |
109 | } | 110 | } |
110 | else | 111 | else |
111 | { | 112 | { |
112 | if (NULL == p->tth) | 113 | if (NULL == p->tth) |
113 | { | 114 | { |
114 | GNUNET_break (0); | 115 | GNUNET_break (0); |
115 | } | 116 | } |
116 | p->tth = NULL; | 117 | p->tth = NULL; |
117 | } | 118 | } |
118 | 119 | ||
119 | msg = (struct GNUNET_MessageHeader *) &msgbuf; | 120 | msg = (struct GNUNET_MessageHeader *) &msgbuf; |
@@ -145,30 +146,32 @@ send_ping_ready_cb (void *cls, size_t size, void *buf) | |||
145 | 146 | ||
146 | static void | 147 | static void |
147 | comm_schedule_send (void *cls, | 148 | comm_schedule_send (void *cls, |
148 | const struct GNUNET_SCHEDULER_TaskContext* tc) | 149 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
149 | { | 150 | { |
150 | struct BenchmarkPartner *p = cls; | 151 | struct BenchmarkPartner *p = cls; |
151 | 152 | ||
152 | p->tg->send_task = GNUNET_SCHEDULER_NO_TASK; | 153 | p->tg->send_task = GNUNET_SCHEDULER_NO_TASK; |
153 | |||
154 | p->last_message_sent = GNUNET_TIME_absolute_get(); | 154 | p->last_message_sent = GNUNET_TIME_absolute_get(); |
155 | if (GNUNET_YES == top->test_core) | 155 | if (GNUNET_YES == top->test_core) |
156 | { | 156 | { |
157 | p->cth = GNUNET_CORE_notify_transmit_ready ( | 157 | p->cth = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO, |
158 | p->me->ch, GNUNET_NO, | 158 | GNUNET_CORE_PRIO_BEST_EFFORT, |
159 | GNUNET_CORE_PRIO_BEST_EFFORT, | 159 | GNUNET_TIME_UNIT_MINUTES, |
160 | GNUNET_TIME_UNIT_MINUTES, &p->dest->id, | 160 | &p->dest->id, |
161 | TEST_MESSAGE_SIZE, &send_ping_ready_cb, p); | 161 | TEST_MESSAGE_SIZE, |
162 | &send_ping_ready_cb, p); | ||
162 | } | 163 | } |
163 | else | 164 | else |
164 | { | 165 | { |
165 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready ( | 166 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th, |
166 | p->me->th, &p->dest->id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES, | 167 | &p->dest->id, |
167 | &send_ping_ready_cb, p); | 168 | TEST_MESSAGE_SIZE, |
169 | GNUNET_TIME_UNIT_MINUTES, | ||
170 | &send_ping_ready_cb, p); | ||
168 | } | 171 | } |
169 | |||
170 | } | 172 | } |
171 | 173 | ||
174 | |||
172 | static size_t | 175 | static size_t |
173 | comm_send_pong_ready (void *cls, size_t size, void *buf) | 176 | comm_send_pong_ready (void *cls, size_t size, void *buf) |
174 | { | 177 | { |
@@ -223,11 +226,12 @@ GNUNET_ATS_TEST_traffic_handle_ping (struct BenchmarkPartner *p) | |||
223 | { | 226 | { |
224 | GNUNET_assert (NULL == p->tth); | 227 | GNUNET_assert (NULL == p->tth); |
225 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th, &p->dest->id, | 228 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready (p->me->th, &p->dest->id, |
226 | TEST_MESSAGE_SIZE, 0, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready, | 229 | TEST_MESSAGE_SIZE, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready, |
227 | p); | 230 | p); |
228 | } | 231 | } |
229 | } | 232 | } |
230 | 233 | ||
234 | |||
231 | void | 235 | void |
232 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | 236 | GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) |
233 | { | 237 | { |
@@ -265,9 +269,8 @@ GNUNET_ATS_TEST_traffic_handle_pong (struct BenchmarkPartner *p) | |||
265 | * Generate between the source master and the partner and send traffic with a | 269 | * Generate between the source master and the partner and send traffic with a |
266 | * maximum rate. | 270 | * maximum rate. |
267 | * | 271 | * |
268 | * @base_rate traffic base rate to send data with | 272 | * @param base_rate traffic base rate to send data with |
269 | * @max_rate traffic maximum rate to send data with | 273 | * @param max_rate traffic maximum rate to send data with |
270 | * @frequency | ||
271 | */ | 274 | */ |
272 | struct TrafficGenerator * | 275 | struct TrafficGenerator * |
273 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | 276 | GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, |
@@ -278,8 +281,7 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | |||
278 | struct GNUNET_TIME_Relative period, | 281 | struct GNUNET_TIME_Relative period, |
279 | struct GNUNET_TIME_Relative duration) | 282 | struct GNUNET_TIME_Relative duration) |
280 | { | 283 | { |
281 | struct TrafficGenerator * tg; | 284 | struct TrafficGenerator *tg; |
282 | tg = NULL; | ||
283 | 285 | ||
284 | if (NULL != dest->tg) | 286 | if (NULL != dest->tg) |
285 | { | 287 | { |
@@ -318,10 +320,10 @@ GNUNET_ATS_TEST_generate_traffic_start (struct BenchmarkPeer *src, | |||
318 | return tg; | 320 | return tg; |
319 | } | 321 | } |
320 | 322 | ||
323 | |||
321 | void | 324 | void |
322 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) | 325 | GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) |
323 | { | 326 | { |
324 | |||
325 | GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg); | 327 | GNUNET_CONTAINER_DLL_remove (tg_head, tg_tail, tg); |
326 | tg->dest->tg = NULL; | 328 | tg->dest->tg = NULL; |
327 | 329 | ||
@@ -332,23 +334,24 @@ GNUNET_ATS_TEST_generate_traffic_stop (struct TrafficGenerator *tg) | |||
332 | } | 334 | } |
333 | if (top->test_core) | 335 | if (top->test_core) |
334 | { | 336 | { |
335 | if (NULL != tg->dest->cth) | 337 | if (NULL != tg->dest->cth) |
336 | { | 338 | { |
337 | GNUNET_CORE_notify_transmit_ready_cancel (tg->dest->cth); | 339 | GNUNET_CORE_notify_transmit_ready_cancel (tg->dest->cth); |
338 | tg->dest->cth = NULL; | 340 | tg->dest->cth = NULL; |
339 | } | 341 | } |
340 | } | 342 | } |
341 | else | 343 | else |
342 | { | 344 | { |
343 | if (NULL != tg->dest->tth) | 345 | if (NULL != tg->dest->tth) |
344 | { | 346 | { |
345 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (tg->dest->tth); | 347 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (tg->dest->tth); |
346 | tg->dest->tth = NULL; | 348 | tg->dest->tth = NULL; |
347 | } | 349 | } |
348 | } | 350 | } |
349 | GNUNET_free (tg); | 351 | GNUNET_free (tg); |
350 | } | 352 | } |
351 | 353 | ||
354 | |||
352 | /** | 355 | /** |
353 | * Stop all traffic generators | 356 | * Stop all traffic generators |
354 | */ | 357 | */ |