@Test public void testFloodMessageTest() { FloodMessage<P2PNodeTest> m = new FloodMessage<>(1, 0, 0); network.sendPeers(m, n0); Assert.assertEquals(1, n0.getMsgReceived(m.msgId()).size()); network.runMs(2); int nodeCt = 0; for (P2PNodeTest n : network.allNodes) { if (n == n0 || n0.peers.contains(n)) { Assert.assertEquals(1, n.getMsgReceived(m.msgId()).size()); nodeCt++; } else { Assert.assertEquals(0, n.getMsgReceived(m.msgId()).size()); } } for (int i = 0; i < MoreMath.log2(network.allNodes.size()) + 1 && nodeCt < network.allNodes.size(); i++) { network.runMs(2); int nodeCt2 = count(m); Assert.assertTrue(nodeCt2 > nodeCt); nodeCt = nodeCt2; } Assert.assertEquals(network.allNodes.size(), nodeCt); }
public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } P2PNetwork(int connectionCount, boolean minimum); }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } P2PNetwork(int connectionCount, boolean minimum); void setPeers(); void disconnect(TN p); void createLink(TN p1, TN p2); void removeLink(TN p1, TN p2); int avgPeers(); void sendPeers(FloodMessage<TN> msg, TN from); }
P2PNetwork extends Network<TN> { public void sendPeers(FloodMessage<TN> msg, TN from) { msg.addToReceived(from); List<TN> dest = new ArrayList<>(from.peers); Collections.shuffle(dest, rd); send(msg, time + 1 + msg.localDelay, from, dest, msg.delayBetweenPeers); } P2PNetwork(int connectionCount, boolean minimum); void setPeers(); void disconnect(TN p); void createLink(TN p1, TN p2); void removeLink(TN p1, TN p2); int avgPeers(); void sendPeers(FloodMessage<TN> msg, TN from);  }