diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-13 15:01:41 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-13 15:01:41 +0000 |
commit | 0fcf414562219d1b2016df33eb43a6a3899b557f (patch) | |
tree | 204edec5876ea69c700242e98ea406db3caa96ca /src | |
parent | b06de9fad684e2e657329d2d395b9c639e74acac (diff) | |
download | gnunet-0fcf414562219d1b2016df33eb43a6a3899b557f.tar.gz gnunet-0fcf414562219d1b2016df33eb43a6a3899b557f.zip |
- connect in clique
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/mesh_profiler.c | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/mesh/mesh_profiler.c b/src/mesh/mesh_profiler.c index fd360c34b..b15f2acf1 100644 --- a/src/mesh/mesh_profiler.c +++ b/src/mesh/mesh_profiler.c | |||
@@ -76,6 +76,9 @@ struct MeshPeer | |||
76 | * Channel handle for the dest peer | 76 | * Channel handle for the dest peer |
77 | */ | 77 | */ |
78 | struct GNUNET_MESH_Channel *incoming_ch; | 78 | struct GNUNET_MESH_Channel *incoming_ch; |
79 | |||
80 | unsigned int dest; | ||
81 | GNUNET_SCHEDULER_TaskIdentifier ping_task; | ||
79 | }; | 82 | }; |
80 | 83 | ||
81 | /** | 84 | /** |
@@ -543,6 +546,34 @@ channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel, | |||
543 | 546 | ||
544 | 547 | ||
545 | /** | 548 | /** |
549 | * @brief Send data to destination | ||
550 | * | ||
551 | * @param cls Closure (peer). | ||
552 | * @param tc Task context. | ||
553 | */ | ||
554 | static void | ||
555 | ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
556 | { | ||
557 | struct MeshPeer *peer = (struct MeshPeer *) cls; | ||
558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n"); | ||
559 | |||
560 | GNUNET_MESH_notify_transmit_ready (peer->ch, GNUNET_NO, | ||
561 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
562 | size_payload, &tmt_rdy, (void *) 1L); | ||
563 | } | ||
564 | |||
565 | |||
566 | static struct GNUNET_TIME_Relative | ||
567 | delay_ms_rnd (unsigned int max) | ||
568 | { | ||
569 | unsigned int rnd; | ||
570 | |||
571 | rnd = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, max); | ||
572 | return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, rnd); | ||
573 | } | ||
574 | |||
575 | |||
576 | /** | ||
546 | * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES. | 577 | * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES. |
547 | * | 578 | * |
548 | * Testcase continues when the root receives confirmation of connected peers, | 579 | * Testcase continues when the root receives confirmation of connected peers, |
@@ -555,6 +586,7 @@ static void | |||
555 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 586 | do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
556 | { | 587 | { |
557 | enum GNUNET_MESH_ChannelOption flags; | 588 | enum GNUNET_MESH_ChannelOption flags; |
589 | unsigned long i; | ||
558 | 590 | ||
559 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | 591 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) |
560 | return; | 592 | return; |
@@ -568,17 +600,22 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
568 | (void *) __LINE__); | 600 | (void *) __LINE__); |
569 | 601 | ||
570 | flags = GNUNET_MESH_OPTION_DEFAULT; | 602 | flags = GNUNET_MESH_OPTION_DEFAULT; |
571 | peers[0].ch = GNUNET_MESH_channel_create (peers[0].mesh, NULL, | 603 | for (i = 0; i < TOTAL_PEERS; i++) |
572 | &peers[TOTAL_PEERS -1].id, | 604 | { |
573 | 1, flags); | 605 | peers[i].dest = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
574 | 606 | TOTAL_PEERS); | |
607 | peers[i].ch = GNUNET_MESH_channel_create (peers[i].mesh, NULL, | ||
608 | &peers[peers[i].dest].id, | ||
609 | 1, flags); | ||
610 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u -> %u\n", i, peers[i].dest); | ||
611 | peers[i].ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd(2000), | ||
612 | &ping, &peers[i]); | ||
613 | } | ||
575 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n"); | 614 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n"); |
576 | data_ack = 0; | 615 | data_ack = 0; |
577 | data_received = 0; | 616 | data_received = 0; |
578 | data_sent = 0; | 617 | data_sent = 0; |
579 | GNUNET_MESH_notify_transmit_ready (peers[0].ch, GNUNET_NO, | 618 | |
580 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
581 | size_payload, &tmt_rdy, (void *) 1L); | ||
582 | } | 619 | } |
583 | 620 | ||
584 | 621 | ||
@@ -592,7 +629,7 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
592 | * NULL if the operation is successfull | 629 | * NULL if the operation is successfull |
593 | */ | 630 | */ |
594 | static void | 631 | static void |
595 | pi_cb (void *cls, | 632 | peer_id_cb (void *cls, |
596 | struct GNUNET_TESTBED_Operation *op, | 633 | struct GNUNET_TESTBED_Operation *op, |
597 | const struct GNUNET_TESTBED_PeerInformation *pinfo, | 634 | const struct GNUNET_TESTBED_PeerInformation *pinfo, |
598 | const char *emsg) | 635 | const char *emsg) |
@@ -651,7 +688,7 @@ tmain (void *cls, | |||
651 | peers[i].op = | 688 | peers[i].op = |
652 | GNUNET_TESTBED_peer_get_information (testbed_handles[i], | 689 | GNUNET_TESTBED_peer_get_information (testbed_handles[i], |
653 | GNUNET_TESTBED_PIT_IDENTITY, | 690 | GNUNET_TESTBED_PIT_IDENTITY, |
654 | &pi_cb, (void *) i); | 691 | &peer_id_cb, (void *) i); |
655 | } | 692 | } |
656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n"); | 693 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n"); |
657 | /* Continues from pi_cb -> do_test */ | 694 | /* Continues from pi_cb -> do_test */ |