## 4 Enhancing the Dynamic Multi-Hop Routing (EDMR) Protocol
### The Routing Phase of the EDMR Protocol
#### 4.2.2 The Active/Sleep Sub-Phase
In this study, the TH was set to 0.03 as a design assumption. Upon receiving the broadcast message from the BS, the CH typically broadcasts a message instructing all cluster nodes to enter sleep mode, while the CH itself remains active throughout the remainder of the round. The main purpose of this procedure is to enable the CH to cooperate with other active CHs and INs in routing their data to the BS. Algorithm 3 presents the pseudocode for the static sleeping scenario. At this point, the new structure of the network comprises the active clusters, the INs, and the CHs of the deactivated clusters. They utilize their RTs to forward data toward the BS. During the round, updated messages are sent within each cluster (intra-cluster) to update the entries of the selection tables of the Ns, so that the routes may dynamically change during the round toward their CHs. Similarly, updated messages are broadcast across the levels to update the RTs of the CHs and the INs, which may also dynamically change their routes toward the BS. ```
Definitions \(\text{CH}[\text{m}]\) \(\in\) the set of CHs TH: Threshold value N: Normal node \(V_{new}\): the new data value \(V_{pre}\): the previously stored data value \(\Delta\): the relative difference
1: begin
2: for each (CH[m])
3: transmit \(V_{new}\) to the BS;
4: for each (\(V_{new}\) received by BS from CH[m])
5: Compute \(\Delta\);
6: if (\(\Delta<\text{TH}\))
7: mark cluster [m] as deactivated;
8: send broadcast message (CH[m]_ID, mode_bit = 1);
9: else
10: mark CH[m] as activated;
11: end if
12: end for
13: if (CH[m] received broadcast message from the BS)
14: CH[m] broadcasts a sleep message to its Ns;
15: Ns enter sleep mode;
16: remain CH[m] active;
17: else
18: remain Ns active;
19: end if
20: end for
```  
**Algorithm 3**Static Sleeping Scenario  
Dynamic Sleeping Scenario  
In this scenario, the WSN is used in applications that continuously require updates about the surrounding environment. Hence, it is essential for the proposed protocol to adapt to the expected environmental changes throughout the rounds. Furthermore, the proposed protocol assumes that each round consists of a fixed number of identical cycles. When the BS receives the aggregated data sent by the CHs during the initial routing sub-phase, it calculates \(\Delta\) and compares it with the TH. If \(\Delta\) is less than the TH, it indicates that the aggregated data lack significant information or do not reflect any noticeable changes. Consequently, the BS sets the mode bit to 1 (deactivated) and broadcasts messages to these CHs, instructing their corresponding clusters to enter sleep mode. In response, the CHs that receive such broadcast messages also notify their associated Ns to switch to sleep mode. Unlike the static scenario, the proposed protocol assumes that clusters in sleep mode do not remain inactive for the remainder of the round. From this perspective, the remainder of the round is also divided into cycles. A dynamic mechanism, proposed in this section, ensures that the deactivated clusters can wake up again during these cycles. The active clusters in the first cycle continue sensing the surrounding environment. The dynamic routing approach, as discussed in Section 3.2.4 (Intra-cluster Routing), is employed to forward the sensed data across the two levels toward the corresponding CH. The aggregated data from each cluster are then transmitted toward the BS. The inter-cluster transmission is also performed dynamically using the approach outlined in Section 3.2.4 (Inter-cluster Routing). By the end of the cycle, the BS has a clear understanding of the state of each cluster for the upcoming cycle. In other words, it determines which clusters should remain active, which should be reactivated, and which should be deactivated. At the beginning of each cycle, the BS periodically broadcasts control messages to activate the required clusters and deactivate those that are unnecessary for the current cycle.