nl.tudelft.ewi.alg.distsim.net
Class RandomDelay

java.lang.Object
  extended by nl.tudelft.ewi.alg.distsim.net.RandomDelay
All Implemented Interfaces:
NetSimulator

public class RandomDelay
extends java.lang.Object
implements NetSimulator

Simulator for a non-lossy network with uniform random latency between two bounds.

Author:
Léon Planken

Field Summary
 
Fields inherited from interface nl.tudelft.ewi.alg.distsim.net.NetSimulator
LOST
 
Constructor Summary
RandomDelay(java.util.Random rnd, int minMS, int maxMS)
          Construct a new instance with the specified bounds.
 
Method Summary
 long send(int senderID, int receiverID, long sendTime)
          Simulate the sending of a message m by giving the message's delivery time, possibly losing it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomDelay

public RandomDelay(java.util.Random rnd,
                   int minMS,
                   int maxMS)
Construct a new instance with the specified bounds.

Parameters:
rnd - Random number generator
minMS - Minimum delay in milliseconds
maxMS - Maximum delay in milliseconds
Method Detail

send

public long send(int senderID,
                 int receiverID,
                 long sendTime)
Simulate the sending of a message m by giving the message's delivery time, possibly losing it.

Specified by:
send in interface NetSimulator
Parameters:
senderID - sender of the message
receiverID - receiver of the message
sendTime - clock time (in nanoseconds) when the message was sent
Returns:
clock time (in nanoseconds) when the message is to be delivered, or NetSimulator.LOST if lost