es.ants.felixgm.trmsim_wsn.trm.eigentrust
Class EigenTrust_Network

java.lang.Object
  extended by es.ants.felixgm.trmsim_wsn.network.Network
      extended by es.ants.felixgm.trmsim_wsn.trm.eigentrust.EigenTrust_Network

public class EigenTrust_Network
extends Network

This class models a network composed by sensors implementing EigenTrust

Since:
0.2
Version:
0.4
Author:
Félix Gómez Mármol, Gregorio Martínez Pérez and Antonio Bernárdez

Field Summary
 
Fields inherited from class es.ants.felixgm.trmsim_wsn.network.Network
clients, maxDistance, sensors, servers, services
 
Constructor Summary
EigenTrust_Network(int numSensors, double probClients, double rangeFactor, java.util.Collection<java.lang.Double> probServices, java.util.Collection<java.lang.Double> probGoodness, java.util.Collection<Service> services)
          This constructor creates a new random EigenTrust Network using the given parameters
EigenTrust_Network(java.lang.String xmlFilePath)
          This method loads a network from a XML file and creates the specific corresponding EigenTrust Network
 
Method Summary
 long get_sensorsTransmittedDistance(ISearchCondition searchCondition, Service requiredService)
          Average transmitted distance per sensor of this network
 Sensor newSensor()
          This method creates a new sensor.
 Sensor newSensor(int id, double x, double y)
          This method creates a new sensor.
 void oscillate(Service service)
          This method turns every benevolent server in the network into malicious and counts the number of swapped servers.
protected  boolean reachesQualifiedService(Sensor sensor, Service requiredService)
          This method checks if a given sensor can reach any client and any benevolent server offering a given service
 void reset()
          This method resets this network to its initial state
 void writeToXMLFile(java.lang.String fileName)
          This method writes the current Network into a XML file following this structure
 
Methods inherited from class es.ants.felixgm.trmsim_wsn.network.Network
get_clients, get_maxDistance, get_numClients, get_numSensors, get_numServers, get_sensors, get_servers, get_services, getSensor, set_collusion, set_dynamic, setNewNeighbors, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EigenTrust_Network

public EigenTrust_Network(int numSensors,
                          double probClients,
                          double rangeFactor,
                          java.util.Collection<java.lang.Double> probServices,
                          java.util.Collection<java.lang.Double> probGoodness,
                          java.util.Collection<Service> services)
This constructor creates a new random EigenTrust Network using the given parameters

Parameters:
numSensors - Number of sensors composing the network
probClients - Probability of a sensor to act as a client requesting services
rangeFactor - Maximum wireless range of every sensor. It determines the neighborhood of every sensor
probServices - A collection of probabilities of offering a certain service, one per service
probGoodness - A collection of goodnesses about offering a certain service, one per service
services - All the services offered by the generated Network

EigenTrust_Network

public EigenTrust_Network(java.lang.String xmlFilePath)
                   throws java.lang.Exception
This method loads a network from a XML file and creates the specific corresponding EigenTrust Network

Parameters:
xmlFilePath - Path of the XML to load the network from
Throws:
java.lang.Exception - If the XML file given does not have the appropriate structure, or if a sensor links to an undefined sensor, or if a sensor links to itself
Method Detail

reset

public void reset()
Description copied from class: Network
This method resets this network to its initial state

Overrides:
reset in class Network

writeToXMLFile

public void writeToXMLFile(java.lang.String fileName)
                    throws java.lang.Exception
Description copied from class: Network
This method writes the current Network into a XML file following this structure

Overrides:
writeToXMLFile in class Network
Parameters:
fileName - Path of the XML file where to write the current Network
Throws:
java.lang.Exception - If there is any problem when writing to the XML file

get_sensorsTransmittedDistance

public long get_sensorsTransmittedDistance(ISearchCondition searchCondition,
                                           Service requiredService)
Description copied from class: Network
Average transmitted distance per sensor of this network

Overrides:
get_sensorsTransmittedDistance in class Network
Parameters:
searchCondition - Condition to be accomplished by the querying sensors
requiredService - Service requested by the clients
Returns:
Average transmitted distance per sensor of this network

reachesQualifiedService

protected boolean reachesQualifiedService(Sensor sensor,
                                          Service requiredService)
Description copied from class: Network
This method checks if a given sensor can reach any client and any benevolent server offering a given service

Overrides:
reachesQualifiedService in class Network
Parameters:
sensor - Sensor to find out whether it can reach a benevolent server or not
requiredService - Service requested by the clients
Returns:
true if the given sensor can reach any client and any benevolent server offering the given service, false otherwise

oscillate

public void oscillate(Service service)
Description copied from class: Network
This method turns every benevolent server in the network into malicious and counts the number of swapped servers. Then (when every server is malicious) it randomly selects malicious servers and converts them into benevolent until the number of benevolent servers is equal to the one before calling this method

Overrides:
oscillate in class Network
Parameters:
service - Service over what the oscillation is to be carried out

newSensor

public Sensor newSensor()
Description copied from class: Network
This method creates a new sensor. It must be redefined in each subclass according to the requirements of each particular trust and reputation model

Specified by:
newSensor in class Network
Returns:
New created sensor

newSensor

public Sensor newSensor(int id,
                        double x,
                        double y)
Description copied from class: Network
This method creates a new sensor. It must be redefined in each subclass according to the requirements of each particular trust and reputation model

Specified by:
newSensor in class Network
Parameters:
id - Sensor's identifier
x - X coordinate of the new sensor
y - Y coordinate of the new sensor
Returns:
New created sensor