Thursday, 11 November 2010

PeerSim - General Notes

Here are some general notes that I have learned from PeerSim.

LifeCycles:
1. Read the configuration file
2. Setup the network
2.1 Initialize the nodes of the network
2.2 Initialize the protocols

General
  • The network is a list of nodes which are interconnected
  • Each node is composed by N protocols.
  • Each object in PeerSim (controls and protocols) is assigned a Scheduler object which defines when they are executed exactly.
  • By default, all the object are executed in each cycle.
  • All the object created during the simulation are instances of classes that implement one or more interfaces. (Node, CDProtocol, Linkable, Control)
  • By default in PeerSim, the "degree" is the out-degree.
Nodes
  • Each node has the same kinds of protocols (instances)
  • The instance of the nodes and protocols are created by cloning. Then, only one instance is constructed using the constructor of the object (Prototype).
  • All the nodes in the network are cloned from the prototype.
  • All the nodes are initialized by the control object (The initialization of the object is separate from the definition of the object)
Protocols
  • Each protocol has a number as identification, which is accessible from the control class using:
private static final String PAR_PROT = "protocol"
Private static int pid;
public constructor (String prefix)
pid = Configuration.getPid(prefix + "." + "PAR_PROT");
  • The bottom protocol is Linkable, which is the protocol 0. The instances of the same linkable protocol class over the nodes define an overlay network
  • As the variable protocol, all the variable defined in the configuration file has similar way to be accessed. You just has to vary the name.
  • All the protocols object implements Protocol class, which should contain at least one constructor and, optionally, the clone class.
  • The initialize class implements Control class, which at least should contain the constructor and the execute method.
  • The constructor of the initialize class can get parameters from the configuration file. At least it should get the identification of the protocol (pid)
  • The execute method of the initialize class return always false.
  • You can use the Network class to contact with other protocols and call their methods
Node n = Network.get(2)
  • To generate random numbers, the static field r of CommonState MUST be used at all times, because that way the experiment are guarantee to be reproducible (to check)
prot.setX(CommonState.r.nextdouble());
  • To compute statistics of the degree distribution, the user can use peersim.reports.DegreeStats.
  • To test the network robustness, peersim.reports.RandRemoval can be used. it prints statistics about the number of generated clusters and their size, as a function of the number of randomly removed nodes.
  • To dump the topology to a file in a plottable form, we need to write our own observer. It could extend peersim.reports.GraphObserver
  • If you extend GraphObserver, the execute() method MUST call updateGraph() in order to check if some change has occurred on the actual graph. The scope of this mechanism is to save the time of constructing the graph if many observers are run on the same graph.

Others
More information here (pdf):
http://peersim.sourceforge.net/tutorial1/tutorial1.pdf
PeerSim, source code and tutorials:
http://peersim.sourceforge.net/

No comments:

Post a Comment