2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file mesh/gnunet-mesh-profiler.c
23 * @brief Profiler for mesh experiments.
27 #include "mesh_test_lib.h"
28 #include "gnunet_mesh_service.h"
29 #include "gnunet_statistics_service.h"
36 * How many peers to run
38 #define TOTAL_PEERS 20
41 * How many peers do pinging
46 * Duration of each round.
48 #define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
51 * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD)
53 #define PING_PERIOD 1000
56 * How long until we give up on connecting the peers?
58 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
61 * Time to wait for stuff that should be rather fast
63 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
66 * Ratio of peers active. First round always is 1.0.
68 static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.0};
71 * Total number of rounds.
73 static const unsigned int number_rounds = sizeof(rounds)/sizeof(rounds[0]);
76 * Message type for pings.
78 struct MeshPingMessage
81 * Header. Type PING/PONG.
83 struct GNUNET_MessageHeader header;
91 * Time the message was sent.
93 struct GNUNET_TIME_AbsoluteNBO timestamp;
98 uint32_t round_number;
107 * Testbed Operation (to get peer id, etc).
109 struct GNUNET_TESTBED_Operation *op;
114 struct GNUNET_PeerIdentity id;
117 * Mesh handle for the root peer
119 struct GNUNET_MESH_Handle *mesh;
122 * Channel handle for the root peer
124 struct GNUNET_MESH_Channel *ch;
127 * Channel handle for the dest peer
129 struct GNUNET_MESH_Channel *incoming_ch;
132 * Number of payload packes sent
137 * Number of payload packets received
147 * Destinaton to ping.
149 struct MeshPeer *dest;
152 * Incoming channel for pings.
154 struct MeshPeer *incoming;
157 * Task to do the next ping.
159 GNUNET_SCHEDULER_TaskIdentifier ping_task;
161 float mean[number_rounds];
162 float var[number_rounds];
163 unsigned int pongs[number_rounds];
164 unsigned int pings[number_rounds];
169 * GNUNET_PeerIdentity -> MeshPeer
171 static struct GNUNET_CONTAINER_MultiPeerMap *ids;
174 * Testbed peer handles.
176 static struct GNUNET_TESTBED_Peer **testbed_handles;
179 * Testbed Operation (to get stats).
181 static struct GNUNET_TESTBED_Operation *stats_op;
184 * Operation to get peer ids.
186 struct MeshPeer peers[TOTAL_PEERS];
191 static unsigned int p_ids;
194 * Total number of currently running peers.
196 static unsigned long long peers_running;
199 * Test context (to shut down).
201 static struct GNUNET_MESH_TEST_Context *test_ctx;
204 * Task called to shutdown test.
206 static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
209 * Task called to disconnect peers, before shutdown.
211 static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
214 * Task to perform tests
216 static GNUNET_SCHEDULER_TaskIdentifier test_task;
221 static unsigned int current_round;
224 * Flag to notify callbacks not to generate any new traffic anymore.
226 static int test_finished;
229 * Calculate a random delay.
231 * @param max Exclusive maximum, in ms.
233 * @return A time between 0 a max-1 ms.
235 static struct GNUNET_TIME_Relative
236 delay_ms_rnd (unsigned int max)
240 rnd = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, max);
241 return GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, rnd);
246 * Get the index of a peer in the peers array.
248 * @param peer Peer whose index to get.
250 * @return Index of peer in peers.
253 get_index (struct MeshPeer *peer)
260 * Show the results of the test (banwidth acheived) and log them to GAUGER
265 struct MeshPeer *peer;
269 for (i = 0; i < number_rounds; i++)
271 for (j = 0; j < PING_PEERS; j++)
274 FPRINTF (stdout, "ROUND %u PEER %u: %f, PINGS: %u, PONGS: %u\n",
275 i, j, ((float)peer->sum_delay[i])/peer->pongs[i],
276 peer->pings[i], peer->pongs[i]);
283 * Shut down peergroup, clean up.
285 * @param cls Closure (unused).
286 * @param tc Task Context.
289 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
291 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n");
292 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
297 * Disconnect from mesh services af all peers, call shutdown.
299 * @param cls Closure (unused).
300 * @param tc Task Context.
303 disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
305 long line = (long) cls;
308 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
309 "disconnecting mesh service, called from line %ld\n", line);
310 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
311 for (i = 0; i < TOTAL_PEERS; i++)
313 if (NULL != peers[i].op)
314 GNUNET_TESTBED_operation_done (peers[i].op);
316 if (peers[i].up != GNUNET_YES)
319 if (NULL != peers[i].ch)
321 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: channel %p\n", i, peers[i].ch);
322 GNUNET_MESH_channel_destroy (peers[i].ch);
324 if (NULL != peers[i].incoming_ch)
326 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: incoming channel %p\n",
327 i, peers[i].incoming_ch);
328 GNUNET_MESH_channel_destroy (peers[i].incoming_ch);
331 GNUNET_MESH_TEST_cleanup (test_ctx);
332 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
334 GNUNET_SCHEDULER_cancel (shutdown_handle);
336 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
341 * Finish test normally: schedule disconnect and shutdown
343 * @param line Line in the code the abort is requested from (__LINE__).
346 abort_test (long line)
348 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
350 GNUNET_SCHEDULER_cancel (disconnect_task);
351 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
357 * Stats callback. Finish the stats testbed operation and when all stats have
358 * been iterated, shutdown the test.
361 * @param op the operation that has been finished
362 * @param emsg error message in case the operation has failed; will be NULL if
363 * operation has executed successfully.
366 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
368 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "... collecting statistics done.\n");
369 GNUNET_TESTBED_operation_done (stats_op);
371 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
372 GNUNET_SCHEDULER_cancel (disconnect_task);
373 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
380 * Process statistic values.
383 * @param peer the peer the statistic belong to
384 * @param subsystem name of subsystem that created the statistic
385 * @param name the name of the datum
386 * @param value the current value
387 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
388 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
391 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
392 const char *subsystem, const char *name,
393 uint64_t value, int is_persistent)
397 i = GNUNET_TESTBED_get_index (peer);
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " STATS %u - %s [%s]: %llu\n",
399 i, subsystem, name, value);
406 * Task check that keepalives were sent and received.
408 * @param cls Closure (NULL).
409 * @param tc Task Context.
412 collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
414 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
417 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
418 stats_op = GNUNET_TESTBED_get_statistics (TOTAL_PEERS, testbed_handles,
420 stats_iterator, stats_cont, NULL);
425 * @brief Finish profiler normally. Signal finish and start collecting stats.
427 * @param cls Closure (unused).
428 * @param tc Task context.
431 finish_profiler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
433 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
436 test_finished = GNUNET_YES;
438 GNUNET_SCHEDULER_add_now (&collect_stats, NULL);
442 * Set the total number of running peers.
444 * @param target Desired number of running peers.
447 adjust_running_peers (unsigned int target)
449 struct GNUNET_TESTBED_Operation *op;
455 GNUNET_assert (target <= TOTAL_PEERS);
457 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "adjust peers to %u\n", target);
458 if (target > peers_running)
460 delta = target - peers_running;
465 delta = peers_running - target;
469 for (i = 0; i < delta; i++)
472 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
473 TOTAL_PEERS - PING_PEERS);
475 } while (peers[r].up == run || NULL != peers[r].incoming);
476 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n",
477 run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id));
479 if (GNUNET_SCHEDULER_NO_TASK != peers[r].ping_task)
480 GNUNET_SCHEDULER_cancel (peers[r].ping_task);
481 peers[r].ping_task = GNUNET_SCHEDULER_NO_TASK;
485 if (NULL != peers[r].ch)
486 GNUNET_MESH_channel_destroy (peers[r].ch);
488 if (NULL != peers[r].dest)
490 if (NULL != peers[r].dest->incoming_ch)
491 GNUNET_MESH_channel_destroy (peers[r].dest->incoming_ch);
492 peers[r].dest->incoming_ch = NULL;
495 op = GNUNET_TESTBED_peer_manage_service (&peers[r], testbed_handles[r],
496 "mesh", NULL, NULL, run);
497 GNUNET_break (NULL != op);
498 peers_running += run ? 1 : -1;
499 GNUNET_assert (peers_running > 0);
505 * @brief Move to next round.
507 * @param cls Closure (round #).
508 * @param tc Task context.
511 next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
513 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
516 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ROUND %ld\n", current_round);
517 if (0.0 == rounds[current_round])
519 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Finishing\n");
520 GNUNET_SCHEDULER_add_now (&finish_profiler, NULL);
523 adjust_running_peers (rounds[current_round] * TOTAL_PEERS);
526 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL);
531 * Transmit ping callback.
533 * @param cls Closure (peer for PING, NULL for PONG).
534 * @param size Size of the tranmist buffer.
535 * @param buf Pointer to the beginning of the buffer.
537 * @return Number of bytes written to buf.
540 tmt_rdy_ping (void *cls, size_t size, void *buf);
544 * Transmit pong callback.
546 * @param cls Closure (copy of PING message, to be freed).
547 * @param size Size of the buffer we have.
548 * @param buf Buffer to copy data to.
551 tmt_rdy_pong (void *cls, size_t size, void *buf)
553 struct MeshPingMessage *ping = cls;
554 struct MeshPingMessage *pong;
556 if (0 == size || NULL == buf)
561 pong = (struct MeshPingMessage *) buf;
562 memcpy (pong, ping, sizeof (*ping));
563 pong->header.type = htons (PONG);
566 return sizeof (*ping);
571 * @brief Send a ping to destination
573 * @param cls Closure (peer).
574 * @param tc Task context.
577 ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
579 struct MeshPeer *peer = (struct MeshPeer *) cls;
581 peer->ping_task = GNUNET_SCHEDULER_NO_TASK;
583 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0
584 || GNUNET_YES == test_finished)
587 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u -> %u (%u)\n",
588 get_index (peer), get_index (peer->dest), peer->data_sent);
590 GNUNET_MESH_notify_transmit_ready (peer->ch, GNUNET_NO,
591 GNUNET_TIME_UNIT_FOREVER_REL,
592 sizeof (struct MeshPingMessage),
593 &tmt_rdy_ping, peer);
597 * @brief Reply with a pong to origin.
599 * @param cls Closure (peer).
600 * @param tc Task context.
603 pong (struct GNUNET_MESH_Channel *channel, const struct MeshPingMessage *ping)
605 struct MeshPingMessage *copy;
607 copy = GNUNET_new (struct MeshPingMessage);
608 memcpy (copy, ping, sizeof (*ping));
609 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
610 GNUNET_TIME_UNIT_FOREVER_REL,
611 sizeof (struct MeshPingMessage),
612 &tmt_rdy_pong, copy);
617 * Transmit ping callback
619 * @param cls Closure (peer).
620 * @param size Size of the buffer we have.
621 * @param buf Buffer to copy data to.
624 tmt_rdy_ping (void *cls, size_t size, void *buf)
626 struct MeshPeer *peer = (struct MeshPeer *) cls;
627 struct MeshPingMessage *msg = buf;
629 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy called, filling buffer\n");
630 if (size < sizeof (struct MeshPingMessage) || NULL == buf)
633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
634 "size %u, buf %p, data_sent %u, data_received %u\n",
635 size, buf, peer->data_sent, peer->data_received);
639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending: msg %d\n", peer->data_sent);
640 msg->header.size = htons (size);
641 msg->header.type = htons (PING);
642 msg->counter = htonl (peer->data_sent++);
643 msg->round_number = htonl (current_round);
644 msg->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
645 peer->pings[current_round]++;
646 peer->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (PING_PERIOD),
649 return sizeof (struct MeshPingMessage);
654 * Function is called whenever a PING message is received.
656 * @param cls closure (peer #, set from GNUNET_MESH_connect)
657 * @param channel connection to the other end
658 * @param channel_ctx place to store local state associated with the channel
659 * @param message the actual message
660 * @return GNUNET_OK to keep the connection open,
661 * GNUNET_SYSERR to close it (signal serious error)
664 ping_handler (void *cls, struct GNUNET_MESH_Channel *channel,
666 const struct GNUNET_MessageHeader *message)
670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u got PING\n", n);
671 GNUNET_MESH_receive_done (channel);
672 if (GNUNET_NO == test_finished)
673 pong (channel, (struct MeshPingMessage *) message);
680 * Function is called whenever a PONG message is received.
682 * @param cls closure (peer #, set from GNUNET_MESH_connect)
683 * @param channel connection to the other end
684 * @param channel_ctx place to store local state associated with the channel
685 * @param message the actual message
686 * @return GNUNET_OK to keep the connection open,
687 * GNUNET_SYSERR to close it (signal serious error)
690 pong_handler (void *cls, struct GNUNET_MESH_Channel *channel,
692 const struct GNUNET_MessageHeader *message)
695 struct MeshPeer *peer;
696 struct MeshPingMessage *msg;
697 struct GNUNET_TIME_Absolute send_time;
698 struct GNUNET_TIME_Relative latency;
699 unsigned int ping_round;
701 GNUNET_MESH_receive_done (channel);
704 msg = (struct MeshPingMessage *) message;
706 send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp);
707 latency = GNUNET_TIME_absolute_get_duration (send_time);
708 ping_round = ntohl (msg->round_number);
709 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n",
710 get_index (peer), get_index (peer->dest), ntohl (msg->counter),
711 GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO));
712 peer->sum_delay[ping_round] += latency.rel_value_us;
713 peer->pongs[ping_round]++;
720 * Handlers, for diverse services
722 static struct GNUNET_MESH_MessageHandler handlers[] = {
723 {&ping_handler, PING, sizeof (struct MeshPingMessage)},
724 {&pong_handler, PONG, sizeof (struct MeshPingMessage)},
730 * Method called whenever another peer has added us to a channel
731 * the other peer initiated.
733 * @param cls Closure.
734 * @param channel New handle to the channel.
735 * @param initiator Peer that started the channel.
736 * @param port Port this channel is connected to.
737 * @param options channel option flags
738 * @return Initial channel context for the channel
739 * (can be NULL -- that's not an error).
742 incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
743 const struct GNUNET_PeerIdentity *initiator,
744 uint32_t port, enum GNUNET_MESH_ChannelOption options)
747 struct MeshPeer *peer;
749 peer = GNUNET_CONTAINER_multipeermap_get (ids, initiator);
750 GNUNET_assert (NULL != peer);
751 GNUNET_assert (peer == peers[n].incoming);
752 GNUNET_assert (peer->dest == &peers[n]);
753 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <= %u %p\n",
754 n, get_index (peer), channel);
755 peers[n].incoming_ch = channel;
761 * Function called whenever an inbound channel is destroyed. Should clean up
762 * any associated state.
764 * @param cls closure (set from GNUNET_MESH_connect)
765 * @param channel connection to the other end (henceforth invalid)
766 * @param channel_ctx place where local state associated
767 * with the channel is stored
770 channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel,
774 struct MeshPeer *peer = &peers[n];
776 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
777 "Channel %p disconnected at peer %ld\n", channel, n);
778 if (peer->ch == channel)
783 static struct MeshPeer *
784 select_random_peer (struct MeshPeer *peer)
790 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, TOTAL_PEERS);
791 } while (NULL != peers[r].incoming);
792 peers[r].incoming = peer;
798 * START THE TEST ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES.
800 * Testcase continues when the root receives confirmation of connected peers,
801 * on callback funtion ch.
803 * @param cls Closure (unsued).
804 * @param tc Task Context.
807 start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
809 enum GNUNET_MESH_ChannelOption flags;
812 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
815 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n");
817 flags = GNUNET_MESH_OPTION_DEFAULT;
818 for (i = 0; i < PING_PEERS; i++)
821 peers[i].dest = select_random_peer (&peers[i]);
822 peers[i].ch = GNUNET_MESH_channel_create (peers[i].mesh, NULL,
825 if (NULL == peers[i].ch)
827 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i);
828 GNUNET_SCHEDULER_shutdown ();
831 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u => %u %p\n",
832 i, get_index (peers[i].dest), peers[i].ch);
833 peers[i].ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (2000),
836 peers_running = TOTAL_PEERS;
837 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
838 GNUNET_SCHEDULER_cancel (disconnect_task);
840 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(ROUND_TIME,
842 &disconnect_mesh_peers,
844 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL);
849 * Callback to be called when the requested peer information is available
851 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
852 * @param op the operation this callback corresponds to
853 * @param pinfo the result; will be NULL if the operation has failed
854 * @param emsg error message if the operation has failed;
855 * NULL if the operation is successfull
858 peer_id_cb (void *cls,
859 struct GNUNET_TESTBED_Operation *op,
860 const struct GNUNET_TESTBED_PeerInformation *pinfo,
865 if (NULL == pinfo || NULL != emsg)
867 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
868 abort_test (__LINE__);
871 peers[n].id = *(pinfo->result.id);
872 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " %u id: %s\n",
873 n, GNUNET_i2s (&peers[n].id));
874 GNUNET_break (GNUNET_OK ==
875 GNUNET_CONTAINER_multipeermap_put (ids, &peers[n].id, &peers[n],
876 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
878 GNUNET_TESTBED_operation_done (peers[n].op);
882 if (p_ids < TOTAL_PEERS)
884 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting profiler\n");
885 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
890 * test main: start test when all peers are connected
892 * @param cls Closure.
893 * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end.
894 * @param num_peers Number of peers that are running.
895 * @param testbed_peers Array of peers.
896 * @param meshes Handle to each of the MESHs of the peers.
900 struct GNUNET_MESH_TEST_Context *ctx,
901 unsigned int num_peers,
902 struct GNUNET_TESTBED_Peer **testbed_peers,
903 struct GNUNET_MESH_Handle **meshes)
907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
909 GNUNET_assert (TOTAL_PEERS > 2 * PING_PEERS);
910 GNUNET_assert (TOTAL_PEERS == num_peers);
911 peers_running = num_peers;
912 testbed_handles = testbed_peers;
913 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
914 &disconnect_mesh_peers,
916 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
917 &shutdown_task, NULL);
918 for (i = 0; i < TOTAL_PEERS; i++)
920 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requesting id %ld\n", i);
921 peers[i].up = GNUNET_YES;
922 peers[i].mesh = meshes[i];
924 GNUNET_TESTBED_peer_get_information (testbed_handles[i],
925 GNUNET_TESTBED_PIT_IDENTITY,
926 &peer_id_cb, (void *) i);
928 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
929 /* Continues from pi_cb -> do_test */
934 * Main: start profiler.
937 main (int argc, char *argv[])
939 static uint32_t ports[2];
940 const char *config_file;
942 config_file = "profiler.conf";
944 ids = GNUNET_CONTAINER_multipeermap_create (2 * TOTAL_PEERS, GNUNET_YES);
945 GNUNET_assert (NULL != ids);
947 test_finished = GNUNET_NO;
950 GNUNET_MESH_TEST_run ("mesh-profiler", config_file, TOTAL_PEERS,
951 &tmain, NULL, /* tmain cls */
952 &incoming_channel, &channel_cleaner,
958 /* end of gnunet-mesh-profiler.c */