peersim.transport
Class UniformRandomTransport

java.lang.Object
  extended by peersim.transport.UniformRandomTransport
All Implemented Interfaces:
java.lang.Cloneable, Protocol, Transport

public final class UniformRandomTransport
extends java.lang.Object
implements Transport

Implement a transport layer that reliably delivers messages with a random delay, that is drawn from the configured interval according to the uniform distribution.


Parameter Summary
mindelay
          String name of the parameter used to configure the minimum latency.
maxdelay
          String name of the parameter used to configure the maximum latency.
 
Constructor Summary
UniformRandomTransport(java.lang.String prefix)
          Reads configuration parameter.
 
Method Summary
 java.lang.Object clone()
          Returns this.
 long getLatency(Node src, Node dest)
          Returns a random delay, that is drawn from the configured interval according to the uniform distribution.
 void send(Node src, Node dest, java.lang.Object msg, int pid)
          Delivers the message with a random delay, that is drawn from the configured interval according to the uniform distribution.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

mindelay

String name of the parameter used to configure the minimum latency.


maxdelay

String name of the parameter used to configure the maximum latency. Defaults to "mindelay", which results in a constant delay.

Constructor Detail

UniformRandomTransport

public UniformRandomTransport(java.lang.String prefix)
Reads configuration parameter.

Method Detail

clone

public java.lang.Object clone()
Returns this. This way only one instance exists in the system that is linked from all the nodes. This is because this protocol has no node specific state.

Specified by:
clone in interface Protocol
Overrides:
clone in class java.lang.Object

send

public void send(Node src,
                 Node dest,
                 java.lang.Object msg,
                 int pid)
Delivers the message with a random delay, that is drawn from the configured interval according to the uniform distribution.

Specified by:
send in interface Transport
Parameters:
src - sender node
dest - destination node
msg - message to be sent
pid - protocol identifier

getLatency

public long getLatency(Node src,
                       Node dest)
Returns a random delay, that is drawn from the configured interval according to the uniform distribution.

Specified by:
getLatency in interface Transport
Parameters:
src - sender node
dest - destination node