From 39b810bd799f3e45b86ddbc80461d4b0d0f27cb1 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 27 Sep 2015 16:01:22 +0000 Subject: [PATCH] Tunnels: Use max of 2 not-failing peers in an exploratory tunnel, use high cap for the rest; change outbound exploratory default length from 2 + 0-1 to 3+0. --- history.txt | 12 ++++ .../src/net/i2p/router/RouterVersion.java | 2 +- .../net/i2p/router/TunnelPoolSettings.java | 8 +-- .../tunnel/pool/ExploratoryPeerSelector.java | 71 +++++++++++-------- 4 files changed, 57 insertions(+), 36 deletions(-) diff --git a/history.txt b/history.txt index 2a0172d774..3633628324 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,15 @@ +2015-09-27 zzz + * Console: + - Export SSL cert on creation + - New /certs page to show local SSL certs + - Show 'none' if no leasesets + * SimpleTimer2: Fix bug in forceReschedule() that caused subsequent uncaught IllegalStateException, + affected streaming timers + * Streaming: Move throttler from context timer to streaming timer + * Tunnels: Use max of 2 not-failing peers in an exploratory tunnel, + use high cap for the rest; change outbound exploratory + default length from 2 + 0-1 to 3+0. + 2015-09-25 dg * Rename _() for translation to _t() for Java 9 compatibility (ticket #1456) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index f2522cd4ed..7ca1a3ec2c 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 9; + public final static long BUILD = 10; /** for example "-test" */ public final static String EXTRA = ""; diff --git a/router/java/src/net/i2p/router/TunnelPoolSettings.java b/router/java/src/net/i2p/router/TunnelPoolSettings.java index b7984c085b..24184cc141 100644 --- a/router/java/src/net/i2p/router/TunnelPoolSettings.java +++ b/router/java/src/net/i2p/router/TunnelPoolSettings.java @@ -76,11 +76,11 @@ public class TunnelPoolSettings { private static final int DEFAULT_LENGTH_VARIANCE = 0; /** expl only */ private static final int DEFAULT_IB_EXPL_LENGTH = 2; - //private static final int DEFAULT_OB_EXPL_LENGTH = isSlow ? 2 : 3; - private static final int DEFAULT_OB_EXPL_LENGTH = 2; + private static final int DEFAULT_OB_EXPL_LENGTH = isSlow ? 2 : 3; + //private static final int DEFAULT_OB_EXPL_LENGTH = 2; private static final int DEFAULT_IB_EXPL_LENGTH_VARIANCE = isSlow ? 0 : 1; - //private static final int DEFAULT_OB_EXPL_LENGTH_VARIANCE = 0; - private static final int DEFAULT_OB_EXPL_LENGTH_VARIANCE = isSlow ? 0 : 1; + private static final int DEFAULT_OB_EXPL_LENGTH_VARIANCE = 0; + //private static final int DEFAULT_OB_EXPL_LENGTH_VARIANCE = isSlow ? 0 : 1; public static final boolean DEFAULT_ALLOW_ZERO_HOP = true; public static final int DEFAULT_IP_RESTRICTION = 2; // class B (/16) diff --git a/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java b/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java index 6bb81fbc8c..b6b141e7a8 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java +++ b/router/java/src/net/i2p/router/tunnel/pool/ExploratoryPeerSelector.java @@ -33,12 +33,12 @@ class ExploratoryPeerSelector extends TunnelPeerSelector { return null; } - if (false && shouldSelectExplicit(settings)) { - List rv = selectExplicit(settings, length); - if (l.shouldLog(Log.DEBUG)) - l.debug("Explicit peers selected: " + rv); - return rv; - } + //if (false && shouldSelectExplicit(settings)) { + // List rv = selectExplicit(settings, length); + // if (l.shouldLog(Log.DEBUG)) + // l.debug("Explicit peers selected: " + rv); + // return rv; + //} Set exclude = getExclude(settings.isInbound(), true); exclude.add(ctx.routerHash()); @@ -55,34 +55,43 @@ class ExploratoryPeerSelector extends TunnelPeerSelector { // FloodfillNetworkDatabaseFacade fac = (FloodfillNetworkDatabaseFacade)ctx.netDb(); // exclude.addAll(fac.getFloodfillPeers()); HashSet matches = new HashSet(length); - boolean exploreHighCap = shouldPickHighCap(); - // - // We don't honor IP Restriction here, to be fixed - // + if (length > 0) { + boolean exploreHighCap = shouldPickHighCap(); - // If hidden and inbound, use fast peers - that we probably have recently - // connected to and so they have our real RI - to maximize the chance - // that the adjacent hop can connect to us. - if (settings.isInbound() && ctx.router().isHidden()) { - if (l.shouldLog(Log.INFO)) - l.info("EPS SFP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); - ctx.profileOrganizer().selectFastPeers(length, exclude, matches); - } else if (exploreHighCap) { - if (l.shouldLog(Log.INFO)) - l.info("EPS SHCP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); - ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches); - } else if (ctx.commSystem().haveHighOutboundCapacity()) { - if (l.shouldLog(Log.INFO)) - l.info("EPS SNFP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); - ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false); - } else { // use only connected peers so we don't make more connections - if (l.shouldLog(Log.INFO)) - l.info("EPS SANFP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); - ctx.profileOrganizer().selectActiveNotFailingPeers(length, exclude, matches); + // + // We don't honor IP Restriction here, to be fixed + // + + // If hidden and inbound, use fast peers - that we probably have recently + // connected to and so they have our real RI - to maximize the chance + // that the adjacent hop can connect to us. + if (settings.isInbound() && ctx.router().isHidden()) { + if (l.shouldLog(Log.INFO)) + l.info("EPS SFP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); + ctx.profileOrganizer().selectFastPeers(length, exclude, matches); + } else if (exploreHighCap) { + if (l.shouldLog(Log.INFO)) + l.info("EPS SHCP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); + ctx.profileOrganizer().selectHighCapacityPeers(length, exclude, matches); + } else if (ctx.commSystem().haveHighOutboundCapacity()) { + if (l.shouldLog(Log.INFO)) + l.info("EPS SNFP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); + // As of 0.9.23, we include a max of 2 not failing peers, + // to improve build success on 3-hop tunnels. + // Peer org credits existing items in matches + if (length > 2) + ctx.profileOrganizer().selectHighCapacityPeers(length - 2, exclude, matches); + ctx.profileOrganizer().selectNotFailingPeers(length, exclude, matches, false); + } else { // use only connected peers so we don't make more connections + if (l.shouldLog(Log.INFO)) + l.info("EPS SANFP " + length + (settings.isInbound() ? " IB" : " OB") + " exclude " + exclude.size()); + ctx.profileOrganizer().selectActiveNotFailingPeers(length, exclude, matches); + } + + matches.remove(ctx.routerHash()); } - - matches.remove(ctx.routerHash()); + ArrayList rv = new ArrayList(matches); if (rv.size() > 1) orderPeers(rv, settings.getRandomKey());