diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-22 16:22:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-22 16:22:53 +0000 |
commit | 0c7aa062cb988866f9d859a7c67836707cf1041c (patch) | |
tree | dde37bec39cf05142a36d0dd40d2fb150c7fd595 /src/ats-tests/perf_ats.c | |
parent | 3425604d4fa20375309ec016a6f52f5e57578fac (diff) | |
download | gnunet-0c7aa062cb988866f9d859a7c67836707cf1041c.tar.gz gnunet-0c7aa062cb988866f9d859a7c67836707cf1041c.zip |
changes to traffic generation
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r-- | src/ats-tests/perf_ats.c | 270 |
1 files changed, 25 insertions, 245 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index 9d56ab659..08b6a1518 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c | |||
@@ -35,9 +35,6 @@ | |||
35 | #define TEST_ATS_PREFRENCE_START 1.0 | 35 | #define TEST_ATS_PREFRENCE_START 1.0 |
36 | #define TEST_ATS_PREFRENCE_DELTA 1.0 | 36 | #define TEST_ATS_PREFRENCE_DELTA 1.0 |
37 | 37 | ||
38 | #define TEST_MESSAGE_TYPE_PING 12345 | ||
39 | #define TEST_MESSAGE_TYPE_PONG 12346 | ||
40 | #define TEST_MESSAGE_SIZE 1000 | ||
41 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 38 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
42 | 39 | ||
43 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | 40 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) |
@@ -150,9 +147,6 @@ evaluate () | |||
150 | { | 147 | { |
151 | p = &mp->partners[c_s]; | 148 | p = &mp->partners[c_s]; |
152 | 149 | ||
153 | fprintf (stderr , "%u %u %u\n", p->bytes_sent, (p->bytes_sent / 1024) / duration, duration); | ||
154 | fprintf (stderr , "%u %u %u \n", p->bytes_received, (p->bytes_sent / 1024) / duration, duration); | ||
155 | |||
156 | kb_sent_sec = 0; | 150 | kb_sent_sec = 0; |
157 | kb_recv_sec = 0; | 151 | kb_recv_sec = 0; |
158 | kb_sent_percent = 0.0; | 152 | kb_sent_percent = 0.0; |
@@ -171,16 +165,12 @@ evaluate () | |||
171 | kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; | 165 | kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; |
172 | if (1000 * p->messages_sent > 0) | 166 | if (1000 * p->messages_sent > 0) |
173 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | 167 | rtt = p->total_app_rtt / (1000 * p->messages_sent); |
174 | |||
175 | |||
176 | |||
177 | fprintf (stderr, | 168 | fprintf (stderr, |
178 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", | 169 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", |
179 | (mp->pref_partner == p->dest) ? '*' : ' ', | 170 | (mp->pref_partner == p->dest) ? '*' : ' ', |
180 | mp->no, p->dest->no, | 171 | mp->no, p->dest->no, |
181 | kb_sent_sec, kb_sent_percent, | 172 | kb_sent_sec, kb_sent_percent, |
182 | kb_recv_sec, kb_recv_percent); | 173 | kb_recv_sec, kb_recv_percent); |
183 | |||
184 | fprintf (stderr, | 174 | fprintf (stderr, |
185 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | 175 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", |
186 | (mp->pref_partner == p->dest) ? '*' : ' ', | 176 | (mp->pref_partner == p->dest) ? '*' : ' ', |
@@ -216,63 +206,6 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
216 | GNUNET_ATS_TEST_shutdown_topology(); | 206 | GNUNET_ATS_TEST_shutdown_topology(); |
217 | } | 207 | } |
218 | 208 | ||
219 | static size_t | ||
220 | comm_send_ready (void *cls, size_t size, void *buf) | ||
221 | { | ||
222 | static char msgbuf[TEST_MESSAGE_SIZE]; | ||
223 | struct BenchmarkPartner *p = cls; | ||
224 | struct GNUNET_MessageHeader *msg; | ||
225 | |||
226 | if (GNUNET_YES == test_core) | ||
227 | p->cth = NULL; | ||
228 | else | ||
229 | p->tth = NULL; | ||
230 | |||
231 | if (NULL == buf) | ||
232 | { | ||
233 | GNUNET_break (0); | ||
234 | return 0; | ||
235 | } | ||
236 | if (size < TEST_MESSAGE_SIZE) | ||
237 | { | ||
238 | GNUNET_break (0); | ||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Master [%u]: Sending PING to [%u]\n", | ||
243 | p->me->no, p->dest->no); | ||
244 | |||
245 | p->messages_sent++; | ||
246 | p->bytes_sent += TEST_MESSAGE_SIZE; | ||
247 | p->me->total_messages_sent++; | ||
248 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | ||
249 | |||
250 | msg = (struct GNUNET_MessageHeader *) &msgbuf; | ||
251 | memset (&msgbuf, 'a', TEST_MESSAGE_SIZE); | ||
252 | msg->type = htons (TEST_MESSAGE_TYPE_PING); | ||
253 | msg->size = htons (TEST_MESSAGE_SIZE); | ||
254 | memcpy (buf, msg, TEST_MESSAGE_SIZE); | ||
255 | return TEST_MESSAGE_SIZE; | ||
256 | } | ||
257 | |||
258 | static void | ||
259 | comm_schedule_send (struct BenchmarkPartner *p) | ||
260 | { | ||
261 | p->last_message_sent = GNUNET_TIME_absolute_get(); | ||
262 | if (GNUNET_YES == test_core) | ||
263 | { | ||
264 | p->cth = GNUNET_CORE_notify_transmit_ready ( | ||
265 | p->me->ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &p->dest->id, | ||
266 | TEST_MESSAGE_SIZE, &comm_send_ready, p); | ||
267 | } | ||
268 | else | ||
269 | { | ||
270 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready ( | ||
271 | p->me->th, &p->dest->id, TEST_MESSAGE_SIZE, 0,GNUNET_TIME_UNIT_MINUTES, | ||
272 | &comm_send_ready, p); | ||
273 | } | ||
274 | |||
275 | } | ||
276 | 209 | ||
277 | static void | 210 | static void |
278 | print_progress () | 211 | print_progress () |
@@ -306,64 +239,50 @@ ats_pref_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
306 | } | 239 | } |
307 | 240 | ||
308 | static void | 241 | static void |
309 | do_benchmark (void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *slaves) | 242 | start_benchmark() |
310 | { | 243 | { |
311 | int c_m; | 244 | int c_m; |
312 | int c_s; | 245 | int c_s; |
313 | 246 | ||
314 | mps = masters; | ||
315 | sps = slaves; | ||
316 | |||
317 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking start\n")); | 247 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Benchmarking start\n")); |
318 | 248 | ||
319 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | 249 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) |
320 | GNUNET_SCHEDULER_cancel (shutdown_task); | 250 | GNUNET_SCHEDULER_cancel(shutdown_task); |
321 | shutdown_task = GNUNET_SCHEDULER_add_delayed (perf_duration, | 251 | shutdown_task = GNUNET_SCHEDULER_add_delayed(perf_duration, &do_shutdown, |
322 | &do_shutdown, NULL ); | 252 | NULL ); |
323 | 253 | ||
324 | progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL ); | 254 | progress_task = GNUNET_SCHEDULER_add_now(&print_progress, NULL ); |
325 | 255 | ||
326 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Topology connected, start benchmarking...\n"); | 256 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
257 | "Topology connected, start benchmarking...\n"); | ||
327 | 258 | ||
328 | /* Start sending test messages */ | 259 | /* Start sending test messages */ |
329 | for (c_m = 0; c_m < num_masters; c_m++) | 260 | for (c_m = 0; c_m < num_masters; c_m++) |
330 | { | 261 | { |
331 | for (c_s = 0; c_s < num_slaves; c_s++) | 262 | for (c_s = 0; c_s < num_slaves; c_s++) |
332 | comm_schedule_send (&masters[c_m].partners[c_s]); | 263 | { |
333 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | 264 | GNUNET_ATS_TEST_generate_traffic_start (&mps[c_m], &mps[c_m].partners[c_s], |
334 | masters[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &masters[c_m]); | 265 | UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL); |
335 | } | 266 | } |
267 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | ||
268 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now(&ats_pref_task, &mps[c_m]); | ||
269 | } | ||
336 | 270 | ||
337 | if (GNUNET_YES == logging) | 271 | if (GNUNET_YES == logging) |
338 | GNUNET_ATS_TEST_logging_start (log_frequency, testname, mps, num_masters); | 272 | GNUNET_ATS_TEST_logging_start(log_frequency, testname, mps, num_masters); |
339 | } | 273 | } |
340 | 274 | ||
341 | 275 | static void | |
342 | static size_t | 276 | do_benchmark (void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *slaves) |
343 | comm_send_pong_ready (void *cls, size_t size, void *buf) | ||
344 | { | 277 | { |
345 | static char msgbuf[TEST_MESSAGE_SIZE]; | 278 | mps = masters; |
346 | struct BenchmarkPartner *p = cls; | 279 | sps = slaves; |
347 | struct GNUNET_MessageHeader *msg; | ||
348 | 280 | ||
349 | if (GNUNET_YES == test_core) | 281 | GNUNET_SCHEDULER_add_now(&start_benchmark, NULL); |
350 | p->cth = NULL; | 282 | } |
351 | else | ||
352 | p->tth = NULL; | ||
353 | 283 | ||
354 | p->messages_sent++; | ||
355 | p->bytes_sent += TEST_MESSAGE_SIZE; | ||
356 | p->me->total_messages_sent++; | ||
357 | p->me->total_bytes_sent += TEST_MESSAGE_SIZE; | ||
358 | 284 | ||
359 | msg = (struct GNUNET_MessageHeader *) &msgbuf; | ||
360 | memset (&msgbuf, 'a', TEST_MESSAGE_SIZE); | ||
361 | msg->type = htons (TEST_MESSAGE_TYPE_PONG); | ||
362 | msg->size = htons (TEST_MESSAGE_SIZE); | ||
363 | memcpy (buf, msg, TEST_MESSAGE_SIZE); | ||
364 | 285 | ||
365 | return TEST_MESSAGE_SIZE; | ||
366 | } | ||
367 | 286 | ||
368 | static struct BenchmarkPartner * | 287 | static struct BenchmarkPartner * |
369 | find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer) | 288 | find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer) |
@@ -384,91 +303,12 @@ find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer) | |||
384 | return NULL; | 303 | return NULL; |
385 | } | 304 | } |
386 | 305 | ||
387 | static int | ||
388 | comm_handle_ping (void *cls, const struct GNUNET_PeerIdentity *other, | ||
389 | const struct GNUNET_MessageHeader *message) | ||
390 | { | ||
391 | |||
392 | struct BenchmarkPeer *me = cls; | ||
393 | struct BenchmarkPartner *p = NULL; | ||
394 | |||
395 | if (NULL == (p = find_partner(me, other))) | ||
396 | { | ||
397 | GNUNET_break(0); | ||
398 | return GNUNET_SYSERR; | ||
399 | } | ||
400 | |||
401 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
402 | "Slave [%u]: Received PING from [%u], sending PONG\n", me->no, | ||
403 | p->dest->no); | ||
404 | |||
405 | p->messages_received++; | ||
406 | p->bytes_received += TEST_MESSAGE_SIZE; | ||
407 | p->me->total_messages_received++; | ||
408 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | ||
409 | |||
410 | if (GNUNET_YES == test_core) | ||
411 | { | ||
412 | GNUNET_assert (NULL == p->cth); | ||
413 | p->cth = GNUNET_CORE_notify_transmit_ready (me->ch, GNUNET_NO, 0, | ||
414 | GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE, | ||
415 | &comm_send_pong_ready, p); | ||
416 | } | ||
417 | else | ||
418 | { | ||
419 | GNUNET_assert (NULL == p->tth); | ||
420 | p->tth = GNUNET_TRANSPORT_notify_transmit_ready (me->th, &p->dest->id, | ||
421 | TEST_MESSAGE_SIZE, 0, GNUNET_TIME_UNIT_MINUTES, &comm_send_pong_ready, | ||
422 | p); | ||
423 | } | ||
424 | return GNUNET_OK; | ||
425 | } | ||
426 | |||
427 | static int | ||
428 | comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, | ||
429 | const struct GNUNET_MessageHeader *message) | ||
430 | { | ||
431 | struct BenchmarkPeer *me = cls; | ||
432 | struct BenchmarkPartner *p = NULL; | ||
433 | |||
434 | if (NULL == (p = find_partner (me, other))) | ||
435 | { | ||
436 | GNUNET_break(0); | ||
437 | return GNUNET_SYSERR; | ||
438 | } | ||
439 | |||
440 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
441 | "Master [%u]: Received PONG from [%u], next message\n", me->no, | ||
442 | p->dest->no); | ||
443 | |||
444 | p->messages_received++; | ||
445 | p->bytes_received += TEST_MESSAGE_SIZE; | ||
446 | p->me->total_messages_received++; | ||
447 | p->me->total_bytes_received += TEST_MESSAGE_SIZE; | ||
448 | p->total_app_rtt += GNUNET_TIME_absolute_get_difference(p->last_message_sent, | ||
449 | GNUNET_TIME_absolute_get()).rel_value_us; | ||
450 | |||
451 | comm_schedule_send (p); | ||
452 | return GNUNET_OK; | ||
453 | } | ||
454 | |||
455 | |||
456 | static void | 306 | static void |
457 | test_recv_cb (void *cls, | 307 | test_recv_cb (void *cls, |
458 | const struct GNUNET_PeerIdentity * peer, | 308 | const struct GNUNET_PeerIdentity * peer, |
459 | const struct GNUNET_MessageHeader * message) | 309 | const struct GNUNET_MessageHeader * message) |
460 | { | 310 | { |
461 | if (TEST_MESSAGE_SIZE != ntohs (message->size) || | ||
462 | (TEST_MESSAGE_TYPE_PING != ntohs (message->type) && | ||
463 | TEST_MESSAGE_TYPE_PONG != ntohs (message->type))) | ||
464 | { | ||
465 | return; | ||
466 | } | ||
467 | if (TEST_MESSAGE_TYPE_PING == ntohs (message->type)) | ||
468 | comm_handle_ping (cls, peer, message); | ||
469 | 311 | ||
470 | if (TEST_MESSAGE_TYPE_PONG == ntohs (message->type)) | ||
471 | comm_handle_pong (cls, peer, message); | ||
472 | } | 312 | } |
473 | 313 | ||
474 | 314 | ||
@@ -509,61 +349,9 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
509 | GNUNET_i2s (&p->dest->id), | 349 | GNUNET_i2s (&p->dest->id), |
510 | GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)), | 350 | GNUNET_ATS_print_property_type(ntohl(ats[c_a].type)), |
511 | ntohl(ats[c_a].value)); | 351 | ntohl(ats[c_a].value)); |
512 | switch (ntohl (ats[c_a].type )) | ||
513 | { | ||
514 | case GNUNET_ATS_ARRAY_TERMINATOR: | ||
515 | break; | ||
516 | case GNUNET_ATS_UTILIZATION_OUT: | ||
517 | if (p->ats_utilization_up != ntohl (ats[c_a].value)) | ||
518 | log = GNUNET_YES; | ||
519 | p->ats_utilization_up = ntohl (ats[c_a].value); | ||
520 | |||
521 | break; | ||
522 | case GNUNET_ATS_UTILIZATION_IN: | ||
523 | if (p->ats_utilization_down != ntohl (ats[c_a].value)) | ||
524 | log = GNUNET_YES; | ||
525 | p->ats_utilization_down = ntohl (ats[c_a].value); | ||
526 | break; | ||
527 | case GNUNET_ATS_NETWORK_TYPE: | ||
528 | if (p->ats_network_type != ntohl (ats[c_a].value)) | ||
529 | log = GNUNET_YES; | ||
530 | p->ats_network_type = ntohl (ats[c_a].value); | ||
531 | break; | ||
532 | case GNUNET_ATS_QUALITY_NET_DELAY: | ||
533 | if (p->ats_delay != ntohl (ats[c_a].value)) | ||
534 | log = GNUNET_YES; | ||
535 | p->ats_delay = ntohl (ats[c_a].value); | ||
536 | break; | ||
537 | case GNUNET_ATS_QUALITY_NET_DISTANCE: | ||
538 | if (p->ats_distance != ntohl (ats[c_a].value)) | ||
539 | log = GNUNET_YES; | ||
540 | p->ats_distance = ntohl (ats[c_a].value); | ||
541 | GNUNET_break (0); | ||
542 | break; | ||
543 | case GNUNET_ATS_COST_WAN: | ||
544 | if (p->ats_cost_wan != ntohl (ats[c_a].value)) | ||
545 | log = GNUNET_YES; | ||
546 | p->ats_cost_wan = ntohl (ats[c_a].value); | ||
547 | break; | ||
548 | case GNUNET_ATS_COST_LAN: | ||
549 | if (p->ats_cost_lan != ntohl (ats[c_a].value)) | ||
550 | log = GNUNET_YES; | ||
551 | p->ats_cost_lan = ntohl (ats[c_a].value); | ||
552 | break; | ||
553 | case GNUNET_ATS_COST_WLAN: | ||
554 | if (p->ats_cost_wlan != ntohl (ats[c_a].value)) | ||
555 | log = GNUNET_YES; | ||
556 | p->ats_cost_wlan = ntohl (ats[c_a].value); | ||
557 | break; | ||
558 | default: | ||
559 | break; | ||
560 | } | ||
561 | } | 352 | } |
562 | |||
563 | if ((GNUNET_YES == logging) && (GNUNET_YES == log)) | ||
564 | GNUNET_ATS_TEST_logging_now(); | ||
565 | |||
566 | GNUNET_free(peer_id); | 353 | GNUNET_free(peer_id); |
354 | |||
567 | } | 355 | } |
568 | 356 | ||
569 | 357 | ||
@@ -748,21 +536,13 @@ main (int argc, char *argv[]) | |||
748 | } | 536 | } |
749 | 537 | ||
750 | /** | 538 | /** |
751 | * Core message handler to use for PING/PONG messages | ||
752 | */ | ||
753 | static struct GNUNET_CORE_MessageHandler handlers[] = { | ||
754 | {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, | ||
755 | {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, | ||
756 | { NULL, 0, 0 } }; | ||
757 | |||
758 | /** | ||
759 | * Setup the topology | 539 | * Setup the topology |
760 | */ | 540 | */ |
761 | GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, | 541 | GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, |
762 | num_slaves, num_masters, | 542 | num_slaves, num_masters, |
763 | test_core, | 543 | test_core, |
764 | &do_benchmark, | 544 | &do_benchmark, |
765 | NULL, handlers, | 545 | NULL, |
766 | &test_recv_cb, | 546 | &test_recv_cb, |
767 | &ats_performance_info_cb); | 547 | &ats_performance_info_cb); |
768 | 548 | ||