Author: ljn1981
Date: 2006-09-28 15:50:48 +0000 (Thu, 28 Sep 2006)
New Revision: 10539
Modified:
trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
trunk/freenet/src/freenet/node/LocationManager.java
trunk/freenet/src/freenet/node/Node.java
Log:
Statistics page: Estimate average number of peers per node in the network.
Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2006-09-28 14:42:17 UTC (rev 10538)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2006-09-28 15:50:48 UTC (rev 10539)
@@ -100,6 +100,9 @@
contentNode.addChild(core.alerts.createSummary());
+ int swaps = node.getSwaps();
+ int noSwaps = node.getNoSwaps();
+
if(peerNodeStatuses.length>0){
/* node status values */
@@ -109,6 +112,8 @@
int networkSizeEstimateSession =
node.getNetworkSizeEstimate(-1);
int networkSizeEstimate24h = 0;
int networkSizeEstimate48h = 0;
+ int numberOfLocationsSeenInSwaps =
node.getNumberOfLocationsSeenInSwaps();
+
if(nodeUptimeSeconds > (24*60*60)) { // 24 hours
networkSizeEstimate24h =
node.getNetworkSizeEstimate(now - (24*60*60*1000)); // 48 hours
}
@@ -140,6 +145,12 @@
if(nodeUptimeSeconds > (48*60*60)) { // 48
hours
overviewList.addChild("li",
"networkSizeEstimate48h:\u00a0" + networkSizeEstimate48h + "\u00a0nodes");
}
+ if ((networkSizeEstimateSession > 0) && ((swaps
> 0) || (noSwaps > 0))) {
+ overviewList.addChild("li",
"avrPeersPerNodeU:\u00a0" +
(double)((double)networkSizeEstimateSession/(double)(swaps+noSwaps)));
+ }
+ if ((numberOfLocationsSeenInSwaps > 0) &&
((swaps > 0) || (noSwaps > 0))) {
+ overviewList.addChild("li",
"avrPeersPerNodeT:\u00a0" +
(double)((double)numberOfLocationsSeenInSwaps/(double)(swaps+noSwaps)));
+ }
overviewList.addChild("li", "nodeUptime:\u00a0"
+ nodeUptimeString);
overviewList.addChild("li",
"missRoutingDistance:\u00a0" + fix4.format(missRoutingDistance));
overviewList.addChild("li",
"backedoffPercent:\u00a0" + fix1.format(backedoffPercent));
@@ -258,8 +269,6 @@
if(advancedEnabled) {
overviewTableRow = overviewTable.addChild("tr");
nextTableCell = overviewTableRow.addChild("td",
"class", "first");
- int swaps = node.getSwaps();
- int noSwaps = node.getNoSwaps();
int startedSwaps = node.getStartedSwaps();
int swapsRejectedAlreadyLocked =
node.getSwapsRejectedAlreadyLocked();
int swapsRejectedNowhereToGo =
node.getSwapsRejectedNowhereToGo();
Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2006-09-28 14:42:17 UTC
(rev 10538)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2006-09-28 15:50:48 UTC
(rev 10539)
@@ -64,6 +64,8 @@
Location loc;
double locChangeSession = 0.0;
+
+ int numberOfLocationsSeenInSwaps = 0;
/**
* @return The current Location of this node.
@@ -287,6 +289,8 @@
}
registerKnownLocation(hisLoc);
+ numberOfLocationsSeenInSwaps++;
+
double[] hisFriendLocs = new double[hisBufLong.length-2];
for(int i=0;i<hisFriendLocs.length;i++) {
hisFriendLocs[i] = Double.longBitsToDouble(hisBufLong[i+2]);
@@ -298,6 +302,8 @@
registerKnownLocation(hisFriendLocs[i]);
}
+ numberOfLocationsSeenInSwaps += hisFriendLocs.length;
+
// Send our SwapComplete
Message confirm = DMT.createFNPSwapComplete(uid, myValue);
@@ -465,6 +471,8 @@
}
registerKnownLocation(hisLoc);
+ numberOfLocationsSeenInSwaps++;
+
double[] hisFriendLocs = new double[hisBufLong.length-2];
for(int i=0;i<hisFriendLocs.length;i++) {
hisFriendLocs[i] =
Double.longBitsToDouble(hisBufLong[i+2]);
@@ -476,6 +484,8 @@
registerKnownLocation(hisFriendLocs[i]);
}
+ numberOfLocationsSeenInSwaps += hisFriendLocs.length;
+
if(shouldSwap(myLoc, friendLocs, hisLoc, hisFriendLocs, random
^ hisRandom)) {
timeLastSuccessfullySwapped = System.currentTimeMillis();
// Swap
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-09-28 14:42:17 UTC (rev
10538)
+++ trunk/freenet/src/freenet/node/Node.java 2006-09-28 15:50:48 UTC (rev
10539)
@@ -2876,6 +2876,10 @@
return lm.locChangeSession;
}
+ public int getNumberOfLocationsSeenInSwaps() {
+ return lm.numberOfLocationsSeenInSwaps;
+ }
+
public boolean isAdvancedDarknetEnabled() {
return clientCore.isAdvancedDarknetEnabled();
}