## 6 Signature Based Routing
However, if the latency of X consecutive packets stays more than the signature value then the gateways force the sender and the destination to follow their suggested path. (Here we assume that the gateways are fully aware of the network topology, node position and have the ability to calculate shortest path between the sender and the destination). The value of X can be fixed depending upon the requirements of the WSN or the application. Few applications require least possible latency so the value of X will be equal to 1, whereas some other applications are able to bear more latency so they will set the value of X equal to 2,3,4.... and so forth. Signature is defined as follows:  
\[S=\frac{\sum_{i=1}^{n}\varphi_{i}}{n} \tag{10}\]  
where \(S\) represents the signature, \(i\) represents the number of gateways in a WSN and \(\varphi\) represents the weighted average latency of each PAN calculated by individual gateways for their respective PANs. Each gateway keeps track of the end-to-end latency of every packet that goes through it, so \(\varphi\) is the average of all those latencies. To get an idea of overall latency of the complete network we take average of the sum of \(\varphi\) of all the PANs. It constitutes our signature. We can calculate the new value of \(\varphi\) :  
\[\varphi_{j}=\frac{w_{i}\times\varphi_{i}+x_{j}}{w_{i}+1} \tag{11}\]  
where \(x_{j}\) represents the current latency observation, \(\varphi_{j}\) represents the new signature value, \(\varphi_{i}\) represents the old signature value, and \(w_{i}\) represents the associated weight, the value of \(w_{i}\) is the number of previously recorded latency values excluding the current observation. Please note that weight helps to calculate a stable signature value. In order to understand the flow of information and decision process we can refer to Figure 13. It shows the flow after the packet arrives at the gateway. As shown in Figure 13, before enforcing the new routing path gateways first check topological information. The decision box \"near nodes\" means that gateways decide if the source and the destination nodes, under consideration, are close enough, in terms of number of hops. Let's say, there is a source to sink communication scenario where observed end-to-end latency stays more than the signature value for \(X\) consecutive times. As explained earlier, this should trigger the new path enforcement process. Let's say the source and destination are on opposite ends of the two PANs. It means all wireless path, probable new path, might have more number of hops. This new path is expected to have more end to end latency as compared to original path. Therefore, gateways decide not to enforce the new path. On the contrary, if the source and the destination are close enough in terms of number of hops, they are expected to have less latency so gateways would enforce the new path. This phase is shown in figure 13 by the decision box \"Near nodes\". We now explain the SBR process in detail. We follow an example scenario. The process is divided into two phases for explanation purpose. The first phase involves the hotline assisted routing. The second phase deals with the newly enforced signature based routing. Latency is measured and compared for both the cases. A simulation is preformed for both the cases and will be discussed separately with each phase (Please note that the detailed evaluation of SBR scheme will be discussed later in the evaluation section of the paper). All the nodes in a PAN send the packets to a fixed destination node of the other PAN. However, for the discussion purpose we follow one source to sink communication, so in Figure 14, S represents that source and D represents that destination. Figure 15 shows the corresponding simulation results showing all the sources sending packets to the destination, where the node that we are following is node 3 (_i.e.,_ node S). Figure 14a shows the topology information sharing phase where the gateways share their node information with each other.