## 4 Partition Aware-RPL Protocol Overview
### Parent Selection Algorithm
This can be practically done through disseminating this information into the DIO messages. We can also exploit the Metric container option [5] to dispatch the needed information. In addition, every sensing node has to save the attribute values of its currently used bridge as well. This should be done every time a new preferred parent is selected. Under the previous assumptions, our proposal can be formulated using Algorithm 1. This Algorithm is executed by every node \(S_{i}\) when it has to select one of two parent node candidates \(P_{1}\) and \(P_{2}\). The meaning of the different variables and methods used in Algorithm 1 are as follows:  
* \(P_{i}\): denotes a parent node structure which is in our case the DIO message sent by the node \(P_{i}\). Note here, that we conflate the parent and its derived DIO message (i.e., both denoted by \(P_{i}\)). * \(P_{i}.getColor()\): a getter to access the color of node \(P_{i}\). * \(P_{i}.getBrETX()\): a getter to access the path ETX value of the bridge of node \(P_{i}\). * \(myColor()\): a local method, invoked by the sensor node executing the algorithm (i.e., \(S_{i}\)) to get its color. * \(P_{i}.getBrId()\): a getter to get the Id of the bridge of node \(P_{i}\). * \(computeETX(P_{i})\): a local method, invoked by the sensor node executing the algorithm (i.e., \(S_{i}\)) to compute the path ETX if it selects \(P_{i}\) as a parent. * \(edgeld(S_{i},P_{j})\): a local method, invoked by the sensor node executing the algorithm (i.e., \(S_{i}\)) to compute an Id of the edge \(S_{i}\to P_{j}\). In our case, this method could be a simple concatenating operation of the two end-points Ids. In this algorithm, we can locate the two discussed main scenarios: The first goes from line 2 to line 17, and corresponds to two potential parents \(P_{1}\) and \(P_{2}\) located in a same parcel. The second situation matches the scenario where \(P_{1}\) and \(P_{2}\) are from two different parcels; and is treated in our algorithm from line 17 to line 39. Figure 5: Examples of parent selection situations. ```
1:This is an OF that selects the best parent between \(P_{1}\) and \(P_{2}\)* if\(P_{1}.getColor()==P_{2}.getColor()\)then//\(P_{1}\) and \(P_{2}\) are in the same parcel \(C\gets P_{1}.getColor()\) if\((myColor()==C)\)and\((P_{1}.getBrId()\
eq P_{2}.getBrId())\)then//\(1\)st case: all in the same parcel but \(P_{1}\) and \(P_{2}\) have different bridges \(P_{1}.getBrETX()\leq P_{2}.getBrETX()\)then//decision based on the ETX values of the bridges  return\(P_{1}\) else return\(P_{2}\) endif else//\(2\)nd case: both correspond to bridges or are using the same bridge if\(computeETX(P_{1})\leq computeETX(P_{2})\)then//decision based on the best local ETX return\(P_{1}\) else return\(P_{2}\) endif endif else//\(P_{1}\) and \(P_{2}\) are located in different parcels if\(P_{1}.getColor()==myColor()\)then//\(S_{i}\) and \(P_{1}\) are in the same parcel, and \(P_{2}\) forms a bridge if\(P_{1}.getBrId()==algeld(this,P_{2})\)then//\((S_{i}\to P_{2})\) is the bridge used by \(P_{1}\) remove\(P_{1}\) from the neighbor list return\(P_{2}\) else//\(S_{i}\) switches to \(P_{1}\) return\(P_{1}\) else//\(S_{i}\) switches to \(P_{2}\) return\(P_{2}\) endif else//\(P_{1}\) and \(P_{2}\) correspond to bridges from different parcels if\(computeETX(P_{1})\leq computeETX(P_{2})\)then//decision based on the best local ETX return\(P_{1}\) else return\(P_{2}\) endif endif endif
```  
**Algorithm 1** BestParent(\(P_{1},P_{2}\))  
```
### Illustrative Example

To better see how PA-RPL runs and builds its DODAG in a way that reflects the farmland layout, we decide to simulate various farmland scenarios. For that, we built our simulation on Cooja [26], known to have multilevel simulation capabilities. We randomly place 150 fixed sensor nodes, emulating the Tmote sky sensors [27], in an arbitrary chosen rectangular farmland of dimensions \(400\) m \(\times\)\(200\) m (i.e., 8 hectares). A sink node, destined to be the root of the DODAG, is placed in position \((10,110)\).