diff options
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 606 |
1 files changed, 391 insertions, 215 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 01777bd90..4a4a9ee1a 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -46,6 +46,7 @@ uint32_t num_peers; | |||
46 | //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 46 | //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
47 | static struct GNUNET_TIME_Relative timeout; | 47 | static struct GNUNET_TIME_Relative timeout; |
48 | 48 | ||
49 | |||
49 | /** | 50 | /** |
50 | * Portion of malicious peers | 51 | * Portion of malicious peers |
51 | */ | 52 | */ |
@@ -106,6 +107,52 @@ static struct OpListEntry *oplist_tail; | |||
106 | 107 | ||
107 | 108 | ||
108 | /** | 109 | /** |
110 | * A pending reply: A request was sent and the reply is pending. | ||
111 | */ | ||
112 | struct PendingReply | ||
113 | { | ||
114 | /** | ||
115 | * DLL next,prev ptr | ||
116 | */ | ||
117 | struct PendingReply *next; | ||
118 | struct PendingReply *prev; | ||
119 | |||
120 | /** | ||
121 | * Handle to the request we are waiting for | ||
122 | */ | ||
123 | struct GNUNET_RPS_Request_Handle *req_handle; | ||
124 | |||
125 | /** | ||
126 | * The peer that requested | ||
127 | */ | ||
128 | struct RPSPeer *rps_peer; | ||
129 | }; | ||
130 | |||
131 | |||
132 | /** | ||
133 | * A pending request: A request was not made yet but is scheduled for later. | ||
134 | */ | ||
135 | struct PendingRequest | ||
136 | { | ||
137 | /** | ||
138 | * DLL next,prev ptr | ||
139 | */ | ||
140 | struct PendingRequest *next; | ||
141 | struct PendingRequest *prev; | ||
142 | |||
143 | /** | ||
144 | * Handle to the request we are waiting for | ||
145 | */ | ||
146 | struct GNUNET_SCHEDULER_Task *request_task; | ||
147 | |||
148 | /** | ||
149 | * The peer that requested | ||
150 | */ | ||
151 | struct RPSPeer *rps_peer; | ||
152 | }; | ||
153 | |||
154 | |||
155 | /** | ||
109 | * Information we track for each peer. | 156 | * Information we track for each peer. |
110 | */ | 157 | */ |
111 | struct RPSPeer | 158 | struct RPSPeer |
@@ -141,6 +188,33 @@ struct RPSPeer | |||
141 | int online; | 188 | int online; |
142 | 189 | ||
143 | /** | 190 | /** |
191 | * Number of Peer IDs to request | ||
192 | */ | ||
193 | unsigned int num_ids_to_request; | ||
194 | |||
195 | /** | ||
196 | * Pending requests DLL | ||
197 | */ | ||
198 | struct PendingRequest *pending_req_head; | ||
199 | struct PendingRequest *pending_req_tail; | ||
200 | |||
201 | /** | ||
202 | * Number of pending requests | ||
203 | */ | ||
204 | unsigned int num_pending_reqs; | ||
205 | |||
206 | /** | ||
207 | * Pending replies DLL | ||
208 | */ | ||
209 | struct PendingReply *pending_rep_head; | ||
210 | struct PendingReply *pending_rep_tail; | ||
211 | |||
212 | /** | ||
213 | * Number of pending replies | ||
214 | */ | ||
215 | unsigned int num_pending_reps; | ||
216 | |||
217 | /** | ||
144 | * Received PeerIDs | 218 | * Received PeerIDs |
145 | */ | 219 | */ |
146 | struct GNUNET_PeerIdentity *rec_ids; | 220 | struct GNUNET_PeerIdentity *rec_ids; |
@@ -168,6 +242,16 @@ static struct GNUNET_CONTAINER_MultiPeerMap *peer_map; | |||
168 | static struct GNUNET_PeerIdentity *rps_peer_ids; | 242 | static struct GNUNET_PeerIdentity *rps_peer_ids; |
169 | 243 | ||
170 | /** | 244 | /** |
245 | * ID of the targeted peer. | ||
246 | */ | ||
247 | static struct GNUNET_PeerIdentity *target_peer; | ||
248 | |||
249 | /** | ||
250 | * ID of the peer that requests for the evaluation. | ||
251 | */ | ||
252 | static struct RPSPeer *eval_peer; | ||
253 | |||
254 | /** | ||
171 | * Number of online peers. | 255 | * Number of online peers. |
172 | */ | 256 | */ |
173 | static unsigned int num_peers_online; | 257 | static unsigned int num_peers_online; |
@@ -185,6 +269,11 @@ static struct GNUNET_SCHEDULER_Task *churn_task; | |||
185 | 269 | ||
186 | 270 | ||
187 | /** | 271 | /** |
272 | * Called to initialise the given RPSPeer | ||
273 | */ | ||
274 | typedef void (*InitPeer) (struct RPSPeer *rps_peer); | ||
275 | |||
276 | /** | ||
188 | * Called directly after connecting to the service | 277 | * Called directly after connecting to the service |
189 | */ | 278 | */ |
190 | typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); | 279 | typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); |
@@ -224,6 +313,11 @@ struct SingleTestRun | |||
224 | char *name; | 313 | char *name; |
225 | 314 | ||
226 | /** | 315 | /** |
316 | * Called to initialise peer | ||
317 | */ | ||
318 | InitPeer init_peer; | ||
319 | |||
320 | /** | ||
227 | * Called directly after connecting to the service | 321 | * Called directly after connecting to the service |
228 | */ | 322 | */ |
229 | PreTest pre_test; | 323 | PreTest pre_test; |
@@ -398,80 +492,6 @@ make_oplist_entry () | |||
398 | 492 | ||
399 | 493 | ||
400 | /** | 494 | /** |
401 | * Callback to be called when RPS service is started or stopped at peers | ||
402 | * | ||
403 | * @param cls NULL | ||
404 | * @param op the operation handle | ||
405 | * @param emsg NULL on success; otherwise an error description | ||
406 | */ | ||
407 | static void | ||
408 | churn_cb (void *cls, | ||
409 | struct GNUNET_TESTBED_Operation *op, | ||
410 | const char *emsg) | ||
411 | { | ||
412 | // FIXME | ||
413 | struct OpListEntry *entry = cls; | ||
414 | |||
415 | GNUNET_TESTBED_operation_done (entry->op); | ||
416 | if (NULL != emsg) | ||
417 | { | ||
418 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n"); | ||
419 | GNUNET_SCHEDULER_shutdown (); | ||
420 | return; | ||
421 | } | ||
422 | GNUNET_assert (0 != entry->delta); | ||
423 | |||
424 | num_peers_online += entry->delta; | ||
425 | |||
426 | if (0 > entry->delta) | ||
427 | { /* Peer hopefully just went offline */ | ||
428 | if (GNUNET_YES != rps_peers[entry->index].online) | ||
429 | { | ||
430 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
431 | "peer %s was expected to go offline but is still marked as online\n", | ||
432 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
433 | GNUNET_break (0); | ||
434 | } | ||
435 | else | ||
436 | { | ||
437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
438 | "peer %s probably went offline as expected\n", | ||
439 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
440 | } | ||
441 | rps_peers[entry->index].online = GNUNET_NO; | ||
442 | } | ||
443 | |||
444 | else if (0 < entry->delta) | ||
445 | { /* Peer hopefully just went online */ | ||
446 | if (GNUNET_NO != rps_peers[entry->index].online) | ||
447 | { | ||
448 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
449 | "peer %s was expected to go online but is still marked as offline\n", | ||
450 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
451 | GNUNET_break (0); | ||
452 | } | ||
453 | else | ||
454 | { | ||
455 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
456 | "peer %s probably went online as expected\n", | ||
457 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
458 | if (NULL != cur_test_run.pre_test) | ||
459 | { | ||
460 | cur_test_run.pre_test (&rps_peers[entry->index], | ||
461 | rps_peers[entry->index].rps_handle); | ||
462 | } | ||
463 | } | ||
464 | rps_peers[entry->index].online = GNUNET_YES; | ||
465 | } | ||
466 | |||
467 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | ||
468 | GNUNET_free (entry); | ||
469 | //if (num_peers_in_round[current_round] == peers_running) | ||
470 | // run_round (); | ||
471 | } | ||
472 | |||
473 | |||
474 | /** | ||
475 | * Task run on timeout to shut everything down. | 495 | * Task run on timeout to shut everything down. |
476 | */ | 496 | */ |
477 | static void | 497 | static void |
@@ -543,14 +563,15 @@ info_cb (void *cb_cls, | |||
543 | &rps_peer_ids[entry->index], | 563 | &rps_peer_ids[entry->index], |
544 | &rps_peers[entry->index], | 564 | &rps_peers[entry->index], |
545 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 565 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
546 | |||
547 | tofile ("/tmp/rps/peer_ids", | 566 | tofile ("/tmp/rps/peer_ids", |
548 | "%u\t%s\n", | 567 | "%u\t%s\n", |
549 | entry->index, | 568 | entry->index, |
550 | GNUNET_i2s_full (&rps_peer_ids[entry->index])); | 569 | GNUNET_i2s_full (&rps_peer_ids[entry->index])); |
551 | 570 | ||
552 | GNUNET_TESTBED_operation_done (entry->op); | 571 | if (NULL != cur_test_run.init_peer) |
572 | cur_test_run.init_peer (&rps_peers[entry->index]); | ||
553 | 573 | ||
574 | GNUNET_TESTBED_operation_done (entry->op); | ||
554 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | 575 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); |
555 | GNUNET_free (entry); | 576 | GNUNET_free (entry); |
556 | } | 577 | } |
@@ -650,7 +671,15 @@ default_eval_cb (void) | |||
650 | static int | 671 | static int |
651 | no_eval (void) | 672 | no_eval (void) |
652 | { | 673 | { |
653 | return 1; | 674 | return 0; |
675 | } | ||
676 | |||
677 | /** | ||
678 | * Initialise given RPSPeer | ||
679 | */ | ||
680 | static void default_init_peer (struct RPSPeer *rps_peer) | ||
681 | { | ||
682 | rps_peer->num_ids_to_request = 1; | ||
654 | } | 683 | } |
655 | 684 | ||
656 | /** | 685 | /** |
@@ -665,9 +694,15 @@ default_reply_handle (void *cls, | |||
665 | uint64_t n, | 694 | uint64_t n, |
666 | const struct GNUNET_PeerIdentity *recv_peers) | 695 | const struct GNUNET_PeerIdentity *recv_peers) |
667 | { | 696 | { |
668 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | 697 | struct RPSPeer *rps_peer; |
698 | struct PendingReply *pending_rep = (struct PendingReply *) cls; | ||
669 | unsigned int i; | 699 | unsigned int i; |
670 | 700 | ||
701 | rps_peer = pending_rep->rps_peer; | ||
702 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, | ||
703 | rps_peer->pending_rep_tail, | ||
704 | pending_rep); | ||
705 | rps_peer->num_pending_reps--; | ||
671 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
672 | "[%s] got %" PRIu64 " peers:\n", | 707 | "[%s] got %" PRIu64 " peers:\n", |
673 | GNUNET_i2s (rps_peer->peer_id), | 708 | GNUNET_i2s (rps_peer->peer_id), |
@@ -691,20 +726,119 @@ static void | |||
691 | request_peers (void *cls, | 726 | request_peers (void *cls, |
692 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 727 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
693 | { | 728 | { |
694 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | 729 | struct RPSPeer *rps_peer; |
730 | struct PendingRequest *pending_req = (struct PendingRequest *) cls; | ||
731 | struct PendingReply *pending_rep; | ||
695 | 732 | ||
696 | if (GNUNET_YES == in_shutdown) | 733 | if (GNUNET_YES == in_shutdown) |
697 | return; | 734 | return; |
735 | rps_peer = pending_req->rps_peer; | ||
736 | GNUNET_assert (1 <= rps_peer->num_pending_reqs); | ||
737 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, | ||
738 | rps_peer->pending_req_tail, | ||
739 | pending_req); | ||
698 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 740 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
699 | "Requesting one peer\n"); | 741 | "Requesting one peer\n"); |
742 | pending_rep = GNUNET_new (struct PendingReply); | ||
743 | pending_rep->rps_peer = rps_peer; | ||
744 | pending_rep->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle, | ||
745 | 1, | ||
746 | cur_test_run.reply_handle, | ||
747 | pending_rep); | ||
748 | GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_rep_head, | ||
749 | rps_peer->pending_rep_tail, | ||
750 | pending_rep); | ||
751 | rps_peer->num_pending_reps++; | ||
752 | rps_peer->num_pending_reqs--; | ||
753 | } | ||
700 | 754 | ||
701 | GNUNET_free (GNUNET_RPS_request_peers (rps_peer->rps_handle, | 755 | static void |
702 | 1, | 756 | cancel_pending_req (struct PendingRequest *pending_req) |
703 | cur_test_run.reply_handle, | 757 | { |
704 | rps_peer)); | 758 | struct RPSPeer *rps_peer; |
705 | //rps_peer->req_handle = GNUNET_RPS_request_peers (rps_peer->rps_handle, 1, handle_reply, rps_peer); | 759 | |
760 | rps_peer = pending_req->rps_peer; | ||
761 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, | ||
762 | rps_peer->pending_req_tail, | ||
763 | pending_req); | ||
764 | rps_peer->num_pending_reqs--; | ||
765 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
766 | "Cancelling pending request\n"); | ||
767 | GNUNET_SCHEDULER_cancel (pending_req->request_task); | ||
768 | GNUNET_free (pending_req); | ||
706 | } | 769 | } |
707 | 770 | ||
771 | static void | ||
772 | cancel_request (struct PendingReply *pending_rep) | ||
773 | { | ||
774 | struct RPSPeer *rps_peer; | ||
775 | |||
776 | rps_peer = pending_rep->rps_peer; | ||
777 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, | ||
778 | rps_peer->pending_rep_tail, | ||
779 | pending_rep); | ||
780 | rps_peer->num_pending_reps--; | ||
781 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
782 | "Cancelling request\n"); | ||
783 | GNUNET_RPS_request_cancel (pending_rep->req_handle); | ||
784 | GNUNET_free (pending_rep); | ||
785 | } | ||
786 | |||
787 | /** | ||
788 | * Cancel a request. | ||
789 | */ | ||
790 | static void | ||
791 | cancel_request_cb (void *cls, | ||
792 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
793 | { | ||
794 | struct PendingReply *pending_rep; | ||
795 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | ||
796 | |||
797 | if (GNUNET_YES == in_shutdown) | ||
798 | return; | ||
799 | pending_rep = rps_peer->pending_rep_head; | ||
800 | GNUNET_assert (1 <= rps_peer->num_pending_reps); | ||
801 | cancel_request (pending_rep); | ||
802 | } | ||
803 | |||
804 | |||
805 | /** | ||
806 | * Schedule requests for peer @a rps_peer that have neither been scheduled, nor | ||
807 | * issued, nor replied | ||
808 | */ | ||
809 | void | ||
810 | schedule_missing_requests (struct RPSPeer *rps_peer) | ||
811 | { | ||
812 | unsigned int i; | ||
813 | struct PendingRequest *pending_req; | ||
814 | |||
815 | for (i = rps_peer->num_pending_reqs + rps_peer->num_pending_reps; | ||
816 | i < rps_peer->num_ids_to_request; i++) | ||
817 | { | ||
818 | pending_req = GNUNET_new (struct PendingRequest); | ||
819 | pending_req->rps_peer = rps_peer; | ||
820 | pending_req->request_task = GNUNET_SCHEDULER_add_delayed ( | ||
821 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
822 | cur_test_run.request_interval * i), | ||
823 | request_peers, | ||
824 | pending_req); | ||
825 | GNUNET_CONTAINER_DLL_insert_tail (rps_peer->pending_req_head, | ||
826 | rps_peer->pending_req_tail, | ||
827 | pending_req); | ||
828 | rps_peer->num_pending_reqs++; | ||
829 | } | ||
830 | } | ||
831 | |||
832 | void | ||
833 | cancel_pending_req_rep (struct RPSPeer *rps_peer) | ||
834 | { | ||
835 | while (NULL != rps_peer->pending_req_head) | ||
836 | cancel_pending_req (rps_peer->pending_req_head); | ||
837 | GNUNET_assert (0 == rps_peer->num_pending_reqs); | ||
838 | while (NULL != rps_peer->pending_rep_head) | ||
839 | cancel_request (rps_peer->pending_rep_head); | ||
840 | GNUNET_assert (0 == rps_peer->num_pending_reps); | ||
841 | } | ||
708 | 842 | ||
709 | /*********************************** | 843 | /*********************************** |
710 | * MALICIOUS | 844 | * MALICIOUS |
@@ -716,8 +850,8 @@ mal_pre (void *cls, struct GNUNET_RPS_Handle *h) | |||
716 | uint32_t num_mal_peers; | 850 | uint32_t num_mal_peers; |
717 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | 851 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; |
718 | 852 | ||
719 | GNUNET_assert (1 >= portion | 853 | GNUNET_assert ( (1 >= portion) && |
720 | && 0 < portion); | 854 | (0 < portion) ); |
721 | num_mal_peers = round (portion * num_peers); | 855 | num_mal_peers = round (portion * num_peers); |
722 | 856 | ||
723 | if (rps_peer->index < num_mal_peers) | 857 | if (rps_peer->index < num_mal_peers) |
@@ -728,7 +862,8 @@ mal_pre (void *cls, struct GNUNET_RPS_Handle *h) | |||
728 | GNUNET_i2s (rps_peer->peer_id), | 862 | GNUNET_i2s (rps_peer->peer_id), |
729 | num_mal_peers); | 863 | num_mal_peers); |
730 | 864 | ||
731 | GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers, rps_peer_ids); | 865 | GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers, |
866 | rps_peer_ids, target_peer); | ||
732 | } | 867 | } |
733 | #endif /* ENABLE_MALICIOUS */ | 868 | #endif /* ENABLE_MALICIOUS */ |
734 | } | 869 | } |
@@ -739,8 +874,8 @@ mal_cb (struct RPSPeer *rps_peer) | |||
739 | uint32_t num_mal_peers; | 874 | uint32_t num_mal_peers; |
740 | 875 | ||
741 | #ifdef ENABLE_MALICIOUS | 876 | #ifdef ENABLE_MALICIOUS |
742 | GNUNET_assert (1 >= portion | 877 | GNUNET_assert ( (1 >= portion) && |
743 | && 0 < portion); | 878 | (0 < portion) ); |
744 | num_mal_peers = round (portion * num_peers); | 879 | num_mal_peers = round (portion * num_peers); |
745 | 880 | ||
746 | if (rps_peer->index >= num_mal_peers) | 881 | if (rps_peer->index >= num_mal_peers) |
@@ -748,8 +883,7 @@ mal_cb (struct RPSPeer *rps_peer) | |||
748 | it's not sampling */ | 883 | it's not sampling */ |
749 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 884 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
750 | seed_peers, rps_peer); | 885 | seed_peers, rps_peer); |
751 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 886 | schedule_missing_requests (rps_peer); |
752 | request_peers, rps_peer); | ||
753 | } | 887 | } |
754 | #endif /* ENABLE_MALICIOUS */ | 888 | #endif /* ENABLE_MALICIOUS */ |
755 | } | 889 | } |
@@ -772,8 +906,7 @@ mal_eval (void) | |||
772 | static void | 906 | static void |
773 | single_req_cb (struct RPSPeer *rps_peer) | 907 | single_req_cb (struct RPSPeer *rps_peer) |
774 | { | 908 | { |
775 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | 909 | schedule_missing_requests (rps_peer); |
776 | request_peers, rps_peer); | ||
777 | } | 910 | } |
778 | 911 | ||
779 | /*********************************** | 912 | /*********************************** |
@@ -782,10 +915,7 @@ single_req_cb (struct RPSPeer *rps_peer) | |||
782 | static void | 915 | static void |
783 | delay_req_cb (struct RPSPeer *rps_peer) | 916 | delay_req_cb (struct RPSPeer *rps_peer) |
784 | { | 917 | { |
785 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | 918 | schedule_missing_requests (rps_peer); |
786 | request_peers, rps_peer); | ||
787 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
788 | request_peers, rps_peer); | ||
789 | } | 919 | } |
790 | 920 | ||
791 | /*********************************** | 921 | /*********************************** |
@@ -824,8 +954,7 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
824 | { | 954 | { |
825 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | 955 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), |
826 | seed_peers, rps_peer); | 956 | seed_peers, rps_peer); |
827 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), | 957 | schedule_missing_requests (rps_peer); |
828 | request_peers, rps_peer); | ||
829 | } | 958 | } |
830 | 959 | ||
831 | //TODO start big mal | 960 | //TODO start big mal |
@@ -836,16 +965,128 @@ seed_req_cb (struct RPSPeer *rps_peer) | |||
836 | static void | 965 | static void |
837 | req_cancel_cb (struct RPSPeer *rps_peer) | 966 | req_cancel_cb (struct RPSPeer *rps_peer) |
838 | { | 967 | { |
839 | // TODO | 968 | schedule_missing_requests (rps_peer); |
969 | GNUNET_SCHEDULER_add_delayed ( | ||
970 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
971 | (cur_test_run.request_interval + 1)), | ||
972 | cancel_request_cb, rps_peer); | ||
840 | } | 973 | } |
841 | 974 | ||
842 | /*********************************** | 975 | /*********************************** |
843 | * PROFILER | 976 | * PROFILER |
844 | ***********************************/ | 977 | ***********************************/ |
978 | |||
979 | /** | ||
980 | * Callback to be called when RPS service is started or stopped at peers | ||
981 | * | ||
982 | * @param cls NULL | ||
983 | * @param op the operation handle | ||
984 | * @param emsg NULL on success; otherwise an error description | ||
985 | */ | ||
845 | static void | 986 | static void |
846 | churn (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 987 | churn_cb (void *cls, |
988 | struct GNUNET_TESTBED_Operation *op, | ||
989 | const char *emsg) | ||
990 | { | ||
991 | // FIXME | ||
992 | struct OpListEntry *entry = cls; | ||
993 | |||
994 | GNUNET_TESTBED_operation_done (entry->op); | ||
995 | if (NULL != emsg) | ||
996 | { | ||
997 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start/stop RPS at a peer\n"); | ||
998 | GNUNET_SCHEDULER_shutdown (); | ||
999 | return; | ||
1000 | } | ||
1001 | GNUNET_assert (0 != entry->delta); | ||
1002 | |||
1003 | num_peers_online += entry->delta; | ||
1004 | |||
1005 | if (0 > entry->delta) | ||
1006 | { /* Peer hopefully just went offline */ | ||
1007 | if (GNUNET_YES != rps_peers[entry->index].online) | ||
1008 | { | ||
1009 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1010 | "peer %s was expected to go offline but is still marked as online\n", | ||
1011 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
1012 | GNUNET_break (0); | ||
1013 | } | ||
1014 | else | ||
1015 | { | ||
1016 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1017 | "peer %s probably went offline as expected\n", | ||
1018 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
1019 | } | ||
1020 | rps_peers[entry->index].online = GNUNET_NO; | ||
1021 | } | ||
1022 | |||
1023 | else if (0 < entry->delta) | ||
1024 | { /* Peer hopefully just went online */ | ||
1025 | if (GNUNET_NO != rps_peers[entry->index].online) | ||
1026 | { | ||
1027 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1028 | "peer %s was expected to go online but is still marked as offline\n", | ||
1029 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
1030 | GNUNET_break (0); | ||
1031 | } | ||
1032 | else | ||
1033 | { | ||
1034 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1035 | "peer %s probably went online as expected\n", | ||
1036 | GNUNET_i2s (rps_peers[entry->index].peer_id)); | ||
1037 | if (NULL != cur_test_run.pre_test) | ||
1038 | { | ||
1039 | cur_test_run.pre_test (&rps_peers[entry->index], | ||
1040 | rps_peers[entry->index].rps_handle); | ||
1041 | schedule_missing_requests (&rps_peers[entry->index]); | ||
1042 | } | ||
1043 | } | ||
1044 | rps_peers[entry->index].online = GNUNET_YES; | ||
1045 | } | ||
1046 | |||
1047 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | ||
1048 | GNUNET_free (entry); | ||
1049 | //if (num_peers_in_round[current_round] == peers_running) | ||
1050 | // run_round (); | ||
1051 | } | ||
1052 | |||
1053 | static void | ||
1054 | manage_service_wrapper (unsigned int i, unsigned int j, int delta, | ||
1055 | double prob_go_on_off) | ||
847 | { | 1056 | { |
848 | struct OpListEntry *entry; | 1057 | struct OpListEntry *entry; |
1058 | uint32_t prob; | ||
1059 | |||
1060 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
1061 | UINT32_MAX); | ||
1062 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1063 | "%u. selected peer (%u: %s) is %s.\n", | ||
1064 | i, | ||
1065 | j, | ||
1066 | GNUNET_i2s (rps_peers[j].peer_id), | ||
1067 | (delta < 0)? "online" : "offline"); | ||
1068 | if (prob < prob_go_on_off * UINT32_MAX) | ||
1069 | { | ||
1070 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1071 | "%s goes %s\n", | ||
1072 | GNUNET_i2s (rps_peers[j].peer_id), | ||
1073 | (delta < 0) ? "offline" : "online"); | ||
1074 | |||
1075 | entry = make_oplist_entry (); | ||
1076 | entry->delta = delta; | ||
1077 | entry->index = j; | ||
1078 | entry->op = GNUNET_TESTBED_peer_manage_service (NULL, | ||
1079 | testbed_peers[j], | ||
1080 | "rps", | ||
1081 | &churn_cb, | ||
1082 | entry, | ||
1083 | (delta < 0) ? 0 : 1); | ||
1084 | } | ||
1085 | } | ||
1086 | |||
1087 | static void | ||
1088 | churn (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1089 | { | ||
849 | unsigned int i; | 1090 | unsigned int i; |
850 | unsigned int j; | 1091 | unsigned int j; |
851 | double portion_online; | 1092 | double portion_online; |
@@ -853,7 +1094,6 @@ churn (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
853 | double prob_go_offline; | 1094 | double prob_go_offline; |
854 | double portion_go_online; | 1095 | double portion_go_online; |
855 | double portion_go_offline; | 1096 | double portion_go_offline; |
856 | uint32_t prob; | ||
857 | 1097 | ||
858 | /* Compute the probability for an online peer to go offline | 1098 | /* Compute the probability for an online peer to go offline |
859 | * this round */ | 1099 | * this round */ |
@@ -878,65 +1118,22 @@ churn (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
878 | (unsigned int) num_peers); | 1118 | (unsigned int) num_peers); |
879 | 1119 | ||
880 | /* Go over 50% randomly chosen peers */ | 1120 | /* Go over 50% randomly chosen peers */ |
881 | for (i = 0 ; i < .5 * num_peers ; i++) | 1121 | for (i = 0; i < .5 * num_peers; i++) |
882 | { | 1122 | { |
883 | j = permut[i]; | 1123 | j = permut[i]; |
884 | 1124 | ||
885 | /* If online, shut down with certain probability */ | 1125 | /* If online, shut down with certain probability */ |
886 | if (GNUNET_YES == rps_peers[j].online) | 1126 | if (GNUNET_YES == rps_peers[j].online) |
887 | { | 1127 | { |
888 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1128 | cancel_pending_req_rep (&rps_peers[j]); |
889 | UINT32_MAX); | 1129 | manage_service_wrapper (i, j, -1, prob_go_offline); |
890 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1130 | } |
891 | "%u. selected peer (%u: %s) is online.\n", | 1131 | |
892 | i, | 1132 | /* If offline, restart with certain probability */ |
893 | j, | 1133 | else if (GNUNET_NO == rps_peers[j].online) |
894 | GNUNET_i2s (rps_peers[j].peer_id)); | 1134 | { |
895 | if (prob < prob_go_offline * UINT32_MAX) | 1135 | manage_service_wrapper (i, j, 1, 0.66); |
896 | { | 1136 | } |
897 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
898 | "%s goes offline\n", | ||
899 | GNUNET_i2s (rps_peers[j].peer_id)); | ||
900 | |||
901 | entry = make_oplist_entry (); | ||
902 | entry->delta = -1; | ||
903 | entry->index = j; | ||
904 | entry->op = GNUNET_TESTBED_peer_manage_service (NULL, | ||
905 | testbed_peers[j], | ||
906 | "rps", | ||
907 | &churn_cb, | ||
908 | entry, | ||
909 | 0); | ||
910 | } | ||
911 | } | ||
912 | |||
913 | /* If offline, restart with certain probability */ | ||
914 | else if (GNUNET_NO == rps_peers[j].online) | ||
915 | { | ||
916 | prob = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
917 | UINT32_MAX); | ||
918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
919 | "%u. selected peer (%u: %s) is offline.\n", | ||
920 | i, | ||
921 | j, | ||
922 | GNUNET_i2s (rps_peers[j].peer_id)); | ||
923 | if (prob < .66 * UINT32_MAX) | ||
924 | { | ||
925 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
926 | "%s goes online\n", | ||
927 | GNUNET_i2s (rps_peers[j].peer_id)); | ||
928 | |||
929 | entry = make_oplist_entry (); | ||
930 | entry->delta = 1; | ||
931 | entry->index = j; | ||
932 | entry->op = GNUNET_TESTBED_peer_manage_service (NULL, | ||
933 | testbed_peers[j], | ||
934 | "rps", | ||
935 | &churn_cb, | ||
936 | entry, | ||
937 | 1); | ||
938 | } | ||
939 | } | ||
940 | } | 1137 | } |
941 | 1138 | ||
942 | GNUNET_free (permut); | 1139 | GNUNET_free (permut); |
@@ -948,21 +1145,13 @@ churn (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
948 | } | 1145 | } |
949 | 1146 | ||
950 | 1147 | ||
951 | static void | 1148 | /** |
952 | profiler_pre (void *cls, struct GNUNET_RPS_Handle *h) | 1149 | * Initialise given RPSPeer |
1150 | */ | ||
1151 | static void profiler_init_peer (struct RPSPeer *rps_peer) | ||
953 | { | 1152 | { |
954 | //churn_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 1153 | if (num_peers - 1 == rps_peer->index) |
955 | // 10), | 1154 | rps_peer->num_ids_to_request = cur_test_run.num_requests; |
956 | // churn, NULL); | ||
957 | mal_pre (cls, h); | ||
958 | |||
959 | /* if (NULL == churn_task) | ||
960 | { | ||
961 | churn_task = GNUNET_SCHEDULER_add_delayed ( | ||
962 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
963 | churn, | ||
964 | NULL); | ||
965 | } */ | ||
966 | } | 1155 | } |
967 | 1156 | ||
968 | 1157 | ||
@@ -978,52 +1167,50 @@ profiler_reply_handle (void *cls, | |||
978 | uint64_t n, | 1167 | uint64_t n, |
979 | const struct GNUNET_PeerIdentity *recv_peers) | 1168 | const struct GNUNET_PeerIdentity *recv_peers) |
980 | { | 1169 | { |
981 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | 1170 | struct RPSPeer *rps_peer; |
982 | struct RPSPeer *rcv_rps_peer; | 1171 | struct RPSPeer *rcv_rps_peer; |
983 | char *file_name; | 1172 | char *file_name; |
984 | char *file_name_dh; | 1173 | char *file_name_dh; |
985 | unsigned int i; | 1174 | unsigned int i; |
1175 | struct PendingReply *pending_rep = (struct PendingReply *) cls; | ||
986 | 1176 | ||
1177 | rps_peer = pending_rep->rps_peer; | ||
987 | file_name = "/tmp/rps/received_ids"; | 1178 | file_name = "/tmp/rps/received_ids"; |
988 | file_name_dh = "/tmp/rps/diehard_input"; | 1179 | file_name_dh = "/tmp/rps/diehard_input"; |
989 | |||
990 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
991 | "[%s] got %" PRIu64 " peers:\n", | 1181 | "[%s] got %" PRIu64 " peers:\n", |
992 | GNUNET_i2s (rps_peer->peer_id), | 1182 | GNUNET_i2s (rps_peer->peer_id), |
993 | n); | 1183 | n); |
994 | 1184 | for (i = 0; i < n; i++) | |
995 | for (i = 0 ; i < n ; i++) | ||
996 | { | 1185 | { |
997 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
998 | "%u: %s\n", | 1187 | "%u: %s\n", |
999 | i, | 1188 | i, |
1000 | GNUNET_i2s (&recv_peers[i])); | 1189 | GNUNET_i2s (&recv_peers[i])); |
1001 | |||
1002 | /* GNUNET_array_append (rps_peer->rec_ids, rps_peer->num_rec_ids, recv_peers[i]); */ | ||
1003 | tofile (file_name, | 1190 | tofile (file_name, |
1004 | "%s\n", | 1191 | "%s\n", |
1005 | GNUNET_i2s_full (&recv_peers[i])); | 1192 | GNUNET_i2s_full (&recv_peers[i])); |
1006 | |||
1007 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]); | 1193 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]); |
1008 | |||
1009 | tofile (file_name_dh, | 1194 | tofile (file_name_dh, |
1010 | "%" PRIu32 "\n", | 1195 | "%" PRIu32 "\n", |
1011 | (uint32_t) rcv_rps_peer->index); | 1196 | (uint32_t) rcv_rps_peer->index); |
1012 | } | 1197 | } |
1198 | /* Find #PendingReply holding the request handle */ | ||
1199 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, | ||
1200 | rps_peer->pending_rep_tail, | ||
1201 | pending_rep); | ||
1202 | rps_peer->num_pending_reps--; | ||
1013 | } | 1203 | } |
1014 | 1204 | ||
1015 | 1205 | ||
1016 | static void | 1206 | static void |
1017 | profiler_cb (struct RPSPeer *rps_peer) | 1207 | profiler_cb (struct RPSPeer *rps_peer) |
1018 | { | 1208 | { |
1019 | uint32_t i; | 1209 | /* Start churn */ |
1020 | 1210 | if (NULL == churn_task) | |
1021 | /* Churn only at peers that do not request peers for evaluation */ | ||
1022 | if (NULL == churn_task && | ||
1023 | rps_peer->index != num_peers - 2) | ||
1024 | { | 1211 | { |
1025 | churn_task = GNUNET_SCHEDULER_add_delayed ( | 1212 | churn_task = GNUNET_SCHEDULER_add_delayed ( |
1026 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | 1213 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
1027 | churn, | 1214 | churn, |
1028 | NULL); | 1215 | NULL); |
1029 | } | 1216 | } |
@@ -1031,17 +1218,8 @@ profiler_cb (struct RPSPeer *rps_peer) | |||
1031 | /* Only request peer ids at one peer. | 1218 | /* Only request peer ids at one peer. |
1032 | * (It's the before-last because last one is target of the focussed attack.) | 1219 | * (It's the before-last because last one is target of the focussed attack.) |
1033 | */ | 1220 | */ |
1034 | if (rps_peer->index == num_peers - 2) | 1221 | if (eval_peer == rps_peer) |
1035 | { | 1222 | schedule_missing_requests (rps_peer); |
1036 | for (i = 0 ; i < cur_test_run.num_requests ; i++) | ||
1037 | { | ||
1038 | GNUNET_SCHEDULER_add_delayed ( | ||
1039 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
1040 | cur_test_run.request_interval * i), | ||
1041 | request_peers, | ||
1042 | rps_peer); | ||
1043 | } | ||
1044 | } | ||
1045 | } | 1223 | } |
1046 | 1224 | ||
1047 | /** | 1225 | /** |
@@ -1126,7 +1304,6 @@ run (void *cls, | |||
1126 | 1304 | ||
1127 | testbed_peers = peers; | 1305 | testbed_peers = peers; |
1128 | num_peers_online = 0; | 1306 | num_peers_online = 0; |
1129 | |||
1130 | for (i = 0 ; i < num_peers ; i++) | 1307 | for (i = 0 ; i < num_peers ; i++) |
1131 | { | 1308 | { |
1132 | entry = make_oplist_entry (); | 1309 | entry = make_oplist_entry (); |
@@ -1137,16 +1314,6 @@ run (void *cls, | |||
1137 | entry); | 1314 | entry); |
1138 | } | 1315 | } |
1139 | 1316 | ||
1140 | |||
1141 | // This seems not to work | ||
1142 | //if (NULL != strstr (cur_test_run.name, "profiler")) | ||
1143 | //{ | ||
1144 | // churn_task = GNUNET_SCHEDULER_add_delayed ( | ||
1145 | // GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
1146 | // churn, | ||
1147 | // NULL); | ||
1148 | //} | ||
1149 | |||
1150 | GNUNET_assert (num_peers == n_peers); | 1317 | GNUNET_assert (num_peers == n_peers); |
1151 | for (i = 0 ; i < n_peers ; i++) | 1318 | for (i = 0 ; i < n_peers ; i++) |
1152 | { | 1319 | { |
@@ -1161,6 +1328,9 @@ run (void *cls, | |||
1161 | &rps_disconnect_adapter, | 1328 | &rps_disconnect_adapter, |
1162 | &rps_peers[i]); | 1329 | &rps_peers[i]); |
1163 | } | 1330 | } |
1331 | |||
1332 | if (NULL != churn_task) | ||
1333 | GNUNET_SCHEDULER_cancel (churn_task); | ||
1164 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL); | 1334 | GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL); |
1165 | } | 1335 | } |
1166 | 1336 | ||
@@ -1177,13 +1347,13 @@ main (int argc, char *argv[]) | |||
1177 | { | 1347 | { |
1178 | int ret_value; | 1348 | int ret_value; |
1179 | 1349 | ||
1350 | num_peers = 5; | ||
1180 | cur_test_run.name = "test-rps-default"; | 1351 | cur_test_run.name = "test-rps-default"; |
1352 | cur_test_run.init_peer = default_init_peer; | ||
1181 | cur_test_run.pre_test = NULL; | 1353 | cur_test_run.pre_test = NULL; |
1182 | cur_test_run.reply_handle = default_reply_handle; | 1354 | cur_test_run.reply_handle = default_reply_handle; |
1183 | cur_test_run.eval_cb = default_eval_cb; | 1355 | cur_test_run.eval_cb = default_eval_cb; |
1184 | churn_task = NULL; | 1356 | churn_task = NULL; |
1185 | |||
1186 | num_peers = 5; | ||
1187 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); | 1357 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); |
1188 | 1358 | ||
1189 | if (strstr (argv[0], "malicious") != NULL) | 1359 | if (strstr (argv[0], "malicious") != NULL) |
@@ -1259,31 +1429,39 @@ main (int argc, char *argv[]) | |||
1259 | { | 1429 | { |
1260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test cancelling a request\n"); | 1430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test cancelling a request\n"); |
1261 | cur_test_run.name = "test-rps-req-cancel"; | 1431 | cur_test_run.name = "test-rps-req-cancel"; |
1432 | num_peers = 1; | ||
1262 | cur_test_run.main_test = req_cancel_cb; | 1433 | cur_test_run.main_test = req_cancel_cb; |
1434 | cur_test_run.eval_cb = no_eval; | ||
1263 | } | 1435 | } |
1264 | 1436 | ||
1265 | else if (strstr (argv[0], "profiler") != NULL) | 1437 | else if (strstr (argv[0], "profiler") != NULL) |
1266 | { | 1438 | { |
1267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); | 1439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n"); |
1268 | cur_test_run.name = "test-rps-profiler"; | 1440 | cur_test_run.name = "test-rps-profiler"; |
1441 | num_peers = 10; | ||
1269 | mal_type = 3; | 1442 | mal_type = 3; |
1270 | cur_test_run.pre_test = profiler_pre; | 1443 | cur_test_run.init_peer = profiler_init_peer; |
1444 | cur_test_run.pre_test = mal_pre; | ||
1271 | cur_test_run.main_test = profiler_cb; | 1445 | cur_test_run.main_test = profiler_cb; |
1272 | cur_test_run.reply_handle = profiler_reply_handle; | 1446 | cur_test_run.reply_handle = profiler_reply_handle; |
1273 | cur_test_run.eval_cb = profiler_eval; | 1447 | cur_test_run.eval_cb = profiler_eval; |
1274 | cur_test_run.request_interval = 2; | 1448 | cur_test_run.request_interval = 2; |
1275 | cur_test_run.num_requests = 50; | 1449 | cur_test_run.num_requests = 5; |
1276 | 1450 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | |
1277 | num_peers = 50; | ||
1278 | 1451 | ||
1452 | /* 'Clean' directory */ | ||
1279 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); | 1453 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); |
1280 | GNUNET_DISK_directory_create ("/tmp/rps/"); | 1454 | GNUNET_DISK_directory_create ("/tmp/rps/"); |
1281 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | ||
1282 | } | 1455 | } |
1283 | 1456 | ||
1284 | rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); | 1457 | rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); |
1285 | rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); | ||
1286 | peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO); | 1458 | peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO); |
1459 | rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); | ||
1460 | if ( (2 == mal_type) || | ||
1461 | (3 == mal_type)) | ||
1462 | target_peer = &rps_peer_ids[num_peers - 2]; | ||
1463 | if (profiler_eval == cur_test_run.eval_cb) | ||
1464 | eval_peer = &rps_peers[num_peers - 1]; | ||
1287 | 1465 | ||
1288 | ok = 1; | 1466 | ok = 1; |
1289 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, | 1467 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, |
@@ -1293,11 +1471,9 @@ main (int argc, char *argv[]) | |||
1293 | &run, NULL); | 1471 | &run, NULL); |
1294 | 1472 | ||
1295 | ret_value = cur_test_run.eval_cb(); | 1473 | ret_value = cur_test_run.eval_cb(); |
1296 | |||
1297 | GNUNET_free (rps_peers ); | 1474 | GNUNET_free (rps_peers ); |
1298 | GNUNET_free (rps_peer_ids); | 1475 | GNUNET_free (rps_peer_ids); |
1299 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | 1476 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); |
1300 | |||
1301 | return ret_value; | 1477 | return ret_value; |
1302 | } | 1478 | } |
1303 | 1479 | ||