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

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

public class SimpleDelay
extends java.lang.Object
implements NetSimulator

Simulator for a non-lossy network with a fixed message latency.

Author:
Léon Planken

Nested Class Summary
static class SimpleDelay.Unit
          Units for specifying message latency.
 
Field Summary
 long delay
           
 
Fields inherited from interface nl.tudelft.ewi.alg.distsim.net.NetSimulator
LOST
 
Constructor Summary
SimpleDelay(long delay)
          Construct a SimpleDelay instance
SimpleDelay(long delay, SimpleDelay.Unit unit)
          Construct a SimpleDelay instance
 
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
 

Field Detail

delay

public final long delay
Constructor Detail

SimpleDelay

public SimpleDelay(long delay)
Construct a SimpleDelay instance

Parameters:
delay - The (non-negative) delay for delivering messages, in milliseconds.

SimpleDelay

public SimpleDelay(long delay,
                   SimpleDelay.Unit unit)
Construct a SimpleDelay instance

Parameters:
delay - The (non-negative) delay for delivering messages.
unit - the time unit in which the delay has been specified
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