Author: mrogers
Date: 2006-08-08 19:06:57 +0000 (Tue, 08 Aug 2006)
New Revision: 9970

Modified:
   trunk/apps/load-balancing-sims/phase5-coalescing/Node.java
   trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java
Log:
Moved bandwidth limiter from Peer to Node (oops)

Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Node.java  2006-08-08 
15:14:32 UTC (rev 9969)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Node.java  2006-08-08 
19:06:57 UTC (rev 9970)
@@ -6,6 +6,10 @@
        public final static int STORE_SIZE = 10; // Max number of keys in store
        public final static double MIN_SLEEP = 0.01; // Seconds

+       // Token bucket bandwidth limiter
+       public final static int BUCKET_RATE = 10000; // Bytes per second
+       public final static int BUCKET_SIZE = 40000; // Burst size in bytes
+       
        public double location; // Routing location
        public NetworkInterface net;
        private HashMap<Integer,Peer> peers; // Look up a peer by its address
@@ -13,6 +17,7 @@
        private HashSet<Integer> recentlySeenRequests; // Request IDs
        private HashMap<Integer,RequestState> outstandingRequests;
        public LruCache<Integer> cache; // Datastore containing keys
+       public TokenBucket bandwidth; // Bandwidth limiter
        private boolean timerRunning = false; // Is the timer running?

        public Node (double txSpeed, double rxSpeed)
@@ -23,6 +28,7 @@
                recentlySeenRequests = new HashSet<Integer>();
                outstandingRequests = new HashMap<Integer,RequestState>();
                cache = new LruCache<Integer> (STORE_SIZE);
+               bandwidth = new TokenBucket (BUCKET_RATE, BUCKET_SIZE);
        }

        public void connect (Node n, double latency)
@@ -98,8 +104,7 @@
                }
                if (cache.get (r.key)) {
                        log ("key " + r.key + " found in cache");
-                       if (prev == null)
-                               log (r + " succeeded locally");
+                       if (prev == null) log (r + " succeeded locally");
                        else prev.sendMessage (new Response (r.id, r.key));
                        return;
                }
@@ -137,8 +142,7 @@
                Peer next = rs.closestPeer();
                if (next == null) {
                        log ("route not found for " + rs);
-                       if (rs.prev == null)
-                               log (rs + " failed");
+                       if (rs.prev == null) log (rs + " failed");
                        else rs.prev.sendMessage (new RouteNotFound (rs.id));
                        return;
                }

Modified: trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java  2006-08-08 
15:14:32 UTC (rev 9969)
+++ trunk/apps/load-balancing-sims/phase5-coalescing/Peer.java  2006-08-08 
19:06:57 UTC (rev 9970)
@@ -20,10 +20,6 @@
        // Out-of-order delivery with eventual detection of missing packets
        public final static int SEQ_RANGE = 1000;

-       // Token bucket bandwidth limiter
-       public final static int BUCKET_RATE = 2000; // Bytes per second
-       public final static int BUCKET_SIZE = 4000; // Burst size in bytes
-       
        // Sender state
        private double rtt = 5.0; // Estimated round-trip time in seconds
        private int txSeq = 0; // Sequence number of next outgoing data packet
@@ -35,7 +31,6 @@
        private int ackQueueSize = 0; // Size of ack queue in bytes
        private CongestionWindow window; // AIMD congestion window
        private double lastTransmission = 0.0; // Clock time
-       private TokenBucket bandwidth; // Token bucket bandwidth limiter

        // Receiver state
        private HashSet<Integer> rxDupe; // Detect duplicates by sequence number
@@ -51,7 +46,6 @@
                msgQueue = new LinkedList<Deadline<Message>>();
                ackQueue = new LinkedList<Deadline<Integer>>();
                window = new CongestionWindow (this);
-               bandwidth = new TokenBucket (BUCKET_RATE, BUCKET_SIZE);
                rxDupe = new HashSet<Integer>();
        }

@@ -93,7 +87,7 @@
                if (win <= 0) log ("no room in congestion window for messages");
                if (payload > win) payload = win;

-               int bw = bandwidth.available() - headersAndAcks;
+               int bw = node.bandwidth.available() - headersAndAcks;
                if (bw <= 0) log ("no bandwidth available for messages");
                if (payload > bw) payload = bw;

@@ -148,7 +142,7 @@
                // Send the packet
                log ("sending packet " + p.seq + ", " + p.size + " bytes");
                node.net.send (p, address, latency);
-               bandwidth.remove (p.size);
+               node.bandwidth.remove (p.size);
                return true;
        }



Reply via email to