|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectes.ants.felixgm.trmsim_wsn.network.Network
public abstract class Network
This class models a P2P, Ad-hoc or Wireless Sensor Network, or even a multi-agent system.
It is composed of several clients requesting services and servers offering services
The constructor
Network
requires a XML file following the next structure:
<?xml version="1.0" encoding="UTF-8"?>
<wsn>
<client id="1" x="30.5" y="56.2">
<server id="2"/>
<server id="3"/>
</client>
<client id="7" x="10.3" y="26.4">
<server id="4"/>
<server id="6"/>
</client>
<server id="2" x="14.8" y="63.7">
<service id="Relay" goodness="1.0"/>
<server id="4"/>
<server id="5"/>
<client id="1"/>
</server>
<server id="3" x="29.7" y="73.7">
<service id="Relay" goodness="1.0"/>
<service id="Service 1" goodness="0.05"/>
<server id="4"/>
</server>
<server id="4" x="38.4" y="56.2">
<service id="Relay" goodness="1.0"/>
<server id="6"/>
</server>
<server id="5" x="95.6" y="36.8">
<service id="Relay" goodness="1.0"/>
<service id="Service 1" goodness="0.12"/>
<server id="6"/>
<client id="7"/>
</server>
<server id="6" x="53.5" y="97.4">
<service id="Relay" goodness="1.0"/>
<service id="Service 1" goodness="0.98"/>
<server id="3"/>
</server>
</tacs>
This file represents the following network:
A subclass of this class, modelling the specific network, has to be implemented in order to add a new Trust and Reputation Model
| Field Summary | |
|---|---|
protected java.util.Collection<Sensor> |
clients
The clients requesting services |
protected static double |
maxDistance
Maximum distance between two nodes in the network |
protected java.util.Collection<Sensor> |
sensors
All the sensors composing the network |
protected java.util.Collection<Sensor> |
servers
The servers offering services |
protected java.util.Collection<Service> |
services
All the services offered by the network |
| Constructor Summary | |
|---|---|
Network(java.util.Collection<Sensor> clients,
java.util.Collection<Sensor> servers,
java.util.Collection<Service> services)
This constructor creates a new Network from a given set of clients, servers and services |
|
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 Network using the given parameters |
|
Network(java.lang.String xmlFilePath)
This method reads a Network from a XML file and builds its corresponding object The XML file given should have this structure |
|
| Method Summary | |
|---|---|
java.util.Collection<Sensor> |
get_clients()
This method retrieves the set of clients belonging to this network |
static double |
get_maxDistance()
This method retrieves the maximum distance between two nodes in this network |
int |
get_numClients()
This method retrieves the number of clients belonging to this network |
int |
get_numSensors()
This method retrieves the total number of sensors composing this network |
int |
get_numServers()
This method retrieves the number of servers belonging to this network |
java.util.Collection<Sensor> |
get_sensors()
This method retrieves the set of sensors belonging to this network |
long |
get_sensorsTransmittedDistance(ISearchCondition searchCondition,
Service requiredService)
Average transmitted distance per sensor of this network |
java.util.Collection<Sensor> |
get_servers()
This method retrieves the set of servers belonging to this network |
java.util.Collection<Service> |
get_services()
This method retrieves the set of services offered by this network |
abstract Sensor |
newSensor()
This method creates a new sensor. |
abstract 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 |
set_collusion(boolean collusion)
This method establishes if a collusion is to be formed or not in this network |
void |
set_dynamic(boolean dynamic)
This method establishes if the topology of this network is dynamic, because sensors can sleep or not |
void |
setNewNeighbors(double newRange)
This methid establishes every sensor's new neighborhood according to a new wireless range |
java.lang.String |
toString()
Prints the whole Network, with all the offered services |
void |
writeToXMLFile(java.lang.String fileName)
This method writes the current Network into a XML file following this structure |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final double maxDistance
protected java.util.Collection<Sensor> clients
protected java.util.Collection<Sensor> servers
protected java.util.Collection<Sensor> sensors
protected java.util.Collection<Service> services
| Constructor Detail |
|---|
public Network(java.util.Collection<Sensor> clients,
java.util.Collection<Sensor> servers,
java.util.Collection<Service> services)
clients - The clients requesting servicesservers - The servers offering servicesservices - All the services offered by the network
public 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)
numSensors - Number of sensors composing the networkprobClients - Probability of a sensor to act as a client requesting servicesrangeFactor - Maximum wireless range of every sensor. It determines the neighborhood of every sensorprobServices - A collection of probabilities of offering a certain service, one per serviceprobGoodness - A collection of goodnesses about offering a certain service, one per serviceservices - All the services offered by the generated Network
public Network(java.lang.String xmlFilePath)
throws java.lang.Exception
This method reads a Network from a XML file and builds its corresponding object
The XML file given should have this structure
xmlFilePath - Path of the XML file describing the Network to create
java.lang.Exception - If the XML file given does not have the structure shown before, or if
a node links to an undefined node, or if a node links to itself| Method Detail |
|---|
public void oscillate(Service service)
service - Service over what the oscillation is to be carried outpublic abstract Sensor newSensor()
public abstract Sensor newSensor(int id,
double x,
double y)
id - Sensor's identifierx - X coordinate of the new sensory - Y coordinate of the new sensor
public void reset()
public void setNewNeighbors(double newRange)
newRange - New wireless range determining every sensor's neighbors
public void writeToXMLFile(java.lang.String fileName)
throws java.lang.Exception
fileName - Path of the XML file where to write the current Network
java.lang.Exception - If there is any problem when writing to the XML filepublic java.lang.String toString()
toString in class java.lang.Object
public long get_sensorsTransmittedDistance(ISearchCondition searchCondition,
Service requiredService)
searchCondition - Condition to be accomplished by the querying sensorsrequiredService - Service requested by the clients
protected boolean reachesQualifiedService(Sensor sensor,
Service requiredService)
sensor - Sensor to find out whether it can reach a benevolent server or notrequiredService - Service requested by the clients
public java.util.Collection<Sensor> get_clients()
public java.util.Collection<Sensor> get_servers()
public java.util.Collection<Sensor> get_sensors()
public java.util.Collection<Service> get_services()
public int get_numSensors()
public int get_numClients()
public int get_numServers()
public static double get_maxDistance()
public void set_collusion(boolean collusion)
collusion - Indicates if a collusion is to be formed or not in this networkpublic void set_dynamic(boolean dynamic)
dynamic - Indicates if the topology of this network is dynamic, because
sensors can sleep or not
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||