From 24ecc858f16720531f8c36a7d9ea72dd64263c5f Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 9 Nov 2016 21:32:19 +0000 Subject: [PATCH] Tunnels: Reduce default VTBM records from 5 to 4 --- .../router/tunnel/pool/BuildRequestor.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java b/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java index 15c90b092c..ca3caa1b71 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java +++ b/router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java @@ -25,9 +25,23 @@ import net.i2p.util.VersionComparator; */ abstract class BuildRequestor { private static final List<Integer> ORDER = new ArrayList<Integer>(TunnelBuildMessage.MAX_RECORD_COUNT); + private static final String MIN_VARIABLE_VERSION = "0.7.12"; + private static final boolean SEND_VARIABLE = true; + private static final int SHORT_RECORDS = 4; + private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS); + /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */ + private static final int MEDIUM_RECORDS = 5; + private static final List<Integer> MEDIUM_ORDER = new ArrayList<Integer>(MEDIUM_RECORDS); static { - for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++) + for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++) { ORDER.add(Integer.valueOf(i)); + } + for (int i = 0; i < SHORT_RECORDS; i++) { + SHORT_ORDER.add(Integer.valueOf(i)); + } + for (int i = 0; i < MEDIUM_RECORDS; i++) { + MEDIUM_ORDER.add(Integer.valueOf(i)); + } } private static final int PRIORITY = OutNetMessage.PRIORITY_MY_BUILD_REQUEST; @@ -223,17 +237,6 @@ abstract class BuildRequestor { // + "ms and dispatched in " + (System.currentTimeMillis()-beforeDispatch)); return true; } - - private static final String MIN_VARIABLE_VERSION = "0.7.12"; - /** change this to true in 0.7.13 if testing goes well */ - private static final boolean SEND_VARIABLE = true; - /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */ - private static final int SHORT_RECORDS = 5; - private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS); - static { - for (int i = 0; i < SHORT_RECORDS; i++) - SHORT_ORDER.add(Integer.valueOf(i)); - } /** @since 0.7.12 */ private static boolean supportsVariable(RouterContext ctx, Hash h) { @@ -256,7 +259,7 @@ abstract class BuildRequestor { Log log = ctx.logManager().getLog(BuildRequestor.class); long replyTunnel = 0; Hash replyRouter = null; - boolean useVariable = SEND_VARIABLE && cfg.getLength() <= SHORT_RECORDS; + boolean useVariable = SEND_VARIABLE && cfg.getLength() <= MEDIUM_RECORDS; if (cfg.isInbound()) { //replyTunnel = 0; // as above replyRouter = ctx.routerHash(); @@ -295,10 +298,13 @@ abstract class BuildRequestor { TunnelBuildMessage msg; List<Integer> order; if (useVariable) { - msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS); - order = new ArrayList<Integer>(SHORT_ORDER); - //if (log.shouldLog(Log.INFO)) - // log.info("Using new VTBM"); + if (cfg.getLength() <= SHORT_RECORDS) { + msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS); + order = new ArrayList<Integer>(SHORT_ORDER); + } else { + msg = new VariableTunnelBuildMessage(ctx, MEDIUM_RECORDS); + order = new ArrayList<Integer>(MEDIUM_ORDER); + } } else { msg = new TunnelBuildMessage(ctx); order = new ArrayList<Integer>(ORDER); -- GitLab