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, 5)
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 * Total number of rounds.
68 #define number_rounds sizeof(rounds)/sizeof(rounds[0])
71 * Ratio of peers active. First round always is 1.0.
73 static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.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++)
275 "ROUND %3u PEER %3u: %10.2f / %10.2f, PINGS: %3u, PONGS: %3u\n",
276 i, j, peer->mean[i], sqrt (peer->var[i] / (peer->pongs[i] - 1)),
277 peer->pings[i], peer->pongs[i]);
284 * Shut down peergroup, clean up.
286 * @param cls Closure (unused).
287 * @param tc Task Context.
290 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
292 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Ending test.\n");
293 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
298 * Disconnect from mesh services af all peers, call shutdown.
300 * @param cls Closure (unused).
301 * @param tc Task Context.
304 disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
306 long line = (long) cls;
309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
310 "disconnecting mesh service, called from line %ld\n", line);
311 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
312 for (i = 0; i < TOTAL_PEERS; i++)
314 if (NULL != peers[i].op)
315 GNUNET_TESTBED_operation_done (peers[i].op);
317 if (peers[i].up != GNUNET_YES)
320 if (NULL != peers[i].ch)
322 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: channel %p\n", i, peers[i].ch);
323 GNUNET_MESH_channel_destroy (peers[i].ch);
325 if (NULL != peers[i].incoming_ch)
327 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u: incoming channel %p\n",
328 i, peers[i].incoming_ch);
329 GNUNET_MESH_channel_destroy (peers[i].incoming_ch);
332 GNUNET_MESH_TEST_cleanup (test_ctx);
333 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
335 GNUNET_SCHEDULER_cancel (shutdown_handle);
337 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
342 * Finish test normally: schedule disconnect and shutdown
344 * @param line Line in the code the abort is requested from (__LINE__).
347 abort_test (long line)
349 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
351 GNUNET_SCHEDULER_cancel (disconnect_task);
352 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
358 * Stats callback. Finish the stats testbed operation and when all stats have
359 * been iterated, shutdown the test.
362 * @param op the operation that has been finished
363 * @param emsg error message in case the operation has failed; will be NULL if
364 * operation has executed successfully.
367 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
369 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "... collecting statistics done.\n");
370 GNUNET_TESTBED_operation_done (stats_op);
372 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
373 GNUNET_SCHEDULER_cancel (disconnect_task);
374 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
381 * Process statistic values.
384 * @param peer the peer the statistic belong to
385 * @param subsystem name of subsystem that created the statistic
386 * @param name the name of the datum
387 * @param value the current value
388 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
389 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
392 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
393 const char *subsystem, const char *name,
394 uint64_t value, int is_persistent)
398 i = GNUNET_TESTBED_get_index (peer);
399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " STATS %u - %s [%s]: %llu\n",
400 i, subsystem, name, value);
407 * Task check that keepalives were sent and received.
409 * @param cls Closure (NULL).
410 * @param tc Task Context.
413 collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
415 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
418 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start collecting statistics...\n");
419 stats_op = GNUNET_TESTBED_get_statistics (TOTAL_PEERS, testbed_handles,
421 stats_iterator, stats_cont, NULL);
426 * @brief Finish profiler normally. Signal finish and start collecting stats.
428 * @param cls Closure (unused).
429 * @param tc Task context.
432 finish_profiler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
434 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
437 test_finished = GNUNET_YES;
439 GNUNET_SCHEDULER_add_now (&collect_stats, NULL);
443 * Set the total number of running peers.
445 * @param target Desired number of running peers.
448 adjust_running_peers (unsigned int target)
450 struct GNUNET_TESTBED_Operation *op;
456 GNUNET_assert (target <= TOTAL_PEERS);
458 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "adjust peers to %u\n", target);
459 if (target > peers_running)
461 delta = target - peers_running;
466 delta = peers_running - target;
470 for (i = 0; i < delta; i++)
473 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
474 TOTAL_PEERS - PING_PEERS);
476 } while (peers[r].up == run || NULL != peers[r].incoming);
477 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "St%s peer %u: %s\n",
478 run ? "arting" : "opping", r, GNUNET_i2s (&peers[r].id));
480 if (GNUNET_SCHEDULER_NO_TASK != peers[r].ping_task)
481 GNUNET_SCHEDULER_cancel (peers[r].ping_task);
482 peers[r].ping_task = GNUNET_SCHEDULER_NO_TASK;
486 if (NULL != peers[r].ch)
487 GNUNET_MESH_channel_destroy (peers[r].ch);
489 if (NULL != peers[r].dest)
491 if (NULL != peers[r].dest->incoming_ch)
492 GNUNET_MESH_channel_destroy (peers[r].dest->incoming_ch);
493 peers[r].dest->incoming_ch = NULL;
496 op = GNUNET_TESTBED_peer_manage_service (&peers[r], testbed_handles[r],
497 "mesh", NULL, NULL, run);
498 GNUNET_break (NULL != op);
499 peers_running += run ? 1 : -1;
500 GNUNET_assert (peers_running > 0);
506 * @brief Move to next round.
508 * @param cls Closure (round #).
509 * @param tc Task context.
512 next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
514 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
517 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ROUND %ld\n", current_round);
518 if (0.0 == rounds[current_round])
520 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Finishing\n");
521 GNUNET_SCHEDULER_add_now (&finish_profiler, NULL);
524 adjust_running_peers (rounds[current_round] * TOTAL_PEERS);
527 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL);
532 * Transmit ping callback.
534 * @param cls Closure (peer for PING, NULL for PONG).
535 * @param size Size of the tranmist buffer.
536 * @param buf Pointer to the beginning of the buffer.
538 * @return Number of bytes written to buf.
541 tmt_rdy_ping (void *cls, size_t size, void *buf);
545 * Transmit pong callback.
547 * @param cls Closure (copy of PING message, to be freed).
548 * @param size Size of the buffer we have.
549 * @param buf Buffer to copy data to.
552 tmt_rdy_pong (void *cls, size_t size, void *buf)
554 struct MeshPingMessage *ping = cls;
555 struct MeshPingMessage *pong;
557 if (0 == size || NULL == buf)
562 pong = (struct MeshPingMessage *) buf;
563 memcpy (pong, ping, sizeof (*ping));
564 pong->header.type = htons (PONG);
567 return sizeof (*ping);
572 * @brief Send a ping to destination
574 * @param cls Closure (peer).
575 * @param tc Task context.
578 ping (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
580 struct MeshPeer *peer = (struct MeshPeer *) cls;
582 peer->ping_task = GNUNET_SCHEDULER_NO_TASK;
584 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0
585 || GNUNET_YES == test_finished)
588 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u -> %u (%u)\n",
589 get_index (peer), get_index (peer->dest), peer->data_sent);
591 GNUNET_MESH_notify_transmit_ready (peer->ch, GNUNET_NO,
592 GNUNET_TIME_UNIT_FOREVER_REL,
593 sizeof (struct MeshPingMessage),
594 &tmt_rdy_ping, peer);
598 * @brief Reply with a pong to origin.
600 * @param cls Closure (peer).
601 * @param tc Task context.
604 pong (struct GNUNET_MESH_Channel *channel, const struct MeshPingMessage *ping)
606 struct MeshPingMessage *copy;
608 copy = GNUNET_new (struct MeshPingMessage);
609 memcpy (copy, ping, sizeof (*ping));
610 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
611 GNUNET_TIME_UNIT_FOREVER_REL,
612 sizeof (struct MeshPingMessage),
613 &tmt_rdy_pong, copy);
618 * Transmit ping callback
620 * @param cls Closure (peer).
621 * @param size Size of the buffer we have.
622 * @param buf Buffer to copy data to.
625 tmt_rdy_ping (void *cls, size_t size, void *buf)
627 struct MeshPeer *peer = (struct MeshPeer *) cls;
628 struct MeshPingMessage *msg = buf;
630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy called, filling buffer\n");
631 if (size < sizeof (struct MeshPingMessage) || NULL == buf)
634 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
635 "size %u, buf %p, data_sent %u, data_received %u\n",
636 size, buf, peer->data_sent, peer->data_received);
640 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending: msg %d\n", peer->data_sent);
641 msg->header.size = htons (size);
642 msg->header.type = htons (PING);
643 msg->counter = htonl (peer->data_sent++);
644 msg->round_number = htonl (current_round);
645 msg->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
646 peer->pings[current_round]++;
647 peer->ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (PING_PERIOD),
650 return sizeof (struct MeshPingMessage);
655 * Function is called whenever a PING message is received.
657 * @param cls closure (peer #, set from GNUNET_MESH_connect)
658 * @param channel connection to the other end
659 * @param channel_ctx place to store local state associated with the channel
660 * @param message the actual message
661 * @return GNUNET_OK to keep the connection open,
662 * GNUNET_SYSERR to close it (signal serious error)
665 ping_handler (void *cls, struct GNUNET_MESH_Channel *channel,
667 const struct GNUNET_MessageHeader *message)
671 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u got PING\n", n);
672 GNUNET_MESH_receive_done (channel);
673 if (GNUNET_NO == test_finished)
674 pong (channel, (struct MeshPingMessage *) message);
681 * Function is called whenever a PONG message is received.
683 * @param cls closure (peer #, set from GNUNET_MESH_connect)
684 * @param channel connection to the other end
685 * @param channel_ctx place to store local state associated with the channel
686 * @param message the actual message
687 * @return GNUNET_OK to keep the connection open,
688 * GNUNET_SYSERR to close it (signal serious error)
691 pong_handler (void *cls, struct GNUNET_MESH_Channel *channel,
693 const struct GNUNET_MessageHeader *message)
696 struct MeshPeer *peer;
697 struct MeshPingMessage *msg;
698 struct GNUNET_TIME_Absolute send_time;
699 struct GNUNET_TIME_Relative latency;
700 unsigned int r /* Ping round */;
703 GNUNET_MESH_receive_done (channel);
706 msg = (struct MeshPingMessage *) message;
708 send_time = GNUNET_TIME_absolute_ntoh (msg->timestamp);
709 latency = GNUNET_TIME_absolute_get_duration (send_time);
710 r = ntohl (msg->round_number);
711 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <- %u (%u) latency: %s\n",
712 get_index (peer), get_index (peer->dest), ntohl (msg->counter),
713 GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_NO));
715 /* Online variance calculation */
717 delta = latency.rel_value_us - peer->mean[r];
718 peer->mean[r] = peer->mean[r] + delta/peer->pongs[r];
719 peer->var[r] += delta * (latency.rel_value_us - peer->mean[r]);
726 * Handlers, for diverse services
728 static struct GNUNET_MESH_MessageHandler handlers[] = {
729 {&ping_handler, PING, sizeof (struct MeshPingMessage)},
730 {&pong_handler, PONG, sizeof (struct MeshPingMessage)},
736 * Method called whenever another peer has added us to a channel
737 * the other peer initiated.
739 * @param cls Closure.
740 * @param channel New handle to the channel.
741 * @param initiator Peer that started the channel.
742 * @param port Port this channel is connected to.
743 * @param options channel option flags
744 * @return Initial channel context for the channel
745 * (can be NULL -- that's not an error).
748 incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
749 const struct GNUNET_PeerIdentity *initiator,
750 uint32_t port, enum GNUNET_MESH_ChannelOption options)
753 struct MeshPeer *peer;
755 peer = GNUNET_CONTAINER_multipeermap_get (ids, initiator);
756 GNUNET_assert (NULL != peer);
757 GNUNET_assert (peer == peers[n].incoming);
758 GNUNET_assert (peer->dest == &peers[n]);
759 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u <= %u %p\n",
760 n, get_index (peer), channel);
761 peers[n].incoming_ch = channel;
767 * Function called whenever an inbound channel is destroyed. Should clean up
768 * any associated state.
770 * @param cls closure (set from GNUNET_MESH_connect)
771 * @param channel connection to the other end (henceforth invalid)
772 * @param channel_ctx place where local state associated
773 * with the channel is stored
776 channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel,
780 struct MeshPeer *peer = &peers[n];
782 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
783 "Channel %p disconnected at peer %ld\n", channel, n);
784 if (peer->ch == channel)
789 static struct MeshPeer *
790 select_random_peer (struct MeshPeer *peer)
796 r = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, TOTAL_PEERS);
797 } while (NULL != peers[r].incoming);
798 peers[r].incoming = peer;
804 * START THE TEST ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES.
806 * Testcase continues when the root receives confirmation of connected peers,
807 * on callback funtion ch.
809 * @param cls Closure (unsued).
810 * @param tc Task Context.
813 start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
815 enum GNUNET_MESH_ChannelOption flags;
818 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
821 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Start profiler\n");
823 flags = GNUNET_MESH_OPTION_DEFAULT;
824 for (i = 0; i < PING_PEERS; i++)
827 peers[i].dest = select_random_peer (&peers[i]);
828 peers[i].ch = GNUNET_MESH_channel_create (peers[i].mesh, NULL,
831 if (NULL == peers[i].ch)
833 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Channel %lu failed\n", i);
834 GNUNET_SCHEDULER_shutdown ();
837 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%u => %u %p\n",
838 i, get_index (peers[i].dest), peers[i].ch);
839 peers[i].ping_task = GNUNET_SCHEDULER_add_delayed (delay_ms_rnd (2000),
842 peers_running = TOTAL_PEERS;
843 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
844 GNUNET_SCHEDULER_cancel (disconnect_task);
846 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(ROUND_TIME,
848 &disconnect_mesh_peers,
850 GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL);
855 * Callback to be called when the requested peer information is available
857 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
858 * @param op the operation this callback corresponds to
859 * @param pinfo the result; will be NULL if the operation has failed
860 * @param emsg error message if the operation has failed;
861 * NULL if the operation is successfull
864 peer_id_cb (void *cls,
865 struct GNUNET_TESTBED_Operation *op,
866 const struct GNUNET_TESTBED_PeerInformation *pinfo,
871 if (NULL == pinfo || NULL != emsg)
873 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
874 abort_test (__LINE__);
877 peers[n].id = *(pinfo->result.id);
878 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " %u id: %s\n",
879 n, GNUNET_i2s (&peers[n].id));
880 GNUNET_break (GNUNET_OK ==
881 GNUNET_CONTAINER_multipeermap_put (ids, &peers[n].id, &peers[n],
882 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
884 GNUNET_TESTBED_operation_done (peers[n].op);
888 if (p_ids < TOTAL_PEERS)
890 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting profiler\n");
891 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
896 * test main: start test when all peers are connected
898 * @param cls Closure.
899 * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end.
900 * @param num_peers Number of peers that are running.
901 * @param testbed_peers Array of peers.
902 * @param meshes Handle to each of the MESHs of the peers.
906 struct GNUNET_MESH_TEST_Context *ctx,
907 unsigned int num_peers,
908 struct GNUNET_TESTBED_Peer **testbed_peers,
909 struct GNUNET_MESH_Handle **meshes)
913 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
915 GNUNET_assert (TOTAL_PEERS > 2 * PING_PEERS);
916 GNUNET_assert (TOTAL_PEERS == num_peers);
917 peers_running = num_peers;
918 testbed_handles = testbed_peers;
919 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
920 &disconnect_mesh_peers,
922 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
923 &shutdown_task, NULL);
924 for (i = 0; i < TOTAL_PEERS; i++)
926 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requesting id %ld\n", i);
927 peers[i].up = GNUNET_YES;
928 peers[i].mesh = meshes[i];
930 GNUNET_TESTBED_peer_get_information (testbed_handles[i],
931 GNUNET_TESTBED_PIT_IDENTITY,
932 &peer_id_cb, (void *) i);
934 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
935 /* Continues from pi_cb -> do_test */
940 * Main: start profiler.
943 main (int argc, char *argv[])
945 static uint32_t ports[2];
946 const char *config_file;
948 config_file = "profiler.conf";
950 ids = GNUNET_CONTAINER_multipeermap_create (2 * TOTAL_PEERS, GNUNET_YES);
951 GNUNET_assert (NULL != ids);
953 test_finished = GNUNET_NO;
956 GNUNET_MESH_TEST_run ("mesh-profiler", config_file, TOTAL_PEERS,
957 &tmain, NULL, /* tmain cls */
958 &incoming_channel, &channel_cleaner,
964 /* end of gnunet-mesh-profiler.c */