aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-03-13 15:01:39 +0000
committerBart Polot <bart@net.in.tum.de>2014-03-13 15:01:39 +0000
commit6c814b8eb899ebbe3d0ea269aafa46b01aaeedbc (patch)
tree267619c87be48ba462fbacf3170774297332c7a1 /src
parent2c85065ca263b3b9354ac798afd95d7757199c79 (diff)
downloadgnunet-6c814b8eb899ebbe3d0ea269aafa46b01aaeedbc.tar.gz
gnunet-6c814b8eb899ebbe3d0ea269aafa46b01aaeedbc.zip
- change test to profiler
Diffstat (limited to 'src')
-rw-r--r--src/mesh/mesh_profiler.c265
1 files changed, 72 insertions, 193 deletions
diff --git a/src/mesh/mesh_profiler.c b/src/mesh/mesh_profiler.c
index 985d36dc7..2eebeccde 100644
--- a/src/mesh/mesh_profiler.c
+++ b/src/mesh/mesh_profiler.c
@@ -51,6 +51,40 @@
51#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) 51#define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
52 52
53 53
54struct MeshPeer
55{
56 /**
57 * Testbed Operation (to get peer id, etc).
58 */
59 struct GNUNET_TESTBED_Operation *op;
60
61 /**
62 * Testbed peer handle.
63 */
64 struct GNUNET_TESTBED_Peer *testbed_peer;
65
66 /**
67 * Peer ID.
68 */
69 struct GNUNET_PeerIdentity *id;
70
71 /**
72 * Mesh handle for the root peer
73 */
74 static struct GNUNET_MESH_Handle *mesh;
75
76 /**
77 * Channel handle for the root peer
78 */
79 static struct GNUNET_MESH_Channel *ch;
80
81 /**
82 * Channel handle for the dest peer
83 */
84 static struct GNUNET_MESH_Channel *incoming_ch;
85};
86
87
54/** 88/**
55 * How many events have happened 89 * How many events have happened
56 */ 90 */
@@ -69,27 +103,7 @@ size_t size_payload = sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t);
69/** 103/**
70 * Operation to get peer ids. 104 * Operation to get peer ids.
71 */ 105 */
72struct GNUNET_TESTBED_Operation *t_op[TOTAL_PEERS]; 106struct MeshPeer peers[TOTAL_PEERS];
73
74/**
75 * Peer ids.
76 */
77struct GNUNET_PeerIdentity *p_id[TOTAL_PEERS];
78
79/**
80 * Mesh handle for the root peer
81 */
82static struct GNUNET_MESH_Handle *mesh_h[TOTAL_PEERS];
83
84/**
85 * Channel handle for the root peer
86 */
87static struct GNUNET_MESH_Channel *ch;
88
89/**
90 * Channel handle for the dest peer
91 */
92static struct GNUNET_MESH_Channel *incoming_ch;
93 107
94/** 108/**
95 * Peer ids counter. 109 * Peer ids counter.
@@ -147,14 +161,9 @@ static GNUNET_SCHEDULER_TaskIdentifier test_task;
147 */ 161 */
148static struct GNUNET_TIME_Absolute start_time; 162static struct GNUNET_TIME_Absolute start_time;
149 163
150static struct GNUNET_TESTBED_Peer **testbed_peers;
151
152/** 164/**
153 * 165 *
154 */ 166 */
155static struct GNUNET_STATISTICS_Handle *stats;
156static struct GNUNET_STATISTICS_GetHandle *stats_get;
157static struct GNUNET_TESTBED_Operation *stats_op;
158static unsigned int ka_sent; 167static unsigned int ka_sent;
159static unsigned int ka_received; 168static unsigned int ka_received;
160 169
@@ -170,7 +179,6 @@ show_end_data (void)
170 179
171 end_time = GNUNET_TIME_absolute_get(); 180 end_time = GNUNET_TIME_absolute_get();
172 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time); 181 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
173 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
174 FPRINTF (stderr, "Test time %s\n", 182 FPRINTF (stderr, "Test time %s\n",
175 GNUNET_STRINGS_relative_time_to_string (total_time, 183 GNUNET_STRINGS_relative_time_to_string (total_time,
176 GNUNET_YES)); 184 GNUNET_YES));
@@ -214,19 +222,11 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
214 "disconnecting mesh service of peers, called from line %ld\n", 222 "disconnecting mesh service of peers, called from line %ld\n",
215 line); 223 line);
216 disconnect_task = GNUNET_SCHEDULER_NO_TASK; 224 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
217 for (i = 0; i < 2; i++) 225 for (i = 0; i < TOTAL_PEERS; i++)
218 {
219 GNUNET_TESTBED_operation_done (t_op[i]);
220 }
221 if (NULL != ch)
222 {
223 GNUNET_MESH_channel_destroy (ch);
224 ch = NULL;
225 }
226 if (NULL != incoming_ch)
227 { 226 {
228 GNUNET_MESH_channel_destroy (incoming_ch); 227 GNUNET_TESTBED_operation_done (peers[i].op);
229 incoming_ch = NULL; 228 GNUNET_MESH_channel_destroy (peers[i].ch);
229 GNUNET_MESH_channel_destroy (peers[i].incoming_ch);
230 } 230 }
231 GNUNET_MESH_TEST_cleanup (test_ctx); 231 GNUNET_MESH_TEST_cleanup (test_ctx);
232 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle) 232 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
@@ -368,38 +368,12 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
368 return; 368 return;
369 369
370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n"); 370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
371 if (GNUNET_YES == test_backwards) 371
372 {
373 channel = incoming_ch;
374 }
375 else
376 {
377 channel = ch;
378 }
379 th = GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO, 372 th = GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
380 GNUNET_TIME_UNIT_FOREVER_REL, 373 GNUNET_TIME_UNIT_FOREVER_REL,
381 size_payload, &tmt_rdy, (void *) 1L); 374 size_payload, &tmt_rdy, (void *) 1L);
382 if (NULL == th) 375 if (NULL == th)
383 { 376 GNUNET_abort (0);
384 unsigned long i = (unsigned long) cls;
385
386 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retransmission\n");
387 if (0 == i)
388 {
389 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " in 1 ms\n");
390 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
391 &data_task, (void *)1UL);
392 }
393 else
394 {
395 i++;
396 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "in %u ms\n", i);
397 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
398 GNUNET_TIME_UNIT_MILLISECONDS,
399 i),
400 &data_task, (void *)i);
401 }
402 }
403} 377}
404 378
405 379
@@ -416,8 +390,7 @@ tmt_rdy (void *cls, size_t size, void *buf)
416 struct GNUNET_MessageHeader *msg = buf; 390 struct GNUNET_MessageHeader *msg = buf;
417 uint32_t *data; 391 uint32_t *data;
418 392
419 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy called, filling buffer\n");
420 "tmt_rdy called, filling buffer\n");
421 if (size < size_payload || NULL == buf) 394 if (size < size_payload || NULL == buf)
422 { 395 {
423 GNUNET_break (ok >= ok_goal - 2); 396 GNUNET_break (ok >= ok_goal - 2);
@@ -437,7 +410,7 @@ tmt_rdy (void *cls, size_t size, void *buf)
437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
438 "sending initializer\n"); 411 "sending initializer\n");
439 } 412 }
440 else if (SPEED == test) 413 else
441 { 414 {
442 data_sent++; 415 data_sent++;
443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -470,105 +443,19 @@ data_callback (void *cls, struct GNUNET_MESH_Channel *channel,
470 const struct GNUNET_MessageHeader *message) 443 const struct GNUNET_MessageHeader *message)
471{ 444{
472 long client = (long) cls; 445 long client = (long) cls;
473 long expected_target_client;
474 uint32_t *data;
475
476 ok++;
477 446
478 GNUNET_MESH_receive_done (channel); 447 GNUNET_MESH_receive_done (channel);
479 448
480 if ((ok % 20) == 0)
481 {
482 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
483 {
484 GNUNET_SCHEDULER_cancel (disconnect_task);
485 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
486 &disconnect_mesh_peers,
487 (void *) __LINE__);
488 }
489 }
490
491 switch (client)
492 {
493 case 0L:
494 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
495 break;
496 case 4L:
497 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
498 "Leaf client %li got a message.\n",
499 client);
500 break;
501 default:
502 GNUNET_assert (0);
503 break;
504 }
505 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
506 data = (uint32_t *) &message[1];
507 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: (%u)\n", ntohl (*data));
508 if (SPEED == test && GNUNET_YES == test_backwards)
509 {
510 expected_target_client = 0L;
511 }
512 else
513 {
514 expected_target_client = 4L;
515 }
516 449
517 if (GNUNET_NO == initialized) 450 if (GNUNET_NO == initialized)
518 { 451 {
519 initialized = GNUNET_YES; 452 initialized = GNUNET_YES;
520 start_time = GNUNET_TIME_absolute_get (); 453 start_time = GNUNET_TIME_absolute_get ();
521 if (SPEED == test) 454 GNUNET_SCHEDULER_add_now (&data_task, NULL);
522 {
523 GNUNET_assert (4L == client);
524 GNUNET_SCHEDULER_add_now (&data_task, NULL);
525 return GNUNET_OK;
526 }
527 }
528
529 if (client == expected_target_client) // Normally 4
530 {
531 data_received++;
532 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
533 if (SPEED != test || (ok_goal - 2) == ok)
534 {
535 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
536 GNUNET_TIME_UNIT_FOREVER_REL,
537 size_payload, &tmt_rdy, (void *) 1L);
538 return GNUNET_OK;
539 }
540 else
541 {
542 if (data_received < TOTAL_PACKETS)
543 return GNUNET_OK;
544 }
545 }
546 else // Normally 0
547 {
548 if (test == SPEED_ACK || test == SPEED)
549 {
550 data_ack++;
551 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", data_ack);
552 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
553 GNUNET_TIME_UNIT_FOREVER_REL,
554 size_payload, &tmt_rdy, (void *) 1L);
555 if (data_ack < TOTAL_PACKETS && SPEED != test)
556 return GNUNET_OK;
557 if (ok == 2 && SPEED == test)
558 return GNUNET_OK;
559 show_end_data();
560 }
561 if (test == P2P_SIGNAL)
562 {
563 GNUNET_MESH_channel_destroy (incoming_ch);
564 incoming_ch = NULL;
565 }
566 else
567 {
568 GNUNET_MESH_channel_destroy (ch);
569 ch = NULL;
570 }
571 } 455 }
456 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
457 GNUNET_TIME_UNIT_FOREVER_REL,
458 size_payload, &tmt_rdy, (void *) 1L);
572 459
573 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 460 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
574 { 461 {
@@ -608,33 +495,21 @@ incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
608 const struct GNUNET_PeerIdentity *initiator, 495 const struct GNUNET_PeerIdentity *initiator,
609 uint32_t port, enum GNUNET_MESH_ChannelOption options) 496 uint32_t port, enum GNUNET_MESH_ChannelOption options)
610{ 497{
498 long n = (long) cls;
499
611 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 500 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
612 "Incoming channel from %s to peer %d\n", 501 "Incoming channel from %s to peer %ld\n",
613 GNUNET_i2s (initiator), (long) cls); 502 GNUNET_i2s (initiator), n);
614 ok++; 503 ok++;
615 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); 504 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
616 if ((long) cls == 4L) 505 peers[n].incoming_ch = channel;
617 incoming_ch = channel; 506
618 else
619 {
620 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
621 "Incoming channel for unknown client %lu\n", (long) cls);
622 GNUNET_break(0);
623 }
624 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 507 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
625 { 508 {
626 GNUNET_SCHEDULER_cancel (disconnect_task); 509 GNUNET_SCHEDULER_cancel (disconnect_task);
627 if (KEEPALIVE == test) 510 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
628 { 511 &disconnect_mesh_peers,
629 struct GNUNET_TIME_Relative delay; 512 (void *) __LINE__);
630 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS , 5);
631 disconnect_task =
632 GNUNET_SCHEDULER_add_delayed (delay, &collect_stats, NULL);
633 }
634 else
635 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
636 &disconnect_mesh_peers,
637 (void *) __LINE__);
638 } 513 }
639 514
640 return NULL; 515 return NULL;
@@ -653,10 +528,10 @@ static void
653channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel, 528channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel,
654 void *channel_ctx) 529 void *channel_ctx)
655{ 530{
656 long i = (long) cls; 531 long n = (long) cls;
657 532
658 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 533 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
659 "Incoming channel disconnected at peer %d\n", i); 534 "Incoming channel disconnected at peer %ld\n", n);
660 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); 535 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
661 536
662 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) 537 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
@@ -694,13 +569,15 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
694 (void *) __LINE__); 569 (void *) __LINE__);
695 570
696 flags = GNUNET_MESH_OPTION_DEFAULT; 571 flags = GNUNET_MESH_OPTION_DEFAULT;
697 ch = GNUNET_MESH_channel_create (h1, NULL, p_id[1], 1, flags); 572 peers[0].ch = GNUNET_MESH_channel_create (peers[0].mesh, NULL,
573 &peers[TOTAL_PEERS -1].id,
574 1, flags);
698 575
699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n"); 576 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n");
700 data_ack = 0; 577 data_ack = 0;
701 data_received = 0; 578 data_received = 0;
702 data_sent = 0; 579 data_sent = 0;
703 GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO, 580 GNUNET_MESH_notify_transmit_ready (peers[0].ch, GNUNET_NO,
704 GNUNET_TIME_UNIT_FOREVER_REL, 581 GNUNET_TIME_UNIT_FOREVER_REL,
705 size_payload, &tmt_rdy, (void *) 1L); 582 size_payload, &tmt_rdy, (void *) 1L);
706} 583}
@@ -721,7 +598,7 @@ pi_cb (void *cls,
721 const struct GNUNET_TESTBED_PeerInformation *pinfo, 598 const struct GNUNET_TESTBED_PeerInformation *pinfo,
722 const char *emsg) 599 const char *emsg)
723{ 600{
724 long i = (long) cls; 601 long n = (long) cls;
725 602
726 if (NULL == pinfo || NULL != emsg) 603 if (NULL == pinfo || NULL != emsg)
727 { 604 {
@@ -729,7 +606,7 @@ pi_cb (void *cls,
729 abort_test (__LINE__); 606 abort_test (__LINE__);
730 return; 607 return;
731 } 608 }
732 p_id[i] = pinfo->result.id; 609 peers[n].id = pinfo->result.id;
733 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u id: %s\n", 610 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u id: %s\n",
734 i, GNUNET_i2s (p_id[i])); 611 i, GNUNET_i2s (p_id[i]));
735 p_ids++; 612 p_ids++;
@@ -746,14 +623,14 @@ pi_cb (void *cls,
746 * @param cls Closure. 623 * @param cls Closure.
747 * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end. 624 * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end.
748 * @param num_peers Number of peers that are running. 625 * @param num_peers Number of peers that are running.
749 * @param peers Array of peers. 626 * @param testbed_peers Array of peers.
750 * @param meshes Handle to each of the MESHs of the peers. 627 * @param meshes Handle to each of the MESHs of the peers.
751 */ 628 */
752static void 629static void
753tmain (void *cls, 630tmain (void *cls,
754 struct GNUNET_MESH_TEST_Context *ctx, 631 struct GNUNET_MESH_TEST_Context *ctx,
755 unsigned int num_peers, 632 unsigned int num_peers,
756 struct GNUNET_TESTBED_Peer **peers, 633 struct GNUNET_TESTBED_Peer **testbed_peers,
757 struct GNUNET_MESH_Handle **meshes) 634 struct GNUNET_MESH_Handle **meshes)
758{ 635{
759 unsigned long i; 636 unsigned long i;
@@ -763,7 +640,6 @@ tmain (void *cls,
763 test_ctx = ctx; 640 test_ctx = ctx;
764 GNUNET_assert (TOTAL_PEERS == num_peers); 641 GNUNET_assert (TOTAL_PEERS == num_peers);
765 peers_running = num_peers; 642 peers_running = num_peers;
766 testbed_peers = peers;
767 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, 643 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
768 &disconnect_mesh_peers, 644 &disconnect_mesh_peers,
769 (void *) __LINE__); 645 (void *) __LINE__);
@@ -771,9 +647,12 @@ tmain (void *cls,
771 &shutdown_task, NULL); 647 &shutdown_task, NULL);
772 for (i = 0; i < TOTAL_PEERS; i++) 648 for (i = 0; i < TOTAL_PEERS; i++)
773 { 649 {
774 t_op[i] = GNUNET_TESTBED_peer_get_information (peers[i], 650 peers[i].testbed_peer = testbed_peers[i];
775 GNUNET_TESTBED_PIT_IDENTITY, 651 peers[i].mesh = meshes[i];
776 &pi_cb, (void *) i); 652 peers[i].op =
653 GNUNET_TESTBED_peer_get_information (peers[i].testbed_peer,
654 GNUNET_TESTBED_PIT_IDENTITY,
655 &pi_cb, (void *) i);
777 } 656 }
778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n"); 657 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
779 /* Continues from pi_cb -> do_test */ 658 /* Continues from pi_cb -> do_test */