Rice Pastry API

rice.pastry.direct
Interface NetworkSimulator

All Known Implementing Classes:
BasicNetworkSimulator, EuclideanNetwork, GenericNetwork, SphereNetwork

public interface NetworkSimulator

Interface to an object which is simulating the network.

Version:
$Id: NetworkSimulator.java 3502 2006-12-18 14:06:41Z jeffh $
Author:
Andrew Ladd

Method Summary
 boolean addSimulatorListener(SimulatorListener sl)
           
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node)
          Deliver message ASAP.
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node, int delay)
          Deliver message.
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node, int delay, int period)
          Deliver message.
 ScheduledMessage deliverMessageFixedRate(Message msg, DirectPastryNode node, int delay, int period)
          Deliver message.
 void destroy(DirectPastryNode dpn)
          DESCRIBE THE METHOD
 CancellableTask enqueueDelivery(Delivery del, int delay)
          Deliver message.
 NodeRecord generateNodeRecord()
          Generates a random node record
 DirectNodeHandle getClosest(DirectNodeHandle nh)
          Returns the closest Node in proximity.
 Environment getEnvironment()
          Gets the Environment attribute of the NetworkSimulator object
 TestRecord getTestRecord()
          Gets the TestRecord attribute of the NetworkSimulator object
 boolean isAlive(DirectNodeHandle nh)
          Checks to see if a node id is alive.
 float networkDelay(DirectNodeHandle a, DirectNodeHandle b)
          Determines delivery time from a to b.
 void notifySimulatorListeners(Message m, NodeHandle from, NodeHandle to, int delay)
          Call this when a message is sent.
 float proximity(DirectNodeHandle a, DirectNodeHandle b)
          Determines rtt between two nodes.
 void registerNode(DirectPastryNode dpn)
          Registers a node handle with the simulator.
 void removeNode(DirectPastryNode node)
          DESCRIBE THE METHOD
 boolean removeSimulatorListener(SimulatorListener sl)
           
 void setFullSpeed()
          unlimited maxSpeed
 void setMaxSpeed(float rate)
          The max rate of the simulator compared to realtime.
 void setTestRecord(TestRecord tr)
          Sets the TestRecord attribute of the NetworkSimulator object
 void start()
          DESCRIBE THE METHOD
 void stop()
          DESCRIBE THE METHOD
 

Method Detail

getEnvironment

Environment getEnvironment()
Gets the Environment attribute of the NetworkSimulator object

Returns:
The Environment value

registerNode

void registerNode(DirectPastryNode dpn)
Registers a node handle with the simulator.

Parameters:
dpn - DESCRIBE THE PARAMETER

isAlive

boolean isAlive(DirectNodeHandle nh)
Checks to see if a node id is alive.

Parameters:
nh - DESCRIBE THE PARAMETER
Returns:
true if alive, false otherwise.

proximity

float proximity(DirectNodeHandle a,
                DirectNodeHandle b)
Determines rtt between two nodes.

Parameters:
a - a node id.
b - another node id.
Returns:
proximity of b to a.

networkDelay

float networkDelay(DirectNodeHandle a,
                   DirectNodeHandle b)
Determines delivery time from a to b.

Parameters:
a - a node id.
b - another node id.
Returns:
proximity of b to a.

deliverMessage

ScheduledMessage deliverMessage(Message msg,
                                DirectPastryNode node,
                                int delay)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
delay - DESCRIBE THE PARAMETER
Returns:
DESCRIBE THE RETURN VALUE

deliverMessage

ScheduledMessage deliverMessage(Message msg,
                                DirectPastryNode node,
                                int delay,
                                int period)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
delay - DESCRIBE THE PARAMETER
period - to deliver the message after the delay
Returns:
DESCRIBE THE RETURN VALUE

deliverMessageFixedRate

ScheduledMessage deliverMessageFixedRate(Message msg,
                                         DirectPastryNode node,
                                         int delay,
                                         int period)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
delay - DESCRIBE THE PARAMETER
period - to deliver the message after the delay
Returns:
DESCRIBE THE RETURN VALUE

deliverMessage

ScheduledMessage deliverMessage(Message msg,
                                DirectPastryNode node)
Deliver message ASAP.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
Returns:
DESCRIBE THE RETURN VALUE

setTestRecord

void setTestRecord(TestRecord tr)
Sets the TestRecord attribute of the NetworkSimulator object

Parameters:
tr - The new TestRecord value

getTestRecord

TestRecord getTestRecord()
Gets the TestRecord attribute of the NetworkSimulator object

Returns:
The TestRecord value

getClosest

DirectNodeHandle getClosest(DirectNodeHandle nh)
Returns the closest Node in proximity.

Parameters:
nh - DESCRIBE THE PARAMETER
Returns:

destroy

void destroy(DirectPastryNode dpn)
DESCRIBE THE METHOD

Parameters:
dpn - DESCRIBE THE PARAMETER

generateNodeRecord

NodeRecord generateNodeRecord()
Generates a random node record

Returns:

removeNode

void removeNode(DirectPastryNode node)
DESCRIBE THE METHOD

Parameters:
node - DESCRIBE THE PARAMETER

start

void start()
DESCRIBE THE METHOD


stop

void stop()
DESCRIBE THE METHOD


enqueueDelivery

CancellableTask enqueueDelivery(Delivery del,
                                int delay)
Deliver message.

Parameters:
del - DESCRIBE THE PARAMETER
delay - DESCRIBE THE PARAMETER
Returns:
DESCRIBE THE RETURN VALUE

setMaxSpeed

void setMaxSpeed(float rate)
The max rate of the simulator compared to realtime. The rule is that the simulated clock will not be set to a value greater than the factor from system-time that the call was made. Thus if 1 hour ago, you said the simulator should run at 10x realtime the simulated clock will only have advanced 10 hours. Note that if the simulator cannot keep up with the system clock in the early part, it may move faster than the value you set to "catch up" To prevent this speed-up from becoming unbounded, you may wish to call setMaxSpeed() periodically or immediately after periods of expensive calculations. Setting the simulation speed to zero will not pause the simulation, you must call stop() to do that.

Parameters:
rate - The new MaxSpeed value

setFullSpeed

void setFullSpeed()
unlimited maxSpeed


notifySimulatorListeners

void notifySimulatorListeners(Message m,
                              NodeHandle from,
                              NodeHandle to,
                              int delay)
Call this when a message is sent.

Parameters:
m - the message
from - the source
to - the destination
delay - the network proximity (when the message will be received)

addSimulatorListener

boolean addSimulatorListener(SimulatorListener sl)
Parameters:
sl -
Returns:
true if added, false if already a listener

removeSimulatorListener

boolean removeSimulatorListener(SimulatorListener sl)
Parameters:
sl -
Returns:
true if removed, false if not already a listener

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.