## 3 Model and Background
### Data Aggregation and Integrity Detection
6: **if** the subMAC computed by \(N_{i}\) is not equals to which computed by the same MFN-group member monitoring nodes of \(A_{bq}\)  **then**\(A_{c}\) drops the data immediately and informs \(A_{bq}\) endfor Step 2. Aggregate the data. 1: \(A_{c}\) and each monitoring node \(M_{l}\) aggregate all the verified data it received (\(l=1\) to \(T\)). 2: \(A_{c}\) uses the key it shared with \(A_{n}\) to compute subMAC(FH(\(A_{c}\))). \(M_{l}\) uses the group key to compute subMAC(FH(\(M_{l}\))). Each \(M_{l}\) sends its subMAC(FH(\(M_{l}\))) to \(A_{c}\). 3: \(A_{c}\) forms a packet containing FH(\(A_{c}\)), subMAC(FH(\(A_{c}\))) and subMAC(FH(\(M_{l}\))) and sends it to its first forwarding node. Step 3. The forwarding nodes of \(A_{c}\) verify the integrity of the data during data transmission. for(\(j=1\) to \(h\))do  1: **if**\(F_{j}\) is not the member of MFN-groups  **then**\(F_{j}\) just transmits the packet it received to the next forwarding node or \(A_{n}\)  2: **else**\(F_{j}\) verifies the subMAC(FH(\(M_{l}\)))  3: **if** the verification is successful  **then**\(F_{j}\) transmits the packet to the next forwarding node or \(A_{n}\)  4: **else**\(F_{j}\) drops the packet and informs \(A_{c}\) about it endfor Step 4. Repeat the steps above, until the packet arrives at the base station. Relabel \(A_{c}\) and \(A_{n}\) as \(A_{b}\) and \(A_{c}\), respectively. Go to **Step 1** to repeat the steps, until the packet is transmitted to the base station. end for
```  
**Algorithm 3** Data aggregation and integrity detection algorithm  
**Algorithm 4** Data aggregation and integrity detection algorithm  
**Algorithm 5** Data aggregation and integrity detection algorithm  
**Remark 3**. : _The forwarding nodes of \(A_{c}\) verify the integrity of the data during data transmission._  
**Remark 4**. : _The forwarding nodes of \(A_{c}\) verify the integrity of the data during data transmission._  
**Remark 5**. : _The forwarding nodes of \(A_{c}\) verify the integrity of the data during data transmission._  
**Remark 6**. : _The forwarding nodes of \(A_{c}\) verify the integrity of the data during data transmission._  
**Remark 7**. : _The forwarding nodes of \(A_{c}\) verify the integrity of the data during data transmission._  
**Remark 8**. : _The forwarding nodes of 3. \(A_{c}\) collects these \(T+1\) subMACs to transmit to the next aggregator \(A_{n}\) along with aggregated data via forwarding nodes. When the forwarding nodes of \(A_{c}\) receive the packet, the node which is the group member of MFN-group, expressed as \(F_{j}\), computes the subMAC of the aggregated data which is aggregated by its corresponding monitoring node, and then matches this subMAC. If the verification fails, \(F_{j}\) discards this packet immediately and informs \(A_{c}\). Otherwise, if verification is successful, \(F_{j}\) forwards this packet. 4. When the packet arrives at the next aggregator \(A_{n}\), \(A_{n}\) verifies the subMAC which is calculated by \(A_{c}\). If this verification is successful, \(A_{c}\) and \(A_{n}\) are relabeled as \(A_{bq}\) and \(A_{c}\), respectively, then repeat step 1 to verify the data integrity during data aggregation.