2004-12-16 jrandom

* Remove the randomized factor in the tunnel rejection by bandwidth -
      we now accept the request if we've allocated less than our limit
      and reject it if we've allocated more.
    * Stick to the standard capacity scale on tunnel rejection, even for
      the 10m period.
    * Build the time message at the very last possible moment
This commit is contained in:
jrandom
2004-12-16 05:42:03 +00:00
committed by zzz
parent 66aa29e3d4
commit cbc89376d3
6 changed files with 29 additions and 19 deletions

View File

@ -1,4 +1,12 @@
$Id: history.txt,v 1.107 2004/12/14 11:42:35 jrandom Exp $ $Id: history.txt,v 1.108 2004/12/15 21:45:56 jrandom Exp $
2004-12-16 jrandom
* Remove the randomized factor in the tunnel rejection by bandwidth -
we now accept the request if we've allocated less than our limit
and reject it if we've allocated more.
* Stick to the standard capacity scale on tunnel rejection, even for
the 10m period.
* Build the time message at the very last possible moment
2004-12-15 jrandom 2004-12-15 jrandom
* Handle hard disconnects more gracefully within the streaming lib, and * Handle hard disconnects more gracefully within the streaming lib, and

View File

@ -241,7 +241,7 @@ class RouterThrottleImpl implements RouterThrottle {
double allocatedKBps = toAllocate / (10 * 60 * 1024); double allocatedKBps = toAllocate / (10 * 60 * 1024);
if (_context.random().nextInt(100) > 100 * pctFull) { if (pctFull < 1.0) { // (_context.random().nextInt(100) > 100 * pctFull) {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Probabalistically allowing the tunnel w/ " + pctFull + " of our " + bytesAllowed _log.debug("Probabalistically allowing the tunnel w/ " + pctFull + " of our " + bytesAllowed
+ "bytes/" + allocatedKBps + "KBps allocated through " + numTunnels + " tunnels"); + "bytes/" + allocatedKBps + "KBps allocated through " + numTunnels + " tunnels");

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
* *
*/ */
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.112 $ $Date: 2004/12/14 11:42:35 $"; public final static String ID = "$Revision: 1.113 $ $Date: 2004/12/15 21:45:55 $";
public final static String VERSION = "0.4.2.3"; public final static String VERSION = "0.4.2.3";
public final static long BUILD = 6; public final static long BUILD = 7;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION); System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -101,10 +101,10 @@ public class CapacityCalculator extends Calculator {
val -= failed * stretch; val -= failed * stretch;
} }
if ( (period <= 10*60*1000) && (curRejected.getCurrentEventCount() + curRejected.getLastEventCount() > 0) ) { //if ( (period <= 10*60*1000) && (curRejected.getCurrentEventCount() + curRejected.getLastEventCount() > 0) ) {
//System.out.println("10m period has rejected " + (curRejected.getCurrentEventCount() + curRejected.getLastEventCount()) + " times"); // //System.out.println("10m period has rejected " + (curRejected.getCurrentEventCount() + curRejected.getLastEventCount()) + " times");
return 0.0d; // return 0.0d;
} else //} else
val -= stretch * (curRejected.getCurrentEventCount() + curRejected.getLastEventCount()); val -= stretch * (curRejected.getCurrentEventCount() + curRejected.getLastEventCount());
val += GROWTH_FACTOR; val += GROWTH_FACTOR;

View File

@ -92,11 +92,9 @@ class ConnectionRunner implements Runnable {
msg.timestamp("ConnectionRunner.sendMessage data"); msg.timestamp("ConnectionRunner.sendMessage data");
I2NPMessage timeMessage = null; boolean sendTime = false;
if (_lastTimeSend < _context.clock().now() - TIME_SEND_FREQUENCY) { if (_lastTimeSend < _context.clock().now() - TIME_SEND_FREQUENCY)
timeMessage = buildTimeMessage(); sendTime = true;
_lastTimeSend = _context.clock().now();
}
OutputStream out = _con.getOutputStream(); OutputStream out = _con.getOutputStream();
boolean ok = false; boolean ok = false;
@ -106,8 +104,10 @@ class ConnectionRunner implements Runnable {
synchronized (out) { synchronized (out) {
before = _context.clock().now(); before = _context.clock().now();
out.write(buf, 0, written); out.write(buf, 0, written);
if (timeMessage != null) if (sendTime) {
out.write(timeMessage.toByteArray()); out.write(buildTimeMessage().toByteArray());
_lastTimeSend = _context.clock().now();
}
out.flush(); out.flush();
after = _context.clock().now(); after = _context.clock().now();
} }

View File

@ -54,10 +54,12 @@ public class MessageHandler implements I2NPMessageReader.I2NPMessageEventListene
long delta = _con.getRouterContext().clock().now() - remoteTime; long delta = _con.getRouterContext().clock().now() - remoteTime;
if ( (delta > Router.CLOCK_FUDGE_FACTOR) || (delta < 0 - Router.CLOCK_FUDGE_FACTOR) ) { if ( (delta > Router.CLOCK_FUDGE_FACTOR) || (delta < 0 - Router.CLOCK_FUDGE_FACTOR) ) {
_con.closeConnection(); _con.closeConnection();
_transport.addConnectionErrorMessage("Peer " + _identHash.toBase64().substring(0,6) String msg = "Peer " + _identHash.toBase64().substring(0,6) + " is too far skewed ("
+ " is too far skewed (" + DataHelper.formatDuration(delta) + ") after uptime of "
+ DataHelper.formatDuration(delta) + ") after uptime of " + DataHelper.formatDuration(_con.getLifetime());
+ DataHelper.formatDuration(_con.getLifetime())); if (_log.shouldLog(Log.WARN))
_log.warn(msg);
_transport.addConnectionErrorMessage(msg);
_transport.getContext().statManager().addRateData("tcp.disconnectAfterSkew", delta, _con.getLifetime()); _transport.getContext().statManager().addRateData("tcp.disconnectAfterSkew", delta, _con.getLifetime());
} else { } else {
int level = Log.DEBUG; int level = Log.DEBUG;