Changeset 24ecc85


Ignore:
Timestamp:
Nov 9, 2016 9:32:19 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c3181d85
Parents:
e5bcfe4
Message:

Tunnels: Reduce default VTBM records from 5 to 4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/tunnel/pool/BuildRequestor.java

    re5bcfe4 r24ecc85  
    2626abstract class BuildRequestor {
    2727    private static final List<Integer> ORDER = new ArrayList<Integer>(TunnelBuildMessage.MAX_RECORD_COUNT);
     28    private static final String MIN_VARIABLE_VERSION = "0.7.12";
     29    private static final boolean SEND_VARIABLE = true;
     30    private static final int SHORT_RECORDS = 4;
     31    private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS);
     32    /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */
     33    private static final int MEDIUM_RECORDS = 5;
     34    private static final List<Integer> MEDIUM_ORDER = new ArrayList<Integer>(MEDIUM_RECORDS);
    2835    static {
    29         for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++)
     36        for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++) {
    3037            ORDER.add(Integer.valueOf(i));
     38        }
     39        for (int i = 0; i < SHORT_RECORDS; i++) {
     40            SHORT_ORDER.add(Integer.valueOf(i));
     41        }
     42        for (int i = 0; i < MEDIUM_RECORDS; i++) {
     43            MEDIUM_ORDER.add(Integer.valueOf(i));
     44        }
    3145    }
    3246
     
    224238        return true;
    225239    }
    226    
    227     private static final String MIN_VARIABLE_VERSION = "0.7.12";
    228     /** change this to true in 0.7.13 if testing goes well */
    229     private static final boolean SEND_VARIABLE = true;
    230     /** 5 (~2600 bytes) fits nicely in 3 tunnel messages */
    231     private static final int SHORT_RECORDS = 5;
    232     private static final List<Integer> SHORT_ORDER = new ArrayList<Integer>(SHORT_RECORDS);
    233     static {
    234         for (int i = 0; i < SHORT_RECORDS; i++)
    235             SHORT_ORDER.add(Integer.valueOf(i));
    236     }
    237240
    238241    /** @since 0.7.12 */
     
    257260        long replyTunnel = 0;
    258261        Hash replyRouter = null;
    259         boolean useVariable = SEND_VARIABLE && cfg.getLength() <= SHORT_RECORDS;
     262        boolean useVariable = SEND_VARIABLE && cfg.getLength() <= MEDIUM_RECORDS;
    260263        if (cfg.isInbound()) {
    261264            //replyTunnel = 0; // as above
     
    296299        List<Integer> order;
    297300        if (useVariable) {
    298             msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS);
    299             order = new ArrayList<Integer>(SHORT_ORDER);
    300             //if (log.shouldLog(Log.INFO))
    301             //    log.info("Using new VTBM");
     301            if (cfg.getLength() <= SHORT_RECORDS) {
     302                msg = new VariableTunnelBuildMessage(ctx, SHORT_RECORDS);
     303                order = new ArrayList<Integer>(SHORT_ORDER);
     304            } else {
     305                msg = new VariableTunnelBuildMessage(ctx, MEDIUM_RECORDS);
     306                order = new ArrayList<Integer>(MEDIUM_ORDER);
     307            }
    302308        } else {
    303309            msg = new TunnelBuildMessage(ctx);
Note: See TracChangeset for help on using the changeset viewer.