# UAV-Assisted Dynamic Clustering of Wireless Sensor Networks for Crop Health Monitoring
## 5 Three-Layer Architecture of the Developed System
### Discovery  
The UAV performs five main tasks in this phase including: beaconing, estimating the number of connected nodes, shunting, localizing and CH nomination, as explained in Figure 6.  
Figure 5: Multi-layer and multi-phase proposed system architecture.  
Let us suppose that the UAV is flying at a height \(D_{1}\) and initiates its data gathering process by sending a beacon \(B\big{(}T_{ys},D_{2},Th\big{)}\) containing the type \(T_{ys}\) of nodes required to activate for data collection, distance \(D_{2}\) at which it will collect data and \(Th\) which is the threshold to limit the activated nodes who will contest for the role of CH. Initially \(Th=0\) means all nodes can participate in the CH selection process. Suppose that there are \(n\) sensor nodes \(S=\{s_{1},\ s_{2},\ldots,s_{n}\}\) installed in a crop field. Assume \(O\) nodes become activated in response of UAV beacon such that \(1\leq O\leq n\) and \(SS=\big{\{}SS\subseteq S\big{|}SS\in T_{ys}\big{\}}=\big{\{}ss_{1},\ ss_{2}, \ldots,\ ss_{O}\big{\}}\). \(SS\) is the set of nodes that will make cluster in response of this beacon.  
If each active node \(SS_{i}\) has \(\delta_{i}\) bit data to transmit then \(T\delta\) represents the total size of cluster data, that is expected to be transmitted by the CH to the UAV:  
\[T\delta=T\delta(SS)=\sum_{i=0}^{O}\delta_{i} \tag{11}\]  
The energy required to transmit \(T\delta\) to UAV for distance \(D_{2}\) is:  
\[TE_{Tx}=\left(E_{dec}\times T\delta\right)+\left(E_{amp}\times T\delta\times \left(D_{2}\right)^{2}\right) \tag{12}\]  
where \(E_{dec}\) is the energy being dissipated to run the transmitter and \(E_{amp}\) is the energy dissipation to amplify the message up to \(D\) m.  
While UAV is in the discovery phase, activated ground sensors \(SS\) will be in setup phase to form a cluster. Every member of \(SS\) will calculate a Bayesian probability \(\mathrm{P}_{i}\) considering all its parameters (energy, consumption, antenna size, data size, etc.). A detailed discussion on Bayesian probability is given in Section 4. Based on \(E_{i}\), the energy of the node \(SS_{i}\), and \(\mathrm{P}_{i}\), the probability to be selected as CH, a further subset called candidate cluster heads of CCH. \(CCH=\big{\{}cch_{1},\ cch_{2},\ldots,cch_{q}\big{\}}\), where \(1\leq q\ \leq O\), is formed such that:  
\[CCH=\big{\{}CCH\subseteq SS\big{|}\forall\ E_{i_{current}}\ T\delta\ \&\ \mathrm{P}_{i}\big{\}}Th\big{\}} \tag{13}\]  
where \(E_{i_{current}}\) is the current energy of node \(i\).  
As described earlier, \(Th=0\) means any activated node having enough energy can be a member of the CCH.  
All CCH nodes start sending beacon replies to the UAV in the form of narrowband signals. At this point, UAV estimates the number of CCH (\(|CCH|=q\)). If the UAV estimates that \(q=0\) or \(q\geq m-1\), where \(m\) is the number of antenna elements on board, then the shunting process is started to keep the candidate cluster heads within a reasonable range; Otherwise, the UAV will locate all CCH nodes by using a special virtual phase array antenna developed for said purpose (a detailed model is given in Section 4). Based on CCH location and \(\mathrm{P}_{i}\) values, the UAV nominates a final CH and broadcasts a message to all nodes of set \(SS\) to inform them about the CH nomination.  
Figure 6: UAV discovery phase.  
Shunting is the important process of discovery phase to handle the situation when:  
\[q=0\text{ or }q\geq m\]  
If \(q=0\) or \(CCH=\varnothing\), it means no CCH member has the capability to send aggregated data to the UAV; In this case, shunting decreases \(D_{2}\) in steps down to a minimum height depending upon safe flight constraints.  
If \(q\geq m\) means there are many good CCH nodes and UAV cannot locate all at once; in this case, shunting can take three steps:  
* Increase antenna capacity from \(m\) to \(2m\),
* Increase \(D_{2}\) in steps up to the limit of \(F_{2}\),
* Increase \(Th\).  
Once a cluster head is selected the next phase of the UAV is navigation.