peersim.dynamics
Class OscillatingNetwork

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

public class OscillatingNetwork
extends java.lang.Object
implements Control

Makes the network size oscillate. The network size will be the function of time, parameterized by this parameter. The size function is avg+sin(time*pi/"period")*ampl where avg=("maxsize"+"minsize")/2 and ampl=("maxsize"-"minsize")/2. This function is independent of how many times this class is executed, that is, whenever it is executed, it takes the current time and sets the network size accordingly.


Parameter Summary
init
          Config parameter which gives the prefix of node initializers.
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.
period
          Config parameter used to define the length of one period of the oscillation.
 
Constructor Summary
OscillatingNetwork(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()
          Takes the current time and sets the network size according to a periodic function of time.
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
...
 


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.


period

Config parameter used to define the length of one period of the oscillation. The network size will be the function of time, parameterized by this parameter. The size function is avg+sin(time*pi/"period")*ampl where avg=("maxsize"+"minsize")/2 and ampl=("maxsize"-"minsize")/2.

Constructor Detail

OscillatingNetwork

public OscillatingNetwork(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 boolean execute()
Takes the current time and sets the network size according to a periodic function of time. The size function is avg+sin(time*pi/"period")*ampl where avg=("maxsize"+"minsize")/2 and ampl=("maxsize"-"minsize")/2. Calls add(int) or remove(int) depending on whether the size needs to be increased or decreased to get the desired size.

Specified by:
execute in interface Control
Returns:
always false