## 4 Mobility Model of the MS
### Optimization Method
Predicting and preselecting the HN occurs in the phase of allowing the MS to CH to send data by sending the ALLOW_SENDING packet. This phase allows reducing the handover delay compared to BMAC-H, in which CH launches the search of the relay node when the MS is about to leave the radio range of CH. We discuss in detail the phase of predicting the HN further below. In some cases, MS may leave the radio range of the HN without transferring all the handover data from CH due to a large amount of data. The proposed CLR-MSPH deals with this problem by allowing HN to process the handover mechanism. In this case, HN processes a similar handover to the BMAC-H (Algorithm 3), where HN broadcasts a HANDOVER_REQUEST, and it sets a timer to receives all possible HANDOVER_RESPONSE from other nodes in order to select the suitable relay node to process handover data. By allowing HN processes the handover mechanism, CLR-MSPH may perform in three hop routing. The communication between the MS and nodes keep till the RSSI value is \(-93\) dBm (tested in the Omnet++/Castalia [32] simulator; the last ACK received is with a \(-93\) dBm RSSI value). In this work, we set the threshold to \(-90\) dBm to perform the handover process. Therefore, we introduce a controlling mechanism for transmitting stored data in the buffer to MS (Algorithm 5). We make the CH and HN check their buffers while they are sending data to MS and receiving acknowledgments (ACK) of data from the MS (line 1, Algorithm 5). If the RSSI value of ACK message is restricted between \(-90\) dBm and \(-92\) dBm (line 2, Algorithm 5) and the size of the buffer is less than PDR (the default packets delivery rate is 5 pcks/sec), CH or HN continues sending data to MS without performing handover (line 3, Algorithm 5). We believe that it is not necessary to handover a small amount of data in the buffer while it is convenient and enough to send them in this interval of RSSI values. In addition, sending data using this controlling mechanism will reduce the latency (end-to-end delay), avoid the risk, and reduce the probability of losing data packets during the handover process. In the other hand, when the buffer of the CH has a large amount of data, CH performs the handover and transfers data to its HN (line 6, Algorithm 5). The same with the HN, where it performs the handover with the node which is selected by HN (line 8, Algorithm 5). ```
1 If (Buffer_Size() \(\leq\) PDR) Then
2 If(RSSI < -90) And(RSSI > -92) Then
3 Packet.setDestination(MS@);
4 Else
5 If(isCH) Then
6 Packet.setDestination(HN@);
7 If(isHN) Then
8 Packet.setDestination(Node@);/Node is selected by HN to handover data*/
9 EndIf
10 EndIf
```

**Algorithm 5** Control mechanism for transmitting data from buffer of CLR-MSPH

#### 5.2.1 Predicting Handover Node (HN)

The CH receives an ALLOW_SENDING packet with the next destination of the MS. This information helps the CH to predict the HN and to select it for routing the data in the case of CH does not finish transfer all the data in its buffer while the MS passes through its radio range. The CH already knows all the positions of its members thanks to the integration of this information into the JOIN_PACKET in the phase of forming clusters. Where each CM integrates into JOIN_PACKE, its ID and localization then it sends the joining packet to CH (Figure 4). To select the Handover Node (HN), CH performs the following:

1. Find all cluster members (CMs) which are in the same direction as the mobile sink (MS). 2. Calculate the distance between the CM (which are in the same direction as the MS) and the trajectory line of the MS.
3. Search for the closest CM to the trajectory line of the MS and select it as HN by sending the SELECTING_PACKET. (1) CMs in the same direction as MS

First of all, CH finds all the CMs who are in the same direction as the MS trajectory.