## 4 Enhanced Objective Function for Routing in Agricultural Low-Power and Lossy Network
### Energy-Aware Metrics and Objective Function of IPv6 Routing Protocol for A-LLNs  
The energy-aware metrics and OF of IPv6 Routing Protocol for A-LLNs (RPAL) are designed with the following purposes: to mitigate the effects of packet losses and electromagnetic interferences in A-LLNs when they are deployed in harsh environments (e.g., field tests); to balance the energy consumption and prolong the A-LLNs lifetime. As an enhanced version of RPL framework, RPAL can identify and mitigate the energy hole problem. In other words, this proposal is able to avoid congestion or route overuse that will lead to the premature death of A-LLN nodes. Two metrics, namely ETX and RE, which can be organized in a lexicographic manner [37], can ensure the preferred parent selection is more efficient. On the one hand, integrating ETX metric can guarantee that RPAL routers can select the node within enough reliable paths to DODAG root to be its preferred parent. On the other hand, Remained Energy (RE) metric on each node with energetic considerations in the construction of DODAG and preferred parent selection is also combined. Under the help of RE estimated method (_i.e._, PowerTrace model [62]), RPAL model can promote energy balance while still choosing reliable and efficient routing paths. Moreover, RPAL OF algorithm makes use of ETX and RE metrics efficiently to increase A-LLNs lifetime. One A-LLN with seven sensor nodes and one sink is located as shown in Figure 1 where the A-LLN nodes are equipped with agricultural sensors, periodically send monitoring data to the sink. We firstly assume that this is a stable network and the links are symmetric. Only SN1, SN2 and SN3 are in the radio range of the sink and can forward the messages from the other four nodes. Each node has three attributes: Rank, link ETX, and RE. If MrhOF and ETX metrics are used to build routing paths to the sink, SN4, SN6 and SN7 will choose SN2 as their best parent due to its lowest ETX. Consequently, SN2 will deplete its energy faster and become inactive, and the network cannot respond properly to subsequent messages. To overcome this hotspot issue, the RPAL OF algorithm takes the available energy into account. Namely, two routing metrics, ETX and RE of each node are used to compute the best path to the sink. Here is the principle of preferred parent selection: each node chooses its forwarders from its neighbors which have feasible links to the sink. Then from this subset, two nodes having maximum RE are selected to become the best and backup parents of this node. Maximum path residual energy calculation like ELR and MMBCR [63] is used in RPAL OF. Essentially, this metric can avoid the routes traversing the nodes which have the least battery capacity among all possible routes [64]. A DODAG Information Object (DIO) control message [10] is the carrier of ETX and RE metrics. The ETX value is measured by the link layer. ETX of a sink node (SN1 in Figure 1) is zero and the energy of the sink node is constant at 100%. The RE value is represented in percentage values rather than in joules units, so only one byte is required. ETX and RE are reflected in the metric containers [10] defined by ROLL WG and embedded in the options part of the DIO format. Figure 2 presents the RPAL OF algorithm that is also an extension based on the ContikiRPL OF [65]. It assumes there are at least two neighbors/parent candidates for this router/leaf node. The parameters ETX_Threshold and RE_Threshold are re-configurable and dependent on A-LLN's application. The ETX_Threshold represents the maximum level of ETX value considered as a best parent candidate. It is pertinent to packet E2 ED, and depends on the application QoS requirements. The RE_Threshold is the minimum difference of RE for a node to trigger the best parent switch. These two values introduce a configurable level of hysteresis in order to conduct the preferred parents updating, so RPAL OF could be configurable for the specific PA application.