# Key Management Scheme Based on Route Planning of Mobile Sink in Wireless Sensor Networks
## 3 The Scheme Design
### Mobile Route Planning  
In traditional wireless sensor networks, cluster heads directly disseminate data to the base stations after completing data collection and fusion. The greatest disadvantage of directly transmitting the data to the base station from the cluster heads is that sometimes thius causes a larger energy consumption due to the long transmission distances. In this article, MS visits all cluster heads, which can shorten the data transmission distance of cluster heads, and meanwhile it can guarantee the quality of communication links, so the MS path planning problem becomes how to choose the optimal traversal path. Since a sensor node itself has a certain ability of communication, the MS does not have to move to the exact location of cluster heads for data collecting. It only needs to enter the communication range of the cluster heads, and then it implements the data interaction with the cluster heads. Therefore, this kind of mobile model can be abstracted as a TSP problem with neighbor areas, hence we name this kind of model the Traveling Salesman Problem with Neighbor areas (TSPN). A schematic of this kind of mobile route for MSs is shown in Figure 1.  
This scheme addresses the problem of path planning in TSPN by using a Genetic Algorithm due to its good global optimization search capability. The optimization goal is to make the MS first visit the cluster head whose cluster scale is larger, and simultaneously try to reduce the distance a MS has to move. As shown in Figure 2, the probability \(P_{A\to B}\) which presents the probability that a MS moves from cluster head \(A\) to the next stop cluster head \(B\) is defined as Equation (5):  
\[P_{A\to B}=\frac{Num_{C_{B}}}{\sum\limits_{k\
eq A}^{K}Num_{C_{k}}} \tag{5}\]  
where \(Num_{C_{B}}\) is the number of nodes in cluster \(B\), and \(\sum\limits_{k\
eq A}^{K}Num_{C_{k}}\) is the number of all nodes except for the nodes in cluster \(A\). The fitness function is defined as follows:  
\[F=(b\times f_{1}+(1-b)\times f_{2})^{m} \tag{6}\]  
\[f_{1}=1-\frac{len(i)-minlen}{maxlen-minlen} \tag{7}\]  
\[f_{2}=\frac{pro(i)-minpro}{maxpro-minpro} \tag{8}\]  
where \(f_{1}\) is the distance factor which impacts the movement of MS, \(len(i)\) (\(i=1\), \(2\),..., \(n\)) is the sum of distances for all the populations, \(maxlen\) is the maximum sum of route distances among all the populations, \(minlen\) is the minimum sum of route distances among all the populations, \(f_{2}\) is the probability of the route choice factor which influences the movement of \(MS\), \(pro(i)\) (\(i=1\), \(2\),..., \(n\)) is the sum of probabilities of the route choice for all the populations, \(maxpro\) is the maximum sum of the probabilities of the route choice among all the populations, \(minpro\) is the minimum sum of the  
Figure 1: The schematic of mobile route for MS in TSPN. probabilities of the route choice among all the populations, \(b\) is the weight coefficient, \(m\) is acceleration index to eliminate the fitness value, and it should not be given a larger value. The specific process of the route selection algorithm can be summed up as follows:  
1. Generate initial populations. The traversal sequence of cluster heads by MS is regarded as the coding of the algorithm. The initial route combination is a \(1\times N\) scale matrix (\(N\) contains \((N-1)\) cluster heads and a base station) generated randomly, and \(n\) initial populations are generated.Build distance matrix \(D\) and probability matrix \(P\). \(D(i,j)\) denotes the distance between cluster head \(i\) and cluster head \(j\), and \(D(i,j)=\sqrt{\left(x_{i}-x_{j}\right)^{2}+\left(y_{i}-y_{j}\right)^{2}}\). \(P(i,j)\) is the probability of route choice, and \(P(i,j)=Num_{C_{j}}/\sum\limits_{k\
eq i}^{K}C_{k}\). 2. Calculate the total length of all individuals path: _len(\(i\))_ and the total probability of route selection: _pro(\(i\))_. 3. Calculate the fitness values of all individuals by using Equations (6)-(8).