@Test public void testFloodMessageTestWithDelay() { FloodMessage<P2PNodeTest> m = new FloodMessage<>(1, 10, 15); network.sendPeers(m, n0); Assert.assertEquals(1, n0.getMsgReceived(m.msgId()).size()); Assert.assertEquals(1, count(m)); network.runMs(11); Assert.assertEquals(1, count(m)); network.runMs(1); Assert.assertEquals(2, count(m)); Assert.assertEquals(12, network.time); network.runMs(11); Assert.assertEquals(2, count(m)); Assert.assertEquals(23, network.time); network.runMs(1); Assert.assertEquals(3, count(m)); Assert.assertEquals(24, network.time); network.runMs(3); Assert.assertEquals(3, count(m)); Assert.assertEquals(27, network.time); network.runMs(1); Assert.assertEquals(4, count(m)); network.runMs(7); Assert.assertEquals(35, network.time); Assert.assertEquals(4, count(m)); network.runMs(1); Assert.assertEquals(5, count(m)); network.run(1); Assert.assertEquals(network.allNodes.size(), count(m)); }
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);  }