aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2020-11-16 23:57:08 +0100
committerJulius Bünger <buenger@mytum.de>2020-11-16 23:57:08 +0100
commit91e8c2ff26ab0f65bbfec3de0b4acbaa95e52a47 (patch)
tree8c5a26c77d3b535c94f4d361ea80a4fe70707401 /src
parentd30ec0f1fb9ced559b8add2f48eda05a8b58fac0 (diff)
downloadgnunet-91e8c2ff26ab0f65bbfec3de0b4acbaa95e52a47.tar.gz
gnunet-91e8c2ff26ab0f65bbfec3de0b4acbaa95e52a47.zip
rps: deal with currently unused code
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-rps-profiler.c209
-rw-r--r--src/rps/gnunet-service-rps.c2
-rw-r--r--src/rps/rps-sampler_client.c66
3 files changed, 109 insertions, 168 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 7d6bf407f..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
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 48b5194c8..dc4c5dab7 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -2466,6 +2466,7 @@ resize_wrapper (struct RPS_Sampler *sampler, uint32_t new_size)
2466} 2466}
2467 2467
2468 2468
2469#if ENABLE_MALICIOUS
2469/** 2470/**
2470 * Add all peers in @a peer_array to @a peer_map used as set. 2471 * Add all peers in @a peer_array to @a peer_map used as set.
2471 * 2472 *
@@ -2502,6 +2503,7 @@ add_peer_array_to_set (const struct GNUNET_PeerIdentity *peer_array,
2502 } 2503 }
2503 } 2504 }
2504} 2505}
2506#endif /* ENABLE_MALICIOUS */
2505 2507
2506 2508
2507/** 2509/**
diff --git a/src/rps/rps-sampler_client.c b/src/rps/rps-sampler_client.c
index 714943b51..f6e98ce29 100644
--- a/src/rps/rps-sampler_client.c
+++ b/src/rps/rps-sampler_client.c
@@ -258,39 +258,39 @@ RPS_sampler_mod_init (size_t init_size,
258} 258}
259 259
260 260
261/** 261// /**
262 * @brief Compute the probability that we already observed all peers from a 262// * @brief Compute the probability that we already observed all peers from a
263 * biased stream of peer ids. 263// * biased stream of peer ids.
264 * 264// *
265 * Deficiency factor: 265// * Deficiency factor:
266 * As introduced by Brahms: Factor between the number of unique ids in a 266// * As introduced by Brahms: Factor between the number of unique ids in a
267 * truly random stream and number of unique ids in the gossip stream. 267// * truly random stream and number of unique ids in the gossip stream.
268 * 268// *
269 * @param num_peers_estim The estimated number of peers in the network 269// * @param num_peers_estim The estimated number of peers in the network
270 * @param num_peers_observed The number of peers the given element has observed 270// * @param num_peers_observed The number of peers the given element has observed
271 * @param deficiency_factor A factor that catches the 'bias' of a random stream 271// * @param deficiency_factor A factor that catches the 'bias' of a random stream
272 * of peer ids 272// * of peer ids
273 * 273// *
274 * @return The estimated probability 274// * @return The estimated probability
275 */ 275// */
276static double 276// static double
277prob_observed_n_peers (uint32_t num_peers_estim, 277// prob_observed_n_peers (uint32_t num_peers_estim,
278 uint32_t num_peers_observed, 278// uint32_t num_peers_observed,
279 double deficiency_factor) 279// double deficiency_factor)
280{ 280// {
281 uint32_t num_peers = num_peers_estim * (1 / deficiency_factor); 281// uint32_t num_peers = num_peers_estim * (1 / deficiency_factor);
282 uint64_t sum = 0; 282// uint64_t sum = 0;
283 283//
284 for (uint32_t i = 0; i < num_peers; i++) 284// for (uint32_t i = 0; i < num_peers; i++)
285 { 285// {
286 uint64_t a = pow (-1, num_peers - i); 286// uint64_t a = pow (-1, num_peers - i);
287 uint64_t b = binom (num_peers, i); 287// uint64_t b = binom (num_peers, i);
288 uint64_t c = pow (i, num_peers_observed); 288// uint64_t c = pow (i, num_peers_observed);
289 sum += a * b * c; 289// sum += a * b * c;
290 } 290// }
291 291//
292 return sum / (double) pow (num_peers, num_peers_observed); 292// return sum / (double) pow (num_peers, num_peers_observed);
293} 293// }
294 294
295 295
296/** 296/**