@Test public void testCitiesLatency() { CSVLatencyReader lr = new CSVLatencyReader(); Assert.assertTrue(lr.cities().size() > 0); NodeBuilder nb = new NodeBuilder.NodeBuilderWithCity(lr.cities(), new GeoAllCities()); NetworkLatency nl = new NetworkLatency.NetworkLatencyByCity(); Random rd = new Random(); List<Node> ln = new ArrayList<>(); for (int i = 0; i < 100; i++) { ln.add(new Node(rd, nb)); } for (Node f : ln) { for (Node t : ln) { int l = nl.getLatency(f, t, 1); if (f == t) { Assert.assertEquals(1, l); } else if (f.cityName.equals(t.cityName)) { Assert.assertTrue(l > 0); } else { Assert.assertTrue( "l=" + l + ", from=" + f.fullToString() + ", to=" + t.fullToString(), l > 0); } } } }
protected int getLatency(Node from, Node to, int delta) { if (from == to) { return 1; } int base = from.extraLatency + to.extraLatency; base += getExtendedLatency(from, to, delta); return Math.max(1, base); }
NetworkLatency { protected int getLatency(Node from, Node to, int delta) { if (from == to) { return 1; } int base = from.extraLatency + to.extraLatency; base += getExtendedLatency(from, to, delta); return Math.max(1, base); } }
NetworkLatency { protected int getLatency(Node from, Node to, int delta) { if (from == to) { return 1; } int base = from.extraLatency + to.extraLatency; base += getExtendedLatency(from, to, delta); return Math.max(1, base); }  }
NetworkLatency { protected int getLatency(Node from, Node to, int delta) { if (from == to) { return 1; } int base = from.extraLatency + to.extraLatency; base += getExtendedLatency(from, to, delta); return Math.max(1, base); }  @Override String toString(); static MeasuredNetworkLatency estimateLatency(Network net, final int rounds); static MeasuredNetworkLatency estimateP2PLatency(P2PNetwork<?> net, final int rounds); static MeasuredNetworkLatency estimateLatency(
      Network net, PeerGetter pg, final int rounds); }
NetworkLatency { protected int getLatency(Node from, Node to, int delta) { if (from == to) { return 1; } int base = from.extraLatency + to.extraLatency; base += getExtendedLatency(from, to, delta); return Math.max(1, base); }  @Override String toString(); static MeasuredNetworkLatency estimateLatency(Network net, final int rounds); static MeasuredNetworkLatency estimateP2PLatency(P2PNetwork<?> net, final int rounds); static MeasuredNetworkLatency estimateLatency(
      Network net, PeerGetter pg, final int rounds);  }