Author: mrogers
Date: 2006-08-17 16:19:51 +0000 (Thu, 17 Aug 2006)
New Revision: 10165

Modified:
   trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java
   trunk/apps/load-balancing-sims/phase5-no-ack-delay/Peer.java
Log:
Fixed excessive retransmissions, phase6 will be based on phase5-coalescing

Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java  2006-08-17 
16:17:38 UTC (rev 10164)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java  2006-08-17 
16:19:51 UTC (rev 10165)
@@ -90,9 +90,8 @@
                if (payload > bw) payload = bw;

                // Delay small packets for coalescing
-               double delay = deadline (now) - now;
-               if (delay > 0.0) {
-                       log ("delaying transmission of " + payload + " bytes 
for " + delay + " seconds");
+               if (now < deadline (now)) {
+                       log ("delaying transmission of " + payload + " bytes");
                        return false;
                }

@@ -258,19 +257,30 @@
        // Work out when the first message or ack needs to be sent
        private double deadline (double now)
        {
-               double ackDeadline = Double.POSITIVE_INFINITY;
+               return Math.min (ackDeadline(), msgDeadline (now));
+       }
+
+       // Work out when the first ack needs to be sent
+       private double ackDeadline()
+       {
                Deadline<Integer> firstAck = ackQueue.peek();
-               if (firstAck != null) ackDeadline = firstAck.deadline;
-               
-               double msgDeadline = Double.POSITIVE_INFINITY;
+               if (firstAck == null) return Double.POSITIVE_INFINITY;
+               return firstAck.deadline;
+       }
+       
+       // Work out when the first message needs to be sent
+       private double msgDeadline (double now)
+       {
                Deadline<Message> firstMsg = msgQueue.peek();
-               if (firstMsg != null) msgDeadline = firstMsg.deadline;
-               if (window.available() < Packet.SENSIBLE_PAYLOAD + 
Packet.HEADER_SIZE) msgDeadline = Double.POSITIVE_INFINITY; // Wait for an ack
-               if (node.bandwidth.available() < Packet.SENSIBLE_PAYLOAD + 
Packet.HEADER_SIZE) msgDeadline = Math.max (msgDeadline, now + 
Node.SHORT_SLEEP); // Poll the bandwidth limiter
-               
-               if (ackDeadline <= msgDeadline) return ackDeadline;
-               if (msgDeadline == Double.POSITIVE_INFINITY) return msgDeadline;
-               if (msgQueueSize < Packet.SENSIBLE_PAYLOAD) return msgDeadline;
+               if (firstMsg == null) return Double.POSITIVE_INFINITY;
+               double deadline = firstMsg.deadline;
+               if (msgQueueSize < Packet.SENSIBLE_PAYLOAD) return deadline;
+               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 Math.max (deadline, now + Node.SHORT_SLEEP);
                return now;
        }


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 16:17:38 UTC (rev 10164)
+++ trunk/apps/load-balancing-sims/phase5-no-ack-delay/Peer.java        
2006-08-17 16:19:51 UTC (rev 10165)
@@ -242,14 +242,16 @@
        // Work out when the first message needs to be sent
        private double deadline (double now)
        {
-               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
+               double deadline = firstMsg.deadline;
+               if (msgQueueSize < Packet.SENSIBLE_PAYLOAD) return deadline;
+               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 Math.max (deadline, now + Node.SHORT_SLEEP);
                return now;
        }



Reply via email to