KadServer

- Introduced artificial latency when we're in testing mode

ContentLookup & NodeLookup Operations
- Reduce the wait time between data checks to 10 milliseconds
This commit is contained in:
Joshua Kissoon 2014-05-07 23:14:49 +05:30
parent e771c8fd44
commit 1d5d8004df
3 changed files with 11 additions and 3 deletions

View File

@ -214,6 +214,15 @@ public class KadServer
* Simulating network latency * Simulating network latency
* We pause for 1 millisecond/100 bytes * We pause for 1 millisecond/100 bytes
*/ */
int pause = packet.getLength() / 100;
try
{
Thread.sleep(pause);
}
catch (InterruptedException ex)
{
}
} }
/* We've received a packet, now handle it */ /* We've received a packet, now handle it */

View File

@ -112,7 +112,7 @@ public class ContentLookupOperation implements Operation, Receiver
* keey trying until config.operationTimeout() time has expired * keey trying until config.operationTimeout() time has expired
*/ */
int totalTimeWaited = 0; int totalTimeWaited = 0;
int timeInterval = 100; // We re-check every 300 milliseconds int timeInterval = 10; // We re-check every 10 milliseconds
while (totalTimeWaited < this.config.operationTimeout()) while (totalTimeWaited < this.config.operationTimeout())
{ {
if (!this.askNodesorFinish() && !isContentFound) if (!this.askNodesorFinish() && !isContentFound)

View File

@ -12,7 +12,6 @@ import kademlia.KademliaNode;
import kademlia.core.KadConfiguration; import kademlia.core.KadConfiguration;
import kademlia.core.KadServer; import kademlia.core.KadServer;
import kademlia.exceptions.RoutingException; import kademlia.exceptions.RoutingException;
import kademlia.exceptions.UnknownMessageException;
import kademlia.message.Message; import kademlia.message.Message;
import kademlia.message.NodeLookupMessage; import kademlia.message.NodeLookupMessage;
import kademlia.message.NodeReplyMessage; import kademlia.message.NodeReplyMessage;
@ -101,7 +100,7 @@ public class NodeLookupOperation implements Operation, Receiver
/* If we haven't finished as yet, wait for a maximum of config.operationTimeout() time */ /* If we haven't finished as yet, wait for a maximum of config.operationTimeout() time */
int totalTimeWaited = 0; int totalTimeWaited = 0;
int timeInterval = 50; // We re-check every 300 milliseconds int timeInterval = 10; // We re-check every 300 milliseconds
while (totalTimeWaited < this.config.operationTimeout()) while (totalTimeWaited < this.config.operationTimeout())
{ {
if (!this.askNodesorFinish()) if (!this.askNodesorFinish())