summaryrefslogtreecommitdiff
path: root/src/rps/test_rps.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-08-04 10:42:57 +0000
committerJulius Bünger <buenger@mytum.de>2015-08-04 10:42:57 +0000
commit044454cd9bf77d99d8ed96fa28ac178ac9c32b34 (patch)
tree163a4f7384b38b44833c14cb14837d031e9f9936 /src/rps/test_rps.c
parent7da3754925a744ae68b6911e58f02dd099b06297 (diff)
downloadgnunet-044454cd9bf77d99d8ed96fa28ac178ac9c32b34.tar.gz
gnunet-044454cd9bf77d99d8ed96fa28ac178ac9c32b34.zip
-test seeding many peers
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r--src/rps/test_rps.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index f6c7ec205..8c0be24fb 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -530,6 +530,39 @@ seed_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
530 GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids); 530 GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
531} 531}
532 532
533/**
534 * Seed peers.
535 */
536 void
537seed_peers_big (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
538{
539 struct RPSPeer *peer = (struct RPSPeer *) cls;
540 unsigned int seed_msg_size;
541 uint32_t num_peers_max;
542 unsigned int amount;
543 unsigned int i;
544
545 seed_msg_size = 8; /* sizeof (struct GNUNET_RPS_CS_SeedMessage) */
546 num_peers_max = (GNUNET_SERVER_MAX_MESSAGE_SIZE - seed_msg_size) /
547 sizeof (struct GNUNET_PeerIdentity);
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
549 "Peers that fit in one seed msg; %u\n",
550 num_peers_max);
551 amount = num_peers_max + (0.5 * num_peers_max);
552 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
553 "Seeding many (%u) peers:\n",
554 amount);
555 struct GNUNET_PeerIdentity ids_to_seed[amount];
556 for (i = 0; i < amount; i++)
557 {
558 ids_to_seed[i] = *peer->peer_id;
559 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
560 i,
561 GNUNET_i2s (&ids_to_seed[i]));
562 }
563
564 GNUNET_RPS_seed_ids (peer->rps_handle, amount, ids_to_seed);
565}
533 566
534/** 567/**
535 * Get the id of peer i. 568 * Get the id of peer i.
@@ -935,8 +968,9 @@ delay_req_cb (struct RPSPeer *rps_peer)
935static void 968static void
936seed_cb (struct RPSPeer *rps_peer) 969seed_cb (struct RPSPeer *rps_peer)
937{ 970{
938 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), 971 GNUNET_SCHEDULER_add_delayed (
939 seed_peers, rps_peer); 972 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
973 seed_peers, rps_peer);
940} 974}
941 975
942/*********************************** 976/***********************************
@@ -946,6 +980,9 @@ static void
946seed_big_cb (struct RPSPeer *rps_peer) 980seed_big_cb (struct RPSPeer *rps_peer)
947{ 981{
948 // TODO test seeding > GNUNET_SERVER_MAX_MESSAGE_SIZE peers 982 // TODO test seeding > GNUNET_SERVER_MAX_MESSAGE_SIZE peers
983 GNUNET_SCHEDULER_add_delayed (
984 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
985 seed_peers_big, rps_peer);
949} 986}
950 987
951/*********************************** 988/***********************************
@@ -963,8 +1000,9 @@ single_peer_seed_cb (struct RPSPeer *rps_peer)
963static void 1000static void
964seed_req_cb (struct RPSPeer *rps_peer) 1001seed_req_cb (struct RPSPeer *rps_peer)
965{ 1002{
966 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), 1003 GNUNET_SCHEDULER_add_delayed (
967 seed_peers, rps_peer); 1004 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2),
1005 seed_peers, rps_peer);
968 schedule_missing_requests (rps_peer); 1006 schedule_missing_requests (rps_peer);
969} 1007}
970 1008
@@ -1416,8 +1454,11 @@ main (int argc, char *argv[])
1416 else if (strstr (argv[0], "_seed_big") != NULL) 1454 else if (strstr (argv[0], "_seed_big") != NULL)
1417 { 1455 {
1418 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_SERVER_MAX_MESSAGE_SIZE)\n"); 1456 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_SERVER_MAX_MESSAGE_SIZE)\n");
1457 num_peers = 1;
1419 cur_test_run.name = "test-rps-seed-big"; 1458 cur_test_run.name = "test-rps-seed-big";
1420 cur_test_run.main_test = seed_big_cb; 1459 cur_test_run.main_test = seed_big_cb;
1460 cur_test_run.eval_cb = no_eval;
1461 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1421 } 1462 }
1422 1463
1423 else if (strstr (argv[0], "_single_peer_seed") != NULL) 1464 else if (strstr (argv[0], "_single_peer_seed") != NULL)