aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-03-25 22:01:20 +0000
committerJulius Bünger <buenger@mytum.de>2015-03-25 22:01:20 +0000
commit21892bd440255898e5f9d74a765e37e979e50b68 (patch)
tree89bddb0227d65e34273ae8eb91eb0f2c1a59e5bc /src
parent92c7a1c4e25d8e367e6a3f16890d3af8076fa4b1 (diff)
downloadgnunet-21892bd440255898e5f9d74a765e37e979e50b68.tar.gz
gnunet-21892bd440255898e5f9d74a765e37e979e50b68.zip
-refined mal peer type 1
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 96f2d6faa..06c98ab64 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -1620,48 +1620,78 @@ do_mal_round (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1620 uint32_t i; 1620 uint32_t i;
1621 struct GNUNET_TIME_Relative time_next_round; 1621 struct GNUNET_TIME_Relative time_next_round;
1622 struct AttackedPeer *tmp_att_peer; 1622 struct AttackedPeer *tmp_att_peer;
1623 struct AttackedPeer *att_stop_peer;
1623 1624
1624 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round maliciously.\n"); 1625 LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to execute next round maliciously.\n");
1625 1626
1626 /* Do malicious actions */ 1627 /* Do malicious actions */
1627 if (1 == mal_type) 1628 if (1 == mal_type)
1628 { /* Try to maximise representation */ 1629 { /* Try to maximise representation */
1630
1631 /* The maximum of pushes we're going to send this round */
1629 num_pushes = min (min (push_limit, 1632 num_pushes = min (min (push_limit,
1630 num_attacked_peers), 1633 num_attacked_peers),
1631 GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE); 1634 GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE);
1632 1635
1636
1633 /* Send PUSHes to attacked peers */ 1637 /* Send PUSHes to attacked peers */
1638
1639 /* If we see this peer again while iterating over peers
1640 * we can stop iterating, as peers will ignore multiple
1641 * pushes from one peer in one round */
1642 if (att_peers_head == att_peer_index)
1643 att_stop_peer = att_peers_tail;
1644 else
1645 att_peers_tail = att_peer_index->prev;
1646
1634 for (i = 0 ; i < num_pushes ; i++) 1647 for (i = 0 ; i < num_pushes ; i++)
1635 { 1648 {
1636 if (att_peers_tail == att_peer_index) 1649 if (att_peers_tail == att_peer_index)
1637 att_peer_index = att_peers_head; 1650 att_peer_index = att_peers_head;
1651 else if (att_stop_peer == att_peer_index)
1652 break;
1638 else 1653 else
1639 att_peer_index = att_peer_index->next; 1654 att_peer_index = att_peer_index->next;
1640 1655
1641 send_push (att_peer_index->peer_id); 1656 send_push (att_peer_index->peer_id);
1642 } 1657 }
1643 1658
1659
1644 /* Send PULLs to some peers to learn about additional peers to attack */ 1660 /* Send PULLs to some peers to learn about additional peers to attack */
1661
1662 /* If we see this peer again while iterating over peers
1663 * we can stop iterating, as peers will ignore multiple
1664 * pushes from one peer in one round */
1645 tmp_att_peer = att_peer_index; 1665 tmp_att_peer = att_peer_index;
1666 if (att_peers_head == att_peer_index)
1667 att_stop_peer = att_peers_tail;
1668 else
1669 att_peers_tail = att_peer_index->prev;
1670
1646 for (i = 0 ; i < num_pushes * alpha ; i++) 1671 for (i = 0 ; i < num_pushes * alpha ; i++)
1647 { 1672 {
1648 if (att_peers_tail == tmp_att_peer) 1673 if (att_peers_tail == tmp_att_peer)
1649 tmp_att_peer = att_peers_head; 1674 tmp_att_peer = att_peers_head;
1675 else if (att_stop_peer == att_peer_index)
1676 break;
1650 else 1677 else
1651 att_peer_index = tmp_att_peer->next; 1678 att_peer_index = tmp_att_peer->next;
1652 1679
1653 send_pull_request (tmp_att_peer->peer_id); 1680 send_pull_request (tmp_att_peer->peer_id);
1654 } 1681 }
1655
1656 } 1682 }
1683
1684
1657 else if (2 == mal_type) 1685 else if (2 == mal_type)
1658 { /** 1686 { /**
1659 * Try to partition the network 1687 * Try to partition the network
1660 * Send as many pushes to attacked peer as possible 1688 * Send as many pushes to the attacked peer as possible
1689 * That is one push per round as it will ignore more.
1661 */ 1690 */
1662 send_push (&attacked_peer); 1691 send_push (&attacked_peer);
1663 } 1692 }
1664 1693
1694
1665 /* Schedule next round */ 1695 /* Schedule next round */
1666 time_next_round = compute_rand_delay (round_interval, 2); 1696 time_next_round = compute_rand_delay (round_interval, 2);
1667 1697