## 4 Mobility Model of the MS
### Optimization Method  
The tabu search algorithm is considered one of metaheuristic algorithms used to find optimal solutions for problems. This method is also used to solve the TSP problem, which is similar to the problem of finding the moving plan of the MS [30; 31]. Tabu search is based on a local search procedure to search for an improved solution from a potential solution using a neighborhood search function and tabu list to avoid dealing with solutions already obtained. The search for an optimal solution continues until a stop condition is reached. The role of Algorithm 1 is to find the best neighbor of a solution in the search space. In line 3 to 12, the algorithm searches the best cost in terms of distance of a solution by the permutation in the order of cluster heads in the itinerary of the MS (lines 5 and 6). Then it calculates the cost of the neighbor of the current solution (line 7). If the cost of this neighbor solution is better than the previous one and it is not in the tabu list (line 8), then this neighbor solution is selected as the best neighbor of the current solution (lines 9 and 10). After searching with all cluster heads, the best solution is returned as the best neighbor solution (line 14). ```
1\(Sol^{\prime}=Sol\); /*Initiate the \(Sol^{\prime}\) with the initial solution \(Sol\) */
2\(BestCost=f(Sol^{\prime})\); /* To calculate current cost*/
3 For(i=1 ToN) Do /*N is the number of Clusters*/
4 For(j=1 ToN) Do
5\(TempSol=Sol^{\prime}\); /* TempSol: Temporary Solution*/
6\(TempSol=\text{Permutation}\big{(}CH_{i},CH_{j}\big{)}\); /* Switching between Cluster Heads */
7\(BestTempCost=f(TempSol)\); /*The cost of TempSol */
8\(If(BestTempCost<BestCost)And(TempSol\
eq T)Then/*T\): Tabu List*/
9\(Sol^{\prime}=TempSol\) ;
10\(BestCost=BestTempCost\) ;
11\(EndIf\)
12\(EndFor\)
13\(EndFor\)
14 Return Sol*
```  
**Algorithm 1** Neighborhood Search  
Algorithm 2 is the main algorithm of tabu search. This algorithm is based on a tabu list to avoid dealing with the previous solution (line 3) and the number of the maximal number of iterations to search the best solution (line 4). First, an initial solution must be defined to process the Tabu search (line 1 and 2). While the number of iterations is still less than the maximal iteration number (line 5 to 13), the search of the best path for the MS passing by all CHs in the network is processing. In this search, the algorithm searches the best neighbor of the current solution, which is not tabu using Algorithm 1 (lines 6 to 10). At each iteration, the tabu list is updated (line 11). When the number of iterations reaches the maximal number, the algorithm returns the best solution found (line 14). ```
1\(Sol=IT\); /*Initial Solution: Initial Trajectory(IT) */
2\(f^{\prime}=f(Sol)\); /*Calculate the cost of the solution Sol using \(f\) (Objective Function) */
3\(T=\varnothing\); /* Initiate the tabu list */
4\(I=0\); \(I_{max}=i_{max}\); /* \(i_{max}\): The maximal number of iteration */
5 Repeat
6\(Sol^{\prime}=\) The best neighbor of the solution \(Sol\) is not tabu (Algorithm 1);
7\(If\)\((Sol^{\prime})<f(Sol)\)  Then
8\(Sol=Sol^{\prime}\);
9\(f^{\prime}=f(Sol)\);
10\(EndIf\)
11 Update the tabu list T;
12\(l\)++;
13 Until(StopCondition\((I=I_{max})\));
14 Return Sol. ```  
**Algorithm 3** The Algorithm Algorithm 3  
```
1\(Sol=IT\); /*Initial Solution: Initial Trajectory(IT) */
2\(f^{\prime}=f(Sol)\); /*Calculate the cost of the solution Sol using \(f\) (Objective Function) */
3\(T=\varnothing\); /* Initiate

==WARNING: Truncated because of repetitions==



+++

As in BMAC-H, the handover process of data starts when the last ACK frame received from MS with RSSI value less or equal to the RSSI threshold. At this moment, the CH sends data directly to HN, which is already selected by CH to handover data to MS (line 14, Algorithm 4). In the case where CH estimates that it cannot finish sending all data in its buffer and the MS starts leaving its radio range, CH sends the remaining data directly to the HN then HN routes them to MS in two hop routing.