aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-rps-profiler.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-11-18 19:19:10 +0100
committerChristian Grothoff <christian@grothoff.org>2020-11-18 19:19:10 +0100
commit8ea5327297c6dc43c9bea725ca10cd379533ae2c (patch)
treec71b7753076b8cf7323e7daca2932ef8a1244715 /src/rps/gnunet-rps-profiler.c
parent75f764ad21fd850bd068f5746b8db89d49e784d1 (diff)
parent52968789d280ee066e4527d6b191691625bd993a (diff)
downloadgnunet-8ea5327297c6dc43c9bea725ca10cd379533ae2c.tar.gz
gnunet-8ea5327297c6dc43c9bea725ca10cd379533ae2c.zip
Merge branch 'master' of git+ssh://gnunet.org/gnunet
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r--src/rps/gnunet-rps-profiler.c212
1 files changed, 76 insertions, 136 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 392a3c18f..0ec2fec71 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -59,10 +59,10 @@ static struct GNUNET_TIME_Relative duration;
59static struct GNUNET_TIME_Relative timeout; 59static struct GNUNET_TIME_Relative timeout;
60 60
61 61
62/** 62// /**
63 * Portion of malicious peers 63// * Portion of malicious peers
64 */ 64// */
65static double portion = .1; 65// static double portion = .1;
66 66
67/** 67/**
68 * Type of malicious peer to test 68 * Type of malicious peer to test
@@ -1229,29 +1229,6 @@ post_test_op (void *cls)
1229 1229
1230 1230
1231/** 1231/**
1232 * Seed peers.
1233 */
1234static void
1235seed_peers (void *cls)
1236{
1237 struct RPSPeer *peer = cls;
1238 unsigned int amount;
1239 unsigned int i;
1240
1241 // TODO if malicious don't seed mal peers
1242 amount = round (.5 * num_peers);
1243
1244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n");
1245 for (i = 0; i < amount; i++)
1246 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding %u. peer: %s\n",
1247 i,
1248 GNUNET_i2s (&rps_peer_ids[i]));
1249
1250 GNUNET_RPS_seed_ids (peer->rps_handle, amount, rps_peer_ids);
1251}
1252
1253
1254/**
1255 * Get the id of peer i. 1232 * Get the id of peer i.
1256 */ 1233 */
1257void 1234void
@@ -1635,76 +1612,76 @@ cancel_pending_req_rep (struct RPSPeer *rps_peer)
1635* MALICIOUS 1612* MALICIOUS
1636***********************************/ 1613***********************************/
1637 1614
1638/** 1615///**
1639 * Initialise only non-mal RPSPeers 1616// * Initialise only non-mal RPSPeers
1640 */ 1617// */
1641static void 1618//static void
1642mal_init_peer (struct RPSPeer *rps_peer) 1619//mal_init_peer (struct RPSPeer *rps_peer)
1643{ 1620//{
1644 if (rps_peer->index >= round (portion * num_peers)) 1621// if (rps_peer->index >= round (portion * num_peers))
1645 rps_peer->num_ids_to_request = 1; 1622// rps_peer->num_ids_to_request = 1;
1646} 1623//}
1647 1624
1648 1625
1649/** 1626///**
1650 * @brief Set peers to (non-)malicious before execution 1627// * @brief Set peers to (non-)malicious before execution
1651 * 1628// *
1652 * Of signature #PreTest 1629// * Of signature #PreTest
1653 * 1630// *
1654 * @param rps_peer the peer to set (non-) malicious 1631// * @param rps_peer the peer to set (non-) malicious
1655 * @param h the handle to the service 1632// * @param h the handle to the service
1656 */ 1633// */
1657static void 1634//static void
1658mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 1635//mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1659{ 1636//{
1660 #if ENABLE_MALICIOUS 1637// #if ENABLE_MALICIOUS
1661 uint32_t num_mal_peers; 1638// uint32_t num_mal_peers;
1662 1639//
1663 GNUNET_assert ((1 >= portion) && 1640// GNUNET_assert ((1 >= portion) &&
1664 (0 < portion)); 1641// (0 < portion));
1665 num_mal_peers = round (portion * num_peers); 1642// num_mal_peers = round (portion * num_peers);
1666 1643//
1667 if (rps_peer->index < num_mal_peers) 1644// if (rps_peer->index < num_mal_peers)
1668 { 1645// {
1669 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1646// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1670 "%u. peer [%s] of %" PRIu32 1647// "%u. peer [%s] of %" PRIu32
1671 " malicious peers turning malicious\n", 1648// " malicious peers turning malicious\n",
1672 rps_peer->index, 1649// rps_peer->index,
1673 GNUNET_i2s (rps_peer->peer_id), 1650// GNUNET_i2s (rps_peer->peer_id),
1674 num_mal_peers); 1651// num_mal_peers);
1675 1652//
1676 GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers, 1653// GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers,
1677 rps_peer_ids, target_peer); 1654// rps_peer_ids, target_peer);
1678 } 1655// }
1679 #endif /* ENABLE_MALICIOUS */ 1656// #endif /* ENABLE_MALICIOUS */
1680} 1657//}
1681 1658
1682 1659
1683static void 1660// static void
1684mal_cb (struct RPSPeer *rps_peer) 1661// mal_cb (struct RPSPeer *rps_peer)
1685{ 1662// {
1686 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test)) 1663// if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1687 { 1664// {
1688 return; 1665// return;
1689 } 1666// }
1690 1667//
1691 #if ENABLE_MALICIOUS 1668// #if ENABLE_MALICIOUS
1692 uint32_t num_mal_peers; 1669// uint32_t num_mal_peers;
1693 1670//
1694 GNUNET_assert ((1 >= portion) && 1671// GNUNET_assert ((1 >= portion) &&
1695 (0 < portion)); 1672// (0 < portion));
1696 num_mal_peers = round (portion * num_peers); 1673// num_mal_peers = round (portion * num_peers);
1697 1674//
1698 if (rps_peer->index >= num_mal_peers) 1675// if (rps_peer->index >= num_mal_peers)
1699 { /* It's useless to ask a malicious peer about a random sample - 1676// { /* It's useless to ask a malicious peer about a random sample -
1700 it's not sampling */ 1677// it's not sampling */
1701 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply ( 1678// GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
1702 GNUNET_TIME_UNIT_SECONDS, 2), 1679// GNUNET_TIME_UNIT_SECONDS, 2),
1703 seed_peers, rps_peer); 1680// seed_peers, rps_peer);
1704 schedule_missing_requests (rps_peer); 1681// schedule_missing_requests (rps_peer);
1705 } 1682// }
1706 #endif /* ENABLE_MALICIOUS */ 1683// #endif /* ENABLE_MALICIOUS */
1707} 1684// }
1708 1685
1709 1686
1710/*********************************** 1687/***********************************
@@ -1714,44 +1691,6 @@ mal_cb (struct RPSPeer *rps_peer)
1714static void 1691static void
1715churn (void *cls); 1692churn (void *cls);
1716 1693
1717/**
1718 * @brief Starts churn
1719 *
1720 * Has signature of #MainTest
1721 *
1722 * This is not implemented too nicely as this is called for each peer, but we
1723 * only need to call it once. (Yes we check that we only schedule the task
1724 * once.)
1725 *
1726 * @param rps_peer The peer it's called for
1727 */
1728static void
1729churn_test_cb (struct RPSPeer *rps_peer)
1730{
1731 if ((GNUNET_YES == in_shutdown) || (GNUNET_YES == post_test))
1732 {
1733 return;
1734 }
1735
1736 /* Start churn */
1737 if ((HAVE_CHURN == cur_test_run.have_churn) && (NULL == churn_task))
1738 {
1739 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1740 "Starting churn task\n");
1741 churn_task = GNUNET_SCHEDULER_add_delayed (
1742 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
1743 churn,
1744 NULL);
1745 }
1746 else
1747 {
1748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1749 "Not starting churn task\n");
1750 }
1751
1752 schedule_missing_requests (rps_peer);
1753}
1754
1755 1694
1756/*********************************** 1695/***********************************
1757* PROFILER 1696* PROFILER
@@ -2652,10 +2591,11 @@ pre_profiler (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
2652 store_prefix_file_name (rps_peer->index, "probs"); 2591 store_prefix_file_name (rps_peer->index, "probs");
2653 rps_peer->file_name_probs_hist = 2592 rps_peer->file_name_probs_hist =
2654 store_prefix_file_name (rps_peer->index, "probs_hist"); 2593 store_prefix_file_name (rps_peer->index, "probs_hist");
2594 rps_peer->eval_probs_cache = GNUNET_new_array (num_peers, double);
2595 memset (rps_peer->eval_probs_cache, 0, num_peers * sizeof (double));
2655 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer); 2596 GNUNET_RPS_view_request (h, 0, view_update_cb, rps_peer);
2656} 2597}
2657 2598
2658
2659void 2599void
2660write_final_stats (void) 2600write_final_stats (void)
2661{ 2601{