Author: mrogers
Date: 2006-08-17 13:28:38 +0000 (Thu, 17 Aug 2006)
New Revision: 10158
Modified:
trunk/apps/load-balancing-sims/phase5-coalescing/CongestionWindow.java
trunk/apps/load-balancing-sims/phase5-coalescing/Node.java
trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java
trunk/apps/load-balancing-sims/phase5-coalescing/Sim.java
trunk/apps/load-balancing-sims/phase5-no-ack-delay/Node.java
trunk/apps/load-balancing-sims/phase5-no-ack-delay/Peer.java
trunk/apps/load-balancing-sims/phase5-no-ack-delay/Sim.java
Log:
I am, in fact, an idiot.
Modified: trunk/apps/load-balancing-sims/phase5-coalescing/CongestionWindow.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/CongestionWindow.java
2006-08-17 10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/CongestionWindow.java
2006-08-17 13:28:38 UTC (rev 10158)
@@ -28,6 +28,7 @@
public int available()
{
+ peer.log ((int)(cwind - inflight) + " bytes in window");
return (int) cwind - inflight;
}
Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Node.java 2006-08-17
10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Node.java 2006-08-17
13:28:38 UTC (rev 10158)
@@ -7,9 +7,10 @@
{
public final static int STORE_SIZE = 10; // Max number of keys in store
public final static double MIN_SLEEP = 0.01; // Seconds
+ public final static double SHORT_SLEEP = 0.05; // Poll the bw limiter
// Token bucket bandwidth limiter
- public final static int BUCKET_RATE = 10000; // Bytes per second
+ public final static int BUCKET_RATE = 20000; // Bytes per second
public final static int BUCKET_SIZE = 40000; // Burst size in bytes
public double location; // Routing location
Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java 2006-08-17
10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java 2006-08-17
13:28:38 UTC (rev 10158)
@@ -58,7 +58,6 @@
double now = Event.time();
msgQueue.add (new Deadline<Message> (m, now + MAX_DELAY));
msgQueueSize += m.size;
- log (msgQueue.size() + " messages in queue");
// Start the node's timer if necessary
node.startTimer();
// Send as many packets as possible
@@ -72,6 +71,8 @@
log ("no messages or acks to send");
return false;
}
+ log (ackQueue.size() + " acks in queue");
+ log (msgQueue.size() + " messages in queue");
// Return to slow start when the link is idle
double now = Event.time();
@@ -83,17 +84,13 @@
int headersAndAcks = Packet.HEADER_SIZE + ackQueueSize;
int payload = Packet.MAX_SIZE - headersAndAcks;
if (payload > msgQueueSize) payload = msgQueueSize;
-
int win = window.available() - headersAndAcks;
- if (win <= 0) log ("no room in congestion window for messages");
if (payload > win) payload = win;
-
int bw = node.bandwidth.available() - headersAndAcks;
- if (bw <= 0) log ("no bandwidth available for messages");
if (payload > bw) payload = bw;
// Delay small packets for coalescing
- if (payload < Packet.SENSIBLE_PAYLOAD && now < deadline()) {
+ if (now < deadline (now)) {
log ("delaying transmission of " + payload + " bytes");
return false;
}
@@ -150,7 +147,6 @@
double now = Event.time();
ackQueue.add (new Deadline<Integer> (seq, now + MAX_DELAY));
ackQueueSize += Packet.ACK_SIZE;
- log (ackQueue.size() + " acks in queue");
// Start the node's timer if necessary
node.startTimer();
// Send as many packets as possible
@@ -240,13 +236,14 @@
log ("checking timeouts");
// Send as many packets as possible
while (send());
+
+ double now = Event.time();
if (txBuffer.isEmpty()) {
log ("no packets in flight");
- return deadline();
+ return deadline (now);
}
- double now = Event.time();
for (Packet p : txBuffer) {
- if (now - p.sent > RTO * rtt) {
+ if (now - p.sent > RTO * rtt + MAX_DELAY) {
// Retransmission timeout
log ("retransmitting packet " + p.seq);
p.sent = now;
@@ -254,18 +251,26 @@
window.timeout (now);
}
}
- return Math.min (now + MAX_DELAY, deadline());
+ return Math.min (now + MAX_DELAY, deadline (now));
}
- // Work out when the first ack or message needs to be sent
- private double deadline()
+ // Work out when the first message or ack needs to be sent
+ private double deadline (double now)
{
- double deadline = Double.POSITIVE_INFINITY;
- Deadline<Integer> ack = ackQueue.peek();
- if (ack != null) deadline = ack.deadline;
- Deadline<Message> msg = msgQueue.peek();
- if (msg != null) deadline = Math.min (deadline, msg.deadline);
- return deadline;
+ double ackDeadline = Double.POSITIVE_INFINITY;
+ Deadline<Integer> firstAck = ackQueue.peek();
+ if (firstAck != null) ackDeadline = firstAck.deadline;
+
+ double msgDeadline = Double.POSITIVE_INFINITY;
+ Deadline<Message> firstMsg = msgQueue.peek();
+ if (firstMsg != null) msgDeadline = firstMsg.deadline;
+
+ if (ackDeadline <= msgDeadline) return ackDeadline;
+ if (msgDeadline == Double.POSITIVE_INFINITY) return msgDeadline;
+ if (msgQueueSize < Packet.SENSIBLE_PAYLOAD) return msgDeadline;
+ if (window.available() < Packet.SENSIBLE_PAYLOAD +
Packet.HEADER_SIZE) return Double.POSITIVE_INFINITY; // Wait for an ack
+ if (node.bandwidth.available() < Packet.SENSIBLE_PAYLOAD +
Packet.HEADER_SIZE) return now + Node.SHORT_SLEEP; // Poll the bandwidth limiter
+ return now;
}
public void log (String message)
Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Sim.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Sim.java 2006-08-17
10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Sim.java 2006-08-17
13:28:38 UTC (rev 10158)
@@ -6,7 +6,7 @@
{
public static void main (String[] args)
{
- double txSpeed = 1000000, rxSpeed = 1000000; // Bytes per second
+ double txSpeed = 150000, rxSpeed = 150000; // Bytes per second
// rxSpeed = Math.exp (rand.nextGaussian() + 11.74);
// txSpeed = rxSpeed / 5.0;
Modified: trunk/apps/load-balancing-sims/phase5-no-ack-delay/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-no-ack-delay/Node.java
2006-08-17 10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-no-ack-delay/Node.java
2006-08-17 13:28:38 UTC (rev 10158)
@@ -7,9 +7,10 @@
{
public final static int STORE_SIZE = 10; // Max number of keys in store
public final static double MIN_SLEEP = 0.01; // Seconds
+ public final static double SHORT_SLEEP = 0.05; // Poll the bw limiter
// Token bucket bandwidth limiter
- public final static int BUCKET_RATE = 10000; // Bytes per second
+ public final static int BUCKET_RATE = 20000; // Bytes per second
public final static int BUCKET_SIZE = 40000; // Burst size in bytes
public double location; // Routing location
Modified: trunk/apps/load-balancing-sims/phase5-no-ack-delay/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-no-ack-delay/Peer.java
2006-08-17 10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-no-ack-delay/Peer.java
2006-08-17 13:28:38 UTC (rev 10158)
@@ -78,18 +78,13 @@
// Work out how large a packet we can send
int payload = Packet.MAX_SIZE - Packet.HEADER_SIZE;
if (payload > msgQueueSize) payload = msgQueueSize;
-
int win = window.available() - Packet.HEADER_SIZE;
- if (win <= 0) log ("no room in congestion window for messages");
if (payload > win) payload = win;
-
int bw = node.bandwidth.available() - Packet.HEADER_SIZE;
- if (bw <= 0) log ("no bandwidth available for messages");
if (payload > bw) payload = bw;
// Delay small packets for coalescing
- if (payload < Packet.SENSIBLE_PAYLOAD &&
- now < deadline() && ack == Packet.NO_ACK) {
+ if (now < deadline (now) && ack == Packet.NO_ACK) {
log ("delaying transmission of " + payload + " bytes");
return false;
}
@@ -226,11 +221,12 @@
log ("checking timeouts");
// Send as many packets as possible
while (send (Packet.NO_ACK));
+
+ double now = Event.time();
if (txBuffer.isEmpty()) {
log ("no packets in flight");
- return deadline();
+ return deadline (now);
}
- double now = Event.time();
for (Packet p : txBuffer) {
if (now - p.sent > RTO * rtt) {
// Retransmission timeout
@@ -240,16 +236,21 @@
window.timeout (now);
}
}
- return Math.min (now + MAX_DELAY, deadline());
+ return Math.min (now + MAX_DELAY, deadline (now));
}
- // Work out when the first ack or message needs to be sent
- private double deadline()
+ // Work out when the first message needs to be sent
+ private double deadline (double now)
{
- double deadline = Double.POSITIVE_INFINITY;
- Deadline<Message> msg = msgQueue.peek();
- if (msg != null) deadline = msg.deadline;
- return deadline;
+ double msgDeadline = Double.POSITIVE_INFINITY;
+ Deadline<Message> firstMsg = msgQueue.peek();
+ if (firstMsg == null) return Double.POSITIVE_INFINITY;
+ else msgDeadline = firstMsg.deadline;
+
+ if (msgQueueSize < Packet.SENSIBLE_PAYLOAD) return msgDeadline;
+ if (window.available() < Packet.SENSIBLE_PAYLOAD +
Packet.HEADER_SIZE) return Double.POSITIVE_INFINITY; // Wait for an ack
+ if (node.bandwidth.available() < Packet.SENSIBLE_PAYLOAD +
Packet.HEADER_SIZE) return now + Node.SHORT_SLEEP; // Poll the bandwidth limiter
+ return now;
}
public void log (String message)
Modified: trunk/apps/load-balancing-sims/phase5-no-ack-delay/Sim.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-no-ack-delay/Sim.java 2006-08-17
10:19:50 UTC (rev 10157)
+++ trunk/apps/load-balancing-sims/phase5-no-ack-delay/Sim.java 2006-08-17
13:28:38 UTC (rev 10158)
@@ -6,7 +6,7 @@
{
public static void main (String[] args)
{
- double txSpeed = 1000000, rxSpeed = 1000000; // Bytes per second
+ double txSpeed = 150000, rxSpeed = 150000; // Bytes per second
// rxSpeed = Math.exp (rand.nextGaussian() + 11.74);
// txSpeed = rxSpeed / 5.0;