peersim.transport
Class UnreliableTransport

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

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

This transport protocol can be combined with other transports to simulate message losses. Its behavior is the following: each message can be dropped based on the configured probability, or it will be sent using the underlying transport protocol.

The memory requirements are minimal, as a single instance is created and inserted in the protocol array of all nodes (because instances have no state that depends on the hosting node).


Parameter Summary
transport
          The name of the underlying transport protocol.
drop
          String name of the parameter used to configure the probability that a message sent through this transport is lost.
 
Constructor Summary
UnreliableTransport(java.lang.String prefix)
          Reads configuration parameter.
 
Method Summary
 java.lang.Object clone()
          Returns this.
 long getLatency(Node src, Node dest)
          Returns the latency of the underlying protocol.
 void send(Node src, Node dest, java.lang.Object msg, int pid)
          Sends the message according to the underlying transport protocol.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

transport

The name of the underlying transport protocol. This transport is extended with dropping messages.


drop

String name of the parameter used to configure the probability that a message sent through this transport is lost.

Constructor Detail

UnreliableTransport

public UnreliableTransport(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 state that depends on the hosting node.

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)
Sends the message according to the underlying transport protocol. With the configured probability, the message is not sent (i.e. the method does nothing).

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 the latency of the underlying protocol.

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