## 4 Optimization Mechanism Design
### General Design of DDAR
#### Phase 1:  
Configuration of service tag  
Each aggregator identifies its service tag in this phase. The service requirements of all sensors in the pre-set range are counted, and the most frequent requirement is set as its service tag. If no sensor is near the aggregator, the aggregator determines its tag in phase 4. In Figure 6, aggregator \(\alpha\) communicates with the sensors a and b. As the requirement of these sensors is level 2, the tag of \(\alpha\) is set as 2. The sensors in aggregator \(\beta\)'s data collection range need level 1 service, \(\beta\)'s tag is set as 1. Figure 5: \(\rho\) vs. different value of service setting. Figure 6: The sample operations in phase 1 of DDAR. The process can be described by Algorithm 1. ```
1: Aggregator \(\sigma\) sends a broadcast message to sensors in its predetermined communication range to inquire the rank of service of each node. 2: Each sensor replies a message to inform the rank of service \(Q^{i}\) to the aggregator. 3:For each \(Q_{\varepsilon}\) received by the aggregator do
4:\(\quad\)q\(\left[l(Q_{\varepsilon})\right]\)++
5:End for
6: maxIndex = 0
7:For each q\(\left[l(Q_{\varepsilon})\right]\)do
8:If q\(\left[l(Q_{\varepsilon})\right]>\) q\(\left[\)maxIndex\(\right]\)then
9:\(\quad\)maxIndex = \(\left[l(Q_{\varepsilon})\right]\)
10:End if
11:\(\mathcal{S}_{\sigma}\) = maxIndex
```  
**Algorithm 1** Configuration of Service Tag of Aggregator \(\sigma\). _Phase 2:_ Configuration of \(N_{t}\) and \(T_{t}\)  
The parameters which dominate aggregation are aggregation timer and aggregation threshold, the average aggregation delay linearly increases as the aggregation timer or the aggregation threshold increases but is saturated at sufficiently large values of the aggregation timer or the aggregation threshold. After the identification of service tag, \(N_{t}\) and \(T_{t}\) are calculated. We design a formula for aggregators to configure \(N_{t}\) and \(T_{t}\) according to the tag, ensuring that the data service guarantee rates are suitable for comparison. The aggregators without tag don't configure \(N_{t}\) and \(T_{t}\) until they have a tag. The configuration formula of \(N_{t}\) and \(T_{t}\) is as follows (the formula of \(T_{t}\) is same as that of \(N_{t}\)). \[N_{t}^{i}=0.5*v(Q^{i})*\frac{1}{\eta}*P_{\alpha}*\lambda^{0.5} \tag{6}\]  
_Phase 3:_ Finding the corresponding aggregator  
Because of sensors' limited power, sensed data needs to be transmitted to the sink via aggregators. In this phase, sensors choose the aggregators which their data reaches. After the aggregators determine their service tag, each sensor broadcasts to all surrounding aggregators in sensors' data transmission range to inquire about their service tags. The requirement matching aggregator with the shortest distance is considered as the destination of the sensor's data transmission. If none, the sensor would from bad to good selects an aggregator with better service as its data's destination. If there is no node with a better service, the sensor from good to bad selects an aggregator with worse service. In Figure 7, aggregators in the data transmission range of a, b and c, d are \(\alpha\) and \(\beta\) separately. The tag of \(\alpha\) is same as the requirement of a and b, and the tag of \(\beta\) is same as the requirement of c and d. Therefore, a and b select \(\alpha\) as their data's destination, c and d select \(\beta\) as the destination. The process can be described by Algorithm 2. ```
1: Sensor \(\varepsilon\) sends a broadcast message to aggregators in its predetermined communication range to inquire the tag of service of each node. 2: Each aggregator replies a message to inform the tag of service \(\mathcal{S}_{\sigma}\) to the sensor.