## 5 Proposed Model
### MTD-Based Secure Two-Way Routing  
After performing scheduling, the proposed work performs secure two-way routing to overcome the malicious routing attacks such as black-hole and wormhole attacks, respectively. For that, we have selected the optimal and secure routing paths using the proposed Secure and Optimal Routing Protocol (SORP), which involves metaheuristics algorithms named Alibaba and Forty Thieves (AFT) and Multi Criteria Decision Making (MCDM) algorithm. The AFT is responsible for selecting the multiple optimal routes based on metrics such as link stability, direction, trust, and energy, whereas the MCDM is responsible for ranking the selected multiple routes based on high link stability, high trust, and less cost. AFT-Based Multiple Optimal Route Selection  
At first, the possible route positions (ro) are initialized in the dim dimensional search space, which can be formulated as  
\[\text{ro}= \begin{bmatrix}\text{ro}_{1}^{1}&\text{ro}_{2}^{1}&\cdots&\text{ro}_{ \text{dim}}^{1}\\ \text{ro}_{1}^{2}&\text{ro}_{2}^{2}&\cdots&\text{ro}_{\text{dim}}^{2}\\ \vdots&\vdots&\vdots&\vdots\\ \text{ro}_{1}^{n}&\text{ro}_{1}^{n}&\cdots&\text{ro}_{\text{dim}}^{n}\\ \end{bmatrix}  \tag{22}\]  
From Equation (22), the position of possible routes in the SDWSN environment is denoted as \(\text{ro}_{\text{dim}}^{n}\) position of n-th route in dim. The formulation of route position population can be formulated as:  
\[\text{ro}^{j}=\text{lb}_{i}+\text{RA}\times\left(\text{up}_{i}-\text{lb}_{i}\right) \tag{23}\]  
From Equation (23), roi denotes the j-th route position, RA denotes the random number [0, 1], and up\({}_{i}\)and lb\({}_{i}\) denote the upper and lower bound functions, respectively. Among all the routes in the proposed SDWSN environment, the best routes with respect to the all the ro can be formulated as:\[\mathrm{b}^{\mathrm{ro}}= \begin{bmatrix}\mathrm{b}^{\mathrm{ro}1}_{\frac{1}{1}}& \mathrm{b}^{\mathrm{ro}1}_{\frac{2}{2}}&\cdots&\mathrm{b}^{\mathrm{ro}1}_{\mathrm{ dim}}\\ \mathrm{b}^{\mathrm{ro}2}_{\frac{1}{1}}&\mathrm{b}^{\mathrm{ro}2}_{\frac{1}{ 2}}&\cdots&\mathrm{b}^{\mathrm{ro}2}_{\mathrm{dim}}\\ \vdots&\vdots&\vdots&\vdots\\ \mathrm{b}^{\mathrm{ron}}_{1}&\mathrm{b}^{\mathrm{ron}}_{2}&\cdots&\mathrm{b}^ {\mathrm{ron}}_{\mathrm{dim}}\end{bmatrix}  \tag{24}\]  
From Equation (24), \(\mathrm{b}^{\mathrm{ron}}_{\mathrm{dim}}\) denotes the n-th best route among the routes of dimension dim. The fitness value of the route position can be assessed by:  
\[\mathrm{fi}= \begin{bmatrix}\mathrm{fi}^{1}\big{(}\mathrm{ro}^{1}_{1},\mathrm{ ro}^{1}_{2},\dots,\mathrm{ro}^{1}_{\mathrm{dim}}\big{)}\\ \mathrm{fi}^{2}\big{(}\mathrm{ro}^{2}_{1},\mathrm{ro}^{2}_{2},\dots,\mathrm{ro }^{2}_{\mathrm{dim}}\big{)}\\ \vdots\\ \mathrm{fi}^{n}\big{(}\mathrm{ro}^{n}_{1},\mathrm{ro}^{n}_{2},\dots,\mathrm{ro }^{n}_{\mathrm{dim}}\big{)}\end{bmatrix}  \tag{25}\]  
The array is used to store the fitness value of route positions in which the fitness value of the n-th route of dim is denoted as \(\mathrm{ro}^{n}_{\mathrm{dim}}\). There are three cases in which the optimal route can be obtained. In the first case, the best route can be obtained based on link stability and direction. In that case, the route positions are updated by:  
\[\mathrm{ro}^{j}_{\mathrm{t+1}}=\mathrm{glo}^{\mathrm{best}}+\Big{[}\mathrm{tdis }^{t}\Big{(}\mathrm{best}^{j}_{t}-\mathrm{b}^{\mathrm{ro}j}_{t}\Big{)}\mathrm{ RA}^{1}+\mathrm{tdis}^{t}\Big{(}\mathrm{b}^{\mathrm{ro}j}_{t}-\mathrm{b}^{\mathrm{rob}j}_{t} \Big{)}\mathrm{RA}^{2}\Big{]}\mathrm{sgn}(\mathrm{RA}-0.5) \tag{26}\]  
From Equation (26), \(\mathrm{ro}^{j}_{\mathrm{t+1}}\) denotes the j-th route position at t+1 iteration, \(\mathrm{b}^{\mathrm{ro}j}_{t}\) denotes the best route position among all the routes, the global best route based on link stability and direction can be denoted as \(\mathrm{glo}^{\mathrm{best}}\), \(\mathrm{b}^{\mathrm{rob}(j)}_{t}\) denotes the super best method to determine the optimal route, and the distance of tracking from the optimal route can be denoted as \(\mathrm{tdis}^{t}\).