Author: mrogers
Date: 2006-11-02 13:23:48 +0000 (Thu, 02 Nov 2006)
New Revision: 10795
Modified:
trunk/apps/load-balancing-sims/phase7/sim/DeadlineQueue.java
trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
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/Sim.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
Log:
Fixed a stupid bug that was causing transfers to time out
Modified: trunk/apps/load-balancing-sims/phase7/sim/DeadlineQueue.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/DeadlineQueue.java
2006-11-02 07:17:51 UTC (rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/DeadlineQueue.java
2006-11-02 13:23:48 UTC (rev 10795)
@@ -6,7 +6,7 @@
class DeadlineQueue<MESSAGE extends Message>
{
- public int size = 0; // Size in bytes
+ public int size = 0; // Size of the queue in bytes
private LinkedList<MESSAGE> messages = new LinkedList<MESSAGE>();
public void add (MESSAGE m)
Modified: trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
2006-11-02 07:17:51 UTC (rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/NetworkInterface.java
2006-11-02 13:23:48 UTC (rev 10795)
@@ -5,14 +5,14 @@
class NetworkInterface implements EventTarget
{
- public int address; // Represents an IP address and port
+ public final int address; // Represents an IP address and port
private Node node; // The owner of this network interface
private double txSpeed, rxSpeed; // Bytes per second
private LinkedList<Packet> txQueue; // Queue of outgoing packets
private LinkedList<Packet> rxQueue; // Queue of incoming packets
- private int txQueueSize, rxQueueSize; // Limited-size drop-tail queues
- private int txQueueMaxSize, rxQueueMaxSize; // Bytes
+ private int txQueueSize, rxQueueSize; // Number of bytes in each queue
+ private int txQueueMaxSize, rxQueueMaxSize; // Drop-tail queues
public NetworkInterface (Node node, double txSpeed, double rxSpeed)
{
Modified: trunk/apps/load-balancing-sims/phase7/sim/Node.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-02 07:17:51 UTC
(rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/Node.java 2006-11-02 13:23:48 UTC
(rev 10795)
@@ -38,14 +38,14 @@
peers = new HashMap<Integer,Peer>();
recentlySeenRequests = new HashSet<Integer>();
messageHandlers = new HashMap<Integer,MessageHandler>();
- chkStore = new LruCache<Integer> (1000);
- chkCache = new LruCache<Integer> (1000);
- sskStore = new LruMap<Integer,Integer> (1000);
- sskCache = new LruMap<Integer,Integer> (1000);
- pubKeyCache = new LruCache<Integer> (1000);
+ chkStore = new LruCache<Integer> (16000);
+ chkCache = new LruCache<Integer> (16000);
+ sskStore = new LruMap<Integer,Integer> (16000);
+ sskCache = new LruMap<Integer,Integer> (16000);
+ pubKeyCache = new LruCache<Integer> (16000);
if (Math.random() < 0.5) decrementMaxHtl = true;
if (Math.random() < 0.25) decrementMinHtl = true;
- bandwidth = new TokenBucket (15000, 30000);
+ bandwidth = new TokenBucket (15000, 60000);
}
// Return true if a connection was added, false if already connected
@@ -157,7 +157,7 @@
{
if (timerRunning) return;
timerRunning = true;
- log ("starting retransmission timer");
+ // log ("starting retransmission timer");
Event.schedule (this, RETX_TIMER, CHECK_TIMEOUTS, null);
}
@@ -391,7 +391,7 @@
boolean stopTimer = true;
for (Peer p : peers()) if (p.checkTimeouts()) stopTimer = false;
if (stopTimer) {
- log ("stopping retransmission timer");
+ // log ("stopping retransmission timer");
timerRunning = false;
}
else Event.schedule (this, RETX_TIMER, CHECK_TIMEOUTS, null);
Modified: trunk/apps/load-balancing-sims/phase7/sim/Peer.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Peer.java 2006-11-02 07:17:51 UTC
(rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/Peer.java 2006-11-02 13:23:48 UTC
(rev 10795)
@@ -313,7 +313,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/Sim.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/Sim.java 2006-11-02 07:17:51 UTC
(rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/Sim.java 2006-11-02 13:23:48 UTC
(rev 10795)
@@ -4,11 +4,11 @@
class Sim
{
private final int NODES = 100; // Number of nodes
- private final int DEGREE = 4; // Average degree
- private final double SPEED = 40000; // Bytes per second
+ private final int DEGREE = 5; // Average degree
+ private final double SPEED = 40000; // Network speed, bytes per second
private final double LATENCY = 0.1; // Latency of all links in seconds
- private final double RATE = 0.005; // Inserts per second
- private final int INSERTS = 50;
+ private final double RATE = 1/120.0; // Inserts per publisher per second
+ private final int INSERTS = 60; // Number of inserts per publisher
private Node[] nodes;
public Sim()
@@ -22,16 +22,17 @@
nodes[i] = new Node (1.0 / NODES * i, SPEED, SPEED);
// Connect the nodes
makeKleinbergNetwork();
-
- // One publisher, ten randomly chosen readers
- SimplePublisher pub
- = new SimplePublisher (RATE, INSERTS, nodes[0]);
- int readers = 0;
- while (readers < 10) {
- int index = (int) (Math.random() * NODES);
- if (pub.addReader (nodes[index])) readers++;
+ // One in ten nodes is a publisher, each with ten readers
+ for (int i = 0; i < NODES; i += 10) {
+ SimplePublisher pub
+ = new SimplePublisher (RATE, INSERTS, nodes[i]);
+ int readers = 0;
+ while (readers < 10) {
+ int index = (int) (Math.random() * NODES);
+ if (index == i) continue;
+ if (pub.addReader (nodes[index])) readers++;
+ }
}
-
// Run the simulation
Event.run();
}
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
2006-11-02 07:17:51 UTC (rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkInsertHandler.java
2006-11-02 13:23:48 UTC (rev 10795)
@@ -71,9 +71,9 @@
if (blocks[b.index] != null) return; // Ignore duplicates
blocks[b.index] = b;
blocksReceived++;
- if (inState != TRANSFERRING) return; // Forward it later
// Forward the block to all receivers
- for (Peer p : receivers) p.sendMessage (b);
+ if (inState == TRANSFERRING)
+ for (Peer p : receivers) p.sendMessage (b);
// If the transfer is complete, consider finishing
if (blocksReceived == 32) {
inState = COMPLETED;
@@ -197,7 +197,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != SENT) return;
- node.log (this + " accepted timeout waiting for " + p);
+ node.log (this + " accepted timeout for " + p);
forwardSearch(); // Try another peer
}
@@ -205,7 +205,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != ACCEPTED) return;
- node.log (this + " search timeout waiting for " + p);
+ node.log (this + " search timeout for " + p);
if (prev == null) node.log (this + " failed");
searchState = COMPLETED;
considerFinishing();
@@ -214,7 +214,7 @@
private void dataTimeout()
{
if (inState != STARTED) return;
- node.log (this + " data timeout waiting for " + prev);
+ node.log (this + " data timeout for " + prev);
if (prev == null) node.log (this + " failed");
else prev.sendMessage (new TransfersCompleted (id));
finish();
@@ -223,7 +223,7 @@
private void transferInTimeout()
{
if (inState != TRANSFERRING) return;
- node.log (this + " transfer timeout receiving from " + prev);
+ node.log (this + " transfer timeout from " + prev);
if (prev == null) node.log (this + " failed");
else prev.sendMessage (new TransfersCompleted (id));
finish();
@@ -232,7 +232,7 @@
private void transferOutTimeout (Peer p)
{
if (!receivers.remove (p)) return;
- node.log (this + " transfer timeout sending to " + p);
+ node.log (this + " transfer timeout to " + p);
considerFinishing();
}
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
2006-11-02 07:17:51 UTC (rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/ChkRequestHandler.java
2006-11-02 13:23:48 UTC (rev 10795)
@@ -57,11 +57,12 @@
if (blocks[b.index] != null) return; // Ignore duplicates
blocks[b.index] = b;
blocksReceived++;
- if (searchState == TRANSFERRING) return; // Forward it later
- // Forward the block
- if (prev != null) {
- node.log ("forwarding " + b);
- prev.sendMessage (b);
+ if (searchState == TRANSFERRING) {
+ // Forward the block
+ if (prev != null) {
+ node.log ("forwarding " + b);
+ prev.sendMessage (b);
+ }
}
// If the transfer is complete, cache the data
if (blocksReceived == 32) {
@@ -79,5 +80,5 @@
public String toString()
{
return new String ("CHK request (" + id + "," + key + ")");
- }
+ }
}
Modified: trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
2006-11-02 07:17:51 UTC (rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/RequestHandler.java
2006-11-02 13:23:48 UTC (rev 10795)
@@ -93,7 +93,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != SENT) return;
- node.log (this + " accepted timeout waiting for " + p);
+ node.log (this + " accepted timeout for " + p);
forwardSearch(); // Try another peer
}
@@ -101,7 +101,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != ACCEPTED) return;
- node.log (this + " search timeout waiting for " + p);
+ node.log (this + " search timeout for " + p);
if (prev == null) node.log (this + " failed");
finish();
}
@@ -109,7 +109,7 @@
protected void transferTimeout (Peer p)
{
if (searchState != TRANSFERRING) return;
- node.log (this + " transfer timeout receiving from " + p);
+ node.log (this + " transfer timeout from " + p);
if (prev == null) node.log (this + " failed");
finish();
}
Modified:
trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
===================================================================
--- trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
2006-11-02 07:17:51 UTC (rev 10794)
+++ trunk/apps/load-balancing-sims/phase7/sim/handlers/SskInsertHandler.java
2006-11-02 13:23:48 UTC (rev 10795)
@@ -174,7 +174,7 @@
private void keyTimeout()
{
if (searchState != STARTED) return;
- node.log (this + " key timeout waiting for " + prev);
+ node.log (this + " key timeout for " + prev);
finish();
}
@@ -182,7 +182,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != SENT) return;
- node.log (this + " accepted timeout waiting for " + p);
+ node.log (this + " accepted timeout for " + p);
forwardSearch(); // Try another peer
}
@@ -190,7 +190,7 @@
{
if (p != next) return; // We've already moved on to another peer
if (searchState != ACCEPTED) return;
- node.log (this + " search timeout waiting for " + p);
+ node.log (this + " search timeout for " + p);
if (prev == null) node.log (this + " failed");
finish();
}