* Transport:

- Fixes and cleanups when NTCP and/or UDP transports disabled
      - More TCP removal cleanup
      - Clean up bandwidth limiting, centralize defaults
      - Force burst to be >= limit
      - Increase default bw to 48/24, burst 64/32
This commit is contained in:
zzz
2008-12-03 18:53:57 +00:00
parent 8e5c4a3e22
commit 85cebc7992
9 changed files with 105 additions and 158 deletions

View File

@ -1072,11 +1072,13 @@ public class Router {
return true;
}
private static final String PROP_BANDWIDTH_SHARE_PERCENTAGE = "router.sharePercentage";
public static final String PROP_BANDWIDTH_SHARE_PERCENTAGE = "router.sharePercentage";
public static final int DEFAULT_SHARE_PERCENTAGE = 80;
/**
* What fraction of the bandwidth specified in our bandwidth limits should
* we allow to be consumed by participating tunnels?
* @returns a number less than one, not a percentage!
*
*/
public double getSharePercentage() {
@ -1095,7 +1097,7 @@ public class Router {
_log.info("Unable to get the share percentage");
}
}
return 0.8;
return DEFAULT_SHARE_PERCENTAGE / 100.0d;
}
public int get1sRate() { return get1sRate(false); }

View File

@ -411,7 +411,10 @@ class RouterThrottleImpl implements RouterThrottle {
}
public long getMessageDelay() {
Rate delayRate = _context.statManager().getRate("transport.sendProcessingTime").getRate(60*1000);
RateStat rs = _context.statManager().getRate("transport.sendProcessingTime");
if (rs == null)
return 0;
Rate delayRate = rs.getRate(60*1000);
return (long)delayRate.getAverageValue();
}
@ -422,6 +425,8 @@ class RouterThrottleImpl implements RouterThrottle {
public double getInboundRateDelta() {
RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
if (receiveRate == null)
return 0;
double nowBps = getBps(receiveRate.getRate(60*1000));
double fiveMinBps = getBps(receiveRate.getRate(5*60*1000));
double hourBps = getBps(receiveRate.getRate(60*60*1000));

View File

@ -107,8 +107,11 @@ public class FIFOBandwidthLimiter {
public float getSendBps15s() { return _sendBps15s; }
public float getReceiveBps15s() { return _recvBps15s; }
/** These are the configured maximums, not the current rate */
public int getOutboundKBytesPerSecond() { return _refiller.getOutboundKBytesPerSecond(); }
public int getInboundKBytesPerSecond() { return _refiller.getInboundKBytesPerSecond(); }
public int getOutboundBurstKBytesPerSecond() { return _refiller.getOutboundBurstKBytesPerSecond(); }
public int getInboundBurstKBytesPerSecond() { return _refiller.getInboundBurstKBytesPerSecond(); }
public void reinitialize() {
_pendingInboundRequests.clear();
@ -191,8 +194,8 @@ public class FIFOBandwidthLimiter {
void setOutboundBurstKBps(int kbytesPerSecond) {
_maxOutbound = kbytesPerSecond * 1024;
}
int getInboundBurstBytes() { return _maxInboundBurst; }
int getOutboundBurstBytes() { return _maxOutboundBurst; }
public int getInboundBurstBytes() { return _maxInboundBurst; }
public int getOutboundBurstBytes() { return _maxOutboundBurst; }
void setInboundBurstBytes(int bytes) { _maxInboundBurst = bytes; }
void setOutboundBurstBytes(int bytes) { _maxOutboundBurst = bytes; }

View File

@ -6,7 +6,7 @@ import java.util.List;
import net.i2p.I2PAppContext;
import net.i2p.util.Log;
class FIFOBandwidthRefiller implements Runnable {
public class FIFOBandwidthRefiller implements Runnable {
private Log _log;
private I2PAppContext _context;
private FIFOBandwidthLimiter _limiter;
@ -34,9 +34,9 @@ class FIFOBandwidthRefiller implements Runnable {
//public static final String PROP_REPLENISH_FREQUENCY = "i2np.bandwidth.replenishFrequencyMs";
// no longer allow unlimited bandwidth - the user must specify a value, and if they do not, it is 32/16KBps
public static final int DEFAULT_INBOUND_BANDWIDTH = 32;
public static final int DEFAULT_OUTBOUND_BANDWIDTH = 16;
public static final int DEFAULT_INBOUND_BURST_BANDWIDTH = 48;
public static final int DEFAULT_INBOUND_BANDWIDTH = 48;
public static final int DEFAULT_OUTBOUND_BANDWIDTH = 24;
public static final int DEFAULT_INBOUND_BURST_BANDWIDTH = 64;
public static final int DEFAULT_OUTBOUND_BURST_BANDWIDTH = 32;
public static final int DEFAULT_BURST_SECONDS = 60;
@ -217,10 +217,10 @@ class FIFOBandwidthRefiller implements Runnable {
// bandwidth was specified *and* changed
try {
int in = Integer.parseInt(inBwStr);
if ( (in <= 0) || (in > MIN_INBOUND_BANDWIDTH) )
if ( (in <= 0) || (in >= _inboundKBytesPerSecond) )
_inboundBurstKBytesPerSecond = in;
else
_inboundBurstKBytesPerSecond = MIN_INBOUND_BANDWIDTH;
_inboundBurstKBytesPerSecond = _inboundKBytesPerSecond;
if (_log.shouldLog(Log.DEBUG))
_log.debug("Updating inbound burst rate to " + _inboundBurstKBytesPerSecond);
} catch (NumberFormatException nfe) {
@ -247,10 +247,10 @@ class FIFOBandwidthRefiller implements Runnable {
// bandwidth was specified *and* changed
try {
int out = Integer.parseInt(outBwStr);
if ( (out <= 0) || (out >= MIN_OUTBOUND_BANDWIDTH) )
if ( (out <= 0) || (out >= _outboundKBytesPerSecond) )
_outboundBurstKBytesPerSecond = out;
else
_outboundBurstKBytesPerSecond = MIN_OUTBOUND_BANDWIDTH;
_outboundBurstKBytesPerSecond = _outboundKBytesPerSecond;
if (_log.shouldLog(Log.DEBUG))
_log.debug("Updating outbound burst rate to " + _outboundBurstKBytesPerSecond);
} catch (NumberFormatException nfe) {
@ -335,4 +335,6 @@ class FIFOBandwidthRefiller implements Runnable {
int getOutboundKBytesPerSecond() { return _outboundKBytesPerSecond; }
int getInboundKBytesPerSecond() { return _inboundKBytesPerSecond; }
int getOutboundBurstKBytesPerSecond() { return _outboundBurstKBytesPerSecond; }
int getInboundBurstKBytesPerSecond() { return _inboundBurstKBytesPerSecond; }
}

View File

@ -36,7 +36,6 @@ public class TransportManager implements TransportEventListener {
private List _transports;
private RouterContext _context;
private final static String PROP_DISABLE_TCP = "i2np.tcp.disable";
private final static String PROP_ENABLE_UDP = "i2np.udp.enable";
private final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable";
private final static String DEFAULT_ENABLE_NTCP = "true";
@ -66,8 +65,6 @@ public class TransportManager implements TransportEventListener {
transport.setListener(null);
}
static final boolean ALLOW_TCP = false;
private void configTransports() {
String enableUDP = _context.router().getConfigSetting(PROP_ENABLE_UDP);
if (enableUDP == null)
@ -77,13 +74,16 @@ public class TransportManager implements TransportEventListener {
udp.setListener(this);
_transports.add(udp);
}
enableNTCP(_context);
NTCPTransport ntcp = new NTCPTransport(_context);
ntcp.setListener(this);
_transports.add(ntcp);
if (enableNTCP(_context)) {
NTCPTransport ntcp = new NTCPTransport(_context);
ntcp.setListener(this);
_transports.add(ntcp);
}
if (_transports.size() <= 0)
_log.log(Log.CRIT, "No transports are enabled");
}
static boolean enableNTCP(RouterContext ctx) {
public static boolean enableNTCP(RouterContext ctx) {
String enableNTCP = ctx.router().getConfigSetting(PROP_ENABLE_NTCP);
if (enableNTCP == null)
enableNTCP = DEFAULT_ENABLE_NTCP;