## 4 Proposed CH Selection Algorithm Based Bacterial Foraging Paradigm
### Proposed Energy-Transmission Boundary Range-Cognitive Routing Algorithm  
The proposed transmission-aware single hop to MS algorithm is a trajectory algorithm that is generated by selected visiting CHs by MS based on the proposed CH selection algorithm in Section 4.2. The objective of this algorithm is that the MS can navigate all of the CH nodes and collect the necessary information. The collected data is transmitted to BS. An exemplary MS trajectory showing all of these processes is shown in Figure 7.  
The important aspect of this proposed algorithm is to reduce the tour time and the length that MS travels. In this sense, the penetration of the MS into the transmission range of the CHs will be sufficient to acquire data, as seen transmission range points from Figure 7. This means that it does not need to enter the exact position of the CH in the clusters that have different sensor node numbers. Accordingly, in a delay-aware method, the MS trajectory will occur. Afterwards, MS delivers all of the collected and aggregated data (\(M\_CDA\)) to the base station (BS). Thanks to BS, the data are saved as data or information to databases. Finally, someone who wants to view or use the data can access them from the computer or wireless channel. The pseudo-code of the proposed algorithm is provided in Algorithm 4. For route discovery CH(i) to MS, the routing packet format that is transferred in the network can be given in Figure 8 and a description of the routing packet seg  
Figure 7: A sample of Mobile Sink (MS) trajectory. ```
1:Input: Set of \(CH\)\([CH_{1},CH_{2},\ldots,CH_{n}]\). 2:Output: trajectory of MS.
3:Compute the path according to crusal method;
4:trajectory=crusal path;
5:limitArea=set of trajectory edges;
6:for\(i\)=1 to n do
7:\(x\) =0;
8:Dist=calculate RSSI distance between \(CH_{i}\) and MS;
9:ifDist\(\leq R(i)\)then
10:\(x\) =1;
11:limitArea=limitArea of trajectory;
12:endif
13:if\(x\) =1 then
14:if\(IP\
eq\varnothing\)then
15:\(CHofIP(i)=set\)\(of\)\(the\)\(closest\)\(IP\)\(for\)\(R(i)\);
16:endif
17:if\(CHofIP(i)=\varnothing\)then
18:\(IP=IP\) and \(CHofIP(i)\);
19:endif
20:endfor
```  
**Algorithm 4**Proposed energy-delay and transmission aware routing algorithm. **Illustration 7:** Intersection points are updated as \(IP=IP\)_and_\(CHofIP(i)\). Hence, d the best MS trajectories are obtained on behalf of energy aware transmission routing mechanism. According to Algorithm 4, the input values as a parameter are a set of CHs. The output is the trajectory belonging to MS (line 1-2). First, starting from the first CH, when considering the MS, a path is created with the crusal method, which is one of the minimum spanning tree algorithms. This path is assigned to the _trajectory_ (line 3-4). As seen on line 5 of the Algorithm 4, trajectory edges are recorded in the edge section called _limitArea_. For the CH number, the first \(x\) value is 0. This \(x\) value in the boolean data type determines whether the MS is in the CH transmission range or not. _Dist_ distance between CH and MS is measured (line 6-8). If this distance is less than or equal to the transmission range \(R(i)\), then the \(x\) value is set to 1 and the trajectory boundary edge is assigned to the previously defined _limitArea_ (line 9-11). These boundary edges describe the formation of a trajectory that may be sufficient by the joining of MS into the transmission range of the CH. This prevents delays resulting from navigating (delay-aware effect). Subsequently, if the value of \(x\) is 1, then the nearest called _intersection point_ (\(IP\)) is assigned to the cluster (\(CHofIP(i)\)), called the intersection point, which intersects the transmission