# New Detection Paradigms to Improve Wireless Sensor Network Performance under Jamming Attacks
## 4 Analysis of Results  
The results are tested in a grid of \(7\times 7\) with a collector node in the lower left corner, with 5 m between each node and its neighbor horizontally and vertically, see Figure 1. In this figure, we show three shading nodes, representing the three possible points of an attacker node. The traffic rate is 10 packets per second in every node. The jammer node is sending packets under reactive jamming. Table 1 describes the parameters of the simulations. Figure 1: Network grid. ```
Require nodes start; Require cont = 0; for all\(Node_{i}\)do Require set \(positionRingNode_{i}\); Require Calculate \(Energy_{i}\); Require Calculate \(ReTx_{i}\); Require Calculate \(CsmaRetries_{i}\); Require send HELLO packet with metrics information; if Algorithm == Extended Mechanism then Collector node sends broadcast to receive information of all nodes; Collector node sets metric values for each \(node_{i}\); Collector node compares each value per metric for each positionRing; while\(positionRingNode_{i}==positionRingNode_{x}\)do if\(Energy_{i}\)!=\([Energy_{x}min,Energy_{x}max]\)then cont++; endif if\(ReTx_{i}\)!=\([ReTx_{x}min,ReTx_{x}max]\)then cont++; endif if\(CsmaRetries_{i}\)!=\([CsmaRetries_{x}min,CsmaRetries_{x}max]\)then cont++; endif endwhile endif if Algorithm == Connected Mechanism then for all\(Node_{x}\) neighbor of \(Node_{i}\)do if\(Energy_{i}\)!=\([Energy_{x}min,Energy_{x}max]\)then cont++; endif if\(ReTx_{i}\)!=\([ReTx_{x}min,ReTx_{x}max]\)then cont++; endif if\(CsmaRetries_{i}\)!=\([CsmaRetries_{x}min,CsmaRetries_{x}max]\)then cont++; endif endfor if\(Cont>=2\)then Node\({}_{i}\) sends a control packet to every \(Node_{x}\); Node\({}_{x}\) deletes \(Node_{i}\) from its routing table; endif endfor endfor
```  
**Algorithm 1**Collaborative detection mechanism. WSNs are extensively studied with several network simulators that analyze various performance and energy consumption metrics. However, the use of these simulators aims at the analysis of some topologies or already defined and parametrized environments, as Network Simulator 2 (NS-2) [32]. We can also find network simulators as TOSSIM [33], that estimates the energy consumption while considering the batteries lifetime of the devices and set realistic scenarios with known platforms. This work enables us to build a network simulator based on an event-driven system where we have an approach to the Physical, MAC and, Network layers. Thus, we can simulate any topology, implementing several routing protocols, observe and count collisions, retransmissions, channel retries, and establish models to evaluate energy consumption techniques. Currently available simulators must have the possibility to allow flexibility for modifications to incorporate new protocols. Therefore, we designed and implemented a network simulator based on events using the C++ language. The simulator was conceived with the paradigm of object-oriented programming (OOP), where nodes are autonomous entities (objects) that have properties and functions as transmit, receive, and route packets. Simulation events are managed by a planner which serves as a \"task organizer\" for objects involved in the simulation. Some advantages of the C++ simulator are the speed of the program execution and the OOP that provides easiness of managing various classes as a separate entities that interact autonomously, for example, a node. We use this event-driven simulator based on C++ language reported in [34]. This is a network simulator with parameters of Physical, MAC and Network layers. There are two perspectives for forming the groups of nodes that deliver information for the self-aware jamming algorithm: Connected Mechanism and Extended Mechanism. In the Connected Mechanism the nodes are neighbors directly connected, and the values of performance parameters are obtained from them and compared with the actual parameters of the node in evaluation.