au.edu.usyd.corona.middleLayer
Class Clustering

java.lang.Object
  extended by au.edu.usyd.corona.middleLayer.Clustering
All Implemented Interfaces:
RoutingConstants

 class Clustering
extends java.lang.Object
implements RoutingConstants

This class implements the HEED clustering protocol as described in http://www.cs.purdue.edu/homes/fahmy/papers/tmc04.pdf. It also stores information about this nodes cluster head/cluster children.

Author:
Khaled Almi'ani, Raymes Khoury, Tim Dawborn

Field Summary
(package private) static int DEFAULT_INTER_CLUSTER_POWER_LEVEL
           
(package private) static int DEFAULT_INTRA_CLUSTER_POWER_LEVEL
           
 
Fields inherited from interface au.edu.usyd.corona.middleLayer.RoutingConstants
ACTION_ADD_REPLY, ACTION_ADD_START, ACTION_ADD_START_CLUSTERING, ACTION_ADD_WAITING_FOR_PARENTS_TIMEOUT, ACTION_BASE_CLUSTERING_START, ACTION_BASE_REGULAR_RE_ROUTE, ACTION_BASE_ROUTING_START, ACTION_CLUSTERING_CH_FINAL, ACTION_CLUSTERING_CH_JOIN, ACTION_CLUSTERING_CH_TENTATIVE, ACTION_CLUSTERING_FINISHED, ACTION_CLUSTERING_STEP2, ACTION_CLUSTERING_STEP3, ACTION_DEAD_NODE, ACTION_FORCED_CLUSTERING_START, ACTION_FORCED_ROUTING_MAKE_CHILD, ACTION_FORCED_ROUTING_START, ACTION_FORCED_WAITING_FOR_PARENTS_FINAL_TIMEOUT, ACTION_FORCED_WAITING_FOR_PARENTS_TIMEOUT, ACTION_NODE_STATUS, ACTION_NOT_YOUR_PARENT, ACTION_REGULAR_HEARTBEAT, ACTION_SEND_HEIGHT, STATE_ADD_CLUSTERING, STATE_ADD_WAITING_FOR_PARENTS, STATE_FORCED_CLUSTERING, STATE_FORCED_WAITING_FOR_PARENTS, STATE_NO_ROUTE, STATE_NODE_DEAD, STATE_ROUTED_HEAD, STATE_ROUTED_MEMBER
 
Constructor Summary
Clustering()
           
 
Method Summary
(package private)  void addChild(long node)
          Add a child node
(package private)  void clearChildren()
          Remove all cluster children
 void doStep2(RoutingAction action)
          Run one iteration of step 2 of the clustering algorithm
(package private)  void doStep3(RoutingAction action)
           
(package private)  java.lang.Long[] getChildren()
          Return an array of children of this cluster head
(package private)  long getClusterHead()
          Return this nodes cluster head
(package private)  int getCost()
          Get the cost of this node to determine which cluster head to join
(package private)  int getInterClusterPowerLevel()
          Return the power level for inter-cluster communications
(package private)  int getIntraClusterPowerLevel()
          Return the power level to be used for intra-cluster communications
(package private)  int getNumberChildren()
          Return the number of children this cluster head has
(package private)  boolean hasChild(java.lang.Long node)
          Return whether this cluster head has a child with the given ID
(package private)  boolean hasChildren()
          Return whether this node has any cluster children
(package private)  boolean isClusterHead()
          True if this node is a cluster head, otherwise false
(package private)  void receiveCHFinal(RoutingAction action)
          Receive a final cluster head message from a cluster head.
(package private)  void receiveCHTentative(RoutingAction action)
          Receive a tentative cluster head message from a tentative cluster head.
(package private)  void removeChild(long node)
          Remove a cluster child
(package private)  void removeCost(long node)
          Remove the cost of a node, registered in the costs table
(package private)  void removeHead(long node)
          Remove a potential cluster head
(package private)  void resetState()
          Remove all cluster heads and children.
(package private)  void runHEED()
          Run the HEED clustering algorithm on this node.
(package private)  void sendClusterHeadMessage(byte type)
          Broadcast a cluster head message
(package private)  void sendClusterHeadMessage(byte type, long node)
          Send a cluster head message to a particular node
(package private)  void setInterClusterPowerLevel(int powerLevel)
           
(package private)  void setIntraClusterPowerLevel(int powerLevel)
           
(package private)  void updateCost(long node, int cost)
          Update the cost of a node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INTRA_CLUSTER_POWER_LEVEL

static final int DEFAULT_INTRA_CLUSTER_POWER_LEVEL
See Also:
Constant Field Values

DEFAULT_INTER_CLUSTER_POWER_LEVEL

static final int DEFAULT_INTER_CLUSTER_POWER_LEVEL
See Also:
Constant Field Values
Constructor Detail

Clustering

public Clustering()
Method Detail

resetState

void resetState()
Remove all cluster heads and children. Used during a force re-route


receiveCHFinal

void receiveCHFinal(RoutingAction action)
Receive a final cluster head message from a cluster head. Register the cluster head.

Parameters:
action - The routing message

receiveCHTentative

void receiveCHTentative(RoutingAction action)
Receive a tentative cluster head message from a tentative cluster head. Register the tentative cluster head.

Parameters:
action - The routing message

runHEED

void runHEED()
Run the HEED clustering algorithm on this node. Note that a basestation can never be a cluster head.


doStep2

public void doStep2(RoutingAction action)
Run one iteration of step 2 of the clustering algorithm

Parameters:
action - A routing message with the HEED values from the previous iteration of the algorithm

doStep3

void doStep3(RoutingAction action)

sendClusterHeadMessage

void sendClusterHeadMessage(byte type)
Broadcast a cluster head message

Parameters:
type - Tentative of Final cluster head

sendClusterHeadMessage

void sendClusterHeadMessage(byte type,
                            long node)
Send a cluster head message to a particular node

Parameters:
type - Tentative of Final cluster head
node - The node to send to

getCost

int getCost()
Get the cost of this node to determine which cluster head to join

Returns:
a cost function of this node

getClusterHead

long getClusterHead()
Return this nodes cluster head

Returns:
This nodes cluster head

getNumberChildren

int getNumberChildren()
Return the number of children this cluster head has

Returns:
The number of children this cluster head has

getChildren

java.lang.Long[] getChildren()
Return an array of children of this cluster head

Returns:
an array of child addresses of the cluster head

isClusterHead

boolean isClusterHead()
True if this node is a cluster head, otherwise false

Returns:
True if this node is a cluster head, otherwise false

hasChild

boolean hasChild(java.lang.Long node)
Return whether this cluster head has a child with the given ID

Parameters:
node - the node id of a potential cluster child
Returns:
true if the node is a cluster child, false otherwise

setIntraClusterPowerLevel

void setIntraClusterPowerLevel(int powerLevel)
Parameters:
powerLevel - the intracluster power level

setInterClusterPowerLevel

void setInterClusterPowerLevel(int powerLevel)
Parameters:
powerLevel - the intercluster power level

getIntraClusterPowerLevel

int getIntraClusterPowerLevel()
Return the power level to be used for intra-cluster communications

Returns:
the power level for intra-cluster communications

getInterClusterPowerLevel

int getInterClusterPowerLevel()
Return the power level for inter-cluster communications

Returns:
the power level for inter-cluster communications

removeHead

void removeHead(long node)
Remove a potential cluster head

Parameters:
node - The cluster head to remove

removeChild

void removeChild(long node)
Remove a cluster child

Parameters:
node - The cluster child to remove

updateCost

void updateCost(long node,
                int cost)
Update the cost of a node

Parameters:
node - The node to update
cost - The cost of the node

addChild

void addChild(long node)
Add a child node

Parameters:
node - The ID of the node to add as a child

clearChildren

void clearChildren()
Remove all cluster children


hasChildren

boolean hasChildren()
Return whether this node has any cluster children

Returns:
true if this node has any cluster children, false otherwise

removeCost

void removeCost(long node)
Remove the cost of a node, registered in the costs table

Parameters:
node - The cost of the node to remove