1 Introduction

Wireless sensor networks (WSNs) have a large number of tiny, low-power sensor nodes, and those nodes are mainly for their low energy consumption, low cost and wireless communication [1]. Their role is noteworthy in many applications such as Military, Medical, Object Tracking and Nuclear Power Plant and Environment Monitoring. They lack security in many applications such as military sensing and tracking because of their resource constraint nature [2].

Jamming is a notable feature of denial-of-service (DoS) attacks. Jamming drives, electromagnetic energy towards a communication system to prevent signal transmission [3]. In WSNs, jamming interferes into the radio frequencies used by network nodes [4]. DoS attack as “any event that eliminates a network’s capacity to execute its normal function” [5]. According to Xu et al. [6] jammer can be categorized as follows:

  • Constant Jammer: The constant jammer gives out uninterrupted radio signals in the wireless medium. They do not tag on any underlying MAC protocol. They are inefficient

  • Deceptive Jammer: Deceptive jammer also has the features of constant jammer. The main difference is that the transmitted bits are not random in deceptive jammer. It is very effective, but like constant jammer, it is also inefficient

  • Random Jammer: The random jammer is dormant for an arbitrary time and blocks the signal for an arbitrary time. But it is more energy efficient than constant and deceptive jammers

  • Reactive Jammer: The reactive jammer listens to a movement on the channel, and in case of any movement, it sends out a signal immediately to crash with the existing signal on the channel. It is very effective, but like constant and deceptive jammers, it is also energy inefficient

Jamming is the main reason for many problems in the real-world applications. For example, in border security, an intruder has the ability to prevent the communication and cross the border without being detected. So in an unwanted environment, it is very important to detect the place where the channel is jammed [7] or deliver the messages out of the jammed area [7]. In this paper, optimization techniques to detect the place where jamming attacks are established. The previous studies show that detection of jamming attack is made by considering a substantial drop in the Packet Delivery Ratio (PDR) [5], [8], but it takes longer time. The selected research work focuses on quick detection of jamming attacks with the assistance of PDR, Energy, Distance, Packet Loss and Received Signal Strength (RSS) to determine the jamming attacks in WSN using meta-heuristic optimization techniques.

1.1 Metrics Selected for this Research Work

The selected metrics for this research work is PDR, Energy, Distance, Packet Loss and RSS. The reason for the selection have been discussed and summarized.

  1. 1.

    PDR and Packet Loss are very good metrics which are capable of being measured accurately by the node without any computational overhead. Existence of all types of jamming attacks can be shown by these metrics.

  2. 2.

    The energy and distance enable to decide whether the current path is capable of communicating with its neighbours or not.

1.2 Packet Delivery Ratio (PDR)

PDR is defined as the ratio of the number of successful transmission of packets to the total number of packets sent. The PDR can be calculated by counting the acknowledgements of the successful delivery packets and the total number of packets sent.

1.3 Energy

Energy can be defined as the amount of energy taken by sensor nodes at a period of time, and it can be calculated by measuring the fall in the power supply of the node and multiplying its squared value with the time duration and then by dividing the result with the average electrical resistance of the node [9].

1.4 Distance

Distance is a measure used by the routing protocol to calculate the best path to a given destination, if it learns multiple paths to the same destination [10].

1.5 Packet Loss

Packet loss occurs when one or more packets fail to reach desired destination [10].

1.6 Received Signal Strength (RSS)

The RSS is defined as the absolute power of the signal received at the destination side. It can be calculated using formulae as per the selected propagation model.

2 Background and Related Work

In [10], a fuzzy inference system-based jamming detection method is a centralized approach wherein the jamming detection is done in the base station based on the jamming detection metrics received from the respective nodes. Three inputs are used in the base station to compute PDPT and SNR values. To get ‘Jamming Index’ (JI) as output of the system, the base station uses the values of PDPT and SNR as inputs. The JI value varies from 0 to 100, signifying ‘No Jamming’ to ‘Absolute Jamming’, respectively.

In [11], the Ant System forms an agent (ant) that proactively makes use of the WSN node’s information and changes the route accordingly to avoid jamming by predicting it. Parameters such as hops, Energy, Distance, Packet Loss, SNR, Bit Error Rate and PDR affect the probability of selecting a specific path or solution. Limitations of the work are increased the computational and energy cost.

In [12], to defeat the reactive jamming, an immunological anti-jamming method based on adaptive immune system of human beings has been proposed by the author. The system consists of three function modules such as monitoring agent, decision agent and a recovery agent. A monitoring agent monitors the behaviour of its neighbours and sends results to the decision agents. The decision agent detects jamming attacks based on the features of known jamming attacks from the local jamming pattern database. The jamming pattern database gets updated when new jamming attacks are recognized by examining both abnormal behaviours of jammers’. Finally, recovery agents eliminate the impacts of jamming attacks through various mechanisms, such as path switching, direct sequence spread spectrum and frequency hopping spread spectrum.

In [13], the author considered four types of jamming such as interrupt jamming, activity jamming, scan jamming and pulse jamming. The counter measures proposed in this work are as follows: frame masking is a method to defend against interrupt jamming, where the sender and the receiver nodes agree on a secret pseudorandom sequence for the SFD in each packet. Frequency hopping is a method proposed for activity jamming. The author suggests packet fragmentation for scan jamming. Redundant encoding is the proposed method for pulse jamming. The limitation of the proposed work is increased the computational and energy cost. The proposed counter measure against interrupt jamming cannot defend against constant jammer.

In [5], JAM algorithm aids in detecting and mapping of jammed regions. Data are then simply routed around the jammed regions. The function of jamming detection module is to transmit jammed or unjammed message to its neighbour nodes. The jammed node will not be able to send any messages, if MAC protocols require a carrier sense to indicate a clear channel in order to have clearance for transmission. To cope with this problem, the MAC must provide a way to override carrier sense to allow broadcasting a brief, high-priority, unacknowledged message. The drawback of the proposed method is that it will fail if the attacker jams the entire WSN or a significant percentage of nodes.

In [9], Query-based jamming detection algorithm QUJDA is an anomaly-based approach used in this detection system. To compare the initial network conditions with the current network conditions, QUJDA uses the network parameters. The network parameters considered for jamming detection are PDR, bad packet ratio and energy consumption amount. The threshold values are determined to separate network from abnormal condition. The main drawback of this system is processing overhead due to too many parameters.

3 Artificial Bee Colony (ABC)

The ABC algorithm is a meta-heuristic algorithm depends on swarm intelligence instead of the evolutionary process on the foraging behaviour of honey bee colonies. The algorithm contains three components, namely employee, unemployed foragers and food sources [1417]. ABC embodies three groups of artificial bees: employee foragers, onlookers and scouts. The first half of the colony has been occupied by the employee bees. The rest is occupied by the onlookers. Each employee bee depends on a specified food source. The number of employee bee and the number of food source are the same. In order to select a food source, the dance of the employee bees in the hive is analysed by the onlookers. The three rules of ABC search series are as follows:

  1. 1.

    Driving the employee bees to a food source and calculating the nectar quality

  2. 2.

    After getting the information from the employee bees, the onlookers select the food source and calculate the nectar quality

  3. 3.

    Deciding on the scout bees and directing them to the food source.

At the beginning stage, the positions of food sources are chosen randomly, and their nectar qualities are calculated [18]. The nectar information of the sources is sent to the bees in the dance region of the hive by the employee bees. The onlooker bee receives the information from the employee bees at the dance area to select food source.

A new food source is found by a scout bee at random to keep the deserted one back by the onlooker bees. The major steps are.

  1. 1.

    To initialize parameters

  2. 2.

    To repeat

  3. 3.

    To send the employee bees to the food sources

  4. 4.

    To place the onlooker bees on the food sources depending on their nectar amounts

  5. 5.

    To send the scouts to the search new food sources

  6. 6.

    To memorize the best food source

  7. 7.

    Repeat until the requirements are met.

The quantity of nectar in a food source is linked to the quality of the related solution [18], [19]. The number of food sources is equal to the number of employee bees or onlookers.

4 Mathematical Model for ABC

Initially, a topology which consists of 100 wireless sensor nodes is made into a network design. The network assumptions considered for this research work are (1) Nodes with varied energy level, (2) The threshold for each node is different, (3) The distance taken by the agent depends on breathe nodes and (4) Node is punished when the PDR is low and signal-to-noise ratio is high.

The employee bees and onlooker bees are the control parameters which are set up into each node to collect information and to update the status of each node in the network. Such that the initial steps to make up a communication are of, Scouts bees are sent onto the initial food source. Then the employee bees sent onto each node to determine their fitness value using the probability value p(i). In [21], the following steps describe the procedure of ABC.

The generating solution for employee bee is given in Eq. (1):

$$ z_{j} \left( i \right) = {\text{LV}}_{j} + \left( {{\text{UV}}_{j} - {\text{LV}}_{j} } \right)\; \times \;r,\quad r \, = \, \left[ {0, \, 1} \right], \, j = 1, \, 2 \ldots .n \, and \, i = 1 \ldots ..M \, , $$
(1)

where \( z_{j} \left( i \right) \) represents the parameter for the jth employee bee on the ith dimension of the M dimensions, n represents the number of employee bee and \( {\text{UV}}_{j} \) and \( {\text{LV}}_{j} \) are the upper and lower vaults for \( z_{j} \left( i \right) \).

The food position for the onlooker and employee bees are given in Eq. (2):

$$ z_{j}^{'} \left( i \right) = z_{j} \left( i \right) + \varphi \left( {z_{j} \left( i \right) - z_{k} \left( i \right)} \right),\quad i = 1 \ldots ..M, \, k = 1 \ldots n \, and \, k \, \ne \, i, $$
(2)

where \( z_{j}^{'} \left( i \right) \) represents the new solution for \( z_{j} \left( i \right) \), \( z_{k} \left( i \right) \) represents the neighbour bee and \( \varphi \). nerates a uniform random number between −1 and 1.

The selection probability of the jth employee bee is calculated using the Eq. (3):

$$ p\left( i \right) = \frac{{{\text{fit}}\left( j \right)}}{{\sum\nolimits_{i = 1}^{N} {{\text{fit}}\left( i \right)} }}, $$
(3)

where \( {\text{fit}}(j) \). represents the fitness value and it is given by of Distance (\( {\text{D}}_{ij} \)), Energy (\( {\text{En}}_{ij} \)), Signal-to-noise ratio (\( {\text{SNR}}_{ij} \)), PDR (\( {\text{Pdr}}_{ij} \)) and Packet losss (\( {\text{Pl}}_{ij} \)) [21].

$$ {\text{fit}}(i) = {\text{D}}_{ij} \times {\text{En}}_{ij} \times {\text{SNR}}_{ij} \times {\text{Pdr}}_{ij} \times {\text{Pl}}_{ij} . $$
(4)

Distance is calculated initially when the wireless sensor nodes are set in the network is distributed in a 2D plane, using with Euclidean distance as,

$$ D_{ij} = \sqrt {\left( {X_{i} - X_{j} } \right)^{2} + \left( {Y_{i} - Y_{j} } \right)^{2} } , $$
(5)

where i is the source node, j is the destination node and (X i , Y j ) are the Cartesian coordinates of the node. When the jamming occurs, the alternative route is taken, which increases the hop count. As the hop count increases, the distance parameter increases, which detects the presence of jamming attack.

According to ABC algorithm, after all, employee bees complete the search process; they share the fitness information of the solution and their position information with the onlooker bees. An onlooker bee evaluates the fitness information taken from all employee bees and chooses a solution with a probability related to its fitness value and additional parameter signal strength.

After sharing their information with onlookers, every employee bee goes to the solution area visited by it at the previous cycle since that solution exists in memory. Then fitness of a resolution is abandoned by the bees; a novel solution is randomly found by a scout bee and replaced with the forsaken one. In the model, at each cycle, at most one scout is broadcasted for searching a new solution, and the number of employed and onlooker bees is selected to be equal to each other.

Pseudocode for detecting jamming attack using abc algorithm:

5 Performance Evaluation

5.1 Simulation Setup

To evaluate the performance of the proposed method with the presence of jamming attacks, a square grid network and different types of jammers [9] are established in an experimental environment. Different values of the following parameters are selected to adjust the attacking strength of those jammers: jamming range and number of jammers. The proposed detection and defence mechanism are simulated with the help of grTheory toolbox in MATLAB. The performance of the network could be analysed by considering varied Jamming-to-signal ratio (J/S), energy-to-jamming density ratio, energy-to-noise density ratio and multi-path interference. The radio-propagation model and the antenna model are taken for this system are Omni-antenna and Two Ray Ground model, respectively [20]. A classical reactive routing protocol called ad hoc on-demand distance vector is considered for this work. A square grid of 100 immobile nodes (numbered from node 0 to node 99 column by column) is found in the simulated network. Node 0 is the source node and node 100 that spots on the opposite of node 0 is the destination node, where data flow starts at simulation time of 20s.

The source node originates user datagram protocol /constant bit rate flows with a packet size of 1024 bytes and a transmission rate of 0.02 Mbps to its intended destination, and for jammer, the packet size and transmission rate are varied. More simulation parameters are listed as follows: Frequency, wavelength and antenna gain are set to 864.536 MHz, 0.424 m and 1.5 dB, respectively. The MAC protocol used in this proposed method is BMAC. The transmitted power of a sensor network is 8.56 × 10–4 W, and for jammer, it is varied. The received sensitivity and path loss are 3.652 × 10–4 W and 1.5 dB. Initially, the number of jammed nodes in a period t seconds is 12. Hence, the number of nodes jammed is 12 out of 100 in the network. Similarly, in each case nodes are jammed for t seconds.

The jammer was programmed to transmit at the same power level as the node which is power level 1. Figure 1 shows the square grid 100 node WSNs topology and the jammer’s various positions for testing the protocol. Depending on the position of a node in the network, the number of neighbours for a node varied from 6 to 14 nodes. Although the nodes were not time synchronized, they were all running at the same interval of time. Nodes which lie on the edge of the network were having less number of neighbours, and nodes which lie in the network were having more number of neighbours. Tests were carried out to record the detection time, detection rate and the false alarm rate of the protocol.

Fig. 1
figure 1

Proposed square grid 100 node WSN network

5.2 Simulation Results

Figures 2, 3, 4, 5 illustrate scenarios using different types of jammer and the performance of the network based on the energy depleted, distance, packet loss and PDR. The proposed ABC technique is evaluated with the results of particle swam optimization (PSO) and Ant System. From the result, the proposed method detects jamming attacks by checking the Energy, Distance, Packet Loss and PDR and investigating the abnormal behaviour of neighbours radio signals. Then the proposed method recovers the network from jamming attacks using path switching. Thus, the proposed method is effective to protect the network from attacks launched by different jammers. Comparative results are presented in Figs. 2, 3, 4, 5. From the figure, the superiority of the ABC technique of jamming attack has been proved. Table 1 shows the Characteristics and features of proposed anti-jamming schemes.

Fig. 2
figure 2

Comparison of ABC with PSO and Ant System by means of Energy

Fig. 3
figure 3

Comparison of ABC with PSO and Ant System by means of Distance

Fig. 4
figure 4

Comparison of ABC with PSO and Ant System by means of Packet Loss

Fig. 5
figure 5

Comparison of ABC with PSO and Ant System by means of Packet Delivery Ratio

Table 1 Characteristics and features of proposed anti-jamming schemes

6 Conclusion

This paper proposes a novel method to detect jamming attack using artificial bee colony a meta-heuristic algorithm. The performance parameters such as Energy, Distance, Packet Loss, and PDR influence the decision taken in anti-jamming techniques. The formulation of DoS attack based on each layer can be combined to optimize the attacks using a simple optimization algorithm. The proposed algorithms can separate network conditions caused by various types of jammers or caused by natural sources from each other along with high detection rate and low false positive rate. Another advantage is that no additional hardware is required to implement the algorithms on existing wireless sensor nodes. In the next study planned, the algorithms will be implemented on real world sensor networks and, thus, the performance achievement of the algorithms in a real environment will be elaborated.