|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectes.ants.felixgm.trmsim_wsn.network.Sensor
public abstract class Sensor
This class models a sensor in a Wireless Sensor Network
A subclass of this class, modelling the specific sensors, has to be implemented in order to add a new Trust and Reputation Model
| Field Summary | |
|---|---|
protected static double |
_maxDistance
Maximum distance between two nodes in the network |
protected boolean |
activeState
Indicates if this sensor is currently active or in an idle state |
protected static boolean |
collusion
Indicates if a collusion among malicious sensors is built |
protected static boolean |
dynamic
Indicates if some sensors will switch off sometimes in order to save energy |
protected int |
id
Sensor's identifier |
protected static int |
idCount
Sensors' identifier counter |
protected java.util.Collection<Link> |
links
Outcoming links of this sensor |
protected int |
numRequests
Number of service requests provided by this sensor |
protected static int |
numRequestsThreshold
Number of service requests provided by this sensor after which it goes to sleep |
protected Outcome |
outcome
Last outcome of a performed transaction |
protected Service |
requiredService
Service requested by the clients |
protected java.util.HashMap<Service,java.lang.Double> |
servicesGoodness
Goodness of this sensor related to each provided service |
protected long |
transmittedDistance
Total distance travelled by the messages sent from this sensor |
protected static TRModel_WSN |
trmmodelWSN
Current Trust and Reputation model used by every Sensor |
protected double |
xPosition
X coordinate of this sensor |
protected double |
yPosition
Y coordinate of this sensor |
| Constructor Summary | |
|---|---|
Sensor()
Class Sensor constructor. |
|
Sensor(int id,
double x,
double y)
Class Sensor constructor |
|
| Method Summary | |
|---|---|
void |
addLink(Sensor sensor)
Adds a link to a given sensor |
void |
addService(Service service,
double goodness)
Adds a new service to the set of offered services of this sensor |
void |
addTransmittedDistance(long distance)
This method increases the total distance travelled by the messages sent from this sensor |
double |
distance(Sensor sensor)
Calculates the distance between this sensor and a given one |
boolean |
equals(Sensor node)
It indicates if this sensor is equal to a certain one, according to their id |
java.util.Collection<java.util.Vector<Sensor>> |
findSensors(ISearchCondition searchCondition)
This method finds the shortest paths from this Sensor to any reachable Sensor satisfying a given condition (inactive or idle sensors are excluded from any path) |
double |
get_goodness(Service service)
Gets the goodness of a given service |
int |
get_numServices()
Returns the number of services this sensor provides |
Outcome |
get_outcome()
Returns the last outcome of a performed transaction |
java.util.Collection<Service> |
get_services()
Returns a collection with the services this sensor provides |
long |
get_transmittedDistance()
Returns the total distance travelled by the messages sent from this sensor |
static TRModel_WSN |
get_TRModel_WSN()
Returns Current Trust and Reputation model used by every Sensor |
java.util.Collection<Sensor> |
getNeighbors()
Returns all the neighbors of this sensor, i.e., all the sensors reachable from this one, one step forward |
Service |
getService(java.lang.String service)
Returns the requested service or null if this sensor does not offer such service |
double |
getX()
Returns the X coordenate |
double |
getY()
Returns the Y coordenate |
int |
id()
Returns sensor's id. |
boolean |
isActive()
Indicates if this sensor is active or not |
boolean |
isNeighbor(Sensor sensor)
Indicates if a given sensor is neighbor of this one |
boolean |
offersService(Service service)
Indicates this sensor offers a certain service or not |
protected boolean |
offersService(java.lang.String service)
Indicates if a sensor offers a certain service or not |
void |
removeAllNeighbors()
Deletes all the neighbors of this sesnsor |
void |
removeLink(Sensor sensor)
Removes the link with a given sensor |
void |
removeService(Service service)
Removes a service from the set of offered services by this sensor |
abstract void |
reset()
This method resets a Sensor to its initial state |
static void |
resetId()
Resets the identifier counter to 1 |
void |
run()
This method uses the current trust and reputation model in order to find the most trustworthy server offering the required service. |
Service |
serve(Service service,
java.util.Vector<Sensor> path)
This method returns a requested service. |
void |
set_goodness(Service service,
double goodness)
Sets the goodness of a given service |
void |
set_requiredService(Service requiredService)
Update the client required Service. |
static void |
set_TRModel_WSN(TRModel_WSN TRModel_WSN)
This method sets the current Trust and Reputation model used by every Sensor |
void |
setActiveState(boolean active_state)
This method updates the state of this sensor |
static void |
setCollusion(boolean coll)
Update the collusion value. |
static void |
setDynamic(boolean dyn)
Update the dynamic value. |
static void |
setMaxDistance(double maxDistance)
This method sets the maximum distance between two nodes in the network |
java.lang.String |
toString()
This method returns a String representation of this sensor |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static boolean collusion
protected static boolean dynamic
protected static int idCount
protected int id
protected static double _maxDistance
protected double xPosition
protected double yPosition
protected java.util.Collection<Link> links
protected java.util.HashMap<Service,java.lang.Double> servicesGoodness
protected Service requiredService
protected boolean activeState
protected int numRequests
protected static final int numRequestsThreshold
protected static TRModel_WSN trmmodelWSN
protected Outcome outcome
protected long transmittedDistance
| Constructor Detail |
|---|
public Sensor()
public Sensor(int id,
double x,
double y)
id - Sesnor's identifierx - X coordinate of this sensory - Y coordinate of this sensor| Method Detail |
|---|
public void run()
This method uses the current trust and reputation model in order to find the most trustworthy server offering the required service. It requests that service to the server found and punishes or rewards it according to its satisfaction with the received service
run in interface java.lang.Runnable
public Service serve(Service service,
java.util.Vector<Sensor> path)
service - Requested servicepath - Path leading from the client requesting the service to the server providing it
public void addService(Service service,
double goodness)
service - The new service to be addedgoodness - The goodness when offering that new servicepublic void removeService(Service service)
service - Service to be removed from the set of offered services by this sensor
public double get_goodness(Service service)
throws java.lang.Exception
service - The service to get its goodness
java.lang.Exception - If this sensor does not offer the given service
public void set_goodness(Service service,
double goodness)
throws java.lang.Exception
service - The service to set its goodnessgoodness - The goodness to be set
java.lang.Exception - If this sensor does not offer the given servicepublic int get_numServices()
public java.util.Collection<Service> get_services()
public Service getService(java.lang.String service)
service - Yhe id of the service to be retrieved
public java.util.Collection<java.util.Vector<Sensor>> findSensors(ISearchCondition searchCondition)
searchCondition - Condition to be accomplished by a sensor in order to consider it "reachable"
public boolean offersService(Service service)
service - The asking service
protected boolean offersService(java.lang.String service)
service - The asking service's name
public java.util.Collection<Sensor> getNeighbors()
public void removeAllNeighbors()
public boolean isNeighbor(Sensor sensor)
sensor - The asking sensor
public void addLink(Sensor sensor)
sensor - Sensor to link topublic void removeLink(Sensor sensor)
sensor - Sensor to remove link withpublic double distance(Sensor sensor)
sensor - Sensor to calculate the distance from
public int id()
public double getX()
public double getY()
public long get_transmittedDistance()
public static TRModel_WSN get_TRModel_WSN()
public Outcome get_outcome()
public void setActiveState(boolean active_state)
active_state - New state of this sesnor: true if the new state is active, and false otherwisepublic static void setCollusion(boolean coll)
coll - New collusion value.public static void setDynamic(boolean dyn)
dyn - New dinamic value.public static void setMaxDistance(double maxDistance)
maxDistance - Maximum distance between two nodes in the networkpublic void set_requiredService(Service requiredService)
requiredService - New service.public static void set_TRModel_WSN(TRModel_WSN TRModel_WSN)
TRModel_WSN - New Trust and Reputation model used by every Sensorpublic boolean isActive()
public void addTransmittedDistance(long distance)
distance - Amount of distance to be addedpublic static void resetId()
public boolean equals(Sensor node)
node - Sensor to check its equality
public abstract void reset()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||