From 53f62bd8dd4068abaed5fad1ec59ff69416d1bcb Mon Sep 17 00:00:00 2001 From: mathiasdm Date: Tue, 26 May 2009 17:24:31 +0000 Subject: [PATCH] * Throttling extension by looking at sendProcessingTime --- history.txt | 3 ++ .../net/i2p/router/RouterThrottleImpl.java | 33 +++++++++++++++++++ .../src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 43b625ae5..26eab2bde 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,6 @@ +2009-05-26 Mathiasdm + * Throttling extension by looking at sendProcessingTime + 2009-05-26 zzz * Console: - configlogging.jsp cleanup diff --git a/router/java/src/net/i2p/router/RouterThrottleImpl.java b/router/java/src/net/i2p/router/RouterThrottleImpl.java index acab90a64..8b459ff57 100644 --- a/router/java/src/net/i2p/router/RouterThrottleImpl.java +++ b/router/java/src/net/i2p/router/RouterThrottleImpl.java @@ -110,6 +110,39 @@ class RouterThrottleImpl implements RouterThrottle { setTunnelStatus("Rejecting tunnels: High message delay"); return TunnelHistory.TUNNEL_REJECT_TRANSIENT_OVERLOAD; } + + //Reject tunnels if the time to process messages and send them is too large. Too much time implies congestion. + if(r != null) { + double totalEvents = r.getCurrentEventCount() + r.getLastEventCount(); + double avg = 0; + double current = 0; + double last = 0; + //Calculate times + if(r.getCurrentEventCount() > 0) { + current = r.getCurrentTotalValue()/r.getCurrentEventCount(); + } + if(r.getLastEventCount() > 0) { + last = r.getLastTotalValue()/r.getLastEventCount(); + } + if(totalEvents > 0) { + avg = (r.getCurrentTotalValue() + r.getLastTotalValue())/totalEvents; + } + else { + avg = r.getAverageValue(); + if(_log.shouldLog(Log.WARN)) { + _log.warn("No events occurred. Using 1 minute average to look at message delay."); + } + } + //Set throttling if necessary + if(avg > 400 || current > 500 || last > 500) { + if(_log.shouldLog(Log.WARN)) { + _log.warn("Refusing tunnel request due to sendProcessingTime of " + avg + + " ms over the last two minutes, which is too much."); + } + setTunnelStatus("Rejecting tunnels: High message delay implying possible congestion"); + return TunnelHistory.TUNNEL_REJECT_TRANSIENT_OVERLOAD; + } + } int numTunnels = _context.tunnelManager().getParticipatingCount(); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index aea509c4d..0116da736 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 7; + public final static long BUILD = 8; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;