Author: mrogers
Date: 2006-11-16 15:31:53 +0000 (Thu, 16 Nov 2006)
New Revision: 10944
Modified:
trunk/apps/load-balancing-sims/phase7/sim/Node.java
trunk/apps/load-balancing-sims/phase7/sim/Peer.java
trunk/apps/load-balancing-sims/phase7/sim/TokenBucket.java
Log:
Smoother averaging of bandwidth/congestion delay
Modified: trunk/apps/load-balancing-sims/phase7/sim/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-16 15:15:27 UTC
(rev 10943)
+++ trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-16 15:31:53 UTC
(rev 10944)
@@ -14,7 +14,7 @@
// Flow control
public final static int FLOW_TOKENS = 20; // Shared by all peers
public final static double TOKEN_DELAY = 1.0; // Allocate initial tokens
- public final static double DELAY_DECAY = 0.9; // Exp moving average
+ public final static double DELAY_DECAY = 0.99; // Exp moving average
public double location; // Routing location
public NetworkInterface net;
@@ -31,7 +31,7 @@
public TokenBucket bandwidth; // Bandwidth limiter
private boolean timerRunning = false;
private int spareTokens = FLOW_TOKENS; // Tokens not allocated to a peer
- private double bwDelay = 0.0; // Average delay caused by b/w limiter
+ private double delay = 0.0; // Delay caused by congestion or b/w limiter
public Node (double txSpeed, double rxSpeed)
{
@@ -179,12 +179,11 @@
if (p.messages != null) {
double now = Event.time();
for (Message m : p.messages) {
- double delay = now - m.deadline;
- log ("bandwidth delay " + delay);
- bwDelay *= DELAY_DECAY;
- bwDelay += delay * (1.0 - DELAY_DECAY);
+ double d = now - m.deadline;
+ delay *= DELAY_DECAY;
+ delay += d * (1.0 - DELAY_DECAY);
}
- log ("average bandwidth delay " + bwDelay);
+ log ("average message delay " + delay);
}
// Send the packet
net.sendPacket (p);
Modified: trunk/apps/load-balancing-sims/phase7/sim/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Peer.java 2006-11-16 15:15:27 UTC
(rev 10943)
+++ trunk/apps/load-balancing-sims/phase7/sim/Peer.java 2006-11-16 15:31:53 UTC
(rev 10944)
@@ -314,7 +314,7 @@
public void log (String message)
{
- Event.log (node.net.address + ":" + address + " " + message);
+ // Event.log (node.net.address + ":" + address + " " + message);
}
public String toString()
Modified: trunk/apps/load-balancing-sims/phase7/sim/TokenBucket.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/TokenBucket.java 2006-11-16
15:15:27 UTC (rev 10943)
+++ trunk/apps/load-balancing-sims/phase7/sim/TokenBucket.java 2006-11-16
15:31:53 UTC (rev 10944)
@@ -7,12 +7,12 @@
public TokenBucket (double rate, double size)
{
- this.rate = rate;
- this.size = size;
+ this.rate = rate; // Bandwidth limit in bytes per second
+ this.size = size; // Size of maximum burst in bytes
double poll = Packet.MAX_SIZE / rate;
if (poll < Peer.MIN_SLEEP) poll = Peer.MIN_SLEEP;
if (poll > Peer.MAX_DELAY) poll = Peer.MAX_DELAY;
- this.poll = poll;
+ this.poll = poll; // Polling interval in seconds
tokens = size;
lastUpdated = 0.0; // Clock time
}
@@ -24,13 +24,11 @@
lastUpdated = now;
tokens += elapsed * rate;
if (tokens > size) tokens = size;
- // Event.log (tokens + " tokens available");
return (int) tokens;
}
public void remove (int t)
{
tokens -= t; // Counter can go negative
- // Event.log (t + " tokens removed, " + tokens + " available");
}
}