2 This file is part of GNUnet.
3 Copyright (C) 2009, 2012 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file rps/test_rps.c
22 * @brief Testcase for the random peer sampling service. Starts
23 * a peergroup with a given number of peers, then waits to
24 * receive size pushes/pulls from each peer. Expects to wait
25 * for one message from each peer.
28 #include "gnunet_util_lib.h"
29 #include "gnunet_testbed_service.h"
31 #include "gnunet_rps_service.h"
32 #include "rps-test_util.h"
33 #include "gnunet-service-rps_sampler_elem.h"
39 * How many peers do we start?
41 static uint32_t num_peers;
44 * How long do we run the test?
46 //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
47 static struct GNUNET_TIME_Relative timeout;
51 * Portion of malicious peers
53 static double portion = .1;
56 * Type of malicious peer to test
58 static unsigned int mal_type = 0;
61 * Handles to all of the running peers
63 static struct GNUNET_TESTBED_Peer **testbed_peers;
66 * @brief Indicates whether peer should go off- or online
68 enum PEER_ONLINE_DELTA {
70 * @brief Indicates peer going online
74 * @brief Indicates peer going offline
87 struct OpListEntry *next;
92 struct OpListEntry *prev;
95 * The testbed operation
97 struct GNUNET_TESTBED_Operation *op;
100 * Depending on whether we start or stop RPS service at the peer, set this to
101 * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1)
103 enum PEER_ONLINE_DELTA delta;
106 * Index of the regarding peer
114 static struct OpListEntry *oplist_head;
119 static struct OpListEntry *oplist_tail;
123 * A pending reply: A request was sent and the reply is pending.
130 struct PendingReply *next;
131 struct PendingReply *prev;
134 * Handle to the request we are waiting for
136 struct GNUNET_RPS_Request_Handle *req_handle;
139 * The peer that requested
141 struct RPSPeer *rps_peer;
146 * A pending request: A request was not made yet but is scheduled for later.
148 struct PendingRequest
153 struct PendingRequest *next;
154 struct PendingRequest *prev;
157 * Handle to the request we are waiting for
159 struct GNUNET_SCHEDULER_Task *request_task;
162 * The peer that requested
164 struct RPSPeer *rps_peer;
169 * Information we track for each peer.
179 * Handle for RPS connect operation.
181 struct GNUNET_TESTBED_Operation *op;
184 * Handle to RPS service.
186 struct GNUNET_RPS_Handle *rps_handle;
191 struct GNUNET_PeerIdentity *peer_id;
194 * A request handle to check for an request
196 //struct GNUNET_RPS_Request_Handle *req_handle;
199 * Peer on- or offline?
204 * Number of Peer IDs to request during the whole test
206 unsigned int num_ids_to_request;
209 * Pending requests DLL
211 struct PendingRequest *pending_req_head;
212 struct PendingRequest *pending_req_tail;
215 * Number of pending requests
217 unsigned int num_pending_reqs;
220 * Pending replies DLL
222 struct PendingReply *pending_rep_head;
223 struct PendingReply *pending_rep_tail;
226 * Number of pending replies
228 unsigned int num_pending_reps;
231 * Number of received PeerIDs
233 unsigned int num_recv_ids;
236 * Pending operation on that peer
238 const struct OpListEntry *entry_op_manage;
241 * Testbed operation to connect to statistics service
243 struct GNUNET_TESTBED_Operation *stat_op;
246 * Handle to the statistics service
248 struct GNUNET_STATISTICS_Handle *stats_h;
251 * @brief flags to indicate which statistics values have been already
252 * collected from the statistics service.
253 * Used to check whether we are able to shutdown.
255 uint32_t stat_collected_flags;
258 * @brief File name of the file the stats are finally written to
260 char *file_name_stats;
263 * @brief The current view
265 struct GNUNET_PeerIdentity *cur_view;
268 * @brief Number of peers in the #cur_view.
270 uint32_t cur_view_count;
273 * @brief statistics values
277 uint64_t num_blocks_many_push;
278 uint64_t num_blocks_no_push;
279 uint64_t num_blocks_no_pull;
280 uint64_t num_blocks_many_push_no_pull;
281 uint64_t num_blocks_no_push_no_pull;
282 uint64_t num_issued_push;
283 uint64_t num_issued_pull_req;
284 uint64_t num_issued_pull_rep;
285 uint64_t num_sent_push;
286 uint64_t num_sent_pull_req;
287 uint64_t num_sent_pull_rep;
288 uint64_t num_recv_push;
289 uint64_t num_recv_pull_req;
290 uint64_t num_recv_pull_rep;
295 STAT_TYPE_ROUNDS = 0x1, /* 1 */
296 STAT_TYPE_BLOCKS = 0x2, /* 2 */
297 STAT_TYPE_BLOCKS_MANY_PUSH = 0x4, /* 3 */
298 STAT_TYPE_BLOCKS_NO_PUSH = 0x8, /* 4 */
299 STAT_TYPE_BLOCKS_NO_PULL = 0x10, /* 5 */
300 STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL = 0x20, /* 6 */
301 STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL = 0x40, /* 7 */
302 STAT_TYPE_ISSUED_PUSH_SEND = 0x80, /* 8 */
303 STAT_TYPE_ISSUED_PULL_REQ = 0x100, /* 9 */
304 STAT_TYPE_ISSUED_PULL_REP = 0x200, /* 10 */
305 STAT_TYPE_SENT_PUSH_SEND = 0x400, /* 11 */
306 STAT_TYPE_SENT_PULL_REQ = 0x800, /* 12 */
307 STAT_TYPE_SENT_PULL_REP = 0x1000, /* 13 */
308 STAT_TYPE_RECV_PUSH_SEND = 0x2000, /* 14 */
309 STAT_TYPE_RECV_PULL_REQ = 0x4000, /* 15 */
310 STAT_TYPE_RECV_PULL_REP = 0x8000, /* 16 */
311 STAT_TYPE_MAX = 0x80000000, /* 32 */
316 struct RPSPeer *rps_peer;
317 enum STAT_TYPE stat_type;
322 * Information for all the peers.
324 static struct RPSPeer *rps_peers;
327 * Peermap to get the index of a given peer ID quick.
329 static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
334 static struct GNUNET_PeerIdentity *rps_peer_ids;
337 * ID of the targeted peer.
339 static struct GNUNET_PeerIdentity *target_peer;
342 * ID of the peer that requests for the evaluation.
344 static struct RPSPeer *eval_peer;
347 * Number of online peers.
349 static unsigned int num_peers_online;
352 * Return value from 'main'.
357 * Identifier for the churn task that runs periodically
359 static struct GNUNET_SCHEDULER_Task *shutdown_task;
362 * Identifier for the churn task that runs periodically
364 static struct GNUNET_SCHEDULER_Task *churn_task;
367 * Called to initialise the given RPSPeer
369 typedef void (*InitPeer) (struct RPSPeer *rps_peer);
372 * @brief Called directly after connecting to the service
374 * @param rps_peer Specific peer the function is called on
375 * @param h the handle to the rps service
377 typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h);
380 * @brief Executes functions to test the api/service for a given peer
382 * Called from within #rps_connect_complete_cb ()
383 * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb,
384 * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb
386 * @param rps_peer the peer the task runs on
388 typedef void (*MainTest) (struct RPSPeer *rps_peer);
391 * Callback called once the requested random peers are available
393 typedef void (*ReplyHandle) (void *cls,
395 const struct GNUNET_PeerIdentity *recv_peers);
398 * Called directly before disconnecting from the service
400 typedef void (*PostTest) (struct RPSPeer *peer);
403 * Function called after disconnect to evaluate test success
405 typedef int (*EvaluationCallback) (void);
408 * @brief Do we have Churn?
412 * @brief If we have churn this is set
416 * @brief If we have no churn this is set
422 * @brief Is it ok to quit the test before the timeout?
424 enum OPTION_QUICK_QUIT {
426 * @brief It is ok for the test to quit before the timeout triggers
431 * @brief It is NOT ok for the test to quit before the timeout triggers
437 * @brief Do we collect statistics at the end?
439 enum OPTION_COLLECT_STATISTICS {
441 * @brief We collect statistics at the end
446 * @brief We do not collect statistics at the end
448 NO_COLLECT_STATISTICS,
452 * @brief Do we collect views during run?
454 enum OPTION_COLLECT_VIEW {
456 * @brief We collect view during run
461 * @brief We do not collect the view during run
467 * Structure to define a single test
477 * Called with a single peer in order to initialise that peer
482 * Called directly after connecting to the service
487 * Main function for each peer
492 * Callback called once the requested peers are available
494 ReplyHandle reply_handle;
497 * Called directly before disconnecting from the service
502 * Function to evaluate the test results
504 EvaluationCallback eval_cb;
509 uint32_t request_interval;
512 * Number of Requests to make.
514 uint32_t num_requests;
517 * Run with (-out) churn
519 enum OPTION_CHURN have_churn;
522 * Quit test before timeout?
524 enum OPTION_QUICK_QUIT have_quick_quit;
527 * Collect statistics at the end?
529 enum OPTION_COLLECT_STATISTICS have_collect_statistics;
532 * Collect view during run?
534 enum OPTION_COLLECT_VIEW have_collect_view;
537 * @brief Mark which values from the statistics service to collect at the end
540 uint32_t stat_collect_flags;
544 * Are we shutting down?
546 static int in_shutdown;
549 * Append arguments to file
552 tofile_ (const char *file_name, const char *line)
554 struct GNUNET_DISK_FileHandle *f;
555 /* char output_buffer[512]; */
560 if (NULL == (f = GNUNET_DISK_file_open (file_name,
561 GNUNET_DISK_OPEN_APPEND |
562 GNUNET_DISK_OPEN_WRITE |
563 GNUNET_DISK_OPEN_CREATE,
564 GNUNET_DISK_PERM_USER_READ |
565 GNUNET_DISK_PERM_USER_WRITE |
566 GNUNET_DISK_PERM_GROUP_READ |
567 GNUNET_DISK_PERM_OTHER_READ)))
569 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
570 "Not able to open file %s\n",
574 /* size = GNUNET_snprintf (output_buffer,
575 sizeof (output_buffer),
577 GNUNET_TIME_absolute_get ().abs_value_us,
581 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
582 "Failed to write string to buffer (size: %i)\n",
587 size = strlen (line) * sizeof (char);
589 size2 = GNUNET_DISK_file_write (f, line, size);
592 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
593 "Unable to write to file! (Size: %lu, size2: %lu)\n",
596 if (GNUNET_YES != GNUNET_DISK_file_close (f))
598 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
599 "Unable to close file\n");
604 if (GNUNET_YES != GNUNET_DISK_file_close (f))
606 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
607 "Unable to close file\n");
612 * This function is used to facilitate writing important information to disk
614 #define tofile(file_name, ...) do {\
617 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
619 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
620 "Failed to create tmp_buf\n");\
622 tofile_(file_name,tmp_buf);\
627 * Write the ids and their according index in the given array to a file
631 ids_to_file (char *file_name,
632 struct GNUNET_PeerIdentity *peer_ids,
633 unsigned int num_peer_ids)
637 for (i=0 ; i < num_peer_ids ; i++)
642 GNUNET_i2s_full (&peer_ids[i]));
647 * Test the success of a single test
657 for (i = 0; i < num_peers; i++)
659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
660 "%u. peer [%s] received %u of %u expected peer_ids: %i\n",
662 GNUNET_i2s (rps_peers[i].peer_id),
663 rps_peers[i].num_recv_ids,
664 rps_peers[i].num_ids_to_request,
665 (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids));
666 tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids);
668 return tmp_ok? 0 : 1;
673 * Creates an oplist entry and adds it to the oplist DLL
675 static struct OpListEntry *
678 struct OpListEntry *entry;
680 entry = GNUNET_new (struct OpListEntry);
681 GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
687 * @brief Checks if given peer already received its statistics value from the
688 * statistics service.
690 * @param rps_peer the peer to check for
692 * @return #GNUNET_YES if so
693 * #GNUNET_NO otherwise
695 static int check_statistics_collect_completed_single_peer (
696 const struct RPSPeer *rps_peer)
698 if (cur_test_run.stat_collect_flags !=
699 (cur_test_run.stat_collect_flags &
700 rps_peer->stat_collected_flags))
707 * @brief Checks if all peers already received their statistics value from the
708 * statistics service.
710 * @return #GNUNET_YES if so
711 * #GNUNET_NO otherwise
713 static int check_statistics_collect_completed ()
717 for (i = 0; i < num_peers; i++)
719 if (GNUNET_NO == check_statistics_collect_completed_single_peer (&rps_peers[i]))
721 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
722 "At least Peer %" PRIu32 " did not yet receive all statistics values\n",
727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
728 "All peers received their statistics values\n");
733 * Task run on timeout to shut everything down.
736 shutdown_op (void *cls)
740 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
741 "Shutdown task scheduled, going down.\n");
742 in_shutdown = GNUNET_YES;
743 if (NULL != churn_task)
745 GNUNET_SCHEDULER_cancel (churn_task);
748 for (i = 0; i < num_peers; i++)
750 if (NULL != rps_peers[i].op)
751 GNUNET_TESTBED_operation_done (rps_peers[i].op);
752 if (NULL != cur_test_run.post_test)
754 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i);
755 cur_test_run.post_test (&rps_peers[i]);
758 /* If we do not collect statistics, shut down directly */
759 if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics ||
760 GNUNET_YES == check_statistics_collect_completed())
762 GNUNET_SCHEDULER_shutdown ();
771 seed_peers (void *cls)
773 struct RPSPeer *peer = cls;
777 // TODO if malicious don't seed mal peers
778 amount = round (.5 * num_peers);
780 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n");
781 for (i = 0 ; i < amount ; i++)
782 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
784 GNUNET_i2s (&rps_peer_ids[i]));
786 GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
794 seed_peers_big (void *cls)
796 struct RPSPeer *peer = cls;
797 unsigned int seed_msg_size;
798 uint32_t num_peers_max;
802 seed_msg_size = 8; /* sizeof (struct GNUNET_RPS_CS_SeedMessage) */
803 num_peers_max = (GNUNET_MAX_MESSAGE_SIZE - seed_msg_size) /
804 sizeof (struct GNUNET_PeerIdentity);
805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
806 "Peers that fit in one seed msg; %u\n",
808 amount = num_peers_max + (0.5 * num_peers_max);
809 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
810 "Seeding many (%u) peers:\n",
812 struct GNUNET_PeerIdentity ids_to_seed[amount];
813 for (i = 0; i < amount; i++)
815 ids_to_seed[i] = *peer->peer_id;
816 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
818 GNUNET_i2s (&ids_to_seed[i]));
821 GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed);
825 * Get the id of peer i.
828 info_cb (void *cb_cls,
829 struct GNUNET_TESTBED_Operation *op,
830 const struct GNUNET_TESTBED_PeerInformation *pinfo,
833 struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
835 if (GNUNET_YES == in_shutdown)
840 if (NULL == pinfo || NULL != emsg)
842 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
843 GNUNET_TESTBED_operation_done (entry->op);
847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
850 GNUNET_i2s (pinfo->result.id));
852 rps_peer_ids[entry->index] = *(pinfo->result.id);
853 rps_peers[entry->index].peer_id = &rps_peer_ids[entry->index];
855 GNUNET_assert (GNUNET_OK ==
856 GNUNET_CONTAINER_multipeermap_put (peer_map,
857 &rps_peer_ids[entry->index],
858 &rps_peers[entry->index],
859 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
860 tofile ("/tmp/rps/peer_ids",
863 GNUNET_i2s_full (&rps_peer_ids[entry->index]));
865 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
866 GNUNET_TESTBED_operation_done (entry->op);
872 * Callback to be called when RPS service connect operation is completed
874 * @param cls the callback closure from functions generating an operation
875 * @param op the operation that has been finished
876 * @param ca_result the RPS service handle returned from rps_connect_adapter
877 * @param emsg error message in case the operation has failed; will be NULL if
878 * operation has executed successfully.
881 rps_connect_complete_cb (void *cls,
882 struct GNUNET_TESTBED_Operation *op,
886 struct RPSPeer *rps_peer = cls;
887 struct GNUNET_RPS_Handle *rps = ca_result;
889 if (GNUNET_YES == in_shutdown)
894 rps_peer->rps_handle = rps;
895 rps_peer->online = GNUNET_YES;
898 GNUNET_assert (op == rps_peer->op);
901 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
902 "Failed to connect to RPS service: %s\n",
905 GNUNET_SCHEDULER_shutdown ();
909 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started client successfully\n");
911 cur_test_run.main_test (rps_peer);
916 * Adapter function called to establish a connection to
920 * @param cfg configuration of the peer to connect to; will be available until
921 * GNUNET_TESTBED_operation_done() is called on the operation returned
922 * from GNUNET_TESTBED_service_connect()
923 * @return service handle to return in 'op_result', NULL on error
926 rps_connect_adapter (void *cls,
927 const struct GNUNET_CONFIGURATION_Handle *cfg)
929 struct GNUNET_RPS_Handle *h;
931 h = GNUNET_RPS_connect (cfg);
933 if (NULL != cur_test_run.pre_test)
934 cur_test_run.pre_test (cls, h);
940 * Called to open a connection to the peer's statistics
942 * @param cls peer context
943 * @param cfg configuration of the peer to connect to; will be available until
944 * GNUNET_TESTBED_operation_done() is called on the operation returned
945 * from GNUNET_TESTBED_service_connect()
946 * @return service handle to return in 'op_result', NULL on error
949 stat_connect_adapter (void *cls,
950 const struct GNUNET_CONFIGURATION_Handle *cfg)
952 struct RPSPeer *peer = cls;
954 peer->stats_h = GNUNET_STATISTICS_create ("rps-profiler", cfg);
955 return peer->stats_h;
959 * Called to disconnect from peer's statistics service
961 * @param cls peer context
962 * @param op_result service handle returned from the connect adapter
965 stat_disconnect_adapter (void *cls, void *op_result)
967 struct RPSPeer *peer = cls;
969 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
970 // (peer->stats_h, "core", "# peers connected",
971 // stat_iterator, peer));
972 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
973 // (peer->stats_h, "nse", "# peers connected",
974 // stat_iterator, peer));
975 GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
976 peer->stats_h = NULL;
980 * Called after successfully opening a connection to a peer's statistics
981 * service; we register statistics monitoring for CORE and NSE here.
983 * @param cls the callback closure from functions generating an operation
984 * @param op the operation that has been finished
985 * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
986 * @param emsg error message in case the operation has failed; will be NULL if
987 * operation has executed successfully.
990 stat_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
991 void *ca_result, const char *emsg )
993 //struct GNUNET_STATISTICS_Handle *sh = ca_result;
994 //struct RPSPeer *peer = (struct RPSPeer *) cls;
1001 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
1002 // (sh, "core", "# peers connected",
1003 // stat_iterator, peer));
1004 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
1005 // (sh, "nse", "# peers connected",
1006 // stat_iterator, peer));
1011 * Adapter function called to destroy connection to
1014 * @param cls closure
1015 * @param op_result service handle returned from the connect adapter
1018 rps_disconnect_adapter (void *cls,
1021 struct RPSPeer *peer = cls;
1022 struct GNUNET_RPS_Handle *h = op_result;
1023 GNUNET_assert (NULL != peer);
1024 GNUNET_RPS_disconnect (h);
1025 peer->rps_handle = NULL;
1029 /***********************************************************************
1030 * Definition of tests
1031 ***********************************************************************/
1033 // TODO check whether tests can be stopped earlier
1035 default_eval_cb (void)
1047 * Initialise given RPSPeer
1049 static void default_init_peer (struct RPSPeer *rps_peer)
1051 rps_peer->num_ids_to_request = 1;
1055 * Callback to call on receipt of a reply
1057 * @param cls closure
1058 * @param n number of peers
1059 * @param recv_peers the received peers
1062 default_reply_handle (void *cls,
1064 const struct GNUNET_PeerIdentity *recv_peers)
1066 struct RPSPeer *rps_peer;
1067 struct PendingReply *pending_rep = (struct PendingReply *) cls;
1070 rps_peer = pending_rep->rps_peer;
1071 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
1072 rps_peer->pending_rep_tail,
1074 rps_peer->num_pending_reps--;
1075 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1076 "[%s] got %" PRIu64 " peers:\n",
1077 GNUNET_i2s (rps_peer->peer_id),
1080 for (i = 0; i < n; i++)
1082 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1085 GNUNET_i2s (&recv_peers[i]));
1087 rps_peer->num_recv_ids++;
1090 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)
1092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
1093 GNUNET_assert (NULL != shutdown_task);
1094 GNUNET_SCHEDULER_cancel (shutdown_task);
1095 shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL);
1096 GNUNET_assert (NULL!= shutdown_task);
1101 * Request random peers.
1104 request_peers (void *cls)
1106 struct PendingRequest *pending_req = cls;
1107 struct RPSPeer *rps_peer;
1108 struct PendingReply *pending_rep;
1110 if (GNUNET_YES == in_shutdown)
1112 rps_peer = pending_req->rps_peer;
1113 GNUNET_assert (1 <= rps_peer->num_pending_reqs);
1114 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
1115 rps_peer->pending_req_tail,
1117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1118 "Requesting one peer\n");
1119 pending_rep = GNUNET_new (struct PendingReply);
1120 pending_rep->rps_peer = rps_peer;
1121 pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle,
1123 cur_test_run.reply_handle,
1125 GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head,
1126 rps_peer->pending_rep_tail,
1128 rps_peer->num_pending_reps++;
1129 rps_peer->num_pending_reqs--;
1133 cancel_pending_req (struct PendingRequest *pending_req)
1135 struct RPSPeer *rps_peer;
1137 rps_peer = pending_req->rps_peer;
1138 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
1139 rps_peer->pending_req_tail,
1141 rps_peer->num_pending_reqs--;
1142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1143 "Cancelling pending request\n");
1144 GNUNET_SCHEDULER_cancel (pending_req->request_task);
1145 GNUNET_free (pending_req);
1149 cancel_request (struct PendingReply *pending_rep)
1151 struct RPSPeer *rps_peer;
1153 rps_peer = pending_rep->rps_peer;
1154 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
1155 rps_peer->pending_rep_tail,
1157 rps_peer->num_pending_reps--;
1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1159 "Cancelling request\n");
1160 GNUNET_RPS_request_cancel (pending_rep->req_handle);
1161 GNUNET_free (pending_rep);
1168 cancel_request_cb (void *cls)
1170 struct RPSPeer *rps_peer = cls;
1171 struct PendingReply *pending_rep;
1173 if (GNUNET_YES == in_shutdown)
1175 pending_rep = rps_peer->pending_rep_head;
1176 GNUNET_assert (1 <= rps_peer->num_pending_reps);
1177 cancel_request (pending_rep);
1182 * Schedule requests for peer @a rps_peer that have neither been scheduled, nor
1183 * issued, nor replied
1186 schedule_missing_requests (struct RPSPeer *rps_peer)
1189 struct PendingRequest *pending_req;
1191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1192 "Scheduling %u - %u missing requests\n",
1193 rps_peer->num_ids_to_request,
1194 rps_peer->num_pending_reqs + rps_peer->num_pending_reps);
1195 GNUNET_assert (rps_peer->num_pending_reqs + rps_peer->num_pending_reps <=
1196 rps_peer->num_ids_to_request);
1197 for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps;
1198 i < rps_peer->num_ids_to_request; i++)
1200 pending_req = GNUNET_new (struct PendingRequest);
1201 pending_req->rps_peer = rps_peer;
1202 pending_req->request_task = GNUNET_SCHEDULER_add_delayed (
1203 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
1204 cur_test_run.request_interval * i),
1207 GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_req_head,
1208 rps_peer->pending_req_tail,
1210 rps_peer->num_pending_reqs++;
1215 cancel_pending_req_rep (struct RPSPeer *rps_peer)
1217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1218 "Cancelling all (pending) requests.\n");
1219 while (NULL != rps_peer->pending_req_head)
1220 cancel_pending_req (rps_peer->pending_req_head);
1221 GNUNET_assert (0 == rps_peer->num_pending_reqs);
1222 while (NULL != rps_peer->pending_rep_head)
1223 cancel_request (rps_peer->pending_rep_head);
1224 GNUNET_assert (0 == rps_peer->num_pending_reps);
1227 /***********************************
1229 ***********************************/
1232 * Initialise only non-mal RPSPeers
1234 static void mal_init_peer (struct RPSPeer *rps_peer)
1236 if (rps_peer->index >= round (portion * num_peers))
1237 rps_peer->num_ids_to_request = 1;
1242 * @brief Set peers to (non-)malicious before execution
1244 * Of signature #PreTest
1246 * @param rps_peer the peer to set (non-) malicious
1247 * @param h the handle to the service
1250 mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1252 #ifdef ENABLE_MALICIOUS
1253 uint32_t num_mal_peers;
1255 GNUNET_assert ( (1 >= portion) &&
1257 num_mal_peers = round (portion * num_peers);
1259 if (rps_peer->index < num_mal_peers)
1261 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1262 "%u. peer [%s] of %" PRIu32 " malicious peers turning malicious\n",
1264 GNUNET_i2s (rps_peer->peer_id),
1267 GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
1268 rps_peer_ids, target_peer);
1270 #endif /* ENABLE_MALICIOUS */
1274 mal_cb (struct RPSPeer *rps_peer)
1276 uint32_t num_mal_peers;
1278 if (GNUNET_YES == in_shutdown)
1283 #ifdef ENABLE_MALICIOUS
1284 GNUNET_assert ( (1 >= portion) &&
1286 num_mal_peers = round (portion * num_peers);
1288 if (rps_peer->index >= num_mal_peers)
1289 { /* It's useless to ask a malicious peer about a random sample -
1290 it's not sampling */
1291 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1292 seed_peers, rps_peer);
1293 schedule_missing_requests (rps_peer);
1295 #endif /* ENABLE_MALICIOUS */
1299 /***********************************
1301 ***********************************/
1303 single_req_cb (struct RPSPeer *rps_peer)
1305 if (GNUNET_YES == in_shutdown)
1310 schedule_missing_requests (rps_peer);
1313 /***********************************
1315 ***********************************/
1317 delay_req_cb (struct RPSPeer *rps_peer)
1319 if (GNUNET_YES == in_shutdown)
1324 schedule_missing_requests (rps_peer);
1327 /***********************************
1329 ***********************************/
1331 seed_cb (struct RPSPeer *rps_peer)
1333 if (GNUNET_YES == in_shutdown)
1338 GNUNET_SCHEDULER_add_delayed (
1339 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
1340 seed_peers, rps_peer);
1343 /***********************************
1345 ***********************************/
1347 seed_big_cb (struct RPSPeer *rps_peer)
1349 if (GNUNET_YES == in_shutdown)
1354 // TODO test seeding > GNUNET_MAX_MESSAGE_SIZE peers
1355 GNUNET_SCHEDULER_add_delayed (
1356 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1357 seed_peers_big, rps_peer);
1360 /***********************************
1362 ***********************************/
1364 single_peer_seed_cb (struct RPSPeer *rps_peer)
1369 /***********************************
1371 ***********************************/
1373 seed_req_cb (struct RPSPeer *rps_peer)
1375 if (GNUNET_YES == in_shutdown)
1380 GNUNET_SCHEDULER_add_delayed (
1381 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1382 seed_peers, rps_peer);
1383 schedule_missing_requests (rps_peer);
1386 //TODO start big mal
1388 /***********************************
1390 ***********************************/
1392 req_cancel_cb (struct RPSPeer *rps_peer)
1394 if (GNUNET_YES == in_shutdown)
1399 schedule_missing_requests (rps_peer);
1400 GNUNET_SCHEDULER_add_delayed (
1401 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
1402 (cur_test_run.request_interval + 1)),
1403 cancel_request_cb, rps_peer);
1406 /***********************************
1408 ***********************************/
1414 * @brief Starts churn
1416 * Has signature of #MainTest
1418 * This is not implemented too nicely as this is called for each peer, but we
1419 * only need to call it once. (Yes we check that we only schedule the task
1422 * @param rps_peer The peer it's called for
1425 churn_test_cb (struct RPSPeer *rps_peer)
1427 if (GNUNET_YES == in_shutdown)
1433 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1436 "Starting churn task\n");
1437 churn_task = GNUNET_SCHEDULER_add_delayed (
1438 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
1442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1443 "Not starting churn task\n");
1446 schedule_missing_requests (rps_peer);
1449 /***********************************
1451 ***********************************/
1454 * Callback to be called when RPS service is started or stopped at peers
1457 * @param op the operation handle
1458 * @param emsg NULL on success; otherwise an error description
1461 churn_cb (void *cls,
1462 struct GNUNET_TESTBED_Operation *op,
1466 struct OpListEntry *entry = cls;
1468 if (GNUNET_YES == in_shutdown)
1473 GNUNET_TESTBED_operation_done (entry->op);
1476 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n");
1477 GNUNET_SCHEDULER_shutdown ();
1480 GNUNET_assert (0 != entry->delta);
1482 num_peers_online += entry->delta;
1484 if (PEER_GO_OFFLINE == entry->delta)
1485 { /* Peer hopefully just went offline */
1486 if (GNUNET_YES != rps_peers[entry->index].online)
1488 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1489 "peer %s was expected to go offline but is still marked as online\n",
1490 GNUNET_i2s (rps_peers[entry->index].peer_id));
1495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1496 "peer %s probably went offline as expected\n",
1497 GNUNET_i2s (rps_peers[entry->index].peer_id));
1499 rps_peers[entry->index].online = GNUNET_NO;
1502 else if (PEER_GO_ONLINE < entry->delta)
1503 { /* Peer hopefully just went online */
1504 if (GNUNET_NO != rps_peers[entry->index].online)
1506 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1507 "peer %s was expected to go online but is still marked as offline\n",
1508 GNUNET_i2s (rps_peers[entry->index].peer_id));
1513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1514 "peer %s probably went online as expected\n",
1515 GNUNET_i2s (rps_peers[entry->index].peer_id));
1516 if (NULL != cur_test_run.pre_test)
1518 cur_test_run.pre_test (&rps_peers[entry->index],
1519 rps_peers[entry->index].rps_handle);
1520 schedule_missing_requests (&rps_peers[entry->index]);
1523 rps_peers[entry->index].online = GNUNET_YES;
1527 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1528 "Invalid value for delta: %i\n", entry->delta);
1532 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
1533 rps_peers[entry->index].entry_op_manage = NULL;
1534 GNUNET_free (entry);
1535 //if (num_peers_in_round[current_round] == peers_running)
1540 * @brief Set the rps-service up or down for a specific peer
1542 * @param i index of action
1543 * @param j index of peer
1544 * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1)
1545 * @param prob_go_on_off the probability of the action
1548 manage_service_wrapper (unsigned int i, unsigned int j,
1549 enum PEER_ONLINE_DELTA delta,
1550 double prob_go_on_off)
1552 struct OpListEntry *entry = NULL;
1555 /* make sure that management operation is not already scheduled */
1556 if (NULL != rps_peers[j].entry_op_manage)
1561 prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1564 "%u. selected peer (%u: %s) is %s.\n",
1567 GNUNET_i2s (rps_peers[j].peer_id),
1568 (PEER_GO_ONLINE == delta) ? "online" : "offline");
1569 if (prob < prob_go_on_off * UINT32_MAX)
1571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1573 GNUNET_i2s (rps_peers[j].peer_id),
1574 (PEER_GO_OFFLINE == delta) ? "offline" : "online");
1576 if (PEER_GO_OFFLINE == delta)
1577 cancel_pending_req_rep (&rps_peers[j]);
1578 entry = make_oplist_entry ();
1579 entry->delta = delta;
1581 entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
1586 (PEER_GO_OFFLINE == delta) ? 0 : 1);
1587 rps_peers[j].entry_op_manage = entry;
1597 double portion_online;
1598 unsigned int *permut;
1599 double prob_go_offline;
1600 double portion_go_online;
1601 double portion_go_offline;
1603 if (GNUNET_YES == in_shutdown)
1607 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1608 "Churn function executing\n");
1610 churn_task = NULL; /* Should be invalid by now */
1612 /* Compute the probability for an online peer to go offline
1614 portion_online = num_peers_online * 1.0 / num_peers;
1615 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1616 "Portion online: %f\n",
1618 portion_go_online = ((1 - portion_online) * .5 * .66);
1619 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1620 "Portion that should go online: %f\n",
1622 portion_go_offline = (portion_online + portion_go_online) - .75;
1623 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1624 "Portion that probably goes offline: %f\n",
1625 portion_go_offline);
1626 prob_go_offline = portion_go_offline / (portion_online * .5);
1627 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1628 "Probability of a selected online peer to go offline: %f\n",
1631 permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
1632 (unsigned int) num_peers);
1634 /* Go over 50% randomly chosen peers */
1635 for (i = 0; i < .5 * num_peers; i++)
1639 /* If online, shut down with certain probability */
1640 if (GNUNET_YES == rps_peers[j].online)
1642 manage_service_wrapper (i, j, -1, prob_go_offline);
1645 /* If offline, restart with certain probability */
1646 else if (GNUNET_NO == rps_peers[j].online)
1648 manage_service_wrapper (i, j, 1, 0.66);
1652 GNUNET_free (permut);
1654 churn_task = GNUNET_SCHEDULER_add_delayed (
1655 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1662 * Initialise given RPSPeer
1664 static void profiler_init_peer (struct RPSPeer *rps_peer)
1666 if (num_peers - 1 == rps_peer->index)
1667 rps_peer->num_ids_to_request = cur_test_run.num_requests;
1672 * Callback to call on receipt of a reply
1674 * @param cls closure
1675 * @param n number of peers
1676 * @param recv_peers the received peers
1679 profiler_reply_handle (void *cls,
1681 const struct GNUNET_PeerIdentity *recv_peers)
1683 struct RPSPeer *rps_peer;
1684 struct RPSPeer *rcv_rps_peer;
1688 struct PendingReply *pending_rep = (struct PendingReply *) cls;
1690 rps_peer = pending_rep->rps_peer;
1691 file_name = "/tmp/rps/received_ids";
1692 file_name_dh = "/tmp/rps/diehard_input";
1693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1694 "[%s] got %" PRIu64 " peers:\n",
1695 GNUNET_i2s (rps_peer->peer_id),
1697 for (i = 0; i < n; i++)
1699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1702 GNUNET_i2s (&recv_peers[i]));
1705 GNUNET_i2s_full (&recv_peers[i]));
1706 rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]);
1707 GNUNET_assert (NULL != rcv_rps_peer);
1708 tofile (file_name_dh,
1710 (uint32_t) rcv_rps_peer->index);
1712 default_reply_handle (cls, n, recv_peers);
1717 profiler_cb (struct RPSPeer *rps_peer)
1719 if (GNUNET_YES == in_shutdown)
1725 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1728 "Starting churn task\n");
1729 churn_task = GNUNET_SCHEDULER_add_delayed (
1730 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
1734 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1735 "Not starting churn task\n");
1738 /* Only request peer ids at one peer.
1739 * (It's the before-last because last one is target of the focussed attack.)
1741 if (eval_peer == rps_peer)
1742 schedule_missing_requests (rps_peer);
1746 * Function called from #profiler_eval with a filename.
1748 * @param cls closure
1749 * @param filename complete filename (absolute path)
1750 * @return #GNUNET_OK to continue to iterate,
1751 * #GNUNET_NO to stop iteration with no error,
1752 * #GNUNET_SYSERR to abort iteration with error!
1755 file_name_cb (void *cls, const char *filename)
1757 if (NULL != strstr (filename, "sampler_el"))
1759 struct RPS_SamplerElement *s_elem;
1760 struct GNUNET_CRYPTO_AuthKey auth_key;
1761 const char *key_char;
1764 key_char = filename + 20; /* Length of "/tmp/rps/sampler_el-" */
1765 tofile (filename, "--------------------------\n");
1767 auth_key = string_to_auth_key (key_char);
1768 s_elem = RPS_sampler_elem_create ();
1769 RPS_sampler_elem_set (s_elem, auth_key);
1771 for (i = 0; i < num_peers; i++)
1773 RPS_sampler_elem_next (s_elem, &rps_peer_ids[i]);
1775 RPS_sampler_elem_destroy (s_elem);
1781 * This is run after the test finished.
1783 * Compute all perfect samples.
1786 profiler_eval (void)
1788 /* Compute perfect sample for each sampler element */
1789 if (-1 == GNUNET_DISK_directory_scan ("/tmp/rps/", file_name_cb, NULL))
1791 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n");
1798 * @brief Try to ensure that `/tmp/rps` exists.
1800 * @return #GNUNET_YES on success
1801 * #GNUNET_SYSERR on failure
1803 static int ensure_folder_exist (void)
1805 if (GNUNET_NO == GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
1807 GNUNET_DISK_directory_create ("/tmp/rps");
1809 if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
1811 return GNUNET_SYSERR;
1817 store_stats_file_name (struct RPSPeer *rps_peer)
1819 unsigned int len_file_name;
1820 unsigned int out_size;
1823 if (GNUNET_SYSERR == ensure_folder_exist()) return;
1824 len_file_name = (14 + strlen (GNUNET_i2s_full (rps_peer->peer_id)) + 1) * sizeof (char);
1825 file_name = GNUNET_malloc (len_file_name);
1826 out_size = GNUNET_snprintf (file_name,
1829 GNUNET_i2s_full (rps_peer->peer_id));
1830 if (len_file_name < out_size ||
1833 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1834 "Failed to write string to buffer (size: %i, out_size: %i)\n",
1838 rps_peer->file_name_stats = file_name;
1841 void count_peer_in_views (uint32_t *count_peers)
1845 for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
1847 for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
1849 if (0 == memcmp (rps_peers[i].peer_id,
1850 &rps_peers[i].cur_view[j],
1851 sizeof (struct GNUNET_PeerIdentity)))
1859 void compute_diversity ()
1862 /* ith entry represents the numer of occurrences in other peer's views */
1863 uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t);
1864 uint32_t views_total_size;
1866 /* deviation from expected number of peers */
1867 double *deviation = GNUNET_new_array (num_peers, double);
1869 views_total_size = 0;
1872 /* For each peer count its representation in other peer's views*/
1873 for (i = 0; i < num_peers; i++) /* Peer to count */
1875 views_total_size += rps_peers[i].cur_view_count;
1876 count_peer_in_views (count_peers);
1877 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1878 "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32"\n",
1880 GNUNET_i2s (rps_peers[i].peer_id),
1884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1885 "size of all views combined: %" PRIu32 "\n",
1887 expected = ((double) 1/num_peers) * views_total_size;
1888 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1889 "Expected number of occurrences of each peer in all views: %f\n",
1891 for (i = 0; i < num_peers; i++) /* Peer to count */
1893 deviation[i] = expected - count_peers[i];
1894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1895 "Deviation from expectation: %f\n", deviation[i]);
1897 GNUNET_free (count_peers);
1898 GNUNET_free (deviation);
1901 void print_view_sizes()
1905 for (i = 0; i < num_peers; i++) /* Peer to count */
1907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1908 "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
1910 GNUNET_i2s (rps_peers[i].peer_id),
1911 rps_peers[i].cur_view_count);
1915 void all_views_updated_cb()
1917 compute_diversity();
1921 void view_update_cb (void *cls,
1923 const struct GNUNET_PeerIdentity *peers)
1925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1926 "View was updated (%" PRIu64 ")\n", num_peers);
1927 struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
1928 to_file ("/tmp/rps/view_sizes.txt",
1929 "%" PRIu64 " %" PRIu32 "",
1932 for (int i = 0; i < num_peers; i++)
1934 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1935 "\t%s\n", GNUNET_i2s (&peers[i]));
1937 GNUNET_array_grow (rps_peer->cur_view,
1938 rps_peer->cur_view_count,
1940 //*rps_peer->cur_view = *peers;
1941 memcpy (rps_peer->cur_view,
1943 num_peers * sizeof (struct GNUNET_PeerIdentity));
1944 all_views_updated_cb();
1948 pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1950 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
1953 void write_final_stats (void){
1956 for (i = 0; i < num_peers; i++)
1958 to_file ("/tmp/rps/final_stats.dat",
1959 "%" PRIu32 " " /* index */
1961 PRIu64 " %" /* rounds */
1962 PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */
1963 PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */
1964 PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */
1965 PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
1967 GNUNET_i2s (rps_peers[i].peer_id),
1968 rps_peers[i].num_rounds,
1969 rps_peers[i].num_blocks,
1970 rps_peers[i].num_blocks_many_push,
1971 rps_peers[i].num_blocks_no_push,
1972 rps_peers[i].num_blocks_no_pull,
1973 rps_peers[i].num_blocks_many_push_no_pull,
1974 rps_peers[i].num_blocks_no_push_no_pull,
1975 rps_peers[i].num_issued_push,
1976 rps_peers[i].num_issued_pull_req,
1977 rps_peers[i].num_issued_pull_rep,
1978 rps_peers[i].num_sent_push,
1979 rps_peers[i].num_sent_pull_req,
1980 rps_peers[i].num_sent_pull_rep,
1981 rps_peers[i].num_recv_push,
1982 rps_peers[i].num_recv_pull_req,
1983 rps_peers[i].num_recv_pull_rep);
1988 * Continuation called by #GNUNET_STATISTICS_get() functions.
1990 * Remembers that this specific statistics value was received for this peer.
1991 * Checks whether all peers received their statistics yet.
1992 * Issues the shutdown.
1994 * @param cls closure
1995 * @param success #GNUNET_OK if statistics were
1996 * successfully obtained, #GNUNET_SYSERR if not.
1999 post_test_shutdown_ready_cb (void *cls,
2002 struct STATcls *stat_cls = (struct STATcls *) cls;
2003 struct RPSPeer *rps_peer = stat_cls->rps_peer;
2004 if (GNUNET_OK == success)
2006 /* set flag that we we got the value */
2007 rps_peer->stat_collected_flags |= stat_cls->stat_type;
2009 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2010 "Peer %u did not receive statistics value\n",
2012 GNUNET_free (stat_cls);
2016 if (NULL != rps_peer->stat_op &&
2017 GNUNET_YES == check_statistics_collect_completed_single_peer (rps_peer))
2019 GNUNET_TESTBED_operation_done (rps_peer->stat_op);
2022 if (GNUNET_YES == check_statistics_collect_completed())
2024 write_final_stats ();
2025 GNUNET_free (stat_cls);
2026 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2028 GNUNET_SCHEDULER_shutdown ();
2030 GNUNET_free (stat_cls);
2035 * @brief Converts string representation to the corresponding #STAT_TYPE enum.
2037 * @param stat_str string representation of statistics specifier
2039 * @return corresponding enum
2041 enum STAT_TYPE stat_str_2_type (const char *stat_str)
2043 if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ("# rounds blocked - no pull replies")))
2045 return STAT_TYPE_BLOCKS_NO_PULL;
2047 else if (0 == strncmp ("# rounds blocked - too many pushes, no pull replies", stat_str, strlen ("# rounds blocked - too many pushes, no pull replies")))
2049 return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL;
2051 else if (0 == strncmp ("# rounds blocked - too many pushes", stat_str, strlen ("# rounds blocked - too many pushes")))
2053 return STAT_TYPE_BLOCKS_MANY_PUSH;
2055 else if (0 == strncmp ("# rounds blocked - no pushes, no pull replies", stat_str, strlen ("# rounds blocked - no pushes, no pull replies")))
2057 return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL;
2059 else if (0 == strncmp ("# rounds blocked - no pushes", stat_str, strlen ("# rounds blocked - no pushes")))
2061 return STAT_TYPE_BLOCKS_NO_PUSH;
2063 else if (0 == strncmp ("# rounds blocked", stat_str, strlen ("# rounds blocked")))
2065 return STAT_TYPE_BLOCKS;
2067 else if (0 == strncmp ("# rounds", stat_str, strlen ("# rounds")))
2069 return STAT_TYPE_ROUNDS;
2071 else if (0 == strncmp ("# push send issued", stat_str, strlen ("# push send issued")))
2073 return STAT_TYPE_ISSUED_PUSH_SEND;
2075 else if (0 == strncmp ("# pull request send issued", stat_str, strlen ("# pull request send issued")))
2077 return STAT_TYPE_ISSUED_PULL_REQ;
2079 else if (0 == strncmp ("# pull reply send issued", stat_str, strlen ("# pull reply send issued")))
2081 return STAT_TYPE_ISSUED_PULL_REP;
2083 else if (0 == strncmp ("# pushes sent", stat_str, strlen ("# pushes sent")))
2085 return STAT_TYPE_SENT_PUSH_SEND;
2087 else if (0 == strncmp ("# pull requests sent", stat_str, strlen ("# pull requests sent")))
2089 return STAT_TYPE_SENT_PULL_REQ;
2091 else if (0 == strncmp ("# pull replys sent", stat_str, strlen ("# pull replys sent")))
2093 return STAT_TYPE_SENT_PULL_REP;
2095 else if (0 == strncmp ("# push message received", stat_str, strlen ("# push message received")))
2097 return STAT_TYPE_RECV_PUSH_SEND;
2099 else if (0 == strncmp ("# pull request message received", stat_str, strlen ("# pull request message received")))
2101 return STAT_TYPE_RECV_PULL_REQ;
2103 else if (0 == strncmp ("# pull reply messages received", stat_str, strlen ("# pull reply messages received")))
2105 return STAT_TYPE_RECV_PULL_REP;
2107 return STAT_TYPE_MAX;
2112 * @brief Converts #STAT_TYPE enum to the equivalent string representation that
2113 * is stored with the statistics service.
2115 * @param stat_type #STAT_TYPE enum
2117 * @return string representation that matches statistics value
2119 char* stat_type_2_str (enum STAT_TYPE stat_type)
2123 case STAT_TYPE_ROUNDS:
2125 case STAT_TYPE_BLOCKS:
2126 return "# rounds blocked";
2127 case STAT_TYPE_BLOCKS_MANY_PUSH:
2128 return "# rounds blocked - too many pushes";
2129 case STAT_TYPE_BLOCKS_NO_PUSH:
2130 return "# rounds blocked - no pushes";
2131 case STAT_TYPE_BLOCKS_NO_PULL:
2132 return "# rounds blocked - no pull replies";
2133 case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
2134 return "# rounds blocked - too many pushes, no pull replies";
2135 case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
2136 return "# rounds blocked - no pushes, no pull replies";
2137 case STAT_TYPE_ISSUED_PUSH_SEND:
2138 return "# push send issued";
2139 case STAT_TYPE_ISSUED_PULL_REQ:
2140 return "# pull request send issued";
2141 case STAT_TYPE_ISSUED_PULL_REP:
2142 return "# pull reply send issued";
2143 case STAT_TYPE_SENT_PUSH_SEND:
2144 return "# pushes sent";
2145 case STAT_TYPE_SENT_PULL_REQ:
2146 return "# pull requests sent";
2147 case STAT_TYPE_SENT_PULL_REP:
2148 return "# pull replys sent";
2149 case STAT_TYPE_RECV_PUSH_SEND:
2150 return "# push message received";
2151 case STAT_TYPE_RECV_PULL_REQ:
2152 return "# pull request message received";
2153 case STAT_TYPE_RECV_PULL_REP:
2154 return "# pull reply messages received";
2163 * Callback function to process statistic values.
2165 * @param cls closure
2166 * @param subsystem name of subsystem that created the statistic
2167 * @param name the name of the datum
2168 * @param value the current value
2169 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
2170 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
2173 stat_iterator (void *cls,
2174 const char *subsystem,
2179 const struct STATcls *stat_cls = (const struct STATcls *) cls;
2180 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
2181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
2182 //stat_type_2_str (stat_cls->stat_type),
2185 to_file (rps_peer->file_name_stats,
2186 "%s: %" PRIu64 "\n",
2189 switch (stat_str_2_type (name))
2191 case STAT_TYPE_ROUNDS:
2192 rps_peer->num_rounds = value;
2194 case STAT_TYPE_BLOCKS:
2195 rps_peer->num_blocks = value;
2197 case STAT_TYPE_BLOCKS_MANY_PUSH:
2198 rps_peer->num_blocks_many_push = value;
2200 case STAT_TYPE_BLOCKS_NO_PUSH:
2201 rps_peer->num_blocks_no_push = value;
2203 case STAT_TYPE_BLOCKS_NO_PULL:
2204 rps_peer->num_blocks_no_pull = value;
2206 case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
2207 rps_peer->num_blocks_many_push_no_pull = value;
2209 case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
2210 rps_peer->num_blocks_no_push_no_pull = value;
2212 case STAT_TYPE_ISSUED_PUSH_SEND:
2213 rps_peer->num_issued_push = value;
2215 case STAT_TYPE_ISSUED_PULL_REQ:
2216 rps_peer->num_issued_pull_req = value;
2218 case STAT_TYPE_ISSUED_PULL_REP:
2219 rps_peer->num_issued_pull_rep = value;
2221 case STAT_TYPE_SENT_PUSH_SEND:
2222 rps_peer->num_sent_push = value;
2224 case STAT_TYPE_SENT_PULL_REQ:
2225 rps_peer->num_sent_pull_req = value;
2227 case STAT_TYPE_SENT_PULL_REP:
2228 rps_peer->num_sent_pull_rep = value;
2230 case STAT_TYPE_RECV_PUSH_SEND:
2231 rps_peer->num_recv_push = value;
2233 case STAT_TYPE_RECV_PULL_REQ:
2234 rps_peer->num_recv_pull_req = value;
2236 case STAT_TYPE_RECV_PULL_REP:
2237 rps_peer->num_recv_pull_rep = value;
2241 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2242 "Unknown statistics string: %s\n",
2249 void post_profiler (struct RPSPeer *rps_peer)
2251 if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
2256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2257 "Going to request statistic values with mask 0x%" PRIx32 "\n",
2258 cur_test_run.stat_collect_flags);
2260 struct STATcls *stat_cls;
2262 for (stat_type = STAT_TYPE_ROUNDS;
2263 stat_type < STAT_TYPE_MAX;
2264 stat_type = stat_type <<1)
2266 if (stat_type & cur_test_run.stat_collect_flags)
2268 stat_cls = GNUNET_malloc (sizeof (struct STATcls));
2269 stat_cls->rps_peer = rps_peer;
2270 stat_cls->stat_type = stat_type;
2271 store_stats_file_name (rps_peer);
2272 GNUNET_STATISTICS_get (rps_peer->stats_h,
2274 stat_type_2_str (stat_type),
2275 post_test_shutdown_ready_cb,
2277 (struct STATcls *) stat_cls);
2278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2279 "Requested statistics for %s (peer %" PRIu32 ")\n",
2280 stat_type_2_str (stat_type),
2287 /***********************************************************************
2288 * /Definition of tests
2289 ***********************************************************************/
2293 * Actual "main" function for the testcase.
2295 * @param cls closure
2296 * @param h the run handle
2297 * @param n_peers number of peers in 'peers'
2298 * @param peers handle to peers run in the testbed
2299 * @param links_succeeded the number of overlay link connection attempts that
2301 * @param links_failed the number of overlay link connection attempts that
2306 struct GNUNET_TESTBED_RunHandle *h,
2307 unsigned int n_peers,
2308 struct GNUNET_TESTBED_Peer **peers,
2309 unsigned int links_succeeded,
2310 unsigned int links_failed)
2313 struct OpListEntry *entry;
2315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
2317 /* Check whether we timed out */
2318 if (n_peers != num_peers ||
2320 0 == links_succeeded)
2322 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Going down due to args (eg. timeout)\n");
2323 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers);
2324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n", num_peers);
2325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers);
2326 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n", links_succeeded);
2327 GNUNET_SCHEDULER_shutdown ();
2332 /* Initialize peers */
2333 testbed_peers = peers;
2334 num_peers_online = 0;
2335 for (i = 0; i < num_peers; i++)
2337 entry = make_oplist_entry ();
2339 rps_peers[i].index = i;
2340 if (NULL != cur_test_run.init_peer)
2341 cur_test_run.init_peer (&rps_peers[i]);
2342 if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
2344 rps_peers->cur_view_count = 0;
2345 rps_peers->cur_view = NULL;
2347 entry->op = GNUNET_TESTBED_peer_get_information (peers[i],
2348 GNUNET_TESTBED_PIT_IDENTITY,
2353 /* Bring peers up */
2354 GNUNET_assert (num_peers == n_peers);
2355 for (i = 0; i < n_peers; i++)
2357 rps_peers[i].index = i;
2359 GNUNET_TESTBED_service_connect (&rps_peers[i],
2362 &rps_connect_complete_cb,
2364 &rps_connect_adapter,
2365 &rps_disconnect_adapter,
2367 /* Connect all peers to statistics service */
2368 if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics)
2370 rps_peers[i].stat_op =
2371 GNUNET_TESTBED_service_connect (NULL,
2376 &stat_connect_adapter,
2377 &stat_disconnect_adapter,
2382 if (NULL != churn_task)
2383 GNUNET_SCHEDULER_cancel (churn_task);
2384 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
2389 * Entry point for the testcase, sets up the testbed.
2391 * @param argc unused
2392 * @param argv unused
2393 * @return 0 on success
2396 main (int argc, char *argv[])
2400 /* Defaults for tests */
2402 cur_test_run.name = "test-rps-default";
2403 cur_test_run.init_peer = default_init_peer;
2404 cur_test_run.pre_test = NULL;
2405 cur_test_run.reply_handle = default_reply_handle;
2406 cur_test_run.eval_cb = default_eval_cb;
2407 cur_test_run.post_test = NULL;
2408 cur_test_run.have_churn = HAVE_CHURN;
2409 cur_test_run.have_collect_statistics = NO_COLLECT_STATISTICS;
2410 cur_test_run.stat_collect_flags = 0;
2411 cur_test_run.have_collect_view = NO_COLLECT_VIEW;
2413 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30);
2415 if (strstr (argv[0], "malicious") != NULL)
2417 cur_test_run.pre_test = mal_pre;
2418 cur_test_run.main_test = mal_cb;
2419 cur_test_run.init_peer = mal_init_peer;
2421 if (strstr (argv[0], "_1") != NULL)
2423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 1\n");
2424 cur_test_run.name = "test-rps-malicious_1";
2427 else if (strstr (argv[0], "_2") != NULL)
2429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 2\n");
2430 cur_test_run.name = "test-rps-malicious_2";
2433 else if (strstr (argv[0], "_3") != NULL)
2435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 3\n");
2436 cur_test_run.name = "test-rps-malicious_3";
2441 else if (strstr (argv[0], "_single_req") != NULL)
2443 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n");
2444 cur_test_run.name = "test-rps-single-req";
2445 cur_test_run.main_test = single_req_cb;
2446 cur_test_run.have_churn = HAVE_NO_CHURN;
2449 else if (strstr (argv[0], "_delayed_reqs") != NULL)
2451 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n");
2452 cur_test_run.name = "test-rps-delayed-reqs";
2453 cur_test_run.main_test = delay_req_cb;
2454 cur_test_run.have_churn = HAVE_NO_CHURN;
2457 else if (strstr (argv[0], "_seed_big") != NULL)
2459 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_MAX_MESSAGE_SIZE)\n");
2461 cur_test_run.name = "test-rps-seed-big";
2462 cur_test_run.main_test = seed_big_cb;
2463 cur_test_run.eval_cb = no_eval;
2464 cur_test_run.have_churn = HAVE_NO_CHURN;
2465 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
2468 else if (strstr (argv[0], "_single_peer_seed") != NULL)
2470 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n");
2471 cur_test_run.name = "test-rps-single-peer-seed";
2472 cur_test_run.main_test = single_peer_seed_cb;
2473 cur_test_run.have_churn = HAVE_NO_CHURN;
2476 else if (strstr (argv[0], "_seed_request") != NULL)
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n");
2479 cur_test_run.name = "test-rps-seed-request";
2480 cur_test_run.main_test = seed_req_cb;
2481 cur_test_run.have_churn = HAVE_NO_CHURN;
2484 else if (strstr (argv[0], "_seed") != NULL)
2486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding\n");
2487 cur_test_run.name = "test-rps-seed";
2488 cur_test_run.main_test = seed_cb;
2489 cur_test_run.eval_cb = no_eval;
2490 cur_test_run.have_churn = HAVE_NO_CHURN;
2493 else if (strstr (argv[0], "_req_cancel") != NULL)
2495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test cancelling a request\n");
2496 cur_test_run.name = "test-rps-req-cancel";
2498 cur_test_run.main_test = req_cancel_cb;
2499 cur_test_run.eval_cb = no_eval;
2500 cur_test_run.have_churn = HAVE_NO_CHURN;
2501 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
2504 else if (strstr (argv[0], "_churn") != NULL)
2506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test churn\n");
2507 cur_test_run.name = "test-rps-churn";
2509 cur_test_run.init_peer = default_init_peer;
2510 cur_test_run.main_test = churn_test_cb;
2511 cur_test_run.reply_handle = default_reply_handle;
2512 cur_test_run.eval_cb = default_eval_cb;
2513 cur_test_run.have_churn = HAVE_CHURN;
2514 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
2515 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
2518 else if (strstr (argv[0], "profiler") != NULL)
2520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n");
2521 cur_test_run.name = "test-rps-profiler";
2524 cur_test_run.init_peer = profiler_init_peer;
2525 //cur_test_run.pre_test = mal_pre;
2526 cur_test_run.pre_test = pre_profiler;
2527 cur_test_run.main_test = profiler_cb;
2528 cur_test_run.reply_handle = profiler_reply_handle;
2529 cur_test_run.eval_cb = profiler_eval;
2530 cur_test_run.post_test = post_profiler;
2531 cur_test_run.request_interval = 2;
2532 cur_test_run.num_requests = 5;
2533 cur_test_run.have_churn = HAVE_CHURN;
2534 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
2535 cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
2536 cur_test_run.stat_collect_flags = STAT_TYPE_ROUNDS |
2538 STAT_TYPE_BLOCKS_MANY_PUSH |
2539 STAT_TYPE_BLOCKS_NO_PUSH |
2540 STAT_TYPE_BLOCKS_NO_PULL |
2541 STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL |
2542 STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL |
2543 STAT_TYPE_ISSUED_PUSH_SEND |
2544 STAT_TYPE_ISSUED_PULL_REQ |
2545 STAT_TYPE_ISSUED_PULL_REP |
2546 STAT_TYPE_SENT_PUSH_SEND |
2547 STAT_TYPE_SENT_PULL_REQ |
2548 STAT_TYPE_SENT_PULL_REP |
2549 STAT_TYPE_RECV_PUSH_SEND |
2550 STAT_TYPE_RECV_PULL_REQ |
2551 STAT_TYPE_RECV_PULL_REP;
2552 cur_test_run.have_collect_view = COLLECT_VIEW;
2553 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300);
2555 /* 'Clean' directory */
2556 (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
2557 GNUNET_DISK_directory_create ("/tmp/rps/");
2560 rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
2561 peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
2562 rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);
2563 if ( (2 == mal_type) ||
2565 target_peer = &rps_peer_ids[num_peers - 2];
2566 if (profiler_eval == cur_test_run.eval_cb)
2567 eval_peer = &rps_peers[num_peers - 1]; /* FIXME: eval_peer could be a
2568 malicious peer if not careful
2569 with the malicious portion */
2572 ret_value = GNUNET_TESTBED_test_run (cur_test_run.name,
2577 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2578 "_test_run returned.\n");
2579 if (GNUNET_OK != ret_value)
2581 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2582 "Test did not run successfully!\n");
2585 ret_value = cur_test_run.eval_cb();
2586 if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
2588 GNUNET_array_grow (rps_peers->cur_view,
2589 rps_peers->cur_view_count,
2592 GNUNET_free (rps_peers);
2593 GNUNET_free (rps_peer_ids);
2594 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
2598 /* end of test_rps.c */