Data structures for implementation of ACE
In MATLAB each element of the array is a structure with several fields.The fields can be added one at a time or an entire element can be added with a single statement. Structures can be declared using the struct command. Structures can be declared as needed and so can the fields.
Node has the struct array with fields:
· ID: The Identity number is generated for each node to distinguish from other nodes and their coordinates (X_coord, Y_coord) are required to locate their position.
· State: The nodes have three possible states: clustered, unclustered and cluster head. A cluster is the follower of one or more clusters and unclustered is not a follower of any cluster where as cluster head is leader of cluster. The state is to find out the status of the each node. Initially, all nodes are in unclustered state.
· Membership: The node can be follower of more than one cluster but can pick a single cluster when protocol is running to form a membership only at the end of protocol.
· X_coord: The X_coord coordinate locate the position of X_coord node and populate the array to generate random x coordinate for node.
· Y_coord: The Y_coord coordinate locate the position of Y_coord node and populate the array to generate random y coordinate for node.
Structure of cluster
Clustering of wireless sensor nodes that are randomly spread over an area will result in several numbers of clusters whose size will depend on the communication distance and the density of sensor nodes. The structure of a cluster is as shown below:
global cluster_id_global; cluster_id_global=struct('clusterID','');
cluster = struct('clusterID','','clusterHead',-1,'cluster_members',-1);
Cluster has the struct array with fields:
· Cluster ID
· Cluster members
· Cluster ID: To distinguish each cluster from other clusters unique cluster id is generated. Any number of clusters can be generated with unique cluster ID for each cluster.
· Cluster member: A cluster consists of a single node as cluster head also called as cluster leader and a number of nodes as followers. The nodes that are cluster followers are usually called as cluster members.
Each cluster comprise of a single cluster head and a several cluster member. The formation of cluster is purely based on self-elective process. Each cluster head will periodically POLL its followers to determine the best candidate to become the cluster head. The node that would have the greatest number of nodes as followers will be the best candidate for cluster head.