aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/Makefile.am24
-rw-r--r--src/rps/gnunet-rps-profiler.c2713
-rw-r--r--src/rps/gnunet-rps.c18
-rw-r--r--src/rps/gnunet-service-rps.c18
-rw-r--r--src/rps/gnunet-service-rps_custommap.c18
-rw-r--r--src/rps/gnunet-service-rps_custommap.h18
-rw-r--r--src/rps/gnunet-service-rps_sampler.c18
-rw-r--r--src/rps/gnunet-service-rps_sampler.h18
-rw-r--r--src/rps/gnunet-service-rps_sampler_elem.c18
-rw-r--r--src/rps/gnunet-service-rps_sampler_elem.h18
-rw-r--r--src/rps/gnunet-service-rps_view.c18
-rw-r--r--src/rps/gnunet-service-rps_view.h18
-rw-r--r--src/rps/rps-test_util.c65
-rw-r--r--src/rps/rps-test_util.h21
-rw-r--r--src/rps/rps.conf.in2
-rw-r--r--src/rps/rps.h18
-rw-r--r--src/rps/rps_api.c18
-rw-r--r--src/rps/test_rps.c126
-rw-r--r--src/rps/test_rps.conf2
-rw-r--r--src/rps/test_rps_api.c18
-rw-r--r--src/rps/test_service_rps_custommap.c18
-rw-r--r--src/rps/test_service_rps_sampler_elem.c18
-rw-r--r--src/rps/test_service_rps_view.c18
23 files changed, 3018 insertions, 223 deletions
diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am
index b5f712268..d477ade92 100644
--- a/src/rps/Makefile.am
+++ b/src/rps/Makefile.am
@@ -83,17 +83,18 @@ check_PROGRAMS = \
83 test_rps_churn 83 test_rps_churn
84endif 84endif
85 85
86rps_test_src = \
87 test_rps.c \
88 rps-test_util.h rps-test_util.c \
89 gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c
90
86ld_rps_test_lib = \ 91ld_rps_test_lib = \
87 libgnunetrps.la \ 92 libgnunetrps.la \
88 $(top_builddir)/src/util/libgnunetutil.la \ 93 $(top_builddir)/src/util/libgnunetutil.la \
94 $(top_builddir)/src/statistics/libgnunetstatistics.la \
89 $(top_builddir)/src/testbed/libgnunettestbed.la \ 95 $(top_builddir)/src/testbed/libgnunettestbed.la \
90 -lm 96 -lm
91 97
92rps_test_src = \
93 test_rps.c \
94 rps-test_util.h rps-test_util.c \
95 gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c
96
97if ENABLE_TEST_RUN 98if ENABLE_TEST_RUN
98AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; 99AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
99TESTS = $(check_PROGRAMS) 100TESTS = $(check_PROGRAMS)
@@ -140,10 +141,19 @@ test_rps_seed_big_LDADD = $(ld_rps_test_lib)
140test_rps_churn_SOURCES = $(rps_test_src) 141test_rps_churn_SOURCES = $(rps_test_src)
141test_rps_churn_LDADD = $(ld_rps_test_lib) 142test_rps_churn_LDADD = $(ld_rps_test_lib)
142 143
143gnunet_rps_profiler_SOURCES = $(rps_test_src) 144gnunet_rps_profiler_SOURCES = \
145 gnunet-service-rps_sampler_elem.h gnunet-service-rps_sampler_elem.c \
146 rps-test_util.h rps-test_util.c \
147 gnunet-rps-profiler.c
148
149
144gnunet_rps_profiler_LDADD = \ 150gnunet_rps_profiler_LDADD = \
145 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 151 $(top_builddir)/src/statistics/libgnunetstatistics.la \
146 $(ld_rps_test_lib) 152 libgnunetrps.la \
153 $(top_builddir)/src/util/libgnunetutil.la \
154 $(top_builddir)/src/testbed/libgnunettestbed.la \
155 -lm
156
147 157
148EXTRA_DIST = \ 158EXTRA_DIST = \
149 test_rps.conf 159 test_rps.conf
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
new file mode 100644
index 000000000..5ef42187f
--- /dev/null
+++ b/src/rps/gnunet-rps-profiler.c
@@ -0,0 +1,2713 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009, 2012 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
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 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18/**
19 * @file rps/test_rps.c
20 * @brief Testcase for the random peer sampling service. Starts
21 * a peergroup with a given number of peers, then waits to
22 * receive size pushes/pulls from each peer. Expects to wait
23 * for one message from each peer.
24 */
25#include "platform.h"
26//#include "rps_test_lib.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testbed_service.h"
29
30#include "gnunet_rps_service.h"
31#include "rps-test_util.h"
32#include "gnunet-service-rps_sampler_elem.h"
33
34#include <inttypes.h>
35
36
37#define BIT(n) (1 << (n))
38
39/**
40 * How many peers do we start?
41 */
42static uint32_t num_peers;
43
44/**
45 * How long do we run the test?
46 * In seconds.
47 */
48static uint32_t timeout_s;
49
50/**
51 * How long do we run the test?
52 */
53//#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
54static struct GNUNET_TIME_Relative timeout;
55
56
57/**
58 * Portion of malicious peers
59 */
60static double portion = .1;
61
62/**
63 * Type of malicious peer to test
64 */
65static unsigned int mal_type = 0;
66
67/**
68 * Handles to all of the running peers
69 */
70static struct GNUNET_TESTBED_Peer **testbed_peers;
71
72enum STAT_TYPE
73{
74 STAT_TYPE_ROUNDS, /* 0 */
75 STAT_TYPE_BLOCKS, /* 1 */
76 STAT_TYPE_BLOCKS_MANY_PUSH, /* 2 */
77 STAT_TYPE_BLOCKS_NO_PUSH, /* 3 */
78 STAT_TYPE_BLOCKS_NO_PULL, /* 4 */
79 STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL, /* 5 */
80 STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL, /* 6 */
81 STAT_TYPE_ISSUED_PUSH_SEND, /* 7 */
82 STAT_TYPE_ISSUED_PULL_REQ, /* 8 */
83 STAT_TYPE_ISSUED_PULL_REP, /* 9 */
84 STAT_TYPE_SENT_PUSH_SEND, /* 10 */
85 STAT_TYPE_SENT_PULL_REQ, /* 11 */
86 STAT_TYPE_SENT_PULL_REP, /* 12 */
87 STAT_TYPE_RECV_PUSH_SEND, /* 13 */
88 STAT_TYPE_RECV_PULL_REQ, /* 14 */
89 STAT_TYPE_RECV_PULL_REP, /* 15 */
90 STAT_TYPE_MAX, /* 16 */
91};
92
93struct STATcls
94{
95 struct RPSPeer *rps_peer;
96 enum STAT_TYPE stat_type;
97};
98
99
100/**
101 * @brief Converts string representation to the corresponding #STAT_TYPE enum.
102 *
103 * @param stat_str string representation of statistics specifier
104 *
105 * @return corresponding enum
106 */
107enum STAT_TYPE stat_str_2_type (const char *stat_str)
108{
109 if (0 == strncmp ("# rounds blocked - no pull replies", stat_str, strlen ("# rounds blocked - no pull replies")))
110 {
111 return STAT_TYPE_BLOCKS_NO_PULL;
112 }
113 else if (0 == strncmp ("# rounds blocked - too many pushes, no pull replies", stat_str, strlen ("# rounds blocked - too many pushes, no pull replies")))
114 {
115 return STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL;
116 }
117 else if (0 == strncmp ("# rounds blocked - too many pushes", stat_str, strlen ("# rounds blocked - too many pushes")))
118 {
119 return STAT_TYPE_BLOCKS_MANY_PUSH;
120 }
121 else if (0 == strncmp ("# rounds blocked - no pushes, no pull replies", stat_str, strlen ("# rounds blocked - no pushes, no pull replies")))
122 {
123 return STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL;
124 }
125 else if (0 == strncmp ("# rounds blocked - no pushes", stat_str, strlen ("# rounds blocked - no pushes")))
126 {
127 return STAT_TYPE_BLOCKS_NO_PUSH;
128 }
129 else if (0 == strncmp ("# rounds blocked", stat_str, strlen ("# rounds blocked")))
130 {
131 return STAT_TYPE_BLOCKS;
132 }
133 else if (0 == strncmp ("# rounds", stat_str, strlen ("# rounds")))
134 {
135 return STAT_TYPE_ROUNDS;
136 }
137 else if (0 == strncmp ("# push send issued", stat_str, strlen ("# push send issued")))
138 {
139 return STAT_TYPE_ISSUED_PUSH_SEND;
140 }
141 else if (0 == strncmp ("# pull request send issued", stat_str, strlen ("# pull request send issued")))
142 {
143 return STAT_TYPE_ISSUED_PULL_REQ;
144 }
145 else if (0 == strncmp ("# pull reply send issued", stat_str, strlen ("# pull reply send issued")))
146 {
147 return STAT_TYPE_ISSUED_PULL_REP;
148 }
149 else if (0 == strncmp ("# pushes sent", stat_str, strlen ("# pushes sent")))
150 {
151 return STAT_TYPE_SENT_PUSH_SEND;
152 }
153 else if (0 == strncmp ("# pull requests sent", stat_str, strlen ("# pull requests sent")))
154 {
155 return STAT_TYPE_SENT_PULL_REQ;
156 }
157 else if (0 == strncmp ("# pull replys sent", stat_str, strlen ("# pull replys sent")))
158 {
159 return STAT_TYPE_SENT_PULL_REP;
160 }
161 else if (0 == strncmp ("# push message received", stat_str, strlen ("# push message received")))
162 {
163 return STAT_TYPE_RECV_PUSH_SEND;
164 }
165 else if (0 == strncmp ("# pull request message received", stat_str, strlen ("# pull request message received")))
166 {
167 return STAT_TYPE_RECV_PULL_REQ;
168 }
169 else if (0 == strncmp ("# pull reply messages received", stat_str, strlen ("# pull reply messages received")))
170 {
171 return STAT_TYPE_RECV_PULL_REP;
172 }
173 return STAT_TYPE_MAX;
174}
175
176
177/**
178 * @brief Converts #STAT_TYPE enum to the equivalent string representation that
179 * is stored with the statistics service.
180 *
181 * @param stat_type #STAT_TYPE enum
182 *
183 * @return string representation that matches statistics value
184 */
185char* stat_type_2_str (enum STAT_TYPE stat_type)
186{
187 switch (stat_type)
188 {
189 case STAT_TYPE_ROUNDS:
190 return "# rounds";
191 case STAT_TYPE_BLOCKS:
192 return "# rounds blocked";
193 case STAT_TYPE_BLOCKS_MANY_PUSH:
194 return "# rounds blocked - too many pushes";
195 case STAT_TYPE_BLOCKS_NO_PUSH:
196 return "# rounds blocked - no pushes";
197 case STAT_TYPE_BLOCKS_NO_PULL:
198 return "# rounds blocked - no pull replies";
199 case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
200 return "# rounds blocked - too many pushes, no pull replies";
201 case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
202 return "# rounds blocked - no pushes, no pull replies";
203 case STAT_TYPE_ISSUED_PUSH_SEND:
204 return "# push send issued";
205 case STAT_TYPE_ISSUED_PULL_REQ:
206 return "# pull request send issued";
207 case STAT_TYPE_ISSUED_PULL_REP:
208 return "# pull reply send issued";
209 case STAT_TYPE_SENT_PUSH_SEND:
210 return "# pushes sent";
211 case STAT_TYPE_SENT_PULL_REQ:
212 return "# pull requests sent";
213 case STAT_TYPE_SENT_PULL_REP:
214 return "# pull replys sent";
215 case STAT_TYPE_RECV_PUSH_SEND:
216 return "# push message received";
217 case STAT_TYPE_RECV_PULL_REQ:
218 return "# pull request message received";
219 case STAT_TYPE_RECV_PULL_REP:
220 return "# pull reply messages received";
221 case STAT_TYPE_MAX:
222 default:
223 return "ERROR";
224 ;
225 }
226}
227
228
229/**
230 * @brief Indicates whether peer should go off- or online
231 */
232enum PEER_ONLINE_DELTA {
233 /**
234 * @brief Indicates peer going online
235 */
236 PEER_GO_ONLINE = 1,
237 /**
238 * @brief Indicates peer going offline
239 */
240 PEER_GO_OFFLINE = -1,
241};
242
243/**
244 * Operation map entry
245 */
246struct OpListEntry
247{
248 /**
249 * DLL next ptr
250 */
251 struct OpListEntry *next;
252
253 /**
254 * DLL prev ptr
255 */
256 struct OpListEntry *prev;
257
258 /**
259 * The testbed operation
260 */
261 struct GNUNET_TESTBED_Operation *op;
262
263 /**
264 * Depending on whether we start or stop RPS service at the peer, set this to
265 * #PEER_GO_ONLINE (1) or #PEER_GO_OFFLINE (-1)
266 */
267 enum PEER_ONLINE_DELTA delta;
268
269 /**
270 * Index of the regarding peer
271 */
272 unsigned int index;
273};
274
275/**
276 * OpList DLL head
277 */
278static struct OpListEntry *oplist_head;
279
280/**
281 * OpList DLL tail
282 */
283static struct OpListEntry *oplist_tail;
284
285
286/**
287 * A pending reply: A request was sent and the reply is pending.
288 */
289struct PendingReply
290{
291 /**
292 * DLL next,prev ptr
293 */
294 struct PendingReply *next;
295 struct PendingReply *prev;
296
297 /**
298 * Handle to the request we are waiting for
299 */
300 struct GNUNET_RPS_Request_Handle *req_handle;
301
302 /**
303 * The peer that requested
304 */
305 struct RPSPeer *rps_peer;
306};
307
308
309/**
310 * A pending request: A request was not made yet but is scheduled for later.
311 */
312struct PendingRequest
313{
314 /**
315 * DLL next,prev ptr
316 */
317 struct PendingRequest *next;
318 struct PendingRequest *prev;
319
320 /**
321 * Handle to the request we are waiting for
322 */
323 struct GNUNET_SCHEDULER_Task *request_task;
324
325 /**
326 * The peer that requested
327 */
328 struct RPSPeer *rps_peer;
329};
330
331
332/**
333 * Information we track for each peer.
334 */
335struct RPSPeer
336{
337 /**
338 * Index of the peer.
339 */
340 unsigned int index;
341
342 /**
343 * Handle for RPS connect operation.
344 */
345 struct GNUNET_TESTBED_Operation *op;
346
347 /**
348 * Handle to RPS service.
349 */
350 struct GNUNET_RPS_Handle *rps_handle;
351
352 /**
353 * ID of the peer.
354 */
355 struct GNUNET_PeerIdentity *peer_id;
356
357 /**
358 * A request handle to check for an request
359 */
360 //struct GNUNET_RPS_Request_Handle *req_handle;
361
362 /**
363 * Peer on- or offline?
364 */
365 int online;
366
367 /**
368 * Number of Peer IDs to request during the whole test
369 */
370 unsigned int num_ids_to_request;
371
372 /**
373 * Pending requests DLL
374 */
375 struct PendingRequest *pending_req_head;
376 struct PendingRequest *pending_req_tail;
377
378 /**
379 * Number of pending requests
380 */
381 unsigned int num_pending_reqs;
382
383 /**
384 * Pending replies DLL
385 */
386 struct PendingReply *pending_rep_head;
387 struct PendingReply *pending_rep_tail;
388
389 /**
390 * Number of pending replies
391 */
392 unsigned int num_pending_reps;
393
394 /**
395 * Number of received PeerIDs
396 */
397 unsigned int num_recv_ids;
398
399 /**
400 * Pending operation on that peer
401 */
402 const struct OpListEntry *entry_op_manage;
403
404 /**
405 * Testbed operation to connect to statistics service
406 */
407 struct GNUNET_TESTBED_Operation *stat_op;
408
409 /**
410 * Handle to the statistics service
411 */
412 struct GNUNET_STATISTICS_Handle *stats_h;
413
414 /**
415 * @brief flags to indicate which statistics values have been already
416 * collected from the statistics service.
417 * Used to check whether we are able to shutdown.
418 */
419 uint32_t stat_collected_flags;
420
421 /**
422 * @brief File name of the file the stats are finally written to
423 */
424 const char *file_name_stats;
425
426 /**
427 * @brief File name of the file the stats are finally written to
428 */
429 const char *file_name_probs;
430
431 /**
432 * @brief The current view
433 */
434 struct GNUNET_PeerIdentity *cur_view;
435
436 /**
437 * @brief Number of peers in the #cur_view.
438 */
439 uint32_t cur_view_count;
440
441 /**
442 * @brief Number of occurrences in other peer's view
443 */
444 uint32_t count_in_views;
445
446 /**
447 * @brief statistics values
448 */
449 uint64_t stats[STAT_TYPE_MAX];
450};
451
452/**
453 * Information for all the peers.
454 */
455static struct RPSPeer *rps_peers;
456
457/**
458 * Peermap to get the index of a given peer ID quick.
459 */
460static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
461
462/**
463 * IDs of the peers.
464 */
465static struct GNUNET_PeerIdentity *rps_peer_ids;
466
467/**
468 * ID of the targeted peer.
469 */
470static struct GNUNET_PeerIdentity *target_peer;
471
472/**
473 * ID of the peer that requests for the evaluation.
474 */
475static struct RPSPeer *eval_peer;
476
477/**
478 * Number of online peers.
479 */
480static unsigned int num_peers_online;
481
482/**
483 * @brief The added sizes of the peer's views
484 */
485static unsigned int view_sizes;
486
487/**
488 * Return value from 'main'.
489 */
490static int ok;
491
492/**
493 * Identifier for the churn task that runs periodically
494 */
495static struct GNUNET_SCHEDULER_Task *post_test_task;
496
497/**
498 * Identifier for the churn task that runs periodically
499 */
500static struct GNUNET_SCHEDULER_Task *shutdown_task;
501
502/**
503 * Identifier for the churn task that runs periodically
504 */
505static struct GNUNET_SCHEDULER_Task *churn_task;
506
507/**
508 * Called to initialise the given RPSPeer
509 */
510typedef void (*InitPeer) (struct RPSPeer *rps_peer);
511
512/**
513 * @brief Called directly after connecting to the service
514 *
515 * @param rps_peer Specific peer the function is called on
516 * @param h the handle to the rps service
517 */
518typedef void (*PreTest) (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h);
519
520/**
521 * @brief Executes functions to test the api/service for a given peer
522 *
523 * Called from within #rps_connect_complete_cb ()
524 * Implemented by #churn_test_cb, #profiler_cb, #mal_cb, #single_req_cb,
525 * #delay_req_cb, #seed_big_cb, #single_peer_seed_cb, #seed_cb, #req_cancel_cb
526 *
527 * @param rps_peer the peer the task runs on
528 */
529typedef void (*MainTest) (struct RPSPeer *rps_peer);
530
531/**
532 * Callback called once the requested random peers are available
533 */
534typedef void (*ReplyHandle) (void *cls,
535 uint64_t n,
536 const struct GNUNET_PeerIdentity *recv_peers);
537
538/**
539 * Called directly before disconnecting from the service
540 */
541typedef void (*PostTest) (struct RPSPeer *peer);
542
543/**
544 * Function called after disconnect to evaluate test success
545 */
546typedef int (*EvaluationCallback) (void);
547
548/**
549 * @brief Do we have Churn?
550 */
551enum OPTION_CHURN {
552 /**
553 * @brief If we have churn this is set
554 */
555 HAVE_CHURN,
556 /**
557 * @brief If we have no churn this is set
558 */
559 HAVE_NO_CHURN,
560};
561
562/**
563 * @brief Is it ok to quit the test before the timeout?
564 */
565enum OPTION_QUICK_QUIT {
566 /**
567 * @brief It is ok for the test to quit before the timeout triggers
568 */
569 HAVE_QUICK_QUIT,
570
571 /**
572 * @brief It is NOT ok for the test to quit before the timeout triggers
573 */
574 HAVE_NO_QUICK_QUIT,
575};
576
577/**
578 * @brief Do we collect statistics at the end?
579 */
580enum OPTION_COLLECT_STATISTICS {
581 /**
582 * @brief We collect statistics at the end
583 */
584 COLLECT_STATISTICS,
585
586 /**
587 * @brief We do not collect statistics at the end
588 */
589 NO_COLLECT_STATISTICS,
590};
591
592/**
593 * @brief Do we collect views during run?
594 */
595enum OPTION_COLLECT_VIEW {
596 /**
597 * @brief We collect view during run
598 */
599 COLLECT_VIEW,
600
601 /**
602 * @brief We do not collect the view during run
603 */
604 NO_COLLECT_VIEW,
605};
606
607/**
608 * Structure to define a single test
609 */
610struct SingleTestRun
611{
612 /**
613 * Name of the test
614 */
615 char *name;
616
617 /**
618 * Called with a single peer in order to initialise that peer
619 */
620 InitPeer init_peer;
621
622 /**
623 * Called directly after connecting to the service
624 */
625 PreTest pre_test;
626
627 /**
628 * Main function for each peer
629 */
630 MainTest main_test;
631
632 /**
633 * Callback called once the requested peers are available
634 */
635 ReplyHandle reply_handle;
636
637 /**
638 * Called directly before disconnecting from the service
639 */
640 PostTest post_test;
641
642 /**
643 * Function to evaluate the test results
644 */
645 EvaluationCallback eval_cb;
646
647 /**
648 * Request interval
649 */
650 uint32_t request_interval;
651
652 /**
653 * Number of Requests to make.
654 */
655 uint32_t num_requests;
656
657 /**
658 * Run with (-out) churn
659 */
660 enum OPTION_CHURN have_churn;
661
662 /**
663 * Quit test before timeout?
664 */
665 enum OPTION_QUICK_QUIT have_quick_quit;
666
667 /**
668 * Collect statistics at the end?
669 */
670 enum OPTION_COLLECT_STATISTICS have_collect_statistics;
671
672 /**
673 * Collect view during run?
674 */
675 enum OPTION_COLLECT_VIEW have_collect_view;
676
677 /**
678 * @brief Mark which values from the statistics service to collect at the end
679 * of the run
680 */
681 uint32_t stat_collect_flags;
682} cur_test_run;
683
684/**
685 * Did we finish the test?
686 */
687static int post_test;
688
689/**
690 * Are we shutting down?
691 */
692static int in_shutdown;
693
694/**
695 * Append arguments to file
696 */
697static void
698tofile_ (const char *file_name, const char *line)
699{
700 struct GNUNET_DISK_FileHandle *f;
701 /* char output_buffer[512]; */
702 size_t size;
703 /* int size; */
704 size_t size2;
705
706 if (NULL == (f = GNUNET_DISK_file_open (file_name,
707 GNUNET_DISK_OPEN_APPEND |
708 GNUNET_DISK_OPEN_WRITE |
709 GNUNET_DISK_OPEN_CREATE,
710 GNUNET_DISK_PERM_USER_READ |
711 GNUNET_DISK_PERM_USER_WRITE |
712 GNUNET_DISK_PERM_GROUP_READ |
713 GNUNET_DISK_PERM_OTHER_READ)))
714 {
715 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
716 "Not able to open file %s\n",
717 file_name);
718 return;
719 }
720 /* size = GNUNET_snprintf (output_buffer,
721 sizeof (output_buffer),
722 "%llu %s\n",
723 GNUNET_TIME_absolute_get ().abs_value_us,
724 line);
725 if (0 > size)
726 {
727 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
728 "Failed to write string to buffer (size: %i)\n",
729 size);
730 return;
731 } */
732
733 size = strlen (line) * sizeof (char);
734
735 size2 = GNUNET_DISK_file_write (f, line, size);
736 if (size != size2)
737 {
738 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
739 "Unable to write to file! (Size: %lu, size2: %lu)\n",
740 size,
741 size2);
742 if (GNUNET_YES != GNUNET_DISK_file_close (f))
743 {
744 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
745 "Unable to close file\n");
746 }
747 return;
748 }
749
750 if (GNUNET_YES != GNUNET_DISK_file_close (f))
751 {
752 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
753 "Unable to close file\n");
754 }
755}
756
757/**
758 * This function is used to facilitate writing important information to disk
759 */
760#define tofile(file_name, ...) do {\
761 char tmp_buf[512];\
762 int size;\
763 size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\
764 if (0 > size)\
765 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\
766 "Failed to create tmp_buf\n");\
767 else\
768 tofile_(file_name,tmp_buf);\
769 } while (0);
770
771
772/**
773 * Write the ids and their according index in the given array to a file
774 * Unused
775 */
776/* static void
777ids_to_file (char *file_name,
778 struct GNUNET_PeerIdentity *peer_ids,
779 unsigned int num_peer_ids)
780{
781 unsigned int i;
782
783 for (i=0 ; i < num_peer_ids ; i++)
784 {
785 to_file (file_name,
786 "%u\t%s",
787 i,
788 GNUNET_i2s_full (&peer_ids[i]));
789 }
790} */
791
792/**
793 * Test the success of a single test
794 */
795static int
796evaluate (void)
797{
798 unsigned int i;
799 int tmp_ok;
800
801 tmp_ok = 1;
802
803 for (i = 0; i < num_peers; i++)
804 {
805 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
806 "%u. peer [%s] received %u of %u expected peer_ids: %i\n",
807 i,
808 GNUNET_i2s (rps_peers[i].peer_id),
809 rps_peers[i].num_recv_ids,
810 rps_peers[i].num_ids_to_request,
811 (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids));
812 tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_recv_ids);
813 }
814 return tmp_ok? 0 : 1;
815}
816
817
818/**
819 * Creates an oplist entry and adds it to the oplist DLL
820 */
821static struct OpListEntry *
822make_oplist_entry ()
823{
824 struct OpListEntry *entry;
825
826 entry = GNUNET_new (struct OpListEntry);
827 GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry);
828 return entry;
829}
830
831
832/**
833 * @brief Checks if given peer already received its statistics value from the
834 * statistics service.
835 *
836 * @param rps_peer the peer to check for
837 *
838 * @return #GNUNET_YES if so
839 * #GNUNET_NO otherwise
840 */
841static int check_statistics_collect_completed_single_peer (
842 const struct RPSPeer *rps_peer)
843{
844 if (cur_test_run.stat_collect_flags !=
845 (cur_test_run.stat_collect_flags &
846 rps_peer->stat_collected_flags))
847 {
848 return GNUNET_NO;
849 }
850 return GNUNET_YES;
851}
852/**
853 * @brief Checks if all peers already received their statistics value from the
854 * statistics service.
855 *
856 * @return #GNUNET_YES if so
857 * #GNUNET_NO otherwise
858 */
859static int check_statistics_collect_completed ()
860{
861 uint32_t i;
862
863 for (i = 0; i < num_peers; i++)
864 {
865 if (GNUNET_NO == check_statistics_collect_completed_single_peer (&rps_peers[i]))
866 {
867 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
868 "At least Peer %" PRIu32 " did not yet receive all statistics values\n",
869 i);
870 return GNUNET_NO;
871 }
872 }
873 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
874 "All peers received their statistics values\n");
875 return GNUNET_YES;
876}
877
878/**
879 * Task run on timeout to shut everything down.
880 */
881static void
882shutdown_op (void *cls)
883{
884 unsigned int i;
885
886 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
887 "Shutdown task scheduled, going down.\n");
888 in_shutdown = GNUNET_YES;
889 if (NULL != post_test_task)
890 {
891 GNUNET_SCHEDULER_cancel (post_test_task);
892 }
893 if (NULL != churn_task)
894 {
895 GNUNET_SCHEDULER_cancel (churn_task);
896 churn_task = NULL;
897 }
898 for (i = 0; i < num_peers; i++)
899 {
900 if (NULL != rps_peers[i].rps_handle)
901 {
902 GNUNET_RPS_disconnect (rps_peers[i].rps_handle);
903 }
904 if (NULL != rps_peers[i].op)
905 {
906 GNUNET_TESTBED_operation_done (rps_peers[i].op);
907 }
908 }
909}
910
911
912/**
913 * Task run on timeout to collect statistics and potentially shut down.
914 */
915static void
916post_test_op (void *cls)
917{
918 unsigned int i;
919
920 post_test_task = NULL;
921 post_test = GNUNET_YES;
922 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
923 "Post test task scheduled, going down.\n");
924 if (NULL != churn_task)
925 {
926 GNUNET_SCHEDULER_cancel (churn_task);
927 churn_task = NULL;
928 }
929 for (i = 0; i < num_peers; i++)
930 {
931 if (NULL != rps_peers[i].op)
932 {
933 GNUNET_TESTBED_operation_done (rps_peers[i].op);
934 rps_peers[i].op = NULL;
935 }
936 if (NULL != cur_test_run.post_test)
937 {
938 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i);
939 cur_test_run.post_test (&rps_peers[i]);
940 }
941 }
942 /* If we do not collect statistics, shut down directly */
943 if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics ||
944 GNUNET_YES == check_statistics_collect_completed())
945 {
946 GNUNET_SCHEDULER_shutdown ();
947 }
948}
949
950
951/**
952 * Seed peers.
953 */
954static void
955seed_peers (void *cls)
956{
957 struct RPSPeer *peer = cls;
958 unsigned int amount;
959 unsigned int i;
960
961 // TODO if malicious don't seed mal peers
962 amount = round (.5 * num_peers);
963
964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n");
965 for (i = 0 ; i < amount ; i++)
966 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
967 i,
968 GNUNET_i2s (&rps_peer_ids[i]));
969
970 GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
971}
972
973
974/**
975 * Get the id of peer i.
976 */
977 void
978info_cb (void *cb_cls,
979 struct GNUNET_TESTBED_Operation *op,
980 const struct GNUNET_TESTBED_PeerInformation *pinfo,
981 const char *emsg)
982{
983 struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
984
985 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
986 {
987 return;
988 }
989
990 if (NULL == pinfo || NULL != emsg)
991 {
992 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got Error: %s\n", emsg);
993 GNUNET_TESTBED_operation_done (entry->op);
994 return;
995 }
996
997 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
998 "Peer %u is %s\n",
999 entry->index,
1000 GNUNET_i2s (pinfo->result.id));
1001
1002 rps_peer_ids[entry->index] = *(pinfo->result.id);
1003 rps_peers[entry->index].peer_id = &rps_peer_ids[entry->index];
1004
1005 GNUNET_assert (GNUNET_OK ==
1006 GNUNET_CONTAINER_multipeermap_put (peer_map,
1007 &rps_peer_ids[entry->index],
1008 &rps_peers[entry->index],
1009 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1010 tofile ("/tmp/rps/peer_ids",
1011 "%u\t%s\n",
1012 entry->index,
1013 GNUNET_i2s_full (&rps_peer_ids[entry->index]));
1014
1015 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
1016 GNUNET_TESTBED_operation_done (entry->op);
1017 GNUNET_free (entry);
1018}
1019
1020
1021/**
1022 * Callback to be called when RPS service connect operation is completed
1023 *
1024 * @param cls the callback closure from functions generating an operation
1025 * @param op the operation that has been finished
1026 * @param ca_result the RPS service handle returned from rps_connect_adapter
1027 * @param emsg error message in case the operation has failed; will be NULL if
1028 * operation has executed successfully.
1029 */
1030static void
1031rps_connect_complete_cb (void *cls,
1032 struct GNUNET_TESTBED_Operation *op,
1033 void *ca_result,
1034 const char *emsg)
1035{
1036 struct RPSPeer *rps_peer = cls;
1037 struct GNUNET_RPS_Handle *rps = ca_result;
1038
1039 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1040 {
1041 return;
1042 }
1043
1044 rps_peer->rps_handle = rps;
1045 rps_peer->online = GNUNET_YES;
1046 num_peers_online++;
1047
1048 GNUNET_assert (op == rps_peer->op);
1049 if (NULL != emsg)
1050 {
1051 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1052 "Failed to connect to RPS service: %s\n",
1053 emsg);
1054 ok = 1;
1055 GNUNET_SCHEDULER_shutdown ();
1056 return;
1057 }
1058
1059 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started client successfully\n");
1060
1061 cur_test_run.main_test (rps_peer);
1062}
1063
1064
1065/**
1066 * Adapter function called to establish a connection to
1067 * the RPS service.
1068 *
1069 * @param cls closure
1070 * @param cfg configuration of the peer to connect to; will be available until
1071 * GNUNET_TESTBED_operation_done() is called on the operation returned
1072 * from GNUNET_TESTBED_service_connect()
1073 * @return service handle to return in 'op_result', NULL on error
1074 */
1075static void *
1076rps_connect_adapter (void *cls,
1077 const struct GNUNET_CONFIGURATION_Handle *cfg)
1078{
1079 struct GNUNET_RPS_Handle *h;
1080
1081 h = GNUNET_RPS_connect (cfg);
1082
1083 if (NULL != cur_test_run.pre_test)
1084 cur_test_run.pre_test (cls, h);
1085
1086 return h;
1087}
1088
1089/**
1090 * Called to open a connection to the peer's statistics
1091 *
1092 * @param cls peer context
1093 * @param cfg configuration of the peer to connect to; will be available until
1094 * GNUNET_TESTBED_operation_done() is called on the operation returned
1095 * from GNUNET_TESTBED_service_connect()
1096 * @return service handle to return in 'op_result', NULL on error
1097 */
1098static void *
1099stat_connect_adapter (void *cls,
1100 const struct GNUNET_CONFIGURATION_Handle *cfg)
1101{
1102 struct RPSPeer *peer = cls;
1103
1104 peer->stats_h = GNUNET_STATISTICS_create ("rps-profiler", cfg);
1105 return peer->stats_h;
1106}
1107
1108/**
1109 * Called to disconnect from peer's statistics service
1110 *
1111 * @param cls peer context
1112 * @param op_result service handle returned from the connect adapter
1113 */
1114static void
1115stat_disconnect_adapter (void *cls, void *op_result)
1116{
1117 struct RPSPeer *peer = cls;
1118
1119 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
1120 // (peer->stats_h, "core", "# peers connected",
1121 // stat_iterator, peer));
1122 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch_cancel
1123 // (peer->stats_h, "nse", "# peers connected",
1124 // stat_iterator, peer));
1125 GNUNET_STATISTICS_destroy (op_result, GNUNET_NO);
1126 peer->stats_h = NULL;
1127}
1128
1129/**
1130 * Called after successfully opening a connection to a peer's statistics
1131 * service; we register statistics monitoring for CORE and NSE here.
1132 *
1133 * @param cls the callback closure from functions generating an operation
1134 * @param op the operation that has been finished
1135 * @param ca_result the service handle returned from GNUNET_TESTBED_ConnectAdapter()
1136 * @param emsg error message in case the operation has failed; will be NULL if
1137 * operation has executed successfully.
1138 */
1139static void
1140stat_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
1141 void *ca_result, const char *emsg )
1142{
1143 //struct GNUNET_STATISTICS_Handle *sh = ca_result;
1144 //struct RPSPeer *peer = (struct RPSPeer *) cls;
1145
1146 if (NULL != emsg)
1147 {
1148 GNUNET_break (0);
1149 return;
1150 }
1151 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
1152 // (sh, "core", "# peers connected",
1153 // stat_iterator, peer));
1154 //GNUNET_break (GNUNET_OK == GNUNET_STATISTICS_watch
1155 // (sh, "nse", "# peers connected",
1156 // stat_iterator, peer));
1157}
1158
1159
1160/**
1161 * Adapter function called to destroy connection to
1162 * RPS service.
1163 *
1164 * @param cls closure
1165 * @param op_result service handle returned from the connect adapter
1166 */
1167static void
1168rps_disconnect_adapter (void *cls,
1169 void *op_result)
1170{
1171 struct RPSPeer *peer = cls;
1172 struct GNUNET_RPS_Handle *h = op_result;
1173
1174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect_adapter()\n");
1175 GNUNET_assert (NULL != peer);
1176 GNUNET_RPS_disconnect (h);
1177 peer->rps_handle = NULL;
1178}
1179
1180
1181/***********************************************************************
1182 * Definition of tests
1183***********************************************************************/
1184
1185/**
1186 * Callback to call on receipt of a reply
1187 *
1188 * @param cls closure
1189 * @param n number of peers
1190 * @param recv_peers the received peers
1191 */
1192static void
1193default_reply_handle (void *cls,
1194 uint64_t n,
1195 const struct GNUNET_PeerIdentity *recv_peers)
1196{
1197 struct RPSPeer *rps_peer;
1198 struct PendingReply *pending_rep = (struct PendingReply *) cls;
1199 unsigned int i;
1200
1201 rps_peer = pending_rep->rps_peer;
1202 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
1203 rps_peer->pending_rep_tail,
1204 pending_rep);
1205 rps_peer->num_pending_reps--;
1206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1207 "[%s] got %" PRIu64 " peers:\n",
1208 GNUNET_i2s (rps_peer->peer_id),
1209 n);
1210
1211 for (i = 0; i < n; i++)
1212 {
1213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1214 "%u: %s\n",
1215 i,
1216 GNUNET_i2s (&recv_peers[i]));
1217
1218 rps_peer->num_recv_ids++;
1219 }
1220
1221 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)
1222 {
1223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
1224 GNUNET_assert (NULL != post_test_task);
1225 GNUNET_SCHEDULER_cancel (post_test_task);
1226 post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL);
1227 GNUNET_assert (NULL!= post_test_task);
1228 }
1229}
1230
1231/**
1232 * Request random peers.
1233 */
1234static void
1235request_peers (void *cls)
1236{
1237 struct PendingRequest *pending_req = cls;
1238 struct RPSPeer *rps_peer;
1239 struct PendingReply *pending_rep;
1240
1241 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1242 return;
1243 rps_peer = pending_req->rps_peer;
1244 GNUNET_assert (1 <= rps_peer->num_pending_reqs);
1245 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
1246 rps_peer->pending_req_tail,
1247 pending_req);
1248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1249 "Requesting one peer\n");
1250 pending_rep = GNUNET_new (struct PendingReply);
1251 pending_rep->rps_peer = rps_peer;
1252 pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle,
1253 1,
1254 cur_test_run.reply_handle,
1255 pending_rep);
1256 GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head,
1257 rps_peer->pending_rep_tail,
1258 pending_rep);
1259 rps_peer->num_pending_reps++;
1260 rps_peer->num_pending_reqs--;
1261}
1262
1263static void
1264cancel_pending_req (struct PendingRequest *pending_req)
1265{
1266 struct RPSPeer *rps_peer;
1267
1268 rps_peer = pending_req->rps_peer;
1269 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
1270 rps_peer->pending_req_tail,
1271 pending_req);
1272 rps_peer->num_pending_reqs--;
1273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1274 "Cancelling pending request\n");
1275 GNUNET_SCHEDULER_cancel (pending_req->request_task);
1276 GNUNET_free (pending_req);
1277}
1278
1279static void
1280cancel_request (struct PendingReply *pending_rep)
1281{
1282 struct RPSPeer *rps_peer;
1283
1284 rps_peer = pending_rep->rps_peer;
1285 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
1286 rps_peer->pending_rep_tail,
1287 pending_rep);
1288 rps_peer->num_pending_reps--;
1289 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1290 "Cancelling request\n");
1291 GNUNET_RPS_request_cancel (pending_rep->req_handle);
1292 GNUNET_free (pending_rep);
1293}
1294
1295
1296/**
1297 * Schedule requests for peer @a rps_peer that have neither been scheduled, nor
1298 * issued, nor replied
1299 */
1300void
1301schedule_missing_requests (struct RPSPeer *rps_peer)
1302{
1303 unsigned int i;
1304 struct PendingRequest *pending_req;
1305
1306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1307 "Scheduling %u - %u missing requests\n",
1308 rps_peer->num_ids_to_request,
1309 rps_peer->num_pending_reqs + rps_peer->num_pending_reps);
1310 GNUNET_assert (rps_peer->num_pending_reqs + rps_peer->num_pending_reps <=
1311 rps_peer->num_ids_to_request);
1312 for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps;
1313 i < rps_peer->num_ids_to_request; i++)
1314 {
1315 pending_req = GNUNET_new (struct PendingRequest);
1316 pending_req->rps_peer = rps_peer;
1317 pending_req->request_task = GNUNET_SCHEDULER_add_delayed (
1318 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
1319 cur_test_run.request_interval * i),
1320 request_peers,
1321 pending_req);
1322 GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_req_head,
1323 rps_peer->pending_req_tail,
1324 pending_req);
1325 rps_peer->num_pending_reqs++;
1326 }
1327}
1328
1329void
1330cancel_pending_req_rep (struct RPSPeer *rps_peer)
1331{
1332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1333 "Cancelling all (pending) requests.\n");
1334 while (NULL != rps_peer->pending_req_head)
1335 cancel_pending_req (rps_peer->pending_req_head);
1336 GNUNET_assert (0 == rps_peer->num_pending_reqs);
1337 while (NULL != rps_peer->pending_rep_head)
1338 cancel_request (rps_peer->pending_rep_head);
1339 GNUNET_assert (0 == rps_peer->num_pending_reps);
1340}
1341
1342/***********************************
1343 * MALICIOUS
1344***********************************/
1345
1346/**
1347 * Initialise only non-mal RPSPeers
1348 */
1349static void mal_init_peer (struct RPSPeer *rps_peer)
1350{
1351 if (rps_peer->index >= round (portion * num_peers))
1352 rps_peer->num_ids_to_request = 1;
1353}
1354
1355
1356/**
1357 * @brief Set peers to (non-)malicious before execution
1358 *
1359 * Of signature #PreTest
1360 *
1361 * @param rps_peer the peer to set (non-) malicious
1362 * @param h the handle to the service
1363 */
1364static void
1365mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1366{
1367 #ifdef ENABLE_MALICIOUS
1368 uint32_t num_mal_peers;
1369
1370 GNUNET_assert ( (1 >= portion) &&
1371 (0 < portion) );
1372 num_mal_peers = round (portion * num_peers);
1373
1374 if (rps_peer->index < num_mal_peers)
1375 {
1376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1377 "%u. peer [%s] of %" PRIu32 " malicious peers turning malicious\n",
1378 rps_peer->index,
1379 GNUNET_i2s (rps_peer->peer_id),
1380 num_mal_peers);
1381
1382 GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
1383 rps_peer_ids, target_peer);
1384 }
1385 #endif /* ENABLE_MALICIOUS */
1386}
1387
1388static void
1389mal_cb (struct RPSPeer *rps_peer)
1390{
1391 uint32_t num_mal_peers;
1392
1393 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1394 {
1395 return;
1396 }
1397
1398 #ifdef ENABLE_MALICIOUS
1399 GNUNET_assert ( (1 >= portion) &&
1400 (0 < portion) );
1401 num_mal_peers = round (portion * num_peers);
1402
1403 if (rps_peer->index >= num_mal_peers)
1404 { /* It's useless to ask a malicious peer about a random sample -
1405 it's not sampling */
1406 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1407 seed_peers, rps_peer);
1408 schedule_missing_requests (rps_peer);
1409 }
1410 #endif /* ENABLE_MALICIOUS */
1411}
1412
1413/***********************************
1414 * CHURN
1415***********************************/
1416
1417static void
1418churn (void *cls);
1419
1420/**
1421 * @brief Starts churn
1422 *
1423 * Has signature of #MainTest
1424 *
1425 * This is not implemented too nicely as this is called for each peer, but we
1426 * only need to call it once. (Yes we check that we only schedule the task
1427 * once.)
1428 *
1429 * @param rps_peer The peer it's called for
1430 */
1431static void
1432churn_test_cb (struct RPSPeer *rps_peer)
1433{
1434 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1435 {
1436 return;
1437 }
1438
1439 /* Start churn */
1440 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1441 {
1442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1443 "Starting churn task\n");
1444 churn_task = GNUNET_SCHEDULER_add_delayed (
1445 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
1446 churn,
1447 NULL);
1448 } else {
1449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1450 "Not starting churn task\n");
1451 }
1452
1453 schedule_missing_requests (rps_peer);
1454}
1455
1456/***********************************
1457 * PROFILER
1458***********************************/
1459
1460/**
1461 * Callback to be called when RPS service is started or stopped at peers
1462 *
1463 * @param cls NULL
1464 * @param op the operation handle
1465 * @param emsg NULL on success; otherwise an error description
1466 */
1467static void
1468churn_cb (void *cls,
1469 struct GNUNET_TESTBED_Operation *op,
1470 const char *emsg)
1471{
1472 // FIXME
1473 struct OpListEntry *entry = cls;
1474
1475 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1476 {
1477 return;
1478 }
1479
1480 GNUNET_TESTBED_operation_done (entry->op);
1481 if (NULL != emsg)
1482 {
1483 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n");
1484 GNUNET_SCHEDULER_shutdown ();
1485 return;
1486 }
1487 GNUNET_assert (0 != entry->delta);
1488
1489 num_peers_online += entry->delta;
1490
1491 if (PEER_GO_OFFLINE == entry->delta)
1492 { /* Peer hopefully just went offline */
1493 if (GNUNET_YES != rps_peers[entry->index].online)
1494 {
1495 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1496 "peer %s was expected to go offline but is still marked as online\n",
1497 GNUNET_i2s (rps_peers[entry->index].peer_id));
1498 GNUNET_break (0);
1499 }
1500 else
1501 {
1502 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1503 "peer %s probably went offline as expected\n",
1504 GNUNET_i2s (rps_peers[entry->index].peer_id));
1505 }
1506 rps_peers[entry->index].online = GNUNET_NO;
1507 }
1508
1509 else if (PEER_GO_ONLINE < entry->delta)
1510 { /* Peer hopefully just went online */
1511 if (GNUNET_NO != rps_peers[entry->index].online)
1512 {
1513 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1514 "peer %s was expected to go online but is still marked as offline\n",
1515 GNUNET_i2s (rps_peers[entry->index].peer_id));
1516 GNUNET_break (0);
1517 }
1518 else
1519 {
1520 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1521 "peer %s probably went online as expected\n",
1522 GNUNET_i2s (rps_peers[entry->index].peer_id));
1523 if (NULL != cur_test_run.pre_test)
1524 {
1525 cur_test_run.pre_test (&rps_peers[entry->index],
1526 rps_peers[entry->index].rps_handle);
1527 schedule_missing_requests (&rps_peers[entry->index]);
1528 }
1529 }
1530 rps_peers[entry->index].online = GNUNET_YES;
1531 }
1532 else
1533 {
1534 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1535 "Invalid value for delta: %i\n", entry->delta);
1536 GNUNET_break (0);
1537 }
1538
1539 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
1540 rps_peers[entry->index].entry_op_manage = NULL;
1541 GNUNET_free (entry);
1542 //if (num_peers_in_round[current_round] == peers_running)
1543 // run_round ();
1544}
1545
1546/**
1547 * @brief Set the rps-service up or down for a specific peer
1548 *
1549 * @param i index of action
1550 * @param j index of peer
1551 * @param delta (#PEER_ONLINE_DELTA) down (-1) or up (1)
1552 * @param prob_go_on_off the probability of the action
1553 */
1554static void
1555manage_service_wrapper (unsigned int i, unsigned int j,
1556 enum PEER_ONLINE_DELTA delta,
1557 double prob_go_on_off)
1558{
1559 struct OpListEntry *entry = NULL;
1560 uint32_t prob;
1561
1562 /* make sure that management operation is not already scheduled */
1563 if (NULL != rps_peers[j].entry_op_manage)
1564 {
1565 return;
1566 }
1567
1568 prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
1569 UINT32_MAX);
1570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1571 "%u. selected peer (%u: %s) is %s.\n",
1572 i,
1573 j,
1574 GNUNET_i2s (rps_peers[j].peer_id),
1575 (PEER_GO_ONLINE == delta) ? "online" : "offline");
1576 if (prob < prob_go_on_off * UINT32_MAX)
1577 {
1578 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1579 "%s goes %s\n",
1580 GNUNET_i2s (rps_peers[j].peer_id),
1581 (PEER_GO_OFFLINE == delta) ? "offline" : "online");
1582
1583 if (PEER_GO_OFFLINE == delta)
1584 cancel_pending_req_rep (&rps_peers[j]);
1585 entry = make_oplist_entry ();
1586 entry->delta = delta;
1587 entry->index = j;
1588 entry->op = GNUNET_TESTBED_peer_manage_service (NULL,
1589 testbed_peers[j],
1590 "rps",
1591 &churn_cb,
1592 entry,
1593 (PEER_GO_OFFLINE == delta) ? 0 : 1);
1594 rps_peers[j].entry_op_manage = entry;
1595 }
1596}
1597
1598
1599static void
1600churn (void *cls)
1601{
1602 unsigned int i;
1603 unsigned int j;
1604 double portion_online;
1605 unsigned int *permut;
1606 double prob_go_offline;
1607 double portion_go_online;
1608 double portion_go_offline;
1609
1610 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1611 {
1612 return;
1613 }
1614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1615 "Churn function executing\n");
1616
1617 churn_task = NULL; /* Should be invalid by now */
1618
1619 /* Compute the probability for an online peer to go offline
1620 * this round */
1621 portion_online = num_peers_online * 1.0 / num_peers;
1622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1623 "Portion online: %f\n",
1624 portion_online);
1625 portion_go_online = ((1 - portion_online) * .5 * .66);
1626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1627 "Portion that should go online: %f\n",
1628 portion_go_online);
1629 portion_go_offline = (portion_online + portion_go_online) - .75;
1630 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1631 "Portion that probably goes offline: %f\n",
1632 portion_go_offline);
1633 prob_go_offline = portion_go_offline / (portion_online * .5);
1634 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1635 "Probability of a selected online peer to go offline: %f\n",
1636 prob_go_offline);
1637
1638 permut = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
1639 (unsigned int) num_peers);
1640
1641 /* Go over 50% randomly chosen peers */
1642 for (i = 0; i < .5 * num_peers; i++)
1643 {
1644 j = permut[i];
1645
1646 /* If online, shut down with certain probability */
1647 if (GNUNET_YES == rps_peers[j].online)
1648 {
1649 manage_service_wrapper (i, j, -1, prob_go_offline);
1650 }
1651
1652 /* If offline, restart with certain probability */
1653 else if (GNUNET_NO == rps_peers[j].online)
1654 {
1655 manage_service_wrapper (i, j, 1, 0.66);
1656 }
1657 }
1658
1659 GNUNET_free (permut);
1660
1661 churn_task = GNUNET_SCHEDULER_add_delayed (
1662 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1663 churn,
1664 NULL);
1665}
1666
1667
1668/**
1669 * Initialise given RPSPeer
1670 */
1671static void profiler_init_peer (struct RPSPeer *rps_peer)
1672{
1673 if (num_peers - 1 == rps_peer->index)
1674 {
1675 rps_peer->num_ids_to_request = cur_test_run.num_requests;
1676 } else {
1677 rps_peer->num_ids_to_request = 0;
1678 }
1679 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer shall request %i peers\n",
1680 rps_peer->num_ids_to_request);
1681}
1682
1683
1684/**
1685 * Callback to call on receipt of a reply
1686 *
1687 * @param cls closure
1688 * @param n number of peers
1689 * @param recv_peers the received peers
1690 */
1691static void
1692profiler_reply_handle (void *cls,
1693 uint64_t n,
1694 const struct GNUNET_PeerIdentity *recv_peers)
1695{
1696 struct RPSPeer *rps_peer;
1697 struct RPSPeer *rcv_rps_peer;
1698 char *file_name;
1699 char *file_name_dh;
1700 char *file_name_dhr;
1701 unsigned int i;
1702 struct PendingReply *pending_rep = (struct PendingReply *) cls;
1703
1704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "profiler_reply_handle()\n");
1705 rps_peer = pending_rep->rps_peer;
1706 file_name = "/tmp/rps/received_ids";
1707 file_name_dh = "/tmp/rps/diehard_input";
1708 file_name_dhr = "/tmp/rps/diehard_input_raw";
1709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1710 "[%s] got %" PRIu64 " peers:\n",
1711 GNUNET_i2s (rps_peer->peer_id),
1712 n);
1713 for (i = 0; i < n; i++)
1714 {
1715 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1716 "%u: %s\n",
1717 i,
1718 GNUNET_i2s (&recv_peers[i]));
1719 tofile (file_name,
1720 "%s\n",
1721 GNUNET_i2s_full (&recv_peers[i]));
1722 rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]);
1723 GNUNET_assert (NULL != rcv_rps_peer);
1724 tofile (file_name_dh,
1725 "%" PRIu32 "\n",
1726 (uint32_t) rcv_rps_peer->index);
1727 to_file_raw (file_name_dhr,
1728 &rcv_rps_peer->index,
1729 sizeof (uint32_t));
1730 }
1731 default_reply_handle (cls, n, recv_peers);
1732}
1733
1734
1735static void
1736profiler_cb (struct RPSPeer *rps_peer)
1737{
1738 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1739 {
1740 return;
1741 }
1742
1743 /* Start churn */
1744 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1745 {
1746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1747 "Starting churn task\n");
1748 churn_task = GNUNET_SCHEDULER_add_delayed (
1749 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
1750 churn,
1751 NULL);
1752 } else {
1753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1754 "Not starting churn task\n");
1755 }
1756
1757 /* Only request peer ids at one peer.
1758 * (It's the before-last because last one is target of the focussed attack.)
1759 */
1760 if (eval_peer == rps_peer)
1761 schedule_missing_requests (rps_peer);
1762}
1763
1764/**
1765 * Function called from #profiler_eval with a filename.
1766 *
1767 * @param cls closure
1768 * @param filename complete filename (absolute path)
1769 * @return #GNUNET_OK to continue to iterate,
1770 * #GNUNET_NO to stop iteration with no error,
1771 * #GNUNET_SYSERR to abort iteration with error!
1772 */
1773int
1774file_name_cb (void *cls, const char *filename)
1775{
1776 if (NULL != strstr (filename, "sampler_el"))
1777 {
1778 struct RPS_SamplerElement *s_elem;
1779 struct GNUNET_CRYPTO_AuthKey auth_key;
1780 const char *key_char;
1781 uint32_t i;
1782
1783 key_char = filename + 20; /* Length of "/tmp/rps/sampler_el-" */
1784 tofile (filename, "--------------------------\n");
1785
1786 auth_key = string_to_auth_key (key_char);
1787 s_elem = RPS_sampler_elem_create ();
1788 RPS_sampler_elem_set (s_elem, auth_key);
1789
1790 for (i = 0; i < num_peers; i++)
1791 {
1792 RPS_sampler_elem_next (s_elem, &rps_peer_ids[i]);
1793 }
1794 RPS_sampler_elem_destroy (s_elem);
1795 }
1796 return GNUNET_OK;
1797}
1798
1799/**
1800 * This is run after the test finished.
1801 *
1802 * Compute all perfect samples.
1803 */
1804int
1805profiler_eval (void)
1806{
1807 /* Compute perfect sample for each sampler element */
1808 if (-1 == GNUNET_DISK_directory_scan ("/tmp/rps/", file_name_cb, NULL))
1809 {
1810 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n");
1811 }
1812
1813 return evaluate ();
1814}
1815
1816static uint32_t fac (uint32_t x)
1817{
1818 if (1 >= x)
1819 {
1820 return x;
1821 }
1822 return x * fac (x - 1);
1823}
1824
1825static uint32_t binom (uint32_t n, uint32_t k)
1826{
1827 //GNUNET_assert (n >= k);
1828 if (k > n) return 0;
1829 if (0 > n) return 0;
1830 if (0 > k) return 0;
1831 if (0 == k) return 1;
1832 return fac (n)
1833 /
1834 fac(k) * fac(n - k);
1835}
1836
1837/**
1838 * @brief is b in view of a?
1839 *
1840 * @param a
1841 * @param b
1842 *
1843 * @return
1844 */
1845static int is_in_view (uint32_t a, uint32_t b)
1846{
1847 uint32_t i;
1848 for (i = 0; i < rps_peers[a].cur_view_count; i++)
1849 {
1850 if (0 == memcmp (rps_peers[b].peer_id,
1851 &rps_peers[a].cur_view[i],
1852 sizeof (struct GNUNET_PeerIdentity)))
1853 {
1854 return GNUNET_YES;
1855 }
1856 }
1857 return GNUNET_NO;
1858}
1859
1860static uint32_t get_idx_of_pid (const struct GNUNET_PeerIdentity *pid)
1861{
1862 uint32_t i;
1863
1864 for (i = 0; i < num_peers; i++)
1865 {
1866 if (0 == memcmp (pid,
1867 rps_peers[i].peer_id,
1868 sizeof (struct GNUNET_PeerIdentity)))
1869 {
1870 return i;
1871 }
1872 }
1873 //return 0; /* Should not happen - make compiler happy */
1874 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1875 "No known _PeerIdentity %s!\n",
1876 GNUNET_i2s_full (pid));
1877 GNUNET_assert (0);
1878}
1879
1880/**
1881 * @brief Counts number of peers in view of a that have b in their view
1882 *
1883 * @param a
1884 * @param uint32_tb
1885 *
1886 * @return
1887 */
1888static uint32_t count_containing_views (uint32_t a, uint32_t b)
1889{
1890 uint32_t i;
1891 uint32_t peer_idx;
1892 uint32_t count = 0;
1893
1894 for (i = 0; i < rps_peers[a].cur_view_count; i++)
1895 {
1896 peer_idx = get_idx_of_pid (&rps_peers[a].cur_view[i]);
1897 if (GNUNET_YES == is_in_view (peer_idx, b))
1898 {
1899 count++;
1900 }
1901 }
1902 return count;
1903}
1904
1905/**
1906 * @brief Computes the probability for each other peer to be selected by the
1907 * sampling process based on the views of all peers
1908 *
1909 * @param peer_idx index of the peer that is about to sample
1910 */
1911static void compute_probabilities (uint32_t peer_idx)
1912{
1913 //double probs[num_peers] = { 0 };
1914 double probs[num_peers];
1915 size_t probs_as_str_size = (num_peers * 10 + 1) * sizeof (char);
1916 char *probs_as_str = GNUNET_malloc (probs_as_str_size);
1917 char *probs_as_str_cpy;
1918 uint32_t i;
1919 double prob_push;
1920 double prob_pull;
1921 uint32_t view_size;
1922 uint32_t cont_views;
1923 uint32_t number_of_being_in_pull_events;
1924 int tmp;
1925 uint32_t count_non_zero_prob = 0;
1926
1927 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1928 "Computing probabilities for peer %" PRIu32 "\n", peer_idx);
1929 /* Firstly without knowledge of old views */
1930 for (i = 0; i < num_peers; i++)
1931 {
1932 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1933 "\tfor peer %" PRIu32 ":\n", i);
1934 view_size = rps_peers[i].cur_view_count;
1935 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1936 "\t\tview_size: %" PRIu32 "\n", view_size);
1937 /* For peer i the probability of being sampled is
1938 * evenly distributed among all possibly observed peers. */
1939 /* We could have observed a peer in three cases:
1940 * 1. peer sent a push
1941 * 2. peer was contained in a pull reply
1942 * 3. peer was in history (sampler) - ignored for now */
1943 /* 1. Probability of having received a push from peer i */
1944 if ((GNUNET_YES == is_in_view (i, peer_idx)) &&
1945 (1 <= (0.45 * view_size)))
1946 {
1947 prob_push = 1.0 * binom (0.45 * view_size, 1)
1948 /
1949 binom (view_size, 0.45 * view_size);
1950 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1951 "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n",
1952 peer_idx,
1953 i,
1954 prob_push);
1955 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1956 "\t\tposs choices from view: %" PRIu32 ", containing i: %" PRIu32 "\n",
1957 binom (view_size, 0.45 * view_size),
1958 binom (0.45 * view_size, 1));
1959 } else {
1960 prob_push = 0;
1961 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1962 "\t\t%" PRIu32 " is not in %" PRIu32 "'s view, prob: 0\n",
1963 peer_idx,
1964 i);
1965 }
1966 /* 2. Probability of peer i being contained in pulls */
1967 view_size = rps_peers[peer_idx].cur_view_count;
1968 cont_views = count_containing_views (peer_idx, i);
1969 number_of_being_in_pull_events =
1970 (binom (view_size, 0.45 * view_size) -
1971 binom (view_size - cont_views, 0.45 * view_size));
1972 if (0 != number_of_being_in_pull_events)
1973 {
1974 prob_pull = number_of_being_in_pull_events
1975 /
1976 (1.0 * binom (view_size, 0.45 * view_size));
1977 } else
1978 {
1979 prob_pull = 0;
1980 }
1981 probs[i] = prob_push + prob_pull - (prob_push * prob_pull);
1982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1983 "\t\t%" PRIu32 " has %" PRIu32 " of %" PRIu32
1984 " peers in its view who know %" PRIu32 " prob: %f\n",
1985 peer_idx,
1986 cont_views,
1987 view_size,
1988 i,
1989 prob_pull);
1990 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1991 "\t\tnumber of possible pull combinations: %" PRIu32 "\n",
1992 binom (view_size, 0.45 * view_size));
1993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1994 "\t\tnumber of possible pull combinations without %" PRIu32
1995 ": %" PRIu32 "\n",
1996 i,
1997 binom (view_size - cont_views, 0.45 * view_size));
1998 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1999 "\t\tnumber of possible pull combinations with %" PRIu32
2000 ": %" PRIu32 "\n",
2001 i,
2002 number_of_being_in_pull_events);
2003
2004 if (0 != probs[i]) count_non_zero_prob++;
2005 }
2006 /* normalize */
2007 if (0 != count_non_zero_prob)
2008 {
2009 for (i = 0; i < num_peers; i++)
2010 {
2011 probs[i] = probs[i] * (1.0 / count_non_zero_prob);
2012 }
2013 } else {
2014 for (i = 0; i < num_peers; i++)
2015 {
2016 probs[i] = 0;
2017 }
2018 }
2019 /* str repr */
2020 for (i = 0; i < num_peers; i++)
2021 {
2022 probs_as_str_cpy = GNUNET_strndup (probs_as_str, probs_as_str_size);
2023 tmp = GNUNET_snprintf (probs_as_str,
2024 probs_as_str_size,
2025 "%s %7.6f", probs_as_str_cpy, probs[i]);
2026 GNUNET_free (probs_as_str_cpy);
2027 GNUNET_assert (0 <= tmp);
2028 }
2029
2030 to_file_w_len (rps_peers[peer_idx].file_name_probs,
2031 probs_as_str_size,
2032 probs_as_str);
2033 GNUNET_free (probs_as_str);
2034}
2035
2036/**
2037 * @brief This counts the number of peers in which views a given peer occurs.
2038 *
2039 * It also stores this value in the rps peer.
2040 *
2041 * @param peer_idx the index of the peer to count the representation
2042 *
2043 * @return the number of occurrences
2044 */
2045static uint32_t count_peer_in_views_2 (uint32_t peer_idx)
2046{
2047 uint32_t i, j;
2048 uint32_t count = 0;
2049
2050 for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
2051 {
2052 for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
2053 {
2054 if (0 == memcmp (rps_peers[peer_idx].peer_id,
2055 &rps_peers[i].cur_view[j],
2056 sizeof (struct GNUNET_PeerIdentity)))
2057 {
2058 count++;
2059 break;
2060 }
2061 }
2062 }
2063 rps_peers[peer_idx].count_in_views = count;
2064 return count;
2065}
2066
2067static uint32_t cumulated_view_sizes ()
2068{
2069 uint32_t i;
2070
2071 view_sizes = 0;
2072 for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
2073 {
2074 view_sizes += rps_peers[i].cur_view_count;
2075 }
2076 return view_sizes;
2077}
2078
2079static void count_peer_in_views (uint32_t *count_peers)
2080{
2081 uint32_t i, j;
2082
2083 for (i = 0; i < num_peers; i++) /* Peer in which view is counted */
2084 {
2085 for (j = 0; j < rps_peers[i].cur_view_count; j++) /* entry in view */
2086 {
2087 if (0 == memcmp (rps_peers[i].peer_id,
2088 &rps_peers[i].cur_view[j],
2089 sizeof (struct GNUNET_PeerIdentity)))
2090 {
2091 count_peers[i]++;
2092 }
2093 }
2094 }
2095}
2096
2097void compute_diversity ()
2098{
2099 uint32_t i;
2100 /* ith entry represents the numer of occurrences in other peer's views */
2101 uint32_t *count_peers = GNUNET_new_array (num_peers, uint32_t);
2102 uint32_t views_total_size;
2103 double expected;
2104 /* deviation from expected number of peers */
2105 double *deviation = GNUNET_new_array (num_peers, double);
2106
2107 views_total_size = 0;
2108 expected = 0;
2109
2110 /* For each peer count its representation in other peer's views*/
2111 for (i = 0; i < num_peers; i++) /* Peer to count */
2112 {
2113 views_total_size += rps_peers[i].cur_view_count;
2114 count_peer_in_views (count_peers);
2115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2116 "Counted representation of %" PRIu32 "th peer [%s]: %" PRIu32"\n",
2117 i,
2118 GNUNET_i2s (rps_peers[i].peer_id),
2119 count_peers[i]);
2120 }
2121
2122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2123 "size of all views combined: %" PRIu32 "\n",
2124 views_total_size);
2125 expected = ((double) 1/num_peers) * views_total_size;
2126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2127 "Expected number of occurrences of each peer in all views: %f\n",
2128 expected);
2129 for (i = 0; i < num_peers; i++) /* Peer to count */
2130 {
2131 deviation[i] = expected - count_peers[i];
2132 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2133 "Deviation from expectation: %f\n", deviation[i]);
2134 }
2135 GNUNET_free (count_peers);
2136 GNUNET_free (deviation);
2137}
2138
2139void print_view_sizes()
2140{
2141 uint32_t i;
2142
2143 for (i = 0; i < num_peers; i++) /* Peer to count */
2144 {
2145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2146 "View size of %" PRIu32 ". [%s] is %" PRIu32 "\n",
2147 i,
2148 GNUNET_i2s (rps_peers[i].peer_id),
2149 rps_peers[i].cur_view_count);
2150 }
2151}
2152
2153void all_views_updated_cb()
2154{
2155 compute_diversity();
2156 print_view_sizes();
2157}
2158
2159void view_update_cb (void *cls,
2160 uint64_t view_size,
2161 const struct GNUNET_PeerIdentity *peers)
2162{
2163 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2164 "View was updated (%" PRIu64 ")\n", view_size);
2165 struct RPSPeer *rps_peer = (struct RPSPeer *) cls;
2166 to_file ("/tmp/rps/view_sizes.txt",
2167 "%" PRIu64 " %" PRIu32 "",
2168 rps_peer->index,
2169 view_size);
2170 for (int i = 0; i < view_size; i++)
2171 {
2172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2173 "\t%s\n", GNUNET_i2s (&peers[i]));
2174 }
2175 GNUNET_array_grow (rps_peer->cur_view,
2176 rps_peer->cur_view_count,
2177 view_size);
2178 //*rps_peer->cur_view = *peers;
2179 GNUNET_memcpy (rps_peer->cur_view,
2180 peers,
2181 view_size * sizeof (struct GNUNET_PeerIdentity));
2182 to_file ("/tmp/rps/count_in_views.txt",
2183 "%" PRIu64 " %" PRIu32 "",
2184 rps_peer->index,
2185 count_peer_in_views_2 (rps_peer->index));
2186 cumulated_view_sizes();
2187 if (0 != view_size)
2188 {
2189 to_file ("/tmp/rps/repr.txt",
2190 "%" PRIu64 /* index */
2191 " %" PRIu32 /* occurrence in views */
2192 " %" PRIu32 /* view sizes */
2193 " %f" /* fraction of repr in views */
2194 " %f" /* average view size */
2195 " %f" /* prob of occurrence in view slot */
2196 " %f" "", /* exp frac of repr in views */
2197 rps_peer->index,
2198 count_peer_in_views_2 (rps_peer->index),
2199 view_sizes,
2200 count_peer_in_views_2 (rps_peer->index) / (view_size * 1.0), /* fraction of representation in views */
2201 view_sizes / (view_size * 1.0), /* average view size */
2202 1.0 /view_size, /* prob of occurrence in view slot */
2203 (1.0/view_size) * (view_sizes/view_size) /* expected fraction of repr in views */
2204 );
2205 }
2206 compute_probabilities (rps_peer->index);
2207 all_views_updated_cb();
2208}
2209
2210static void
2211pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
2212{
2213 rps_peer->file_name_probs =
2214 store_prefix_file_name (rps_peer->peer_id, "probs");
2215 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
2216}
2217
2218void write_final_stats (void){
2219 uint64_t sums[STAT_TYPE_MAX] = { 0 };
2220
2221 for (uint32_t i = 0; i < num_peers; i++)
2222 {
2223 to_file ("/tmp/rps/final_stats.dat",
2224 "%" PRIu32 " " /* index */
2225 "%s %" /* id */
2226 PRIu64 " %" /* rounds */
2227 PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */
2228 PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */
2229 PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */
2230 PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
2231 i,
2232 GNUNET_i2s (rps_peers[i].peer_id),
2233 rps_peers[i].stats[STAT_TYPE_ROUNDS],
2234 rps_peers[i].stats[STAT_TYPE_BLOCKS],
2235 rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH],
2236 rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH],
2237 rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PULL],
2238 rps_peers[i].stats[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
2239 rps_peers[i].stats[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
2240 rps_peers[i].stats[STAT_TYPE_ISSUED_PUSH_SEND],
2241 rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REQ],
2242 rps_peers[i].stats[STAT_TYPE_ISSUED_PULL_REP],
2243 rps_peers[i].stats[STAT_TYPE_SENT_PUSH_SEND],
2244 rps_peers[i].stats[STAT_TYPE_SENT_PULL_REQ],
2245 rps_peers[i].stats[STAT_TYPE_SENT_PULL_REP],
2246 rps_peers[i].stats[STAT_TYPE_RECV_PUSH_SEND],
2247 rps_peers[i].stats[STAT_TYPE_RECV_PULL_REQ],
2248 rps_peers[i].stats[STAT_TYPE_RECV_PULL_REP]);
2249 for (uint32_t stat_type = STAT_TYPE_ROUNDS;
2250 stat_type < STAT_TYPE_MAX;
2251 stat_type++)
2252 {
2253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2254 "Add to sum (%" PRIu64 ") %" PRIu64 " of stat type %u - %s\n",
2255 sums[stat_type],
2256 rps_peers[i].stats[stat_type],
2257 stat_type,
2258 stat_type_2_str (stat_type));
2259 sums[stat_type] += rps_peers[i].stats[stat_type];
2260 }
2261 }
2262 to_file ("/tmp/rps/final_stats.dat",
2263 "SUM %"
2264 PRIu64 " %" /* rounds */
2265 PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */
2266 PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */
2267 PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */
2268 PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
2269 sums[STAT_TYPE_ROUNDS],
2270 sums[STAT_TYPE_BLOCKS],
2271 sums[STAT_TYPE_BLOCKS_MANY_PUSH],
2272 sums[STAT_TYPE_BLOCKS_NO_PUSH],
2273 sums[STAT_TYPE_BLOCKS_NO_PULL],
2274 sums[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL],
2275 sums[STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL],
2276 sums[STAT_TYPE_ISSUED_PUSH_SEND],
2277 sums[STAT_TYPE_ISSUED_PULL_REQ],
2278 sums[STAT_TYPE_ISSUED_PULL_REP],
2279 sums[STAT_TYPE_SENT_PUSH_SEND],
2280 sums[STAT_TYPE_SENT_PULL_REQ],
2281 sums[STAT_TYPE_SENT_PULL_REP],
2282 sums[STAT_TYPE_RECV_PUSH_SEND],
2283 sums[STAT_TYPE_RECV_PULL_REQ],
2284 sums[STAT_TYPE_RECV_PULL_REP]);
2285}
2286
2287/**
2288 * Continuation called by #GNUNET_STATISTICS_get() functions.
2289 *
2290 * Remembers that this specific statistics value was received for this peer.
2291 * Checks whether all peers received their statistics yet.
2292 * Issues the shutdown.
2293 *
2294 * @param cls closure
2295 * @param success #GNUNET_OK if statistics were
2296 * successfully obtained, #GNUNET_SYSERR if not.
2297 */
2298void
2299post_test_shutdown_ready_cb (void *cls,
2300 int success)
2301{
2302 struct STATcls *stat_cls = (struct STATcls *) cls;
2303 struct RPSPeer *rps_peer = stat_cls->rps_peer;
2304 if (GNUNET_OK == success)
2305 {
2306 /* set flag that we we got the value */
2307 rps_peer->stat_collected_flags |= BIT(stat_cls->stat_type);
2308 } else {
2309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2310 "Peer %u did not receive statistics value\n",
2311 rps_peer->index);
2312 GNUNET_free (stat_cls);
2313 GNUNET_break (0);
2314 }
2315
2316 if (NULL != rps_peer->stat_op &&
2317 GNUNET_YES == check_statistics_collect_completed_single_peer (rps_peer))
2318 {
2319 GNUNET_TESTBED_operation_done (rps_peer->stat_op);
2320 }
2321
2322 write_final_stats ();
2323 if (GNUNET_YES == check_statistics_collect_completed())
2324 {
2325 //write_final_stats ();
2326 GNUNET_free (stat_cls);
2327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2328 "Shutting down\n");
2329 GNUNET_SCHEDULER_shutdown ();
2330 } else {
2331 GNUNET_free (stat_cls);
2332 }
2333}
2334
2335/**
2336 * Callback function to process statistic values.
2337 *
2338 * @param cls closure
2339 * @param subsystem name of subsystem that created the statistic
2340 * @param name the name of the datum
2341 * @param value the current value
2342 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
2343 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
2344 */
2345int
2346stat_iterator (void *cls,
2347 const char *subsystem,
2348 const char *name,
2349 uint64_t value,
2350 int is_persistent)
2351{
2352 const struct STATcls *stat_cls = (const struct STATcls *) cls;
2353 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
2354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
2355 //stat_type_2_str (stat_cls->stat_type),
2356 name,
2357 value);
2358 to_file (rps_peer->file_name_stats,
2359 "%s: %" PRIu64 "\n",
2360 name,
2361 value);
2362 switch (stat_str_2_type (name))
2363 {
2364 case STAT_TYPE_ROUNDS:
2365 rps_peer->stats[STAT_TYPE_ROUNDS] = value;
2366 break;
2367 case STAT_TYPE_BLOCKS:
2368 rps_peer->stats[STAT_TYPE_BLOCKS] = value;
2369 break;
2370 case STAT_TYPE_BLOCKS_MANY_PUSH:
2371 rps_peer->stats[STAT_TYPE_BLOCKS_MANY_PUSH] = value;
2372 break;
2373 case STAT_TYPE_BLOCKS_NO_PUSH:
2374 rps_peer->stats[STAT_TYPE_BLOCKS_NO_PUSH] = value;
2375 break;
2376 case STAT_TYPE_BLOCKS_NO_PULL:
2377 rps_peer->stats[STAT_TYPE_BLOCKS_NO_PULL] = value;
2378 break;
2379 case STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL:
2380 rps_peer->stats[STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL] = value;
2381 break;
2382 case STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL:
2383 rps_peer->stats[STAT_TYPE_BLOCKS] = value;
2384 break;
2385 case STAT_TYPE_ISSUED_PUSH_SEND:
2386 rps_peer->stats[STAT_TYPE_ISSUED_PUSH_SEND] = value;
2387 break;
2388 case STAT_TYPE_ISSUED_PULL_REQ:
2389 rps_peer->stats[STAT_TYPE_ISSUED_PULL_REQ] = value;
2390 break;
2391 case STAT_TYPE_ISSUED_PULL_REP:
2392 rps_peer->stats[STAT_TYPE_ISSUED_PULL_REP] = value;
2393 break;
2394 case STAT_TYPE_SENT_PUSH_SEND:
2395 rps_peer->stats[STAT_TYPE_SENT_PUSH_SEND] = value;
2396 break;
2397 case STAT_TYPE_SENT_PULL_REQ:
2398 rps_peer->stats[STAT_TYPE_SENT_PULL_REQ] = value;
2399 break;
2400 case STAT_TYPE_SENT_PULL_REP:
2401 rps_peer->stats[STAT_TYPE_SENT_PULL_REP] = value;
2402 break;
2403 case STAT_TYPE_RECV_PUSH_SEND:
2404 rps_peer->stats[STAT_TYPE_RECV_PUSH_SEND] = value;
2405 break;
2406 case STAT_TYPE_RECV_PULL_REQ:
2407 rps_peer->stats[STAT_TYPE_RECV_PULL_REQ] = value;
2408 break;
2409 case STAT_TYPE_RECV_PULL_REP:
2410 rps_peer->stats[STAT_TYPE_RECV_PULL_REP] = value;
2411 break;
2412 case STAT_TYPE_MAX:
2413 default:
2414 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2415 "Unknown statistics string: %s\n",
2416 name);
2417 break;
2418 }
2419 return GNUNET_OK;
2420}
2421
2422void post_profiler (struct RPSPeer *rps_peer)
2423{
2424 if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
2425 {
2426 return;
2427 }
2428
2429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2430 "Going to request statistic values with mask 0x%" PRIx32 "\n",
2431 cur_test_run.stat_collect_flags);
2432
2433 struct STATcls *stat_cls;
2434 uint32_t stat_type;
2435 for (stat_type = STAT_TYPE_ROUNDS;
2436 stat_type < STAT_TYPE_MAX;
2437 stat_type++)
2438 {
2439 if (BIT(stat_type) & cur_test_run.stat_collect_flags)
2440 {
2441 stat_cls = GNUNET_malloc (sizeof (struct STATcls));
2442 stat_cls->rps_peer = rps_peer;
2443 stat_cls->stat_type = stat_type;
2444 rps_peer->file_name_stats =
2445 store_prefix_file_name (rps_peer->peer_id, "stats");
2446 GNUNET_STATISTICS_get (rps_peer->stats_h,
2447 "rps",
2448 stat_type_2_str (stat_type),
2449 post_test_shutdown_ready_cb,
2450 stat_iterator,
2451 (struct STATcls *) stat_cls);
2452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2453 "Requested statistics for %s (peer %" PRIu32 ")\n",
2454 stat_type_2_str (stat_type),
2455 rps_peer->index);
2456 }
2457 }
2458}
2459
2460
2461/***********************************************************************
2462 * /Definition of tests
2463***********************************************************************/
2464
2465
2466/**
2467 * Actual "main" function for the testcase.
2468 *
2469 * @param cls closure
2470 * @param h the run handle
2471 * @param n_peers number of peers in 'peers'
2472 * @param peers handle to peers run in the testbed
2473 * @param links_succeeded the number of overlay link connection attempts that
2474 * succeeded
2475 * @param links_failed the number of overlay link connection attempts that
2476 * failed
2477 */
2478static void
2479test_run (void *cls,
2480 struct GNUNET_TESTBED_RunHandle *h,
2481 unsigned int n_peers,
2482 struct GNUNET_TESTBED_Peer **peers,
2483 unsigned int links_succeeded,
2484 unsigned int links_failed)
2485{
2486 unsigned int i;
2487 struct OpListEntry *entry;
2488
2489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n");
2490 printf ("test 1\n");
2491
2492 /* Check whether we timed out */
2493 if (n_peers != num_peers ||
2494 NULL == peers ||
2495 0 == links_succeeded)
2496 {
2497 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Going down due to args (eg. timeout)\n");
2498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tn_peers: %u\n", n_peers);
2499 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tnum_peers: %" PRIu32 "\n", num_peers);
2500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tpeers: %p\n", peers);
2501 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tlinks_succeeded: %u\n", links_succeeded);
2502 GNUNET_SCHEDULER_shutdown ();
2503 return;
2504 }
2505
2506
2507 /* Initialize peers */
2508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "going to initialise peers\n");
2509 testbed_peers = peers;
2510 num_peers_online = 0;
2511 for (i = 0; i < num_peers; i++)
2512 {
2513 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "initialising %u\n", i);
2514 entry = make_oplist_entry ();
2515 entry->index = i;
2516 rps_peers[i].index = i;
2517 if (NULL != cur_test_run.init_peer)
2518 cur_test_run.init_peer (&rps_peers[i]);
2519 if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
2520 {
2521 rps_peers->cur_view_count = 0;
2522 rps_peers->cur_view = NULL;
2523 }
2524 entry->op = GNUNET_TESTBED_peer_get_information (peers[i],
2525 GNUNET_TESTBED_PIT_IDENTITY,
2526 &info_cb,
2527 entry);
2528 }
2529
2530 /* Bring peers up */
2531 GNUNET_assert (num_peers == n_peers);
2532 for (i = 0; i < n_peers; i++)
2533 {
2534 rps_peers[i].index = i;
2535 rps_peers[i].op =
2536 GNUNET_TESTBED_service_connect (&rps_peers[i],
2537 peers[i],
2538 "rps",
2539 &rps_connect_complete_cb,
2540 &rps_peers[i],
2541 &rps_connect_adapter,
2542 &rps_disconnect_adapter,
2543 &rps_peers[i]);
2544 /* Connect all peers to statistics service */
2545 if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics)
2546 {
2547 rps_peers[i].stat_op =
2548 GNUNET_TESTBED_service_connect (NULL,
2549 peers[i],
2550 "statistics",
2551 stat_complete_cb,
2552 &rps_peers[i],
2553 &stat_connect_adapter,
2554 &stat_disconnect_adapter,
2555 &rps_peers[i]);
2556 }
2557 }
2558
2559 if (NULL != churn_task)
2560 GNUNET_SCHEDULER_cancel (churn_task);
2561 post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL);
2562 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
2563 (timeout_s * 1.2) + 0.1 * num_peers);
2564 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
2565 shutdown_task = GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL);
2566
2567}
2568
2569
2570/**
2571 * Entry point for the testcase, sets up the testbed.
2572 *
2573 * @param argc unused
2574 * @param argv unused
2575 * @return 0 on success
2576 */
2577static void
2578run (void *cls,
2579 char *const *args,
2580 const char *cfgfile,
2581 const struct GNUNET_CONFIGURATION_Handle *cfg)
2582{
2583 //int ret_value;
2584
2585 /* Defaults for tests */
2586 churn_task = NULL;
2587
2588 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n");
2589 cur_test_run.name = "test-rps-profiler";
2590 num_peers = 10;
2591 mal_type = 3;
2592 cur_test_run.init_peer = profiler_init_peer;
2593 //cur_test_run.pre_test = mal_pre;
2594 cur_test_run.pre_test = pre_profiler;
2595 cur_test_run.main_test = profiler_cb;
2596 cur_test_run.reply_handle = profiler_reply_handle;
2597 cur_test_run.eval_cb = profiler_eval;
2598 cur_test_run.post_test = post_profiler;
2599 cur_test_run.request_interval = 2;
2600 cur_test_run.num_requests = 5;
2601 //cur_test_run.have_churn = HAVE_CHURN;
2602 cur_test_run.have_churn = HAVE_NO_CHURN;
2603 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
2604 cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
2605 cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) |
2606 BIT(STAT_TYPE_BLOCKS) |
2607 BIT(STAT_TYPE_BLOCKS_MANY_PUSH) |
2608 BIT(STAT_TYPE_BLOCKS_NO_PUSH) |
2609 BIT(STAT_TYPE_BLOCKS_NO_PULL) |
2610 BIT(STAT_TYPE_BLOCKS_MANY_PUSH_NO_PULL) |
2611 BIT(STAT_TYPE_BLOCKS_NO_PUSH_NO_PULL) |
2612 BIT(STAT_TYPE_ISSUED_PUSH_SEND) |
2613 BIT(STAT_TYPE_ISSUED_PULL_REQ) |
2614 BIT(STAT_TYPE_ISSUED_PULL_REP) |
2615 BIT(STAT_TYPE_SENT_PUSH_SEND) |
2616 BIT(STAT_TYPE_SENT_PULL_REQ) |
2617 BIT(STAT_TYPE_SENT_PULL_REP) |
2618 BIT(STAT_TYPE_RECV_PUSH_SEND) |
2619 BIT(STAT_TYPE_RECV_PULL_REQ) |
2620 BIT(STAT_TYPE_RECV_PULL_REP);
2621 cur_test_run.have_collect_view = COLLECT_VIEW;
2622 timeout_s = 300;
2623
2624 /* 'Clean' directory */
2625 (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
2626 GNUNET_DISK_directory_create ("/tmp/rps/");
2627 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_s);
2628
2629 rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
2630 peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
2631 rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity);
2632 if ( (2 == mal_type) ||
2633 (3 == mal_type))
2634 target_peer = &rps_peer_ids[num_peers - 2];
2635 if (profiler_eval == cur_test_run.eval_cb)
2636 eval_peer = &rps_peers[num_peers - 1]; /* FIXME: eval_peer could be a
2637 malicious peer if not careful
2638 with the malicious portion */
2639
2640 ok = 1;
2641 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2642 "before _run()\n");
2643 GNUNET_TESTBED_run (NULL,
2644 cfg,
2645 num_peers,
2646 0, /* event mask */
2647 NULL,
2648 NULL,
2649 &test_run,
2650 NULL);
2651 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2652 "after _run()\n");
2653 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2654 "gnunet-rps-profiler returned.\n");
2655}
2656
2657/**
2658 * Entry point for the testcase, sets up the testbed.
2659 *
2660 * @param argc unused
2661 * @param argv unused
2662 * @return 0 on success
2663 */
2664int
2665main (int argc, char *argv[])
2666{
2667 int ret_value;
2668 struct GNUNET_GETOPT_CommandLineOption options[] = {
2669 GNUNET_GETOPT_option_uint ('n',
2670 "peers",
2671 "COUNT",
2672 gettext_noop ("number of peers to start"),
2673 &num_peers),
2674 GNUNET_GETOPT_OPTION_END
2675 };
2676
2677 //if (GNUNET_OK !=
2678 // GNUNET_STRINGS_get_utf8_args (argc, argv,
2679 // &argc, &argv))
2680 // return 2;
2681 ret_value = 0;
2682 if (GNUNET_OK !=
2683 GNUNET_PROGRAM_run (argc,
2684 argv,
2685 "gnunet-rps-profiler",
2686 gettext_noop ("Measure quality and performance of the RPS service."),
2687 options,
2688 &run,
2689 NULL))
2690 {
2691 ret_value = 1;
2692 }
2693 if (GNUNET_OK != ret_value)
2694 {
2695 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2696 "Test did not run successfully!\n");
2697 }
2698
2699 ret_value = cur_test_run.eval_cb();
2700 if (NO_COLLECT_VIEW == cur_test_run.have_collect_view)
2701 {
2702 GNUNET_array_grow (rps_peers->cur_view,
2703 rps_peers->cur_view_count,
2704 0);
2705 }
2706 GNUNET_free (rps_peers);
2707 GNUNET_free (rps_peer_ids);
2708 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
2709 printf ("test -1\n");
2710 return ret_value;
2711}
2712
2713/* end of test_rps.c */
diff --git a/src/rps/gnunet-rps.c b/src/rps/gnunet-rps.c
index 8de588568..e09277589 100644
--- a/src/rps/gnunet-rps.c
+++ b/src/rps/gnunet-rps.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index eb47903e0..9e81330bd 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013-2015 GNUnet e.V. 3 Copyright (C) 2013-2015 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index aef081a00..90177cb94 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_custommap.h b/src/rps/gnunet-service-rps_custommap.h
index f339b841d..b42ae9efa 100644
--- a/src/rps/gnunet-service-rps_custommap.h
+++ b/src/rps/gnunet-service-rps_custommap.h
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_sampler.c b/src/rps/gnunet-service-rps_sampler.c
index cfc5ce77b..711d5be63 100644
--- a/src/rps/gnunet-service-rps_sampler.c
+++ b/src/rps/gnunet-service-rps_sampler.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_sampler.h b/src/rps/gnunet-service-rps_sampler.h
index f33e7430c..c44844f96 100644
--- a/src/rps/gnunet-service-rps_sampler.h
+++ b/src/rps/gnunet-service-rps_sampler.h
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_sampler_elem.c b/src/rps/gnunet-service-rps_sampler_elem.c
index 007f818e2..7569801a6 100644
--- a/src/rps/gnunet-service-rps_sampler_elem.c
+++ b/src/rps/gnunet-service-rps_sampler_elem.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_sampler_elem.h b/src/rps/gnunet-service-rps_sampler_elem.h
index bbf2c147b..1dbdcbadd 100644
--- a/src/rps/gnunet-service-rps_sampler_elem.h
+++ b/src/rps/gnunet-service-rps_sampler_elem.h
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_view.c b/src/rps/gnunet-service-rps_view.c
index b7a0ba287..1fa75fc53 100644
--- a/src/rps/gnunet-service-rps_view.c
+++ b/src/rps/gnunet-service-rps_view.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/gnunet-service-rps_view.h b/src/rps/gnunet-service-rps_view.h
index 6a85a2134..127b49faf 100644
--- a/src/rps/gnunet-service-rps_view.h
+++ b/src/rps/gnunet-service-rps_view.h
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 869170a8a..ea55deac5 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
@@ -109,6 +107,53 @@ to_file_ (const char *file_name, char *line)
109 "Unable to close file\n"); 107 "Unable to close file\n");
110} 108}
111 109
110void
111to_file_raw (const char *file_name, void *buf, size_t size_buf)
112{
113 struct GNUNET_DISK_FileHandle *f;
114 size_t size2;
115
116
117 if (NULL == (f = GNUNET_DISK_file_open (file_name,
118 GNUNET_DISK_OPEN_APPEND |
119 GNUNET_DISK_OPEN_WRITE |
120 GNUNET_DISK_OPEN_CREATE,
121 GNUNET_DISK_PERM_USER_READ |
122 GNUNET_DISK_PERM_USER_WRITE |
123 GNUNET_DISK_PERM_GROUP_READ |
124 GNUNET_DISK_PERM_OTHER_READ)))
125 {
126 LOG (GNUNET_ERROR_TYPE_WARNING,
127 "Not able to open file %s\n",
128 file_name);
129 return;
130 }
131
132 size2 = GNUNET_DISK_file_write (f, buf, size_buf);
133 if (size_buf != size2)
134 {
135 LOG (GNUNET_ERROR_TYPE_WARNING,
136 "Unable to write to file! (Size: %u, size2: %u)\n",
137 size_buf,
138 size2);
139
140 if (GNUNET_YES != GNUNET_DISK_file_close (f))
141 LOG (GNUNET_ERROR_TYPE_WARNING,
142 "Unable to close file\n");
143
144 return;
145 }
146
147 //if (512 < size_buf)
148 //{
149 // GNUNET_free (output_buffer_p);
150 //}
151
152 //if (GNUNET_YES != GNUNET_DISK_file_close (f))
153 // LOG (GNUNET_ERROR_TYPE_WARNING,
154 // "Unable to close file\n");
155}
156
112char * 157char *
113auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key) 158auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key)
114{ 159{
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index 59f062331..d42422750 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
@@ -76,5 +74,8 @@ const char *
76store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, 74store_prefix_file_name (const struct GNUNET_PeerIdentity *peer,
77 const char *prefix); 75 const char *prefix);
78 76
77void
78to_file_raw (const char *file_name, void *buf, size_t size_buf);
79
79#endif /* RPS_TEST_UTIL_H */ 80#endif /* RPS_TEST_UTIL_H */
80/* end of gnunet-service-rps.c */ 81/* end of gnunet-service-rps.c */
diff --git a/src/rps/rps.conf.in b/src/rps/rps.conf.in
index b5feb1bd2..733b72601 100644
--- a/src/rps/rps.conf.in
+++ b/src/rps/rps.conf.in
@@ -24,4 +24,4 @@ FILENAME_VALID_PEERS = $GNUNET_DATA_HOME/rps/valid_peers.txt
24# until we receive the first estimate from NSE. 24# until we receive the first estimate from NSE.
25# Keep in mind, that (networksize)^(1/3) should be enough. 25# Keep in mind, that (networksize)^(1/3) should be enough.
26# So, 50 is enough for a network of size 50^3 = 125000 26# So, 50 is enough for a network of size 50^3 = 125000
27INITSIZE = 10 27MINSIZE = 10
diff --git a/src/rps/rps.h b/src/rps/rps.h
index 6a7fa3e14..6bf2273b4 100644
--- a/src/rps/rps.h
+++ b/src/rps/rps.h
@@ -2,20 +2,18 @@
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2012-2013 GNUnet e.V. 3 Copyright (C) 2012-2013 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */ 17 */
20/** 18/**
21 * @file rps/rps.h 19 * @file rps/rps.h
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 0da3bd4a4..ca80e25e8 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20 18
21/** 19/**
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index bae28428f..3ef1e6611 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009, 2012 GNUnet e.V. 3 Copyright (C) 2009, 2012 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file rps/test_rps.c 19 * @file rps/test_rps.c
@@ -42,6 +40,12 @@ static uint32_t num_peers;
42 40
43/** 41/**
44 * How long do we run the test? 42 * How long do we run the test?
43 * In seconds.
44 */
45static uint32_t timeout_s;
46
47/**
48 * How long do we run the test?
45 */ 49 */
46//#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 50//#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
47static struct GNUNET_TIME_Relative timeout; 51static struct GNUNET_TIME_Relative timeout;
@@ -371,6 +375,11 @@ static int ok;
371/** 375/**
372 * Identifier for the churn task that runs periodically 376 * Identifier for the churn task that runs periodically
373 */ 377 */
378static struct GNUNET_SCHEDULER_Task *post_test_task;
379
380/**
381 * Identifier for the churn task that runs periodically
382 */
374static struct GNUNET_SCHEDULER_Task *shutdown_task; 383static struct GNUNET_SCHEDULER_Task *shutdown_task;
375 384
376/** 385/**
@@ -556,6 +565,11 @@ struct SingleTestRun
556} cur_test_run; 565} cur_test_run;
557 566
558/** 567/**
568 * Did we finish the test?
569 */
570static int post_test;
571
572/**
559 * Are we shutting down? 573 * Are we shutting down?
560 */ 574 */
561static int in_shutdown; 575static int in_shutdown;
@@ -755,6 +769,10 @@ shutdown_op (void *cls)
755 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 769 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
756 "Shutdown task scheduled, going down.\n"); 770 "Shutdown task scheduled, going down.\n");
757 in_shutdown = GNUNET_YES; 771 in_shutdown = GNUNET_YES;
772 if (NULL != post_test_task)
773 {
774 GNUNET_SCHEDULER_cancel (post_test_task);
775 }
758 if (NULL != churn_task) 776 if (NULL != churn_task)
759 { 777 {
760 GNUNET_SCHEDULER_cancel (churn_task); 778 GNUNET_SCHEDULER_cancel (churn_task);
@@ -762,8 +780,42 @@ shutdown_op (void *cls)
762 } 780 }
763 for (i = 0; i < num_peers; i++) 781 for (i = 0; i < num_peers; i++)
764 { 782 {
783 if (NULL != rps_peers[i].rps_handle)
784 {
785 GNUNET_RPS_disconnect (rps_peers[i].rps_handle);
786 }
765 if (NULL != rps_peers[i].op) 787 if (NULL != rps_peers[i].op)
788 {
766 GNUNET_TESTBED_operation_done (rps_peers[i].op); 789 GNUNET_TESTBED_operation_done (rps_peers[i].op);
790 }
791 }
792}
793
794
795/**
796 * Task run on timeout to collect statistics and potentially shut down.
797 */
798static void
799post_test_op (void *cls)
800{
801 unsigned int i;
802
803 post_test_task = NULL;
804 post_test = GNUNET_YES;
805 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
806 "Post test task scheduled, going down.\n");
807 if (NULL != churn_task)
808 {
809 GNUNET_SCHEDULER_cancel (churn_task);
810 churn_task = NULL;
811 }
812 for (i = 0; i < num_peers; i++)
813 {
814 if (NULL != rps_peers[i].op)
815 {
816 GNUNET_TESTBED_operation_done (rps_peers[i].op);
817 rps_peers[i].op = NULL;
818 }
767 if (NULL != cur_test_run.post_test) 819 if (NULL != cur_test_run.post_test)
768 { 820 {
769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i); 821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i);
@@ -847,7 +899,7 @@ info_cb (void *cb_cls,
847{ 899{
848 struct OpListEntry *entry = (struct OpListEntry *) cb_cls; 900 struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
849 901
850 if (GNUNET_YES == in_shutdown) 902 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
851 { 903 {
852 return; 904 return;
853 } 905 }
@@ -901,7 +953,7 @@ rps_connect_complete_cb (void *cls,
901 struct RPSPeer *rps_peer = cls; 953 struct RPSPeer *rps_peer = cls;
902 struct GNUNET_RPS_Handle *rps = ca_result; 954 struct GNUNET_RPS_Handle *rps = ca_result;
903 955
904 if (GNUNET_YES == in_shutdown) 956 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
905 { 957 {
906 return; 958 return;
907 } 959 }
@@ -1105,10 +1157,10 @@ default_reply_handle (void *cls,
1105 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) 1157 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)
1106 { 1158 {
1107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); 1159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
1108 GNUNET_assert (NULL != shutdown_task); 1160 GNUNET_assert (NULL != post_test_task);
1109 GNUNET_SCHEDULER_cancel (shutdown_task); 1161 GNUNET_SCHEDULER_cancel (post_test_task);
1110 shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); 1162 post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL);
1111 GNUNET_assert (NULL!= shutdown_task); 1163 GNUNET_assert (NULL!= post_test_task);
1112 } 1164 }
1113} 1165}
1114 1166
@@ -1122,7 +1174,7 @@ request_peers (void *cls)
1122 struct RPSPeer *rps_peer; 1174 struct RPSPeer *rps_peer;
1123 struct PendingReply *pending_rep; 1175 struct PendingReply *pending_rep;
1124 1176
1125 if (GNUNET_YES == in_shutdown) 1177 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1126 return; 1178 return;
1127 rps_peer = pending_req->rps_peer; 1179 rps_peer = pending_req->rps_peer;
1128 GNUNET_assert (1 <= rps_peer->num_pending_reqs); 1180 GNUNET_assert (1 <= rps_peer->num_pending_reqs);
@@ -1185,7 +1237,7 @@ cancel_request_cb (void *cls)
1185 struct RPSPeer *rps_peer = cls; 1237 struct RPSPeer *rps_peer = cls;
1186 struct PendingReply *pending_rep; 1238 struct PendingReply *pending_rep;
1187 1239
1188 if (GNUNET_YES == in_shutdown) 1240 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1189 return; 1241 return;
1190 pending_rep = rps_peer->pending_rep_head; 1242 pending_rep = rps_peer->pending_rep_head;
1191 GNUNET_assert (1 <= rps_peer->num_pending_reps); 1243 GNUNET_assert (1 <= rps_peer->num_pending_reps);
@@ -1290,7 +1342,7 @@ mal_cb (struct RPSPeer *rps_peer)
1290{ 1342{
1291 uint32_t num_mal_peers; 1343 uint32_t num_mal_peers;
1292 1344
1293 if (GNUNET_YES == in_shutdown) 1345 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1294 { 1346 {
1295 return; 1347 return;
1296 } 1348 }
@@ -1317,7 +1369,7 @@ mal_cb (struct RPSPeer *rps_peer)
1317static void 1369static void
1318single_req_cb (struct RPSPeer *rps_peer) 1370single_req_cb (struct RPSPeer *rps_peer)
1319{ 1371{
1320 if (GNUNET_YES == in_shutdown) 1372 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1321 { 1373 {
1322 return; 1374 return;
1323 } 1375 }
@@ -1331,7 +1383,7 @@ single_req_cb (struct RPSPeer *rps_peer)
1331static void 1383static void
1332delay_req_cb (struct RPSPeer *rps_peer) 1384delay_req_cb (struct RPSPeer *rps_peer)
1333{ 1385{
1334 if (GNUNET_YES == in_shutdown) 1386 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1335 { 1387 {
1336 return; 1388 return;
1337 } 1389 }
@@ -1345,7 +1397,7 @@ delay_req_cb (struct RPSPeer *rps_peer)
1345static void 1397static void
1346seed_cb (struct RPSPeer *rps_peer) 1398seed_cb (struct RPSPeer *rps_peer)
1347{ 1399{
1348 if (GNUNET_YES == in_shutdown) 1400 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1349 { 1401 {
1350 return; 1402 return;
1351 } 1403 }
@@ -1361,7 +1413,7 @@ seed_cb (struct RPSPeer *rps_peer)
1361static void 1413static void
1362seed_big_cb (struct RPSPeer *rps_peer) 1414seed_big_cb (struct RPSPeer *rps_peer)
1363{ 1415{
1364 if (GNUNET_YES == in_shutdown) 1416 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1365 { 1417 {
1366 return; 1418 return;
1367 } 1419 }
@@ -1387,7 +1439,7 @@ single_peer_seed_cb (struct RPSPeer *rps_peer)
1387static void 1439static void
1388seed_req_cb (struct RPSPeer *rps_peer) 1440seed_req_cb (struct RPSPeer *rps_peer)
1389{ 1441{
1390 if (GNUNET_YES == in_shutdown) 1442 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1391 { 1443 {
1392 return; 1444 return;
1393 } 1445 }
@@ -1406,7 +1458,7 @@ seed_req_cb (struct RPSPeer *rps_peer)
1406static void 1458static void
1407req_cancel_cb (struct RPSPeer *rps_peer) 1459req_cancel_cb (struct RPSPeer *rps_peer)
1408{ 1460{
1409 if (GNUNET_YES == in_shutdown) 1461 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1410 { 1462 {
1411 return; 1463 return;
1412 } 1464 }
@@ -1439,7 +1491,7 @@ churn (void *cls);
1439static void 1491static void
1440churn_test_cb (struct RPSPeer *rps_peer) 1492churn_test_cb (struct RPSPeer *rps_peer)
1441{ 1493{
1442 if (GNUNET_YES == in_shutdown) 1494 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1443 { 1495 {
1444 return; 1496 return;
1445 } 1497 }
@@ -1480,7 +1532,7 @@ churn_cb (void *cls,
1480 // FIXME 1532 // FIXME
1481 struct OpListEntry *entry = cls; 1533 struct OpListEntry *entry = cls;
1482 1534
1483 if (GNUNET_YES == in_shutdown) 1535 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1484 { 1536 {
1485 return; 1537 return;
1486 } 1538 }
@@ -1615,7 +1667,7 @@ churn (void *cls)
1615 double portion_go_online; 1667 double portion_go_online;
1616 double portion_go_offline; 1668 double portion_go_offline;
1617 1669
1618 if (GNUNET_YES == in_shutdown) 1670 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1619 { 1671 {
1620 return; 1672 return;
1621 } 1673 }
@@ -1731,7 +1783,7 @@ profiler_reply_handle (void *cls,
1731static void 1783static void
1732profiler_cb (struct RPSPeer *rps_peer) 1784profiler_cb (struct RPSPeer *rps_peer)
1733{ 1785{
1734 if (GNUNET_YES == in_shutdown) 1786 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1735 { 1787 {
1736 return; 1788 return;
1737 } 1789 }
@@ -2644,7 +2696,12 @@ run (void *cls,
2644 2696
2645 if (NULL != churn_task) 2697 if (NULL != churn_task)
2646 GNUNET_SCHEDULER_cancel (churn_task); 2698 GNUNET_SCHEDULER_cancel (churn_task);
2699 post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL);
2700 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
2701 (timeout_s * 1.2) + 0.1 * num_peers);
2647 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); 2702 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
2703 shutdown_task = GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL);
2704
2648} 2705}
2649 2706
2650 2707
@@ -2673,7 +2730,7 @@ main (int argc, char *argv[])
2673 cur_test_run.stat_collect_flags = 0; 2730 cur_test_run.stat_collect_flags = 0;
2674 cur_test_run.have_collect_view = NO_COLLECT_VIEW; 2731 cur_test_run.have_collect_view = NO_COLLECT_VIEW;
2675 churn_task = NULL; 2732 churn_task = NULL;
2676 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); 2733 timeout_s = 30;
2677 2734
2678 if (strstr (argv[0], "malicious") != NULL) 2735 if (strstr (argv[0], "malicious") != NULL)
2679 { 2736 {
@@ -2725,7 +2782,7 @@ main (int argc, char *argv[])
2725 cur_test_run.main_test = seed_big_cb; 2782 cur_test_run.main_test = seed_big_cb;
2726 cur_test_run.eval_cb = no_eval; 2783 cur_test_run.eval_cb = no_eval;
2727 cur_test_run.have_churn = HAVE_NO_CHURN; 2784 cur_test_run.have_churn = HAVE_NO_CHURN;
2728 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 2785 timeout_s = 10;
2729 } 2786 }
2730 2787
2731 else if (strstr (argv[0], "_single_peer_seed") != NULL) 2788 else if (strstr (argv[0], "_single_peer_seed") != NULL)
@@ -2761,7 +2818,7 @@ main (int argc, char *argv[])
2761 cur_test_run.main_test = req_cancel_cb; 2818 cur_test_run.main_test = req_cancel_cb;
2762 cur_test_run.eval_cb = no_eval; 2819 cur_test_run.eval_cb = no_eval;
2763 cur_test_run.have_churn = HAVE_NO_CHURN; 2820 cur_test_run.have_churn = HAVE_NO_CHURN;
2764 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 2821 timeout_s = 10;
2765 } 2822 }
2766 2823
2767 else if (strstr (argv[0], "_churn") != NULL) 2824 else if (strstr (argv[0], "_churn") != NULL)
@@ -2775,7 +2832,7 @@ main (int argc, char *argv[])
2775 cur_test_run.eval_cb = default_eval_cb; 2832 cur_test_run.eval_cb = default_eval_cb;
2776 cur_test_run.have_churn = HAVE_NO_CHURN; 2833 cur_test_run.have_churn = HAVE_NO_CHURN;
2777 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; 2834 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
2778 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 2835 timeout_s = 10;
2779 } 2836 }
2780 2837
2781 else if (strstr (argv[0], "profiler") != NULL) 2838 else if (strstr (argv[0], "profiler") != NULL)
@@ -2814,12 +2871,13 @@ main (int argc, char *argv[])
2814 STAT_TYPE_RECV_PULL_REQ | 2871 STAT_TYPE_RECV_PULL_REQ |
2815 STAT_TYPE_RECV_PULL_REP; 2872 STAT_TYPE_RECV_PULL_REP;
2816 cur_test_run.have_collect_view = COLLECT_VIEW; 2873 cur_test_run.have_collect_view = COLLECT_VIEW;
2817 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300); 2874 timeout_s = 150;
2818 2875
2819 /* 'Clean' directory */ 2876 /* 'Clean' directory */
2820 (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); 2877 (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
2821 GNUNET_DISK_directory_create ("/tmp/rps/"); 2878 GNUNET_DISK_directory_create ("/tmp/rps/");
2822 } 2879 }
2880 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_s);
2823 2881
2824 rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); 2882 rps_peers = GNUNET_new_array (num_peers, struct RPSPeer);
2825 peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO); 2883 peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO);
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf
index cf6b3150c..e4ed111e2 100644
--- a/src/rps/test_rps.conf
+++ b/src/rps/test_rps.conf
@@ -33,7 +33,7 @@ OVERLAY_TOPOLOGY = CLIQUE
33 33
34# OVERLAY_RANDOM_LINKS = 25 34# OVERLAY_RANDOM_LINKS = 25
35 35
36# SETUP_TIMEOUT = 2 m 36SETUP_TIMEOUT = 2 m
37 37
38[nse] 38[nse]
39WORKBITS = 0 39WORKBITS = 0
diff --git a/src/rps/test_rps_api.c b/src/rps/test_rps_api.c
index 546d8f285..85a0ccdd0 100644
--- a/src/rps/test_rps_api.c
+++ b/src/rps/test_rps_api.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file rps/test_rps_api.c 19 * @file rps/test_rps_api.c
diff --git a/src/rps/test_service_rps_custommap.c b/src/rps/test_service_rps_custommap.c
index f88842b79..8ce03070e 100644
--- a/src/rps/test_service_rps_custommap.c
+++ b/src/rps/test_service_rps_custommap.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file rps/test_service_rps_custommap.c 19 * @file rps/test_service_rps_custommap.c
diff --git a/src/rps/test_service_rps_sampler_elem.c b/src/rps/test_service_rps_sampler_elem.c
index 6f515d2c2..43efc8691 100644
--- a/src/rps/test_service_rps_sampler_elem.c
+++ b/src/rps/test_service_rps_sampler_elem.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file rps/test_service_rps_sampler_elem.c 19 * @file rps/test_service_rps_sampler_elem.c
diff --git a/src/rps/test_service_rps_view.c b/src/rps/test_service_rps_view.c
index 68d1b11d4..16cf4b832 100644
--- a/src/rps/test_service_rps_view.c
+++ b/src/rps/test_service_rps_view.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 3 Copyright (C)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/ 17*/
20/** 18/**
21 * @file rps/test_service_rps_view.c 19 * @file rps/test_service_rps_view.c