Author: toad
Date: 2008-04-22 14:42:40 +0000 (Tue, 22 Apr 2008)
New Revision: 19498
Modified:
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/NodeStats.java
Log:
Make previous commit optional: node.ignoreLocalVsRemoteBandwidthLiability.
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-04-22
14:31:10 UTC (rev 19497)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-04-22
14:42:40 UTC (rev 19498)
@@ -717,6 +717,8 @@
NodeIPDetector.unknownHostErrorInIPOverride=Unknown host: ${error}
NodeStat.aggressiveGC=AggressiveGC modificator
NodeStat.aggressiveGCLong=Enables the user to tweak the time in between GC and
forced finalization. SHOULD NOT BE CHANGED unless you know what you're doing!
-1 means: disable forced call to System.gc() and System.runFinalization()
+NodeStat.ignoreLocalVsRemoteBandwidthLiability=Treat local requests as remote
requests for bandwidth liability limiting?
+NodeStat.ignoreLocalVsRemoteBandwidthLiabilityLong=Enable this for
significantly lower bandwidth usage and slightly more security against request
starting timing attacks (mostly you don't need to worry about them as
correlation attacks are probably easier)
NodeStat.freeHeapBytesThreshold=Free heap bytes threshold
NodeStat.freeHeapBytesThresholdLong=The node will try to keep it's free heap
bytes above the threshold by refusing new requests
NodeStat.freeHeapPercentThreshold=Free heap percent threshold
Modified: trunk/freenet/src/freenet/node/NodeStats.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStats.java 2008-04-22 14:31:10 UTC
(rev 19497)
+++ trunk/freenet/src/freenet/node/NodeStats.java 2008-04-22 14:42:40 UTC
(rev 19498)
@@ -72,6 +72,7 @@
public boolean nodeAveragePingAlertRelevant;
/** Average proportion of requests rejected immediately due to overload
*/
public final TimeDecayingRunningAverage pInstantRejectIncoming;
+ private boolean ignoreLocalVsRemoteBandwidthLiability;
/** Average delay caused by throttling for sending a packet */
final TimeDecayingRunningAverage throttledPacketSendAverage;
@@ -247,7 +248,23 @@
});
if(statsConfig.getBoolean("memoryChecker"))
myMemoryChecker.start();
+
+ statsConfig.register("ignoreLocalVsRemoteBandwidthLiability",
false, sortOrder++, true, false,
"NodeStat.ignoreLocalVsRemoteBandwidthLiability",
"NodeStat.ignoreLocalVsRemoteBandwidthLiabilityLong", new BooleanCallback() {
+ public boolean get() {
+ synchronized(NodeStats.this) {
+ return
ignoreLocalVsRemoteBandwidthLiability;
+ }
+ }
+
+ public void set(boolean val) throws
InvalidConfigValueException {
+ synchronized(NodeStats.this) {
+ ignoreLocalVsRemoteBandwidthLiability =
val;
+ }
+ }
+
+ });
+
persister = new ConfigurablePersister(this, statsConfig,
"nodeThrottleFile", "node-throttle.dat", sortOrder++, true, false,
"NodeStat.statsPersister",
"NodeStat.statsPersisterLong", node.ps, nodeDir);
@@ -482,7 +499,15 @@
if(logMINOR)
Logger.minor(this, "Running (adjusted): CHK fetch local
"+numLocalCHKRequests+" remote "+numRemoteCHKRequests+" SSK fetch local
"+numLocalSSKRequests+" remote "+numRemoteSSKRequests+" CHK insert local
"+numLocalCHKInserts+" remote "+numRemoteCHKInserts+" SSK insert local
"+numLocalSSKInserts+" remote "+numRemoteSSKInserts+" CHK offer replies local
"+numCHKOfferReplies+" SSK offer replies "+numSSKOfferReplies);
- double bandwidthLiabilityOutput =
+ double bandwidthLiabilityOutput;
+ if(ignoreLocalVsRemoteBandwidthLiability) {
+ bandwidthLiabilityOutput =
+
successfulChkFetchBytesSentAverage.currentValue() * (numRemoteCHKRequests +
numLocalCHKRequests - 1) +
+
successfulSskFetchBytesSentAverage.currentValue() * (numRemoteSSKRequests +
numLocalSSKRequests - 1) +
+
successfulChkInsertBytesSentAverage.currentValue() * (numRemoteCHKInserts +
numLocalCHKInserts - 1) +
+
successfulSskInsertBytesSentAverage.currentValue() * (numRemoteSSKInserts +
numLocalSSKInserts - 1);
+ } else {
+ bandwidthLiabilityOutput =
successfulChkFetchBytesSentAverage.currentValue() *
numRemoteCHKRequests +
// Local requests don't relay data, so use the local
average
localChkFetchBytesSentAverage.currentValue() *
numLocalCHKRequests +
@@ -497,6 +522,7 @@
successfulSskInsertBytesSentAverage.currentValue() *
numLocalSSKInserts +
successfulChkOfferReplyBytesSentAverage.currentValue()
* numCHKOfferReplies +
successfulSskOfferReplyBytesSentAverage.currentValue()
* numSSKOfferReplies;
+ }
double outputAvailablePerSecond =
node.getOutputBandwidthLimit() - sentOverheadPerSecond;
// If there's been an auto-update, we may have used a vast
amount of bandwidth for it.
// Also, if things have broken, our overhead might be above our
bandwidth limit,
@@ -518,7 +544,15 @@
return "Output bandwidth liability
("+bandwidthLiabilityOutput+" > "+bandwidthAvailableOutput+")";
}
- double bandwidthLiabilityInput =
+ double bandwidthLiabilityInput;
+ if(ignoreLocalVsRemoteBandwidthLiability) {
+ bandwidthLiabilityInput =
+
successfulChkFetchBytesReceivedAverage.currentValue() * (numRemoteCHKRequests +
numLocalCHKRequests - 1) +
+
successfulSskFetchBytesReceivedAverage.currentValue() * (numRemoteSSKRequests +
numLocalSSKRequests - 1) +
+
successfulChkInsertBytesReceivedAverage.currentValue() * (numRemoteCHKInserts +
numLocalCHKInserts - 1) +
+
successfulSskInsertBytesReceivedAverage.currentValue() * (numRemoteSSKInserts +
numLocalSSKInserts - 1);
+ } else {
+ bandwidthLiabilityInput =
// For receiving data, local requests are the same as
remote ones
successfulChkFetchBytesReceivedAverage.currentValue() *
numRemoteCHKRequests +
successfulChkFetchBytesReceivedAverage.currentValue() *
numLocalCHKRequests +
@@ -531,6 +565,7 @@
localSskInsertBytesReceivedAverage.currentValue() *
numLocalSSKInserts +
successfulChkOfferReplyBytesReceivedAverage.currentValue() * numCHKOfferReplies
+
successfulSskOfferReplyBytesReceivedAverage.currentValue() * numSSKOfferReplies;
+ }
double bandwidthAvailableInput =
node.getInputBandwidthLimit() * 90; // 90 seconds at
full power
if(bandwidthLiabilityInput > bandwidthAvailableInput) {