* PRNG: Add two stats

* Summary bar:
      - Display Warning for TCP private IP address
      - Display PRNG stats
This commit is contained in:
zzz
2008-06-20 20:22:38 +00:00
parent 53c5b1446a
commit 49e429c166
7 changed files with 52 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import java.util.Set;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.Destination; import net.i2p.data.Destination;
import net.i2p.data.LeaseSet; import net.i2p.data.LeaseSet;
import net.i2p.data.RouterAddress;
import net.i2p.stat.Rate; import net.i2p.stat.Rate;
import net.i2p.stat.RateStat; import net.i2p.stat.RateStat;
import net.i2p.router.CommSystemFacade; import net.i2p.router.CommSystemFacade;
@@ -17,6 +18,7 @@ import net.i2p.router.Router;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
import net.i2p.router.RouterVersion; import net.i2p.router.RouterVersion;
import net.i2p.router.TunnelPoolSettings; import net.i2p.router.TunnelPoolSettings;
import net.i2p.router.transport.ntcp.NTCPAddress;
/** /**
* Simple helper to query the appropriate router for data necessary to render * Simple helper to query the appropriate router for data necessary to render
@@ -120,7 +122,10 @@ public class SummaryHelper {
int status = _context.commSystem().getReachabilityStatus(); int status = _context.commSystem().getReachabilityStatus();
switch (status) { switch (status) {
case CommSystemFacade.STATUS_OK: case CommSystemFacade.STATUS_OK:
return "OK"; RouterAddress ra = _context.router().getRouterInfo().getTargetAddress("NTCP");
if (ra == null || (new NTCPAddress(ra)).isPubliclyRoutable())
return "OK";
return "ERR-Private TCP Address";
case CommSystemFacade.STATUS_DIFFERENT: case CommSystemFacade.STATUS_DIFFERENT:
return "ERR-SymmetricNAT"; return "ERR-SymmetricNAT";
case CommSystemFacade.STATUS_REJECT_UNSOLICITED: case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
@@ -514,6 +519,28 @@ public class SummaryHelper {
return String.valueOf(_context.tunnelManager().getInboundBuildQueueSize()); return String.valueOf(_context.tunnelManager().getInboundBuildQueueSize());
} }
public String getPRNGStatus() {
Rate r = _context.statManager().getRate("prng.bufferWaitTime").getRate(60*1000);
int use = (int) r.getLastEventCount();
int i = (int) (r.getAverageValue() + 0.5);
if (i <= 0) {
r = _context.statManager().getRate("prng.bufferWaitTime").getRate(10*60*1000);
i = (int) (r.getAverageValue() + 0.5);
}
String rv = i + "/";
r = _context.statManager().getRate("prng.bufferFillTime").getRate(60*1000);
i = (int) (r.getAverageValue() + 0.5);
if (i <= 0) {
r = _context.statManager().getRate("prng.bufferFillTime").getRate(10*60*1000);
i = (int) (r.getAverageValue() + 0.5);
}
rv = rv + i + "ms";
// margin == fill time / use time
if (use > 0 && i > 0)
rv = rv + ' ' + (60*1000 / (use * i)) + 'x';
return rv;
}
public boolean updateAvailable() { public boolean updateAvailable() {
return NewsFetcher.getInstance(_context).updateAvailable(); return NewsFetcher.getInstance(_context).updateAvailable();
} }

View File

@@ -95,6 +95,7 @@
<b>Message delay:</b> <jsp:getProperty name="helper" property="messageDelay" /><br /> <b>Message delay:</b> <jsp:getProperty name="helper" property="messageDelay" /><br />
<b>Tunnel lag:</b> <jsp:getProperty name="helper" property="tunnelLag" /><br /> <b>Tunnel lag:</b> <jsp:getProperty name="helper" property="tunnelLag" /><br />
<b>Handle backlog:</b> <jsp:getProperty name="helper" property="inboundBacklog" /><br /> <b>Handle backlog:</b> <jsp:getProperty name="helper" property="inboundBacklog" /><br />
<b>PRNG wait/fill:</b> <jsp:getProperty name="helper" property="PRNGStatus" /><br />
<b><jsp:getProperty name="helper" property="tunnelStatus" /></b><br /> <b><jsp:getProperty name="helper" property="tunnelStatus" /></b><br />
<hr /> <hr />

View File

@@ -2,6 +2,8 @@ package gnu.crypto.prng;
import java.util.*; import java.util.*;
import net.i2p.I2PAppContext;
/** /**
* fortuna instance that tries to avoid blocking if at all possible by using separate * fortuna instance that tries to avoid blocking if at all possible by using separate
* filled buffer segments rather than one buffer (and blocking when that buffer's data * filled buffer segments rather than one buffer (and blocking when that buffer's data
@@ -13,16 +15,20 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
private final byte asyncBuffers[][] = new byte[BUFFERS][BUFSIZE]; private final byte asyncBuffers[][] = new byte[BUFFERS][BUFSIZE];
private final int status[] = new int[BUFFERS]; private final int status[] = new int[BUFFERS];
private int nextBuf = 0; private int nextBuf = 0;
private I2PAppContext _context;
private static final int STATUS_NEED_FILL = 0; private static final int STATUS_NEED_FILL = 0;
private static final int STATUS_FILLING = 1; private static final int STATUS_FILLING = 1;
private static final int STATUS_FILLED = 2; private static final int STATUS_FILLED = 2;
private static final int STATUS_LIVE = 3; private static final int STATUS_LIVE = 3;
public AsyncFortunaStandalone() { public AsyncFortunaStandalone(I2PAppContext context) {
super(); super();
for (int i = 0; i < BUFFERS; i++) for (int i = 0; i < BUFFERS; i++)
status[i] = STATUS_NEED_FILL; status[i] = STATUS_NEED_FILL;
_context = context;
context.statManager().createRateStat("prng.bufferWaitTime", "", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } );
context.statManager().createRateStat("prng.bufferFillTime", "", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } );
} }
public void startup() { public void startup() {
@@ -61,6 +67,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
} catch (InterruptedException ie) {} } catch (InterruptedException ie) {}
waited = System.currentTimeMillis()-before; waited = System.currentTimeMillis()-before;
} }
_context.statManager().addRateData("prng.bufferWaitTime", waited, 0);
if (waited > 10*1000) if (waited > 10*1000)
System.out.println(Thread.currentThread().getName() + ": Took " + waited System.out.println(Thread.currentThread().getName() + ": Took " + waited
+ "ms for a full PRNG buffer to be found"); + "ms for a full PRNG buffer to be found");
@@ -108,6 +115,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
//System.out.println(Thread.currentThread().getName() + ": Prng buffer " + toFill + " filled after " + (after-before)); //System.out.println(Thread.currentThread().getName() + ": Prng buffer " + toFill + " filled after " + (after-before));
asyncBuffers.notifyAll(); asyncBuffers.notifyAll();
} }
_context.statManager().addRateData("prng.bufferFillTime", after - before, 0);
Thread.yield(); Thread.yield();
long waitTime = (after-before)*5; long waitTime = (after-before)*5;
if (waitTime <= 0) // somehow postman saw waitTime show up as negative if (waitTime <= 0) // somehow postman saw waitTime show up as negative
@@ -147,7 +155,7 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
public static void main(String args[]) { public static void main(String args[]) {
try { try {
AsyncFortunaStandalone rand = new AsyncFortunaStandalone(); AsyncFortunaStandalone rand = new AsyncFortunaStandalone(null); // Will cause NPEs above; fix this if you want to test! Sorry...
byte seed[] = new byte[1024]; byte seed[] = new byte[1024];
rand.seed(seed); rand.seed(seed);

View File

@@ -37,13 +37,15 @@ public class StatManager {
public static final String PROP_STAT_REQUIRED = "stat.required"; public static final String PROP_STAT_REQUIRED = "stat.required";
/** /**
* These are all the stats published in netDb, plus those required for the operation of * These are all the stats published in netDb, plus those required for the operation of
* the router (many in RouterThrottleImpl), plus those that are on graphs.jsp by default. * the router (many in RouterThrottleImpl), plus those that are on graphs.jsp by default,
* plus those used on the summary bar (SummaryHelper.java).
* Wildcard ('*') allowed at end of stat only. * Wildcard ('*') allowed at end of stat only.
* Ignore all the rest of the stats unless stat.full=true. * Ignore all the rest of the stats unless stat.full=true.
*/ */
public static final String DEFAULT_STAT_REQUIRED = public static final String DEFAULT_STAT_REQUIRED =
"bw.recvRate,bw.sendBps,bw.sendRate,client.sendAckTime,clock.skew,crypto.elGamal.encrypt," + "bw.recvRate,bw.sendBps,bw.sendRate,client.sendAckTime,clock.skew,crypto.elGamal.encrypt," +
"jobQueue.jobLag,netDb.successTime,router.fastPeers," + "jobQueue.jobLag,netDb.successTime,router.fastPeers," +
"prng.bufferFillTime,prng.bufferWaitTime," +
"transport.receiveMessageSize,transport.sendMessageSize,transport.sendProcessingTime," + "transport.receiveMessageSize,transport.sendMessageSize,transport.sendProcessingTime," +
"tunnel.acceptLoad,tunnel.buildRequestTime,tunnel.rejectOverloaded,tunnel.rejectTimeout" + "tunnel.acceptLoad,tunnel.buildRequestTime,tunnel.rejectOverloaded,tunnel.rejectTimeout" +
"tunnel.buildClientExpire,tunnel.buildClientReject,tunnel.buildClientSuccess," + "tunnel.buildClientExpire,tunnel.buildClientReject,tunnel.buildClientSuccess," +

View File

@@ -32,7 +32,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
public FortunaRandomSource(I2PAppContext context) { public FortunaRandomSource(I2PAppContext context) {
super(context); super(context);
_fortuna = new AsyncFortunaStandalone(); _fortuna = new AsyncFortunaStandalone(context);
byte seed[] = new byte[1024]; byte seed[] = new byte[1024];
if (initSeed(seed)) { if (initSeed(seed)) {
_fortuna.seed(seed); _fortuna.seed(seed);

View File

@@ -1,3 +1,11 @@
2008-06-23 zzz
* configclients.jsp: Add start button for clients and webapps.
* PRNG: Add two stats
* Summary bar:
- Display Warning for TCP private IP address
- Display PRNG stats
* OutNetMessage: Change cache logging from WARN to INFO
2008-06-17 zzz 2008-06-17 zzz
* Comm System: Add new STATUS_HOSED for use when UDP bind fails * Comm System: Add new STATUS_HOSED for use when UDP bind fails
* Summary bar: Display helpful errror message when UDP bind fails * Summary bar: Display helpful errror message when UDP bind fails

View File

@@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $"; public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
public final static String VERSION = "0.6.2"; public final static String VERSION = "0.6.2";
public final static long BUILD = 4; public final static long BUILD = 5;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);