Changeset 55d571f


Ignore:
Timestamp:
Jul 18, 2013 10:25:10 PM (7 years ago)
Author:
zab2 <zab2@…>
Branches:
master
Children:
96de87fd
Parents:
ae347c4
Message:

Hardcode TCP constants

Various suggestions by zzz

Location:
apps/streaming/java/src/net/i2p/client/streaming
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/streaming/java/src/net/i2p/client/streaming/ConnectionOptions.java

    rae347c4 r55d571f  
    2828    private int _rtt;
    2929    private int _rttDev;
    30     private int _rto;
     30    private int _rto = INITIAL_RTO;
    3131    private int _resendDelay;
    3232    private int _sendAckDelay;
     
    5252    private int _maxConns;
    5353    private boolean _disableRejectLog;
    54     private double _alpha;
    55     private double _beta;
    56     private double _kappa;
    5754   
    5855    /** state of a connection */
    59     enum AckInit {
     56    private enum AckInit {
    6057        INIT, // just created
    6158        FIRST, // first received ack
     
    8683    private static final double TCP_BETA = 1.0/4;
    8784    private static final double TCP_KAPPA = 4;
    88     private static final String PROP_TCP_ALPHA= "i2p.streaming.alpha";
    89     private static final String PROP_TCP_BETA= "i2p.streaming.beta";
    90     private static final String PROP_TCP_KAPPA = "i2p.streaming.kappa";
    9185   
    9286    private static final String PROP_INITIAL_RTO = "i2p.streaming.initialRTO";
     
    387381        _maxTotalConnsPerDay = getInt(opts, PROP_MAX_TOTAL_CONNS_DAY, 0);
    388382        _maxConns = getInt(opts, PROP_MAX_STREAMS, 0);
    389        
    390         _alpha = getDouble(opts, PROP_TCP_ALPHA, TCP_ALPHA);
    391         _beta = getDouble(opts, PROP_TCP_BETA, TCP_BETA);
    392         _kappa = getDouble(opts, PROP_TCP_KAPPA, TCP_KAPPA);
    393383       
    394384        _rto = getInt(opts, PROP_INITIAL_RTO, INITIAL_RTO);
     
    459449            _maxConns = getInt(opts, PROP_MAX_STREAMS, 0);
    460450       
    461         _alpha = getDouble(opts, PROP_TCP_ALPHA, TCP_ALPHA);
    462         _beta = getDouble(opts, PROP_TCP_BETA, TCP_BETA);
    463         _kappa = getDouble(opts, PROP_TCP_KAPPA, TCP_KAPPA);
    464451        _rto = getInt(opts, PROP_INITIAL_RTO, INITIAL_RTO);
    465452    }
     
    600587            break;
    601588        case STEADY :
    602             _rto = _rtt + (int) (_rttDev * _kappa);
     589            _rto = _rtt + (int) (_rttDev * TCP_KAPPA);
    603590            break;
    604591        }
     
    633620            break;
    634621        case FIRST:
    635             _initState = AckInit.STEADY;
     622            _initState = AckInit.STEADY; // fall through
    636623        case STEADY:
    637624            // calculation matches that recommended in RFC 6298
    638             _rttDev = (int) ((1-_beta) *_rttDev  + _beta * Math.abs(measuredValue-_rtt));
    639             int smoothed = (int)((1-_alpha)*_rtt + _alpha*measuredValue);       
     625            _rttDev = (int) ((1-TCP_BETA) *_rttDev  + TCP_BETA * Math.abs(measuredValue-_rtt));
     626            int smoothed = (int)((1-TCP_ALPHA)*_rtt + TCP_ALPHA*measuredValue);       
    640627            setRTT(smoothed);
    641628        }
  • apps/streaming/java/src/net/i2p/client/streaming/TCBShare.java

    rae347c4 r55d571f  
    33import java.util.Iterator;
    44import java.util.Map;
     5import java.util.Properties;
    56import java.util.concurrent.ConcurrentHashMap;
    67
     
    4950        _log = ctx.logManager().getLog(TCBShare.class);
    5051       
    51         _rttDampening = getDouble(ctx.getProperties(), RTT_DAMP_PROP, RTT_DAMPENING);
    52         _wdwDampening = getDouble(ctx.getProperties(), WDW_DAMP_PROP, WDW_DAMPENING);
    53         _rttDevDampening = getDouble(ctx.getProperties(), RTTDEV_DAMP_PROP, RTTDEV_DAMPENING);
     52        final Properties props = ctx.getProperties();
     53        _rttDampening = getDouble(props, RTT_DAMP_PROP, RTT_DAMPENING);
     54        _wdwDampening = getDouble(props, WDW_DAMP_PROP, WDW_DAMPENING);
     55        _rttDevDampening = getDouble(props, RTTDEV_DAMP_PROP, RTTDEV_DAMPENING);
    5456       
    5557        _cache = new ConcurrentHashMap<Destination,Entry>(4);
Note: See TracChangeset for help on using the changeset viewer.