MATLAB: How to simulate a wireless sensor network with 500 homogeneous nodes in an area of 100 m X 100 m with a base station at fixed position (0,150) with unlimited energy residues and communication power ? and how to form clusters in this given network

leachsimulation of wsn

each node has initial energy = 2 joule
nodes send data packets of 500 bytes to cluster heads and cluster head sent data to base station if it can otherwise to cluster heads in the between itself and base station.
radio dissipates 50 nJ/bit to run the transmitter an receiver circuitry (Eelec) and 100 pJ/bit/m^2 for transmitter amplifier(Eamp).
energy that a node dissipates for the radio transmission of a message of K bits over a distance of d meters is
Etx = Eelec * k + Eamp * k*d^2
energy that a node dissipates for the radio reception of a message of K bits over a distance of d meters is
Etx = Eelec * k
All the network nodes, which are assumed to be located within the sensor field, are dynamically grouped into clusters. One of the nodes within every cluster is elected to be the cluster head of this cluster.
In order to elect a cluster head, the routing information and the energy spent in the network are formulated as a linear system, the solution of which is computed using the Gaussian elimination algorithm. Therefore, cluster heads are elected as the nodes that minimize the total energy consumption in the cluster.
1.The BS creates a Time Division Multiple Access (TDMA) schedule and requests the nodes to advertise themselves, a process similar to that of other protocols.
2. Each node broadcasts a message to advertise its energy level and location to its neighbors. Based on this exchanged information, each node sets up a neighbor information table that records the energy level and the positions of its neighbors and sends this table along with its corresponding information to its neighbors. This step is repeated until the information of all the nodes in the network is sent to the BS, allowing the BS to have a global knowledge of the network. At this step, all the nodes are cluster head candidates, and each node has a unique ID that is also included in the exchanged table.
3. As soon as the node advertisement is completed, the BS runs the Gaussian elimination algorithm and computes the number of rounds at which every node can be a cluster head, trying to maximize the network lifetime. In the first step of the cluster head selection, the BS chooses the nodes closest to itself to be the high level cluster heads. Moreover, some of the nodes from which the BS has not received any direct advertisement message are considered to be low level cluster heads. The overall number of nodes, which are assigned to be cluster heads, is 5% of the total number of the nodes in the network, as this can be helpful in achieving good performance in a homogeneous network with various parameter settings .
4. The BS broadcasts the unique IDs of the newly selected cluster heads, and their cluster members and the nodes use this information to form and enter a cluster. Therefore, each node has the knowledge of the number of times that it can be a cluster head and the number of times that it cannot. The BS runs the Gaussian elimination algorithm and computes the appropriate number of rounds that the nodes can be cluster heads and sends this information to the nodes.
5. The lower level cluster heads do not transmit directly to the BS. They use the upper level cluster heads as intermediate repeaters of their data to the BS.
6. Each cluster head creates a TDMA schedule and broadcasts this schedule to the nodes in its cluster, in order to inform each node of the timeslot that it can transmit. Moreover, the radio component of each node is allowed to be turned off at all time periods, except during its transmission time. 7. Then, the data transmission starts. The nodes, based on the allocated transmission time, send the data concerning the sensed events to their cluster head. The transmission power of every node is adjusted to the minimum necessary to reach its next hop neighbor.
8. Every lower level cluster head aggregates the data and then transmits the compressed data to the upper lever cluster heads until the data reaches the base station. A round of data transmission has been completed, and the protocol continues from step 4 for the next round.
9. In case that there is a change in the network topology, due to either a change in a node position or in the total dissipation of a node residual energy, the BS uses again the Gaussian elimination algorithm to determine the appropriate cluster head election
10. The execution of the protocol is terminated as soon as all the nodes in the network run out of energy.
Related Question