Author: toad
Date: 2008-03-13 22:29:00 +0000 (Thu, 13 Mar 2008)
New Revision: 18520
Modified:
trunk/freenet/src/freenet/io/xfer/PacketThrottle.java
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeStarter.java
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/simulator/RealNodeBusyNetworkTest.java
trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java
trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
Log:
isLocal() -> !shouldThrottle().
New config option throttleLocalTraffic.
Enable it in the simulator, if and only if we want limiting in this simulation.
Modified: trunk/freenet/src/freenet/io/xfer/PacketThrottle.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/PacketThrottle.java 2008-03-13
22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/io/xfer/PacketThrottle.java 2008-03-13
22:29:00 UTC (rev 18520)
@@ -191,7 +191,7 @@
Logger.minor(this, "Congestion control wait time:
"+waitTime+" for "+this);
MyCallback callback = new MyCallback();
try {
- if(!((PeerNode)peer).isLocalAddress()) {
+ if(!((PeerNode)peer).shouldThrottle()) {
if(logMINOR) Logger.minor(this, "Throttling
"+peer.shortToString()+" : "+packetSize+" for "+this);
long startTime = System.currentTimeMillis();
overallThrottle.blockingGrab(packetSize);
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-03-13
22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-03-13
22:29:00 UTC (rev 18520)
@@ -646,6 +646,8 @@
Node.storeTypeLong=Datastore type. Currently this can be bdb-index (use a
BerkeleyDBFreenetStore to store the index, and keep the data in files on disk),
or ram (keep the index and the data in RAM). Only use ram if you know what you
are doing and have enough RAM to store all your data (and note it will not be
saved on shutdown)!
Node.swapRInterval=Swap request send interval (ms)
Node.swapRIntervalLong=Interval between swap attempting to send swap requests
in milliseconds. Leave this alone!
+Node.throttleLocalTraffic=Throttle local traffic?
+Node.throttleLocalTrafficLong=Throttle local traffic? If enabled, even LAN and
localhost traffic will be subject to bandwidth limiting.
Node.tooSmallMTU=Too small MTU
Node.tooSmallMTULong=Your connection's MTU appears to be ${mtu} bytes. Freenet
will not function well with an MTU of less than ${minMTU} bytes: connections
will be unreliable and possibly slow. Please fix the problem if possible.
NodeClientCore.couldNotFindOrCreateDir=Could not find or create directory
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2008-03-13 22:20:30 UTC (rev
18519)
+++ trunk/freenet/src/freenet/node/Node.java 2008-03-13 22:29:00 UTC (rev
18520)
@@ -396,6 +396,7 @@
final boolean testnetEnabled;
final TestnetHandler testnetHandler;
public final DoubleTokenBucket outputThrottle;
+ public boolean throttleLocalData;
private int outputBandwidthLimit;
private int inputBandwidthLimit;
boolean inputLimitDefault;
@@ -913,6 +914,20 @@
ibwLimit = obwLimit * 4;
}
+ nodeConfig.register("throttleLocalTraffic", false, sortOrder++,
true, false, "Node.throttleLocalTraffic", "Node.throttleLocalTrafficLong", new
BooleanCallback() {
+
+ public boolean get() {
+ return throttleLocalData;
+ }
+
+ public void set(boolean val) throws
InvalidConfigValueException {
+ throttleLocalData = val;
+ }
+
+ });
+
+ throttleLocalData =
nodeConfig.getBoolean("throttleLocalTraffic");
+
// Testnet.
// Cannot be enabled/disabled on the fly.
// If enabled, forces certain other config options.
Modified: trunk/freenet/src/freenet/node/NodeStarter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeStarter.java 2008-03-13 22:20:30 UTC
(rev 18519)
+++ trunk/freenet/src/freenet/node/NodeStarter.java 2008-03-13 22:29:00 UTC
(rev 18520)
@@ -343,7 +343,8 @@
int dropProb, RandomSource random, Executor executor,
int threadLimit,
long storeSize, boolean ramStore, boolean
enableSwapping, boolean enableARKs,
boolean enableULPRs, boolean
enablePerNodeFailureTables,
- boolean enableSwapQueueing, boolean
enablePacketCoalescing) throws NodeInitException {
+ boolean enableSwapQueueing, boolean
enablePacketCoalescing,
+ int outputBandwidthLimit) throws NodeInitException {
File baseDir = new File(testName);
File portDir = new File(baseDir, Integer.toString(port));
@@ -354,6 +355,10 @@
// Set up config for testing
SimpleFieldSet configFS = new SimpleFieldSet(false); // only
happens once in entire simulation
+ if(outputBandwidthLimit > 0) {
+ configFS.put("node.outputBandwidthLimit",
outputBandwidthLimit);
+ configFS.put("node.throttleLocalTraffic", true);
+ }
configFS.put("node.listenPort", port);
configFS.put("node.disableProbabilisticHTLs",
disableProbabilisticHTLs);
configFS.put("fproxy.enabled", false);
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2008-03-13 22:20:30 UTC
(rev 18519)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2008-03-13 22:29:00 UTC
(rev 18520)
@@ -3701,10 +3701,11 @@
sendAsync(DMT.createFNPNetworkID(assignedNetworkID),
null, 0, ctr);
}
- public boolean isLocalAddress() {
+ public boolean shouldThrottle() {
Peer peer = getPeer();
- if(peer == null) return false; // presumably
- return !IPUtil.isValidAddress(peer.getAddress(), false);
+ if(node.throttleLocalData) return true;
+ if(peer == null) return true; // presumably
+ return IPUtil.isValidAddress(peer.getAddress(), false);
}
public void reportPing(long t) {
Modified: trunk/freenet/src/freenet/node/simulator/RealNodeBusyNetworkTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeBusyNetworkTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeBusyNetworkTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -74,7 +74,7 @@
Executor executor = new PooledExecutor();
for(int i=0;i<NUMBER_OF_NODES;i++) {
nodes[i] =
- NodeStarter.createTestNode(5001+i, name, false, true, false,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES,
(CHKBlock.DATA_LENGTH+CHKBlock.TOTAL_HEADERS_LENGTH)*100, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING);
+ NodeStarter.createTestNode(5001+i, name, false, true, false,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES,
(CHKBlock.DATA_LENGTH+CHKBlock.TOTAL_HEADERS_LENGTH)*100, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING, 8000);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}
Modified:
trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeNetworkColoringTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -78,21 +78,21 @@
for(int i=0;i<NUMBER_OF_NODES;i++) {
allNodes[totalNodes] =
subnetA[i] =
- NodeStarter.createTestNode(5001+totalNodes, wd, false, true,
true, MAX_HTL, 0 /* no dropped packets */, random, executor,
500*NUMBER_OF_NODES, storeSize, true, true, false, false, false, false, true);
+ NodeStarter.createTestNode(5001+totalNodes, wd, false, true,
true, MAX_HTL, 0 /* no dropped packets */, random, executor,
500*NUMBER_OF_NODES, storeSize, true, true, false, false, false, false, true,
0);
totalNodes++;
Logger.normal(RealNodeRoutingTest.class, "Created 'A' node
"+totalNodes);
}
for(int i=0;i<NUMBER_OF_NODES;i++) {
allNodes[totalNodes] =
subnetB[i] =
- NodeStarter.createTestNode(5001+totalNodes, wd, false,
true, true, MAX_HTL, 0 /* no dropped packets */, random, executor,
500*NUMBER_OF_NODES, storeSize, true, true, false, false, false, false, true);
+ NodeStarter.createTestNode(5001+totalNodes, wd, false,
true, true, MAX_HTL, 0 /* no dropped packets */, random, executor,
500*NUMBER_OF_NODES, storeSize, true, true, false, false, false, false, true,
0);
totalNodes++;
Logger.normal(RealNodeRoutingTest.class, "Created 'B' node
"+totalNodes);
}
for(int i=0;i<BRIDGES;i++) {
allNodes[totalNodes] =
bridges[i] =
- NodeStarter.createTestNode(5001+totalNodes, wd, false,
true, true, MAX_HTL, 0 /* no dropped packets */, random, executor,
500*NUMBER_OF_NODES, storeSize, true, true, false, false, false, false, true);
+ NodeStarter.createTestNode(5001+totalNodes, wd, false,
true, true, MAX_HTL, 0 /* no dropped packets */, random, executor,
500*NUMBER_OF_NODES, storeSize, true, true, false, false, false, false, true,
0);
totalNodes++;
Logger.normal(RealNodeRoutingTest.class, "Created bridge node
"+totalNodes);
}
Modified: trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodePingTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -33,8 +33,8 @@
RandomSource random = NodeStarter.globalTestInit("pingtest", false,
Logger.ERROR, "");
// Create 2 nodes
Executor executor = new PooledExecutor();
- Node node1 = NodeStarter.createTestNode(5001, "pingtest", false,
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true,
false, false, false, false, false, true);
- Node node2 = NodeStarter.createTestNode(5002, "pingtest", false,
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true,
false, false, false, false, false, true);
+ Node node1 = NodeStarter.createTestNode(5001, "pingtest", false,
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true,
false, false, false, false, false, true, 0);
+ Node node2 = NodeStarter.createTestNode(5002, "pingtest", false,
false, true, Node.DEFAULT_MAX_HTL, 0, random, executor, 1000, 65536, true,
false, false, false, false, false, true, 0);
// Connect
node1.connect(node2);
node2.connect(node1);
Modified:
trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRequestInsertTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -71,7 +71,7 @@
Executor executor = new PooledExecutor();
for(int i=0;i<NUMBER_OF_NODES;i++) {
nodes[i] =
- NodeStarter.createTestNode(5001+i, name, false, true, false,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING);
+ NodeStarter.createTestNode(5001+i, name, false, true, false,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 256*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES,
ENABLE_SWAP_QUEUEING, ENABLE_PACKET_COALESCING, 12000);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}
Modified: trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeRoutingTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -56,7 +56,7 @@
for(int i=0;i<NUMBER_OF_NODES;i++) {
System.err.println("Creating node "+i);
nodes[i] =
- NodeStarter.createTestNode(5001+i, dir, false, true, true,
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES,
65536, true, ENABLE_SWAPPING, false, false, false, ENABLE_SWAP_QUEUEING, true);
+ NodeStarter.createTestNode(5001+i, dir, false, true, true,
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES,
65536, true, ENABLE_SWAPPING, false, false, false, ENABLE_SWAP_QUEUEING, true,
0);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}
Logger.normal(RealNodeRoutingTest.class, "Created "+NUMBER_OF_NODES+"
nodes");
Modified: trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeSecretPingTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -66,7 +66,7 @@
for(int i=0;i<NUMBER_OF_NODES;i++) {
nodes[i] =
- NodeStarter.createTestNode(5001+i, wd, false, true, true,
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES,
storeSize, true, true, false, false, false, true, true);
+ NodeStarter.createTestNode(5001+i, wd, false, true, true,
MAX_HTL, 0 /* no dropped packets */, random, executor, 500*NUMBER_OF_NODES,
storeSize, true, true, false, false, false, true, true, 0);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}
Logger.normal(RealNodeRoutingTest.class, "Created "+NUMBER_OF_NODES+"
nodes");
Modified: trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
2008-03-13 22:20:30 UTC (rev 18519)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
2008-03-13 22:29:00 UTC (rev 18520)
@@ -87,7 +87,7 @@
Executor executor = new PooledExecutor();
for(int i=0;i<NUMBER_OF_NODES;i++) {
nodes[i] =
- NodeStarter.createTestNode(5000+i, testName, false, true, true,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 1024*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES, true,
true);
+ NodeStarter.createTestNode(5000+i, testName, false, true, true,
MAX_HTL, 20 /* 5% */, random, executor, 500*NUMBER_OF_NODES, 1024*1024, true,
ENABLE_SWAPPING, false, ENABLE_ULPRS, ENABLE_PER_NODE_FAILURE_TABLES, true,
true, 0);
Logger.normal(RealNodeRoutingTest.class, "Created node "+i);
}
SimpleFieldSet refs[] = new SimpleFieldSet[NUMBER_OF_NODES];