* 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

@ -3,6 +3,7 @@ package net.i2p.router.web;
import net.i2p.data.RouterInfo; import net.i2p.data.RouterInfo;
import net.i2p.router.LoadTestManager; import net.i2p.router.LoadTestManager;
import net.i2p.router.Router; import net.i2p.router.Router;
import net.i2p.router.transport.FIFOBandwidthRefiller;
import net.i2p.router.transport.udp.UDPTransport; import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask; import net.i2p.router.web.ConfigServiceHandler.UpdateWrapperManagerAndRekeyTask;
import net.i2p.time.Timestamper; import net.i2p.time.Timestamper;
@ -110,26 +111,6 @@ public class ConfigNetHandler extends FormHandler {
boolean restartRequired = false; boolean restartRequired = false;
if (!_ratesOnly) { if (!_ratesOnly) {
if ( (_hostname != null) && (_hostname.length() > 0) ) {
String oldHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_HOSTNAME);
if ( (oldHost == null) || (!oldHost.equalsIgnoreCase(_hostname)) ) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_HOSTNAME, _hostname);
addFormNotice("Updating hostname from " + oldHost + " to " + _hostname);
restartRequired = true;
}
}
if ( (_tcpPort != null) && (_tcpPort.length() > 0) ) {
String oldPort = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT);
if ( (oldPort == null) && (_tcpPort.equals("8887")) ) {
// still on default.. noop
} else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_tcpPort)) ) {
// its not the default OR it has changed
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _tcpPort);
addFormNotice("Updating TCP port from " + oldPort + " to " + _tcpPort);
restartRequired = true;
}
}
// Normalize some things to make the following code a little easier... // Normalize some things to make the following code a little easier...
String oldNHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME); String oldNHost = _context.router().getConfigSetting(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME);
if (oldNHost == null) oldNHost = ""; if (oldNHost == null) oldNHost = "";
@ -181,7 +162,7 @@ public class ConfigNetHandler extends FormHandler {
// still on default.. noop // still on default.. noop
} else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_udpPort)) ) { } else if ( (oldPort == null) || (!oldPort.equalsIgnoreCase(_udpPort)) ) {
// its not the default OR it has changed // its not the default OR it has changed
_context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_TCP_PORT, _udpPort); _context.router().setConfigSetting(ConfigNetHelper.PROP_I2NP_UDP_PORT, _udpPort);
addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort); addFormNotice("Updating UDP port from " + oldPort + " to " + _udpPort);
restartRequired = true; restartRequired = true;
} }
@ -193,9 +174,9 @@ public class ConfigNetHandler extends FormHandler {
if (!_ratesOnly) { if (!_ratesOnly) {
if (_sharePct != null) { if (_sharePct != null) {
String old = _context.router().getConfigSetting(ConfigNetHelper.PROP_SHARE_PERCENTAGE); String old = _context.router().getConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE);
if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) { if ( (old == null) || (!old.equalsIgnoreCase(_sharePct)) ) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_SHARE_PERCENTAGE, _sharePct); _context.router().setConfigSetting(Router.PROP_BANDWIDTH_SHARE_PERCENTAGE, _sharePct);
addFormNotice("Updating bandwidth share percentage"); addFormNotice("Updating bandwidth share percentage");
} }
} }
@ -263,23 +244,23 @@ public class ConfigNetHandler extends FormHandler {
private void updateRates() { private void updateRates() {
boolean updated = false; boolean updated = false;
if ( (_inboundRate != null) && (_inboundRate.length() > 0) ) { if ( (_inboundRate != null) && (_inboundRate.length() > 0) ) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_KBPS, _inboundRate); _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH, _inboundRate);
updated = true; updated = true;
} }
if ( (_outboundRate != null) && (_outboundRate.length() > 0) ) { if ( (_outboundRate != null) && (_outboundRate.length() > 0) ) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_KBPS, _outboundRate); _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH, _outboundRate);
updated = true; updated = true;
} }
if ( (_inboundBurstRate != null) && (_inboundBurstRate.length() > 0) ) { if ( (_inboundBurstRate != null) && (_inboundBurstRate.length() > 0) ) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST_KBPS, _inboundBurstRate); _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH, _inboundBurstRate);
updated = true; updated = true;
} }
if ( (_outboundBurstRate != null) && (_outboundBurstRate.length() > 0) ) { if ( (_outboundBurstRate != null) && (_outboundBurstRate.length() > 0) ) {
_context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST_KBPS, _outboundBurstRate); _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH, _outboundBurstRate);
updated = true; updated = true;
} }
String inBurstRate = _context.router().getConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST_KBPS); String inBurstRate = _context.router().getConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BURST_BANDWIDTH);
if (_inboundBurst != null) { if (_inboundBurst != null) {
int rateKBps = 0; int rateKBps = 0;
@ -292,12 +273,12 @@ public class ConfigNetHandler extends FormHandler {
} }
if ( (rateKBps > 0) && (burstSeconds > 0) ) { if ( (rateKBps > 0) && (burstSeconds > 0) ) {
int kb = rateKBps * burstSeconds; int kb = rateKBps * burstSeconds;
_context.router().setConfigSetting(ConfigNetHelper.PROP_INBOUND_BURST, "" + kb); _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_INBOUND_BANDWIDTH_PEAK, "" + kb);
updated = true; updated = true;
} }
} }
String outBurstRate = _context.router().getConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST_KBPS); String outBurstRate = _context.router().getConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BURST_BANDWIDTH);
if (_outboundBurst != null) { if (_outboundBurst != null) {
int rateKBps = 0; int rateKBps = 0;
@ -310,12 +291,13 @@ public class ConfigNetHandler extends FormHandler {
} }
if ( (rateKBps > 0) && (burstSeconds > 0) ) { if ( (rateKBps > 0) && (burstSeconds > 0) ) {
int kb = rateKBps * burstSeconds; int kb = rateKBps * burstSeconds;
_context.router().setConfigSetting(ConfigNetHelper.PROP_OUTBOUND_BURST, "" + kb); _context.router().setConfigSetting(FIFOBandwidthRefiller.PROP_OUTBOUND_BANDWIDTH_PEAK, "" + kb);
updated = true; updated = true;
} }
} }
if (updated && !_ratesOnly) if (updated && !_ratesOnly)
_context.bandwidthLimiter().reinitialize();
addFormNotice("Updated bandwidth limits"); addFormNotice("Updated bandwidth limits");
} }
} }

View File

@ -5,6 +5,7 @@ import net.i2p.router.CommSystemFacade;
import net.i2p.router.LoadTestManager; import net.i2p.router.LoadTestManager;
import net.i2p.router.Router; import net.i2p.router.Router;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.transport.TransportManager;
import net.i2p.router.transport.udp.UDPAddress; import net.i2p.router.transport.udp.UDPAddress;
import net.i2p.router.transport.udp.UDPTransport; import net.i2p.router.transport.udp.UDPTransport;
import net.i2p.time.Timestamper; import net.i2p.time.Timestamper;
@ -27,37 +28,23 @@ public class ConfigNetHelper {
public ConfigNetHelper() {} public ConfigNetHelper() {}
/** copied from various private TCP components */ /** copied from various private components */
public final static String PROP_I2NP_TCP_HOSTNAME = "i2np.tcp.hostname";
public final static String PROP_I2NP_TCP_PORT = "i2np.tcp.port";
public final static String PROP_I2NP_UDP_PORT = "i2np.udp.port"; public final static String PROP_I2NP_UDP_PORT = "i2np.udp.port";
public final static String PROP_I2NP_INTERNAL_UDP_PORT = "i2np.udp.internalPort"; public final static String PROP_I2NP_INTERNAL_UDP_PORT = "i2np.udp.internalPort";
public String getHostname() {
return _context.getProperty(PROP_I2NP_TCP_HOSTNAME);
}
public String getTcpPort() {
int port = 8887;
String val = _context.getProperty(PROP_I2NP_TCP_PORT);
if (val != null) {
try {
port = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
// ignore, use default from above
}
}
return "" + port;
}
public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname"; public final static String PROP_I2NP_NTCP_HOSTNAME = "i2np.ntcp.hostname";
public final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port"; public final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoip"; public final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoip";
public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoport"; public final static String PROP_I2NP_NTCP_AUTO_IP = "i2np.ntcp.autoport";
public String getNtcphostname() { public String getNtcphostname() {
if (!TransportManager.enableNTCP(_context))
return "\" disabled=\"true";
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME); String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
if (hostname == null) return ""; if (hostname == null) return "";
return hostname; return hostname;
} }
public String getNtcpport() { public String getNtcpport() {
if (!TransportManager.enableNTCP(_context))
return "\" disabled=\"true";
String port = _context.getProperty(PROP_I2NP_NTCP_PORT); String port = _context.getProperty(PROP_I2NP_NTCP_PORT);
if (port == null) return ""; if (port == null) return "";
return port; return port;
@ -116,6 +103,8 @@ public class ConfigNetHelper {
} }
public String getTcpAutoPortChecked() { public String getTcpAutoPortChecked() {
if (!TransportManager.enableNTCP(_context))
return " disabled=\"true\" ";
String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_PORT, "false"); String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_PORT, "false");
if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) ) if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
return " checked "; return " checked ";
@ -124,6 +113,8 @@ public class ConfigNetHelper {
} }
public String getTcpAutoIPChecked() { public String getTcpAutoIPChecked() {
if (!TransportManager.enableNTCP(_context))
return " disabled=\"true\" ";
String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false"); String enabled = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) ) if ( (enabled != null) && ("true".equalsIgnoreCase(enabled)) )
return " checked "; return " checked ";
@ -150,80 +141,33 @@ public class ConfigNetHelper {
} }
} }
public static final String PROP_INBOUND_KBPS = "i2np.bandwidth.inboundKBytesPerSecond";
public static final String PROP_OUTBOUND_KBPS = "i2np.bandwidth.outboundKBytesPerSecond";
public static final String PROP_INBOUND_BURST_KBPS = "i2np.bandwidth.inboundBurstKBytesPerSecond";
public static final String PROP_OUTBOUND_BURST_KBPS = "i2np.bandwidth.outboundBurstKBytesPerSecond";
public static final String PROP_INBOUND_BURST = "i2np.bandwidth.inboundBurstKBytes";
public static final String PROP_OUTBOUND_BURST = "i2np.bandwidth.outboundBurstKBytes";
public static final String PROP_SHARE_PERCENTAGE = "router.sharePercentage";
public static final int DEFAULT_SHARE_PERCENTAGE = 80;
public String getInboundRate() { public String getInboundRate() {
String rate = _context.getProperty(PROP_INBOUND_KBPS); return "" + _context.bandwidthLimiter().getInboundKBytesPerSecond();
if (rate != null)
return rate;
else
return "32";
} }
public String getOutboundRate() { public String getOutboundRate() {
String rate = _context.getProperty(PROP_OUTBOUND_KBPS); return "" + _context.bandwidthLimiter().getOutboundKBytesPerSecond();
if (rate != null)
return rate;
else
return "16";
} }
public String getInboundBurstRate() { public String getInboundBurstRate() {
String rate = _context.getProperty(PROP_INBOUND_BURST_KBPS); return "" + _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();
if (rate != null)
return rate;
else
return "48";
} }
public String getOutboundBurstRate() { public String getOutboundBurstRate() {
String rate = _context.getProperty(PROP_OUTBOUND_BURST_KBPS); return "" + _context.bandwidthLimiter().getOutboundBurstKBytesPerSecond();
if (rate != null)
return rate;
else
return "32";
} }
public String getInboundBurstFactorBox() { public String getInboundBurstFactorBox() {
String rate = _context.getProperty(PROP_INBOUND_BURST_KBPS);
String burst = _context.getProperty(PROP_INBOUND_BURST);
int numSeconds = 1; int numSeconds = 1;
if ( (burst != null) && (rate != null) ) { int rateKBps = _context.bandwidthLimiter().getInboundBurstKBytesPerSecond();
int rateKBps = 0; int burstKB = _context.bandwidthLimiter().getInboundBurstBytes() * 1024;
int burstKB = 0; if ( (rateKBps > 0) && (burstKB > 0) )
try { numSeconds = burstKB / rateKBps;
rateKBps = Integer.parseInt(rate);
burstKB = Integer.parseInt(burst);
} catch (NumberFormatException nfe) {
// ignore
}
if ( (rateKBps > 0) && (burstKB > 0) ) {
numSeconds = burstKB / rateKBps;
}
}
return getBurstFactor(numSeconds, "inboundburstfactor"); return getBurstFactor(numSeconds, "inboundburstfactor");
} }
public String getOutboundBurstFactorBox() { public String getOutboundBurstFactorBox() {
String rate = _context.getProperty(PROP_OUTBOUND_BURST_KBPS);
String burst = _context.getProperty(PROP_OUTBOUND_BURST);
int numSeconds = 1; int numSeconds = 1;
if ( (burst != null) && (rate != null) ) { int rateKBps = _context.bandwidthLimiter().getOutboundBurstKBytesPerSecond();
int rateKBps = 0; int burstKB = _context.bandwidthLimiter().getOutboundBurstBytes() * 1024;
int burstKB = 0; if ( (rateKBps > 0) && (burstKB > 0) )
try { numSeconds = burstKB / rateKBps;
rateKBps = Integer.parseInt(rate);
burstKB = Integer.parseInt(burst);
} catch (NumberFormatException nfe) {
// ignore
}
if ( (rateKBps > 0) && (burstKB > 0) ) {
numSeconds = burstKB / rateKBps;
}
}
return getBurstFactor(numSeconds, "outboundburstfactor"); return getBurstFactor(numSeconds, "outboundburstfactor");
} }
@ -254,43 +198,36 @@ public class ConfigNetHelper {
} }
public String getSharePercentageBox() { public String getSharePercentageBox() {
String pctStr = _context.getProperty(PROP_SHARE_PERCENTAGE); int pct = (int) (100 * _context.router().getSharePercentage());
int pct = DEFAULT_SHARE_PERCENTAGE;
if (pctStr != null)
try { pct = Integer.parseInt(pctStr); } catch (NumberFormatException nfe) {}
StringBuffer buf = new StringBuffer(256); StringBuffer buf = new StringBuffer(256);
buf.append("<select name=\"sharePercentage\">\n"); buf.append("<select name=\"sharePercentage\">\n");
boolean found = false; boolean found = false;
for (int i = 30; i <= 100; i += 10) { for (int i = 30; i <= 110; i += 10) {
buf.append("<option value=\"").append(i).append("\" "); int val = i;
if (pct == i) { if (i == 110) {
if (found)
break;
else
val = pct;
}
buf.append("<option value=\"").append(val).append("\" ");
if (pct == val) {
buf.append("selected=\"true\" "); buf.append("selected=\"true\" ");
found = true; found = true;
} else if ( (i == DEFAULT_SHARE_PERCENTAGE) && (!found) ) {
buf.append("selected=\"true\" ");
} }
buf.append(">Up to ").append(i).append("%</option>\n"); buf.append(">Up to ").append(val).append("%</option>\n");
} }
buf.append("</select>\n"); buf.append("</select>\n");
return buf.toString(); return buf.toString();
} }
public static final int DEFAULT_SHARE_KBPS = 12;
public int getShareBandwidth() { public int getShareBandwidth() {
String irate = _context.getProperty(PROP_INBOUND_KBPS, "32"); int irateKBps = _context.bandwidthLimiter().getInboundKBytesPerSecond();
String orate = _context.getProperty(PROP_OUTBOUND_KBPS, "16"); int orateKBps = _context.bandwidthLimiter().getOutboundKBytesPerSecond();
String pctStr = _context.getProperty(PROP_SHARE_PERCENTAGE, "" + DEFAULT_SHARE_PERCENTAGE); double pct = _context.router().getSharePercentage();
if ( (irate != null) && (orate != null) && (pctStr != null)) { if (irateKBps < 0 || orateKBps < 0)
try { return DEFAULT_SHARE_KBPS;
int irateKBps = Integer.parseInt(irate); return (int) (pct * Math.min(irateKBps, orateKBps));
int orateKBps = Integer.parseInt(orate);
if (irateKBps < 0 || orateKBps < 0)
return 12;
int pct = Integer.parseInt(pctStr);
return (int) (((float) pct) * Math.min(irateKBps, orateKBps) / 100);
} catch (NumberFormatException nfe) {
// ignore
}
}
return 12;
} }
} }

View File

@ -143,6 +143,14 @@ public class SummaryHelper {
return "ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart"; return "ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart";
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
default: default:
ra = _context.router().getRouterInfo().getTargetAddress("UDP");
if (ra == null) {
if (_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME) == null ||
_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_PORT) == null)
return "ERR-UDP Disabled and Inbound TCP host/port not set";
else
return "WARN-Firewalled with UDP Disabled";
}
return "Testing"; return "Testing";
} }
} }

View File

@ -40,8 +40,7 @@
<input name="outboundburstrate" type="text" size="2" value="<jsp:getProperty name="nethelper" property="outboundBurstRate" />" /> KBps for <input name="outboundburstrate" type="text" size="2" value="<jsp:getProperty name="nethelper" property="outboundBurstRate" />" /> KBps for
<jsp:getProperty name="nethelper" property="outboundBurstFactorBox" /><br /> <jsp:getProperty name="nethelper" property="outboundBurstFactorBox" /><br />
<i>KBps = kilobytes per second = 1024 bytes per second = 8192 bits per second.<br /> <i>KBps = kilobytes per second = 1024 bytes per second = 8192 bits per second.<br />
A negative inbound rate means a default limit of 32KBytes per second. A negative rate sets the default.</i><br />
A negative outbound rate means a default limit of 16KBytes per second.</i><br />
Bandwidth share percentage: Bandwidth share percentage:
<jsp:getProperty name="nethelper" property="sharePercentageBox" /><br /> <jsp:getProperty name="nethelper" property="sharePercentageBox" /><br />
<% int share = nethelper.getShareBandwidth(); <% int share = nethelper.getShareBandwidth();
@ -130,6 +129,11 @@
your UDP port is firewalled, and therefore it is likely that your TCP port is firewalled as well. your UDP port is firewalled, and therefore it is likely that your TCP port is firewalled as well.
If your TCP port is firewalled with inbound TCP enabled, routers will not be able to contact If your TCP port is firewalled with inbound TCP enabled, routers will not be able to contact
you via TCP, which will hurt the network. Please open your firewall or disable inbound TCP above. you via TCP, which will hurt the network. Please open your firewall or disable inbound TCP above.
<li><b>WARN - Firewalled with UDP Disabled</b> -
You have configured inbound TCP, however
you have disabled UDP. You appear to be firewalled on TCP, therefore your router cannot
accept inbound connections.
Please open your firewall or enable UDP.
<li><b>ERR - Clock Skew</b> - Your system's clock is skewed, which will make it difficult <li><b>ERR - Clock Skew</b> - Your system's clock is skewed, which will make it difficult
to participate in the network. Correct your clock setting if this error persists. to participate in the network. Correct your clock setting if this error persists.
<li><b>ERR - Private TCP Address</b> - You must never advertise an unroutable IP address such as <li><b>ERR - Private TCP Address</b> - You must never advertise an unroutable IP address such as
@ -141,6 +145,10 @@
Check to see if another program is using port 8887. If so, stop that program or configure Check to see if another program is using port 8887. If so, stop that program or configure
I2P to use a different port. This may be a transient error, if the other program is no longer I2P to use a different port. This may be a transient error, if the other program is no longer
using the port. However, a restart is always required after this error. using the port. However, a restart is always required after this error.
<li><b>ERR - UDP Disabled and Inbound TCP host/port not set</b> -
You have not configured inbound TCP with a hostname and port above, however
you have disabled UDP. Therefore your router cannot accept inbound connections.
Please configure a TCP host and port above or enable UDP.
</ul> </ul>
</p> </p>
<hr /> <hr />

View File

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

View File

@ -411,7 +411,10 @@ class RouterThrottleImpl implements RouterThrottle {
} }
public long getMessageDelay() { 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(); return (long)delayRate.getAverageValue();
} }
@ -422,6 +425,8 @@ class RouterThrottleImpl implements RouterThrottle {
public double getInboundRateDelta() { public double getInboundRateDelta() {
RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize"); RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
if (receiveRate == null)
return 0;
double nowBps = getBps(receiveRate.getRate(60*1000)); double nowBps = getBps(receiveRate.getRate(60*1000));
double fiveMinBps = getBps(receiveRate.getRate(5*60*1000)); double fiveMinBps = getBps(receiveRate.getRate(5*60*1000));
double hourBps = getBps(receiveRate.getRate(60*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 getSendBps15s() { return _sendBps15s; }
public float getReceiveBps15s() { return _recvBps15s; } public float getReceiveBps15s() { return _recvBps15s; }
/** These are the configured maximums, not the current rate */
public int getOutboundKBytesPerSecond() { return _refiller.getOutboundKBytesPerSecond(); } public int getOutboundKBytesPerSecond() { return _refiller.getOutboundKBytesPerSecond(); }
public int getInboundKBytesPerSecond() { return _refiller.getInboundKBytesPerSecond(); } public int getInboundKBytesPerSecond() { return _refiller.getInboundKBytesPerSecond(); }
public int getOutboundBurstKBytesPerSecond() { return _refiller.getOutboundBurstKBytesPerSecond(); }
public int getInboundBurstKBytesPerSecond() { return _refiller.getInboundBurstKBytesPerSecond(); }
public void reinitialize() { public void reinitialize() {
_pendingInboundRequests.clear(); _pendingInboundRequests.clear();
@ -191,8 +194,8 @@ public class FIFOBandwidthLimiter {
void setOutboundBurstKBps(int kbytesPerSecond) { void setOutboundBurstKBps(int kbytesPerSecond) {
_maxOutbound = kbytesPerSecond * 1024; _maxOutbound = kbytesPerSecond * 1024;
} }
int getInboundBurstBytes() { return _maxInboundBurst; } public int getInboundBurstBytes() { return _maxInboundBurst; }
int getOutboundBurstBytes() { return _maxOutboundBurst; } public int getOutboundBurstBytes() { return _maxOutboundBurst; }
void setInboundBurstBytes(int bytes) { _maxInboundBurst = bytes; } void setInboundBurstBytes(int bytes) { _maxInboundBurst = bytes; }
void setOutboundBurstBytes(int bytes) { _maxOutboundBurst = bytes; } void setOutboundBurstBytes(int bytes) { _maxOutboundBurst = bytes; }

View File

@ -6,7 +6,7 @@ import java.util.List;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.util.Log; import net.i2p.util.Log;
class FIFOBandwidthRefiller implements Runnable { public class FIFOBandwidthRefiller implements Runnable {
private Log _log; private Log _log;
private I2PAppContext _context; private I2PAppContext _context;
private FIFOBandwidthLimiter _limiter; private FIFOBandwidthLimiter _limiter;
@ -34,9 +34,9 @@ class FIFOBandwidthRefiller implements Runnable {
//public static final String PROP_REPLENISH_FREQUENCY = "i2np.bandwidth.replenishFrequencyMs"; //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 // 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_INBOUND_BANDWIDTH = 48;
public static final int DEFAULT_OUTBOUND_BANDWIDTH = 16; public static final int DEFAULT_OUTBOUND_BANDWIDTH = 24;
public static final int DEFAULT_INBOUND_BURST_BANDWIDTH = 48; public static final int DEFAULT_INBOUND_BURST_BANDWIDTH = 64;
public static final int DEFAULT_OUTBOUND_BURST_BANDWIDTH = 32; public static final int DEFAULT_OUTBOUND_BURST_BANDWIDTH = 32;
public static final int DEFAULT_BURST_SECONDS = 60; public static final int DEFAULT_BURST_SECONDS = 60;
@ -217,10 +217,10 @@ class FIFOBandwidthRefiller implements Runnable {
// bandwidth was specified *and* changed // bandwidth was specified *and* changed
try { try {
int in = Integer.parseInt(inBwStr); int in = Integer.parseInt(inBwStr);
if ( (in <= 0) || (in > MIN_INBOUND_BANDWIDTH) ) if ( (in <= 0) || (in >= _inboundKBytesPerSecond) )
_inboundBurstKBytesPerSecond = in; _inboundBurstKBytesPerSecond = in;
else else
_inboundBurstKBytesPerSecond = MIN_INBOUND_BANDWIDTH; _inboundBurstKBytesPerSecond = _inboundKBytesPerSecond;
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Updating inbound burst rate to " + _inboundBurstKBytesPerSecond); _log.debug("Updating inbound burst rate to " + _inboundBurstKBytesPerSecond);
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
@ -247,10 +247,10 @@ class FIFOBandwidthRefiller implements Runnable {
// bandwidth was specified *and* changed // bandwidth was specified *and* changed
try { try {
int out = Integer.parseInt(outBwStr); int out = Integer.parseInt(outBwStr);
if ( (out <= 0) || (out >= MIN_OUTBOUND_BANDWIDTH) ) if ( (out <= 0) || (out >= _outboundKBytesPerSecond) )
_outboundBurstKBytesPerSecond = out; _outboundBurstKBytesPerSecond = out;
else else
_outboundBurstKBytesPerSecond = MIN_OUTBOUND_BANDWIDTH; _outboundBurstKBytesPerSecond = _outboundKBytesPerSecond;
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Updating outbound burst rate to " + _outboundBurstKBytesPerSecond); _log.debug("Updating outbound burst rate to " + _outboundBurstKBytesPerSecond);
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
@ -335,4 +335,6 @@ class FIFOBandwidthRefiller implements Runnable {
int getOutboundKBytesPerSecond() { return _outboundKBytesPerSecond; } int getOutboundKBytesPerSecond() { return _outboundKBytesPerSecond; }
int getInboundKBytesPerSecond() { return _inboundKBytesPerSecond; } 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 List _transports;
private RouterContext _context; 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_UDP = "i2np.udp.enable";
private final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable"; private final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable";
private final static String DEFAULT_ENABLE_NTCP = "true"; private final static String DEFAULT_ENABLE_NTCP = "true";
@ -66,8 +65,6 @@ public class TransportManager implements TransportEventListener {
transport.setListener(null); transport.setListener(null);
} }
static final boolean ALLOW_TCP = false;
private void configTransports() { private void configTransports() {
String enableUDP = _context.router().getConfigSetting(PROP_ENABLE_UDP); String enableUDP = _context.router().getConfigSetting(PROP_ENABLE_UDP);
if (enableUDP == null) if (enableUDP == null)
@ -77,13 +74,16 @@ public class TransportManager implements TransportEventListener {
udp.setListener(this); udp.setListener(this);
_transports.add(udp); _transports.add(udp);
} }
enableNTCP(_context); if (enableNTCP(_context)) {
NTCPTransport ntcp = new NTCPTransport(_context); NTCPTransport ntcp = new NTCPTransport(_context);
ntcp.setListener(this); ntcp.setListener(this);
_transports.add(ntcp); _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); String enableNTCP = ctx.router().getConfigSetting(PROP_ENABLE_NTCP);
if (enableNTCP == null) if (enableNTCP == null)
enableNTCP = DEFAULT_ENABLE_NTCP; enableNTCP = DEFAULT_ENABLE_NTCP;