Author: mrogers
Date: 2006-08-10 10:32:54 +0000 (Thu, 10 Aug 2006)
New Revision: 10019

Modified:
   trunk/apps/load-balancing-sims/phase5-coalescing/Node.java
   trunk/apps/load-balancing-sims/phase5-no-ack-delay/Node.java
Log:
When the retransmission/coalescing timer expires, check the peers in a random 
order to avoid giving the same peer the first shot at the available bandwidth

Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Node.java  2006-08-10 
09:24:28 UTC (rev 10018)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Node.java  2006-08-10 
10:32:54 UTC (rev 10019)
@@ -1,5 +1,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.ArrayList;
+import java.util.Collections;

 class Node implements EventTarget
 {
@@ -166,14 +168,18 @@
                log ("generating request " + r.id);
                handleRequest (r, null);
                // Schedule the next request
-               Event.schedule (this, 1.23, GENERATE_REQUEST, null);
+               Event.schedule (this, 0.0123, GENERATE_REQUEST, null);
        }

        // Event callback
        private void checkTimeouts()
        {
+               // Check the peers in a random order each time
+               ArrayList<Peer> shuffled = new ArrayList<Peer> (peers.values());
+               Collections.shuffle (shuffled);
+               
                double deadline = Double.POSITIVE_INFINITY;
-               for (Peer p : peers.values())
+               for (Peer p : shuffled)
                        deadline = Math.min (deadline, p.checkTimeouts());
                if (deadline == Double.POSITIVE_INFINITY) {
                        log ("stopping retransmission/coalescing timer");

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-10 09:24:28 UTC (rev 10018)
+++ trunk/apps/load-balancing-sims/phase5-no-ack-delay/Node.java        
2006-08-10 10:32:54 UTC (rev 10019)
@@ -1,5 +1,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.ArrayList;
+import java.util.Collections;

 class Node implements EventTarget
 {
@@ -166,14 +168,18 @@
                log ("generating request " + r.id);
                handleRequest (r, null);
                // Schedule the next request
-               Event.schedule (this, 1.23, GENERATE_REQUEST, null);
+               Event.schedule (this, 0.0123, GENERATE_REQUEST, null);
        }

        // Event callback
        private void checkTimeouts()
        {
+               // Check the peers in a random order each time
+               ArrayList<Peer> shuffled = new ArrayList<Peer> (peers.values());
+               Collections.shuffle (shuffled);
+               
                double deadline = Double.POSITIVE_INFINITY;
-               for (Peer p : peers.values())
+               for (Peer p : shuffled)
                        deadline = Math.min (deadline, p.checkTimeouts());
                if (deadline == Double.POSITIVE_INFINITY) {
                        log ("stopping retransmission/coalescing timer");


Reply via email to