diff --git a/router/java/src/net/i2p/router/transport/BandwidthLimitedOutputStream.java b/router/java/src/net/i2p/router/transport/BandwidthLimitedOutputStream.java index 1f59a62574b295fb005e7569d80b15e4f78b1e46..df37d951416303c7c57d0cfc4c434d0ab19b3831 100644 --- a/router/java/src/net/i2p/router/transport/BandwidthLimitedOutputStream.java +++ b/router/java/src/net/i2p/router/transport/BandwidthLimitedOutputStream.java @@ -35,6 +35,8 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream { _currentRequest = null; } + public FIFOBandwidthLimiter.Request getCurrentRequest() { return _currentRequest; } + public void write(int val) throws IOException { if (_log.shouldLog(Log.DEBUG)) _log.debug("Writing a single byte!", new Exception("Single byte from...")); diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java index 7a4e13cfe3b176a7720d88374abb0a920ca7d54e..86cdf71a146c16cd92c5515490c34c9323e12cfa 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java @@ -139,8 +139,7 @@ public class FIFOBandwidthLimiter { _log.warn("Still denying the " + _pendingInboundRequests.size() + " pending inbound requests (available " + _availableInboundBytes + "/" + _availableOutboundBytes - + " in/out, longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out)"); + + " in/out, longest waited " + locked_getLongestInboundWait() + " in)"); } } } @@ -169,6 +168,7 @@ public class FIFOBandwidthLimiter { long start = -1; for (int i = 0; i < _pendingOutboundRequests.size(); i++) { SimpleRequest req = (SimpleRequest)_pendingOutboundRequests.get(i); + if (req == null) continue; if ( (start < 0) || (start > req.getRequestTime()) ) start = req.getRequestTime(); } @@ -257,8 +257,7 @@ public class FIFOBandwidthLimiter { + req.getTotalInboundRequested() + " bytes, waited " + waited + "ms) pending " + _pendingInboundRequests.size() - + ", longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out"); + + ", longest waited " + locked_getLongestInboundWait() + " in"); } else { if (_log.shouldLog(Log.INFO)) _log.info("Allocating " + allocated + " bytes inbound to finish the partial grant to " @@ -266,8 +265,7 @@ public class FIFOBandwidthLimiter { + req.getTotalInboundRequested() + " bytes, waited " + waited + "ms) pending " + _pendingInboundRequests.size() - + ", longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out"); + + ", longest waited " + locked_getLongestInboundWait() + " out"); _pendingInboundRequests.remove(i); i--; if (waited > 10) @@ -291,8 +289,7 @@ public class FIFOBandwidthLimiter { _log.warn("Still denying the " + _pendingOutboundRequests.size() + " pending outbound requests (available " + _availableInboundBytes + "/" + _availableOutboundBytes + " in/out, " - + "longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out)"); + + "longest waited " + locked_getLongestOutboundWait() + " out)"); } } } @@ -326,8 +323,7 @@ public class FIFOBandwidthLimiter { + req.getTotalOutboundRequested() + " bytes (waited " + waited + "ms) pending " + _pendingOutboundRequests.size() - + ", longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out"); + + ", longest waited " + locked_getLongestOutboundWait() + " out"); if (waited > 10) _context.statManager().addRateData("bwLimiter.outboundDelayedTime", waited, waited); } @@ -386,8 +382,7 @@ public class FIFOBandwidthLimiter { + req.getTotalOutboundRequested() + " bytes, waited " + waited + "ms) pending " + _pendingOutboundRequests.size() - + ", longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out"); + + ", longest waited " + locked_getLongestOutboundWait() + " out"); } else { if (_log.shouldLog(Log.INFO)) _log.info("Allocating " + allocated + " bytes outbound to finish the partial grant to " @@ -395,8 +390,7 @@ public class FIFOBandwidthLimiter { + req.getTotalOutboundRequested() + " bytes, waited " + waited + "ms) pending " + _pendingOutboundRequests.size() - + ", longest waited " + locked_getLongestInboundWait() - + "/" + locked_getLongestOutboundWait() + " in/out)"); + + ", longest waited " + locked_getLongestOutboundWait() + " out)"); _pendingOutboundRequests.remove(i); i--; if (waited > 10) diff --git a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java index a04cea0743c60c81fe97e172069259d35c34e65f..6b7892b553fea6f8e0e2f6f8982f6b332235f122 100644 --- a/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java +++ b/router/java/src/net/i2p/router/transport/FIFOBandwidthRefiller.java @@ -24,7 +24,7 @@ class FIFOBandwidthRefiller implements Runnable { public static final String PROP_OUTBOUND_BANDWIDTH = "i2np.bandwidth.outboundKBytesPerSecond"; public static final String PROP_INBOUND_BANDWIDTH_PEAK = "i2np.bandwidth.inboundBurstKBytes"; public static final String PROP_OUTBOUND_BANDWIDTH_PEAK = "i2np.bandwidth.outboundBurstKBytes"; - public static final String PROP_REPLENISH_FREQUENCY = "i2np.bandwidth.replenishFrequencyMs"; + //public static final String PROP_REPLENISH_FREQUENCY = "i2np.bandwidth.replenishFrequencyMs"; /** For now, until there is some tuning and safe throttling, we set the floor at 6KBps inbound */ public static final int MIN_INBOUND_BANDWIDTH = 1; @@ -35,9 +35,9 @@ class FIFOBandwidthRefiller implements Runnable { /** For now, until there is some tuning and safe throttling, we set the floor at a 10 second burst */ public static final int MIN_OUTBOUND_BANDWIDTH_PEAK = 1; /** Updating the bandwidth more than once a second is silly. once every 2 or 5 seconds is less so. */ - public static final long MIN_REPLENISH_FREQUENCY = 1000; + public static final long MIN_REPLENISH_FREQUENCY = 100; - private static final long DEFAULT_REPLENISH_FREQUENCY = 1*1000; + private static final long DEFAULT_REPLENISH_FREQUENCY = 100; public FIFOBandwidthRefiller(I2PAppContext context, FIFOBandwidthLimiter limiter) { _limiter = limiter; @@ -79,9 +79,9 @@ class FIFOBandwidthRefiller implements Runnable { + _limiter.getAvailableOutboundBytes()+ ", rate in=" + _inboundKBytesPerSecond + ", out=" + _outboundKBytesPerSecond +")"); - if (numMs >= 1000) { - long inboundToAdd = 1024*_inboundKBytesPerSecond * (numMs/1000); - long outboundToAdd = 1024*_outboundKBytesPerSecond * (numMs/1000); + if (numMs >= MIN_REPLENISH_FREQUENCY) { + long inboundToAdd = (1024*_inboundKBytesPerSecond * numMs)/1000; + long outboundToAdd = (1024*_outboundKBytesPerSecond * numMs)/1000; if (inboundToAdd < 0) inboundToAdd = 0; if (outboundToAdd < 0) outboundToAdd = 0; @@ -118,8 +118,9 @@ class FIFOBandwidthRefiller implements Runnable { updateOutboundRate(); updateInboundPeak(); updateOutboundPeak(); - updateReplenishFrequency(); + _replenishFrequency = DEFAULT_REPLENISH_FREQUENCY; + if (_inboundKBytesPerSecond <= 0) { _limiter.setInboundUnlimited(true); } else { @@ -240,27 +241,4 @@ class FIFOBandwidthRefiller implements Runnable { } } - private void updateReplenishFrequency() { - String freqMs = _context.getProperty(PROP_REPLENISH_FREQUENCY); - if ( (freqMs != null) && - (freqMs.trim().length() > 0) && - (!(freqMs.equals(String.valueOf(_replenishFrequency)))) ) { - // frequency was specified *and* changed - try { - long ms = Long.parseLong(freqMs); - if (ms >= MIN_REPLENISH_FREQUENCY) - _replenishFrequency = ms; - else - _replenishFrequency = MIN_REPLENISH_FREQUENCY; - } catch (NumberFormatException nfe) { - if (_log.shouldLog(Log.WARN)) - _log.warn("Invalid replenish frequency [" + freqMs - + "]"); - } - } else { - if (_log.shouldLog(Log.DEBUG)) - _log.debug("Replenish frequency not specified in the config via " + PROP_REPLENISH_FREQUENCY); - _replenishFrequency = DEFAULT_REPLENISH_FREQUENCY; - } - } } \ No newline at end of file diff --git a/router/java/src/net/i2p/router/transport/TransportImpl.java b/router/java/src/net/i2p/router/transport/TransportImpl.java index c493bfab31d199f840433a8d9d6ef4ace0ff64e1..a6f1925600693b340bcffd24653ef342ec0afc2b 100644 --- a/router/java/src/net/i2p/router/transport/TransportImpl.java +++ b/router/java/src/net/i2p/router/transport/TransportImpl.java @@ -76,12 +76,12 @@ public abstract class TransportImpl implements Transport { if (lifetime > 5000) { if (_log.shouldLog(Log.WARN)) _log.warn("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte " - + msg.getMessageType() + " from " + _context.routerHash().toBase64().substring(0,6) + + msg.getMessageType() + " " + msg.getMessageId() + " from " + _context.routerHash().toBase64().substring(0,6) + " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString()); } else { if (_log.shouldLog(Log.INFO)) _log.info("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte " - + msg.getMessageType() + " from " + _context.routerHash().toBase64().substring(0,6) + + msg.getMessageType() + " " + msg.getMessageId() + " from " + _context.routerHash().toBase64().substring(0,6) + " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString()); }