peersim.dynamics
Class DynamicNetwork

java.lang.Object
  extended by peersim.dynamics.DynamicNetwork
All Implemented Interfaces:
Control

public class DynamicNetwork
extends java.lang.Object
implements Control

This Control can change the size of networks by adding and removing nodes. Can be used to model churn. This class supports only permanent removal of nodes and the addition of brand new nodes. That is, temporary downtime is not supported by this class.


Parameter Summary
init
          Config parameter which gives the prefix of node initializers.
substitute
          If defined, nodes are substituted (an existing node is removed, a new one is added.
add
          Specifies the number of nodes to add or remove.
maxsize
          Nodes are added until the size specified by this parameter is reached.
minsize
          Nodes are removed until the size specified by this parameter is reached.
 
Field Summary
protected  double add
          value of "add"
protected  NodeInitializer[] inits
          node initializers to apply on the newly added nodes
protected  int maxsize
          value of "maxsize"
protected  int minsize
          value of "minsize"
protected  boolean substitute
          value of "substitute"
 
Constructor Summary
DynamicNetwork(java.lang.String prefix)
          Standard constructor that reads the configuration parameters.
 
Method Summary
protected  void add(int n)
          Adds n nodes to the network.
 boolean execute()
          Calls add(int) or remove(int) with the parameters defined by the configuration.
protected  void remove(int n)
          Removes n nodes from the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

init

Config parameter which gives the prefix of node initializers. An arbitrary number of node initializers can be specified (Along with their parameters). These will be applied on the newly created nodes. The initializers are ordered according to alphabetical order if their ID. Example:
control.0 DynamicNetwork
control.0.init.0 RandNI
control.0.init.0.k 5
control.0.init.0.protocol somelinkable
...
 


substitute

If defined, nodes are substituted (an existing node is removed, a new one is added. That is, first the number of nodes to add (or remove if "add" is negative) is calculated, and then exactly the same number of nodes are removed (or added) immediately so that the network size remains constant. Not set by default.


add

Specifies the number of nodes to add or remove. It can be negative in which case nodes are removed. If its absolute value is less than one, then it is interpreted as a proportion of current network size, that is, its value is substituted with add*networksize. Its value is rounded to an integer.


maxsize

Nodes are added until the size specified by this parameter is reached. The network will never exceed this size as a result of this class. If not set, there will be no limit on the size of the network.


minsize

Nodes are removed until the size specified by this parameter is reached. The network will never go below this size as a result of this class. Defaults to 0.

Field Detail

add

protected final double add
value of "add"


substitute

protected final boolean substitute
value of "substitute"


minsize

protected final int minsize
value of "minsize"


maxsize

protected final int maxsize
value of "maxsize"


inits

protected final NodeInitializer[] inits
node initializers to apply on the newly added nodes

Constructor Detail

DynamicNetwork

public DynamicNetwork(java.lang.String prefix)
Standard constructor that reads the configuration parameters. Invoked by the simulation engine.

Parameters:
prefix - the configuration prefix for this class
Method Detail

add

protected void add(int n)
Adds n nodes to the network. Extending classes can implement any algorithm to do that. The default algorithm adds the given number of nodes after calling all the configured initializers on them.

Parameters:
n - the number of nodes to add, must be non-negative.

remove

protected void remove(int n)
Removes n nodes from the network. Extending classes can implement any algorithm to do that. The default algorithm removes random nodes permanently simply by calling Network.remove(int).

Parameters:
n - the number of nodes to remove

execute

public final boolean execute()
Calls add(int) or remove(int) with the parameters defined by the configuration.

Specified by:
execute in interface Control
Returns:
always false