# On Localized Countermeasure Against Reactive Jamming Attacks in Smart Grid Wireless Mesh Networks
## 5 Localized Trigger Identification Algorithm
### Trigger Nodes Detection Procedure
#### 5.2.1 Trigger Node Identification Based on Sequential Group Testing Algorithm (TNI-SGT)  
In accordance with the _TNI-SGT_ algorithm, the identification of trigger nodes has the time complexity of \(O(|C_{T}|\log\Delta)\) when \(C_{T}\) denotes the convex hull of triggers within a hexagon (see Figure 4). As a result, there are no more than \(\Delta+1\) devices in a certain hexagon, where \(\Delta\) indicates the maximum degree of all wireless devices in a Smart Grid wireless mesh network.  
We design an additional scheme named _Quick Identification_ so as to minimize the group testing rounds. As described in the Lemma 2, due to the fact that all the triggering devices within a hexagon invoke an identical jammer, a device is a trigger iff its location is at the intersection between any two hexagons with transmission range \(r\) whose center of transmission disk is the jamming device. The intersected convexity region guarantees that entire wireless devices within a triangle area established by three identified triggers are trigger devices as well. In essence, since all the wireless devices within the convex hull constructed by the identified triggers \(v_{1},\ldots,v_{k}\) are triggers as well, no further testing is required for those devices.  
Algorithm 2 describes the complete _TNI-SGT_. \(U\) and \(T\) represents a group of unidentified devices and identified triggers respectively in every step of the algorithm. We employ the ISTN algorithm to locate a single trigger device \(v_{t}\) among \(U\) that locates with the maximum distance to the arbitrary convex hull of \(T\). In addition, \(v_{t}\) must reside in the convex hull \(C_{T}\) of entire triggers inside the hexagon, which will be provided later.  
```
1 TNI_SGT Function \((U)\) Input : Wireless devices within a hexagon as a group of \(U\) Output : A group of identified triggers as \(T\) out of \(U\)
2/* Entire devices of a group \(N_{h}\) conduct the following procedure to identify triggers*/
3 Devices within \(U\) broadcast the message of \(TEST_{1}\) in the time slot of \(t_{test}\)
4 ifNo Detection on JammingSignal at \(t_{test}+\frac{r}{s}\) laterthen
5 Return \(T=\emptyset\) and terminate
6 end if
7\(T\leftarrow\emptyset\)
8\(v_{0}\gets IdentificationOfASingleTriggerNode(ConvexHull(U))\)
9/* In order to find a first trigger */
10\(U\gets U\setminus v_{0}\)
11\(T\leftarrow\{v_{0}\}\)
12 whileU is not empty setdo
13 /* Until every wireless devices to be identified either trigger or non-trigger */
14 forEvery device \(v_{i}\in U\)do
15\(d_{T}(v_{i})\leftarrow\) minimum distance between \(v_{i}\) and an exterior point of the \(ConvexHull(T)\)
16 end for
17 Ordering \(U=\{v_{1},\ldots,v_{|U|}\}\) such that \(d_{T}(v_{1})\leq\ldots\leq d_{T}(v_{|U|})\)
18\(v_{t}\gets IdentificationOfASingleTriggerNode(U)\)
19 /* Identify a single trigger \(v_{t}\) using \(IdentificationOfASingleTriggerNode(U)\) */
20 if\(v_{t}=\emptyset\)then
21 return\(T\)
22 /* Return \(T\) if trigger does not exists anymore */
23
24 end if
25\(U\gets U\setminus\{v_{t},\ldots,v_{|U|}\}\)
26 /*Quick Elimination of triggers to leverage the identification procedure of the testing */
27\(T\gets T\cup\{v_{t}\}\)
28\(T\gets T\cup\{\) devices within \(ConvexHull(T)\}\)
29 /*Quick Identification of triggers to leverage the identification procedure of the testing */
30\(U\gets U\setminus T\)
31
32 end for
33 return\(T\)
```  
**Algorithm 2**Trigger Node Identification based on Sequential Group Testing Algorithm (TNI-SGT)  
We would be able to remove all wireless devices whose locations from the convex hull of \(T\) are greater than that of \(v_{t}\). The algorithm of the _Quick Identification_ can reduce the testing latency by including all trigger devices inside the new convex hull of \(T\cup\{v_{t}\}\). After the classification of entire devices in each hexagon into non-triggers or triggers, the algorithm completes the testing procedure of identifying trigger nodes.