1 Introduction

The recent development in microelectronic technology and wireless communication has enabled the quick advances of low-cost, tiny, and multi-functional sensors. These sensors are distributed randomly in the target region and form a network called Wireless Sensor Network (WSN). WSN is used to observe any physical features of the surrounding environments like pressure, humidity, and temperature [1]. The sensed information should be transmitted to the sink in an efficient-way and then the sink relays the received information to a remote server for further data analysis. Mobile WSN (MWSN) is a type of WSN, in which sensors and/or sink are mobile. MWSN plays a vital role in today’s real-world applications such as military surveillance, meteorology, mining, disasters and seismic surveillance, monitoring harsh environments, smart homes, undersea navigation, healthcare applications, and agricultural and wildlife observation [2,3,4,5].

Besides the energy constraint of the traditional WSN, MWSN adds new challenges in aspects like packet delivery ratio and the unbalanced energy problem due to frequently moving of sensors. It is unrealistic for replacing the battery of the sensors due to their expensive cost and huge quantity. The best solution for the energy constraint problem is providing batteries of the sensors with massive capacity and introducing energy-efficient routing protocols [6]. On the other hand, the problem of unbalanced energy causes energy holes in which affects the packet delivery ratio of the network. Selecting the same nodes to be head of the cluster for a long time and using the static sink are the main two reasons for the unbalanced energy problem. The nodes around the static sink exhaust their energy faster due to relaying the information of the far sensors to the sink and cause a hot spot problem [7]. Due to frequently varying the topology of MWSNs, The challenge of the MWSN is how to trade-off between the consumption energy and the packet delivery ratio.

Varies clustering based routing protocols [8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26] are developed for MWSNs. These protocols can be grouped into three groups according to the mobile elements on the network namely sink mobility only [8,9,10,11, 13,14,15,16,17,18], nodes mobility only [12, 19,20,21,22,23,24,25], and mobility of sink and sensors together [26]. Most of the previous work focused on considering the mobility of sink or the mobility of sensor nodes and suffer from some restrictions in expended energy, mobility adapting, load balance, fault tolerance, and connectivity. However, considering both the mobility of sink and sensor nodes together did not pay the attention of authors. Therefore, this paper proposes Joint Nodes and Sink Mobility based Immune routing-Clustering protocol (JNSMIC) to avoid these restricted by utilizing the mobility of the sink and sensor nodes together. The main idea of the JNSMIC protocol is based on using the mobile sink for solving the hot spot problem and increasing the network security and also utilizing the Multi-Objective Immune Algorithm (MOIA) for clustering the network. In JNSMIC, the sensor field is divided into R regions and the mobile sink node moves to each region to collect data from the sensor nodes. At each region, the sink node uses the MOIA algorithm to determine its temporary location, the number and locations of CHs. The main contribution of this research can be summarized as follows:

  1. 1.

    Proposing an energy-efficient protocol, called JNSMIC based on the mobility of the sink and the sensor nodes in the network together.

  2. 2.

    Dividing the clustering stage into two phases; the candidate CHs are choosing in the first phase based on the residual energy and the mobility of sensor nodes. While in the second phase, the final CHs are determined using the MOIA algorithm.

  3. 3.

    Considering the consumption energy, network coverage and link connection time in the CH selection criterion.

  4. 4.

    Simulating the energy radio of the sensor nodes as a realistic model.

  5. 5.

    Studying the effect of varying velocity and number of mobile sensor nodes on the performance of JNSMIC protocol using different experiments.

This research is regulated as follows: In Sect. 2, related work is introduced. The preliminaries and objectives are exhibited in Sect. 3. Joint Nodes and Sink Mobility based Immune routing-Clustering protocol (JNSMIC) is demonstrated in Sect. 4. Simulation results are illustrated in Sect. 5. Finally, the conclusion is included in Sect. 6.

2 Related Work

According to literature, different clustering protocols were developed to support the mobility of the MWSNs. These protocols can be grouped into mobile sink supporting protocols [8,9,10,11, 13,14,15,16,17,18], mobile sensors supporting protocols [12, 19,20,21,22,23,24,25] and mobile sink and sensors supporting protocols [26]. In [8], a distributed load balanced clustering and dual data uploading protocol (LBC-DDU) was suggested. The idea of LBC-DDU is based on utilized a mobile collector called SenCar with two antennas for gathering data from CHs and transferring it for the static sink. A Tree-Cluster-Based Data-Gathering Algorithm (TCBDGA) with a mobile sink was developed in [9] for alleviating the hotspot problem. TCBDGA constructs a tree among the sensor nodes depending on a weighting of the distance to sink, the number of neighbors, and residual energy. The root nodes of the constructed trees are considered as the rendezvous points (stop points) of the mobile sink for data collection. Reference [15] presented a Mobile sink-based adaptive immune energy-efficient clustering (MSIEEP) protocol for improving the lifetime and solving the hot spot problem of WSN. The MSIEEP protocol divides the network into different regions and uses the Adaptive Immune Algorithm to determine the optimum location of the sink and the location of CHs in each region.

LEACH-M [19] is the first protocol supports the mobility of the sensor nodes in WSN. LEACH-M is based on assuming that CHs stay fixed on their location after choosing them. LEACH-M has a demerit that the moved sensor outside the cluster must wait for two consecutive timeslots until joining a new cluster. Therefore, this protocol is inefficient in the aspects of expended energy, throughput, and network lifetime. CBR-Mobile [20] also supports the mobility of sensors in the network by adopting mobility and traffic. It depends on assigning the same timeslot to two sensor nodes; original and alternative. Moreover, the CH can reassign the unused timeslot to another sensor in the cluster or for the incoming sensor from another cluster. This allows the disconnected sensors to join another cluster rabidly. In [21] the Mobility Adaptive Cross-layer Routing (MACRO) protocol was suggested to handle some main constraints in MWSNs such as packet delay, energy expenditure, and end-to-end reliability. The idea of MARCO protocol is reducing the undesirable auxiliary packets flooding by utilizing a route discovery approach, data forwarding, and route managing. Additionally, it considers the mobility of the sensor nodes and the link quality for selecting the best routes. However, the process of route discovery causes more delay because of the higher number of MSNs and frequently changed topology in large scale networks.

An Adjustable Range Based Immune hierarchy Clustering (ARBIC) protocol [22] was developed to transfer the sensed information from the MSNs to the sink efficiently for a long time. ARBIC protocol is based on organizing the network into optimum clusters and adapting the cluster size depending on the speed of mobile sensor nodes to conserve the connectivity of clusters. This protocol uses the immune optimization algorithm to compute the locations of the optimum CHs by considering link connection time, remaining energy, connectivity, and mobility factor in the clustering process. A fault tolerance process is occurred after transmitting each frame to deduce the drop of packets. For dealing with the mobility of both sensor nodes and sink, E2 R2 protocol was presented in [26]. This protocol partitions the network in clusters with selecting one CH and two deputy CH, in each cluster. In this protocol, the sink node chooses a set of probable CH sensors and forms the CH panel to reduce the expended energy and re-clustering time. The routing topology between CH nodes and the sink may be direct transmission or multi-hops. Therefore, the data packets move through suitable routes in spite of nodes mobility and frequent link failure. Furthermore, alternative paths are used for transmitting the data between a CH and a sink in case of a path failure. This protocol preserves energy consumption at a low level, but the throughput reduces when the data rate increases. Due to a lack of work for considering the mobility of sink and sensor nodes together, this paper proposes a new protocol called JNSMIC to support the mobility of the sink and the sensor nodes. The idea of the JNSMIC protocol depends on using the mobile sink for solving the hot spot problem and the Multi-Objective Immune Algorithm (MOIA) for clustering the network and finding the visiting locations of the mobile sink.

3 Preliminaries and Objective Function

The network composes of a mobile sink node which is a resource-rich device and N sensor nodes with initial energy E0 distributed randomly in \( \left( {A_{1} \times A_{2} } \right) \) sensor field. These N sensor nodes are a mixture of static and mobile nodes. The MWSN is partitioned into four equal-sized regions \( \left( {R = 4} \right) \) as shown in Fig. 1. Each region r \( \left( {r = 1,2, \ldots ,R} \right) \) is splitted into Lr clusters while an essential CH and deputy CH are assigned for each cluster to receive the sensory information from its members. The CH merges the received information into one frame and sends it to the sink via relayed CHs nodes when it visits the region r.

Fig. 1
figure 1

Sink mobility pattern

3.1 Preliminaries

To establish the proposed JNSMIC protocol, the following assumptions are considered for the network model:

  • The radio channel is symmetric which means that the same power is consumed for transmitting and receiving a message for the same distance.

  • The velocity, direction, and location of each sensor node can be estimated by localization algorithms [27].

  • The information of intra-cluster is highly correlated and can even be assembled, while the information of inter-cluster range cannot be merged because it is uncorrelated.

  • To guarantee the complete network connectivity, the radio range Rr of the sensors for communicating between clusters must be adjusted to at least twice larger than the transmission range Rt of nodes for communicating within the cluster [28].

3.2 Objective Function

The challenge of the MWSN is how to trade-off between the consumption energy and the packet delivery ratio to design an energy-efficient network. This challenge leads us to design a reliable energy-efficient clustering protocol with a mobile sink. Finding the number and location of CHs and the visiting location of the mobile sink in each region subject to reducing the communicating cost, improving the packet delivery ratio and balancing the loads among the sensors is a multi-objective problem. Thus, the proposed protocol utilizes the MOIA algorithm to solve the mentioned problem by harmonizing the intrinsic characteristics variations in the network such as offered load, connectivity, and mobility in its objective function as follows:

Objective 1

Reducing the total expended energy in the communication process.

The communication process consumes the most energy of sensor nodes. In contrast to the previous protocols [8,9,10, 13, 15, 19, 20] that modelled the radio of sensor node as the first-order model, a realistic radio model is considered here. In this model, each sensor node can modify its radio transmission power according to the changes in the transmission distance for sending its data packet. The control packets need maximum energy to be sent. Each node has four power modes, namely receive, transmit, sleep, and idle mode with expended power \( P_{Rx} , P_{Tx} \;P_{sleep} , \) and \( P_{idle} \), respectively. Therefore, the state of sensor nodes and the transmission distance affects the energy expended in the network. Assuming each region r is divided into Lr clusters while the positions of CHs are \( \left( {p_{r} = \left\{ {\left( {x_{1} ,y_{1} } \right), \ldots ,\left( {x_{{L_{r} }} ,y_{{L_{r} }} } \right)} \right\}} \right) \) and each cluster contains \( m_{i} \left( {i = 1, 2, 3, \ldots ,L_{r} } \right) \) member nodes (MN). Each MN generates data packet with length k –bits by a rate Rb (bps) and transmits it to its associated CH by setting its radio to ‘ON’ state during its allocated timeslot (TS) and then going to sleep mode in the other TSs. Therefore, the expended energy in any MN in the cluster is given by:

$$ E_{MN } = E_{Tx} + E_{idle} + E_{sleep} = \left\{ {T_{d} P_{Tx} } \right\} + \left\{ {\left( {T_{slot} - T_{d} } \right)P_{idle} } \right\} + \left\{ {\left( {T_{fr} \left( {\text{i}} \right) - T_{slot} } \right)P_{sleep} } \right\} $$
(1)

where Tslot is the timeslot period, \( T_{d} = K/ R_{b} \) is the time used for information reception or transmission, and \( T_{fr} \left( {\text{i}} \right) = m_{i} T_{slot} \) is the frame period of CH i. Furthermore, the receiver of the elected CH nodes is always regulated to on mode to be available all the time for receiving information from its MNs and low-level CHs. After that, the received packets at the CH are merged and combine with the relayed packets from other CHs and then transmit to the high-level CH or sink node. Therefore, the expended energy in each CH is:

$$ \begin{aligned} E_{CH} \left( {\text{i}} \right) & = E_{Rx} + E_{agg} + E_{Tx} + E_{idle} = \left\{ {m_{i} T_{d} P_{Rx} + R_{pk} \left( i \right)T_{d} P_{Rx} } \right\} + \left\{ {\left( {m_{i} + 1} \right)E_{DA} K} \right\} \\ & \quad + \left\{ {\left( {R_{pk} \left( i \right) + 1} \right)T_{d} P_{Tx} } \right\} + \left\{ {m_{i} \left( {T_{slot} - T_{d} } \right)P_{idle} + R_{pk} \left( {\text{i}} \right)\left( {T_{slot} - T_{d} } \right)P_{idle} } \right\} \\ \end{aligned} $$
(2)

where \( R_{pk} \left( i \right) \) is the count of relay packets from low-level CHs to CH number i and \( E_{DA} \) is the energy of data aggregation. Subsequently, the total expended energy for the Lr constructed clusters in a region r in the communication process during any time frame is given by Eq. (3). So, minimizing the total expended energy is the main objective in solving the energy constraint problem as follows:

$$ minimize E_{exp - r} = \mathop \sum \limits_{i = 1}^{{L_{r} }} \left[ {E_{CH } \left( i \right) + \mathop \sum \limits_{l = 1}^{{m_{i} }} E_{MN } \left( l \right)} \right] $$
(3)

Objective 2

Improving the packet delivery ratio and avoiding the coverage-hole problem

Selecting distributed CHs that cover the sensor field uniformly is the solution for avoiding the coverage-hole problem and improving the packet delivery ratio. This can be done by selecting CHs depending on minimizing the uncovering area in each region r. Assume each region r with size \( \left( {A_{1} /2 \times A_{2} /2} \right) \) is splitted into small square grids with size \( \left( {a_{1} \times a_{2} } \right) \). The coverage of region r is proportionate with the count of grid points covered by at least one CH. Subsequently, the possibility that the grid point \( G\left( {x,y} \right) \) can be covered by a CH number i \( \left( {CH_{i} } \right) \) is:

$$ P\left( {x,y, CH_{i} } \right) = \left\{ {\begin{array}{*{20}l} {1,} \hfill & {if\,i \in \left\{ {1 ,. . ., L_{r} } \right\}, d\left( {CH_{i} ,G} \right) \le R_{{t_{i} }} } \hfill \\ {0,} \hfill & {otherwise} \hfill \\ \end{array} } \right. $$
(4)

where \( d\left( {CH_{i} ,G} \right) \) is the Euclidean distance between \( CH_{i} \) and grid point \( G\left( {x,y} \right) \) and \( A_{tot - r} \) is the total area of part r. By summing the coverage area of all Lr CHs, the total coverage of region r is given by:

$$ A_{cov - r} = \mathop \sum \limits_{x = 1}^{{a_{1} }} \mathop \sum \limits_{y = 1}^{{a_{2} }} \left( {1 - \mathop \prod \limits_{i = 1}^{{L_{r} }} \left( {1 - P\left( {x,y, CH_{i} } \right)} \right)} \right) $$
(5)

Therefore, the second objective for determining CHs is guaranteeing the network connectivity by reducing the uncovered area in region r of the network as follows:

$$ minimize\;A_{uncov} = A_{tot} - A_{cov} $$
(6)

Objective 3

Controlling the number of CHs.

Selecting a minimum number of CHs can not cover the entire field and increases the loss packets, while the high number of CHs wastes the energy of the network. So, the number of CHs should be controlled based on the expended energy.

Objective 4

Ensuring the stability of links between CHs and their members.

Due to the frequent moving of sensor nodes, the constructed clusters should be stable to save the packets from loss. Thus, the CHs should be determined based on maximizing the link connection time (LCT) [29] between CHs and their members. LCT is the period in which a sensor remains connected with its associated CH. Let the points \( \left( {x_{m} ,y_{m} } \right) \) and \( \left( {x_{i} ,y_{i} } \right) \) represents the coordinates of member node m and CHi and they connect at time \( t = 0 \) if the distance between them is lower than or equal \( R_{{t_{i} }} \). Assume a member node m and CHi move with velocities Vm, Vi and with directions \( \theta_{m} \), \( \theta_{i} \), to reach new coordinates \( \left( {x_{nm} ,y_{nm} } \right) \) and \( \left( {x_{ni} ,y_{ni} } \right) \) at time t, respectively. The new coordinates are given by:

$$ \begin{array}{*{20}l} {x_{nm} = x_{m} + V_{m} \cos \left( {\theta_{m} } \right)t,} \hfill & {y_{nm} = y_{m} + V_{m} \cos \left( {\theta_{m} } \right)t} \hfill \\ {x_{ni} = x_{i} + V_{i} \cos \left( {\theta_{i} } \right)t,} \hfill & {y_{ni} = y_{i} + V_{i} \cos \left( {\theta_{i} } \right)t} \hfill \\ \end{array} $$
(7)

Thus, the member node m will be in connection with the CHi whether the Euclidean distance between them is still lower than or equal to \( R_{{t_{i} }} \) as follows:

$$ d\left( {m,i} \right) = \sqrt {\left( {x_{nm} - x_{ni} } \right)^{2} + \left( {y_{nm} - y_{ni} } \right)^{2} } = \sqrt {\left( {a + bt} \right)^{2} + \left( {c + dt} \right)^{2} } \le R_{{t_{i} }} $$
(8)

where \( a = x_{m} - x_{i} , b = V_{m} \cos \left( {\theta_{m} } \right) - V_{i} \cos \left( {\theta_{i} } \right)t, c = y_{m} - y_{i} , d = V_{m} \cos \left( {\theta_{m} } \right) - V_{i} \cos \left( {\theta_{i} } \right) \). Therefore, the LCT between the sensor m and CHi is given by Eq. (9).

$$ LCT\left( {m,i} \right) \le \frac{{ - \left( {ab + cd} \right) \pm \sqrt {\left( {b^{2} + d^{2} } \right)R_{{t_{C} }}^{2} + \left( {ad - cb} \right)^{2} } }}{{\left( {b^{2} + d^{2} } \right)}} $$
(9)

Objective 5

Preserving topology of the clustered network.

In order to preserve the structure of the clustered network, the CHs should be selected from the sensor nodes that have low mobility. The mobility of a sensor node is evaluated by calculating the mobility factor (MF). MF is the ratio between the number of times a node goes outside its cluster to the number of times a node modifies its location.

Objective 6

Balancing the load among the sensor node.

Since the CH consumes more energy than a member node as illustrated by Eqs. (1) and (2), the task of CH should rotate among all sensor nodes. Thus, the CHs should be selected from sensor nodes that have high residual energy (Eres).

4 Joint Nodes and Sink Mobility Based Immune Routing-Clustering protocol (JNSMIC)

In this paper, Joint Nodes and Sink Mobility based Immune routing-Clustering protocol (JNSMIC) is proposed to optimize the trade-off between the consumption energy and the packet delivery ratio. The operation of the proposed JNSMIC protocol is divided into rounds. The framework of each round consists of two stages, namely the establishment stage and the stability stage. Also, an elementary stage is added only at the beginning of the network work to collect the node’s information. The establishment stage is responsible for determining locations of the mobile sink and CHs, constructing a robust routing tree between these CHs and sink, and computing a deputy CH. The stability stage is used for transferring the sensed information from the sensor nodes to the mobile sink through inter and intra-cluster communication via a certain number of frames. A fault-tolerance check is established at the end of the stability stage to achieve stability on the network and enhance the effective throughput. Figure 2 shows the framework of the proposed JNSMIC protocol.

Fig. 2
figure 2

Flow chart of the proposed JNSMIC protocol

  1. (a)

    Elementary stage

This stage is used for preparing the sensor filed and collecting the network information. The sink splits the field into R regions with equal size. Then, the mobile sink moves to the center of each region r and broadcasts the ‘Demand Message’ containing its location to demand the nodes’ information using the flooding method [30]. The sensor nodes that receive this message, reply with sending ‘Self-Information Message’ containing their IDs, initial energy E0, MF, and locations (x, y) to the sink. After that, the sink divides the region r into nc virtual square cells with length of 0.5Rt to construct a candidate CHs set \( S_{r} \) as shown in Fig. 3. The nc is \( n_{cx} \times n_{cy} \) while \( n_{cx} = A_{1} /0.5R_{t} \) is the number of virtual cells along horizontal axes and \( n_{cy} = A_{2} /0.5R_{t} \) is the number of virtual cells along vertical axes. While x is used to round x to the nearest integer less than x.

Fig. 3
figure 3

Virtual cells of sensor field

  1. (b)

    Establishment stage

Based on the information received from all nodes, the mobile sink moves to the center of the first region (\( r = 1 \)) to perform the clustering process and determine its optimum temporary location. This establishment stage runs only if the remaining energy for each CH is lower than \( E_{th} = E_{avg} - E_{std} \) to deduce the overhead control packets and computational time, while \( E_{std} \) and \( E_{avg} \) are the standard and average of the remaining energy of all alive sensor nodes in the field. This stage consists of four steps: CH selection step, routing tree construction, cluster construction, and deputy CH selection as follows:

  1. (1)

    CHs Selection

In order to determine the location of CHs and mobile sink subject to satisfying the above-mentioned objectives, the proposed protocol uses the MOIA algorithm [31] to optimize the following multi-objective function:

$$ F_{r} \left( p \right) = w_{1} \frac{{E_{exp - r} }}{{E_{0 } N_{live - r} }} + w_{2} \frac{{A_{uncov - r} }}{{A_{tot - r} }} + \left( {1 - w_{1} - w_{2} } \right)\frac{{L_{r} }}{{N_{live - r} }} , subject\;to\; E_{res} \ge E_{avg - r} , MF \le MF_{avg - r} \;and\;LCT \ge LCT_{avg - r} $$
(10)

where \( N_{live - r} \) is the count of alive sensor nodes in a region r, and \( E_{avg - r} \) is the average remaining energy in a region r. \( w_{1} ,w_{2} \) are the weight factors in the range of [0 1] which based on the observed variability of the cost function. MF and \( MF_{avg - r} \) are the MF and the average MF of sensor nodes in a region r, respectively. LCT and \( LCT_{avg - r} \) are the LCT time and the average LCT time of sensor nodes in a region r. Since the searching process for the best CHs from all sensors is very complex and consumes a lot of time essentially in the large network. In the JNSMIC protocol, the process of CH selection is performed in two phases to overcome this issue.

  1. (a)

    CHs Selection: First Phase

In the first phase of CHs selection, the candidate CHs set (Sr) is formed from the sensor nodes based on the residual energy, the mobility factor and the LCT. This set \( S_{r} = \left\{ {S_{1} ,S_{2} ,. . . ,S_{{n_{gen - r} }} } \right\} \) is organized by choosing \( n_{vgen} = (n_{gen} )_{r} /n_{c} \) sensors that have high residual energy, low mobility factor and high LCT value (i.e. \( E_{res} \ge E_{avg - r} \), \( MF \le MF_{avg - r} \) and \( LCT \ge LCT_{avg - r} \)) from each virtual cell in region r.

  1. (b)

    CHs Selection: Second Phase

After constructing the candidate CH set, the sink node encodes them utilizing a binary stream to create a population pool \( \left( {Z_{1} ;Z_{2} ; \ldots ;Z_{\text{m}} ; \ldots ;Z_{{P_{\text{s}} }} } \right) \) of \( P_{s} \) antibodies. Each antibody \( Z_{\text{m}} \) contains \( n_{gen - r} \) bits that represent the candidate CHs in the set \( S_{r} \) and another 16 bits which represent the position of the sink node \( \left( {x_{{{\text{S}} - {\text{r}}}} ,y_{{{\text{S}} - {\text{r}}}} } \right) \) in a region r as shown in Table 1. Each bit in the \( n_{gen - r} \) matches one sensor node, while ‘1’ denotes to CH and ‘0’ denotes to ordinary nodes. Then, the proposed protocol uses the MOIA algorithm to select the optimum temporary locations of the sink node and the CH subject to minimizing the objective function of Eq. (10). The procedure of the MOIA algorithm is shown in Fig. 4.

Table 1 CHs binary antibody Zm
Fig. 4
figure 4

Pseudocode of MOIA algorithm

  1. (2)

    Routing tree Construction

Once the CHs are determined, a multi-hop routing tree is constructed among them to deliver the data of the far CHs to the sink. Searching for the optimum next hop NHopt for each CH j which depends on the distance to sink (BS), the remaining energy, and the consumption energy which is represented by the number of hops (Nhs). Thus, the CHj can be selected to be the optimum next-hop of CHi, if it satisfies the following criterion:

$$ CH_{j} \left\{ {\begin{array}{*{20}l} {NH_{opt} ,} \hfill & {if \,d\left( {CH_{i} , CH_{j} } \right) < R_{r} \left( i \right), d\left( {CH_{j} ,BS} \right) < d\left( {CH_{i} ,BS} \right), E_{res} \gg and Nhs \ll } \hfill \\ {CH_{j} } \hfill & {otherwise} \hfill \\ \end{array} } \right. $$
(11)

Then, the sink computes the adaptive number of frames of each round based on the residual energy of CHs of the previous round \( \left( {E_{{CH_{avg - r } }} \left( {ro - 1} \right)} \right) \) and average energy of all nodes \( \left( {E_{avg - r } } \right) \) in the region r. The idea of transmitting data through adaptive frames in the JNSMIC protocol is profitable in reducing the computational time and overhead packets wasted in the establishment stage. The number of frames is calculated as:

$$ FN_{r} = \left[ FN_{r} \left( {ro - 1} \right) \times \frac{{E_{{CH_{avg - r } }} \left( {ro - 1} \right)}}{{E_{avg - r } }} \right]$$
(12)

where [i] means rounding this value to the closest large integer. Subsequently, the sink node sends a CH State Message to CHs to inform them by their next-hop and number of frames.

  1. (3)

    Cluster construction

Once receiving the CH State Message, each CH broadcasts an announcing message containing its information about the position, range, velocity, and ID using CDMA codes within its range. After that, each node computes the LCT values to build a robust cluster. In order to construct a more stable cluster, the sensors should connect to CH with high LCT to avoid a problem of breaking the links frequently due to the continuous moving of sensors. Moreover, the communication cost and the remaining energy metrics are considered during the clustering process to reduce the expended energy in the re-clustering operation. Therefore, each sensor node m chooses the CH i (\( i = 1,2, \ldots ,L_{r} \)) that has a maximum value of the following function:

$$ f\left( {m,CH_{i} } \right) = h_{1} \frac{{LCT\left( {m,CH_{i} } \right)}}{{LCT_{max} }} + h_{2} \left( {1 - \frac{{d\left( {m,CH_{i} } \right)}}{{R_{{t_{C} }} }}} \right) + \left( {1 - h_{1} - h_{2} } \right)\left( {\frac{{E_{res} \left( {CH_{i} } \right)}}{{E_{max} }}} \right); $$
(13)

where \( h_{1} \) and \( h_{2} \) are weighting factors between 0 and 1, \( LCT\left( {m,CH_{i} } \right) \) is the LCT between the sensor m and \( CH_{i} \), and \( LCT_{max} \) is the maximum value of LCT between a node m and all CHs. After determining the best associated CH, the sensor nodes send a Join Request Message which contains \( \left( {ID, x,y,V, \theta , LCT} \right) \) to its associated CH. The node that did not receive any announcing message will drop. After that, each CH builds a TDMA scheme based on the received message and transmits it to each sensor in its cluster and low-level CHs informing them with their allocated timeslots. The radio of each member node is turned off all-time except during its allocated timeslot which avoids intra-cluster collisions and deduces the energy expended.

  1. (4)

    Deputy cluster heads selection

The power depletion and the physical damage of any CH prevent its members from transmitting their packets which might contain important information and packets will be lost. Therefore, JNSMIC protocol assigns a Deputy CH (DCH) for each CH to perform its task of the main CH is failed. Each CH chooses the nearest sensor node to it with the highest remaining energy and the lowest MF to be a DCH by selecting a node that has a minimum value of the following function.

$$ f_{DCH} \left( m \right) = \frac{{h \left( {d\left( {m,CH} \right)/R_{{t_{c} }} } \right) + \left( {1 - h} \right)\left( {MF\left( m \right)/MF_{avg} } \right)}}{{E_{res} \left( m \right)/E_{max} }} $$
(14)

where h is a weighting factor between 0 and 1.

  1. (c)

    Stability stage

In the stability stage, the sensory information is transmitted to the sink through inter and intra-cluster communication via several frames. The stability stage contains two steps: transmitting data step and fault tolerance step.

  1. (1)

    Transmitting data step

After constructing clusters and finding the location of the sink in region r, the sink moves to its determined temporary position to collect data from this region. It transmits a Request Data Message to CHs of this region. Then, CH forwards the Request Data Message to its member nodes in region r during their allocated timeslots to wake them and gather their data, while the other sensors of the other \( \left( {R - 1} \right) \) regions are sleep. If any sensor moves outside its region, do not receive a Request Data Message, it broadcasts a Joint Request Message within its transmission range. Then, the closest CH from it in the other region should send an Acceptance Message to accept it as a member.

The sensors received Request Data Message must determine if it will be joining this CH until the next timeslot or not depending on LCT. If \( LCT < T_{fr} \) (time of frame), the sensor adjusts its state of the next frame to be ‘QUIT’ and should search for new CH to join it; otherwise, it will be ‘JOIN’. Each sensor transmits its sensory information to its associated CH in its allocated timeslot and counts the number of moving outside and inside its cluster. After receiving the sensory information of all members, CH aggregates all packets into one packet using signal processing functions and sends it with the information of low-level CHs to the sink via the established routing tree. The communication between nodes in each cluster is occurred by using a unique CDMA code that differs from codes in other clusters to deduce inter-cluster interference.

If any sensor does not receive a Request Data Message from any CH, its packet will be lost due to its mobility outside the allocated cluster boundary. Moreover, any CH did not receive any information from its members, it transmits a Warning Message to its DCH in the slot pawned to DCH telling about its failure. When the DCH receives this message, it waits a fault tolerance period for broadcasting an Announcing Message containing its ID to its sensors inside its range. Each low-level CH and DCH must be aware of the IDs of the high-level CH and DCH. If the low-level CH did not receive an Acknowledgment that ensures reception from its associated CH in high-level, it resends the aggregated information to the high-level DCH.

  1. (2)

    Fault-Tolerance

In order to ensure the link stability between CH nodes and their members and enhance the throughput, a fault tolerance check is established in the latest timeslot of each frame. Once each CH delivers its information to the sink, it begins to check the states of its members. If it is ‘QUIT’, CH exploits its allocated timeslot with assigning to another node moved into the cluster or removing it and broadcasts an Announcing Message containing new TDMA to their sensors within its range. Furthermore, each sensor with ‘QUIT’ state makes the previous procedure for selecting another CH before beginning the next frame. After reaching the final frame of the round, each sensor computes theirs MF, remaining energy, and position and transmits these values combining with its data to the CH via its assigned timeslot. After that, each CH forwards this information to the sink.

After a certain temporary time, the sink node moves from region r to the center of the next region (r + 1) with a specified velocity. Then the sink implements the clustering of nodes and routing processes to collect the sensory information from the sensors in this region. This procedure is repeated until the sink moves to all the regions of the field and collecting all the information in the network. After finishing the first round, the sink moves to the first region again to start a new round.

5 Simulation Results

5.1 Performance Metrics

The following metrics [19,20,21,22, 26] are used to study the performance of the proposed JNSMIC protocol and compare it with other previous protocols.

  • Throughput It is the ratio between the number of successfully delivered packets to the receiver and the total sent packets. That means that throughput measures the ability of a protocol to transfer data to the receiver. It also may be referred to as a Packet Delivery Ratio (PDR).

  • End-to-End Delay (EED) It is the time duration that the packet takes in its journey from generating the first bit in the transmitter till delivering the last bit to the receiver.

  • Average Energy Expenditure (AEE) It is the average of energy expended in transmitting the data in the network from the source node to the destination node during a certain period and equals \( E_{exp} /N \).

  • Lifetime The period from the beginning of the WSN until the termination of the network or death of the first node.

5.2 Simulation Environment

In this experiment, two scenarios are presented to measure the performance of the proposed JNSMIC protocol. Each one of these scenarios has its characteristics as shown in Table [2]. The sensors are initially distributed randomly and their mobility follows a random waypoint mobility model [24]. Each node selects its direction randomly from [0, 2 π] and its velocity from a certain range. If the sensor crashes into the boundary, the sensor will be reflected [20]. The proposed protocol uses realistic radio model CC2420 in calculating the energy expended in the network. The MOIA parameters are \( P_{s} = 30 \), \( P_{r} = 0.8 \), \( P_{c} = 0.05 \), \( N_{clon} = 5 \), and Maxgen = 100 [22]. Moreover, there are other parameters related to the weighting factors in the proposed JNSMIC protocol; \( w_{1} = 0.5, w_{2} = 0.45, h = 0.4,h_{1} = 0.4, h_{2} = 0.3 \). Each experiment was run for 10 independent runs and the average values were taken as the final results in order to reduce the randomness error.

5.3 Experimental Results

In this section, the proposed JNSMIC protocol is compared with previous protocols \( {\text{E}}^{2} {\text{R}}^{2} \) [26], LEACH-M [19], ARBIC [22], CBR-Mobile [20], and MACRO [21] using two scenarios.

  1. 1.

    First Scenario

In this scenario, the proposed JNSMIC protocol is compared with \( {\text{E}}^{2} {\text{R}}^{2} \) protocol which indicates the mobility of both sink and sensors together and LEACH-M protocol using the parameters in Table 2 [22, 26]. Figure 5 shows the influence of changing the number of mobile sensor nodes deployed in the field in the aspect of throughput on the proposed protocol compared with previous protocols with considering the average nodes’ velocity as 2.5 m/s. It is noticed that the proposed JNSMIC improves the throughput level at the sink with approximately 6.6% and 22% on average compared with that of \( {\text{E}}^{2} {\text{R}}^{2} \) and M-LEACH, respectively. This improvement is due to the mobility of the sink node around the network and the role of DCH. However the increase of link failure due to mobility of sensors, the proposed JNSMIC gives the best and stable performance because of its capability to overcome these faults with using DCH.

Table 2 Simulation parameters of proposed JNSMIC protocol under discussion [22, 26]
Fig. 5
figure 5

Throughput results verses number of MSNs

On the other hand, Fig. 6 studies the influence of changing the number of deployed sensors on the average energy expenditure (AEE) of the three protocols. The AEE increases along with increasing the number of deployed sensor nodes because of the increase in the number of packet exchange which expends more energy. The figure shows also that the proposed JNSMIC improves the AEE comparing with that of \( {\text{E}}^{2} {\text{R}}^{2} \) and M-LEACH. The proposed protocol gives more stability and scalability in energy expenditure while it gives a stable AEE results with increasing the nodes number. Figure 7 shows the performance of these protocols in terms of throughput against the average velocity of sensors. The throughput of these protocols reduces along with increasing the velocity because of the number of breaking links increases at high velocities. The proposed JNSMIC protocol outperforms \( {\text{E}}^{2} {\text{R}}^{2} \) and M-LEACH due to the fault tolerance process which improves the throughput.

Fig. 6
figure 6

Average energy expenditure verses number MSNs

Fig. 7
figure 7

Throughput results verses number of MSNs

  1. 2.

    Second Scenario

This scenario studies the influence of varying the maximum velocity of sensors and the percentage of mobile sensor nodes (MSNs) in aspects of AEE, throughput, and EED on the proposed JNSMIC compared with ARBIC, MACRO, CBR-Mobile, and LEACH-M protocols using the parameters in Table 2.

  1. (a)

    Influence of changing MSNs percentage

In this section, the effect of varying the number of the MSNs in aspects of AEE, throughput, and EED on proposed JNSMIC is studied compared with ARBIC, MACRO, CBR-mobile, and LEACH-M protocols. Therefore, the velocity of MSNs is set to 5 m/s and their percentage is varied from 0 to 90% of the total number of nodes. Figure 8a shows that AEE is increased in both CBR Mobile and LEACH-M protocols with increasing the number of MSNs due to the increase of the disconnected nodes. These nodes expended more energy on keeping its radio on all the time to hear the control message which leads to overhear unwanted messages. The MACRO protocol expends more energy than CBR-Mobile and LEACH-M protocols at lower MSN and the difference in AEE decreases with increasing MSNs. ARBIC protocol saves the expended energy as compared to the three protocols because it takes the values of LCT, MF, connectivity into consideration during the clustering process. Also, it is observed that the proposed JNSMIC protocol outperforms all protocols for saving the expended energy. This due to solving the hot spot problem by utilizing the mobile sink and selecting CHs based on balancing the load among the sensor nodes. Furthermore, the idea of utilizing a fault tolerance at the end of each frame enables the disjoined sensors to connect with a new cluster during a short time and this also saves the expended energy.

Fig. 8
figure 8

Changing percentage of MSNs in proposed JNSMIC, ARBIC, MACRO, CBR-mobile, and LEACH-M protocols in terms of a AEE, b throughput, c EED

Figure 8b shows the throughput of the proposed JNSMIC protocol compared to the other protocols. It is observed that throughput in LEACH-M protocol reduces significantly with increasing the MSNs due to the problem of waiting for two failures until joining a new cluster which causes packet drops. In CBR-Mobile protocol, the disjoint nodes can join the new cluster within a shorter time which causes better performance than the LEACH-M. A more improvement occurs in the MACRO protocol than these two protocols due to its ability to find reliable routes and sustain it. The ARBIC protocol gives better throughput than the three protocols because it ensures the connectivity within clusters by adjusting the transmission range of each CH. The proposed JNSMIC protocol outperforms the other protocols in terms of throughput. That is due to the idea of sink mobility which enables the sink for collecting the information from the far sensors causing an increase in the number of sent packets and throughput.

Figure 8c shows the performance of changing MSNs in terms of EED for the proposed protocol and the other protocols. It is observed that EED for LEACH-M protocol increases exponentially with increasing the number of MSNs due to the waiting of packets in the queue during the disjoint periods. An improvement occurs in CBR-Mobile than LEACH-M protocol because of the disjoint sensors can reconnect to the network during a short duration. MACRO protocol takes more time in discovering the route but it guarantees that the sensors choose the best routes which cause better performance in terms of EED than the two other protocols. ARBIC protocol has approximately stable EED performance because the sensors connect to CHs which have high values of LCT. The proposed JNSMIC protocol gives the best EED performance compared to the other protocols. That is due to the idea of dividing the field into small regions and moving the sink near to the sensors which enable them to send their data across small distances during a short period and hence improve EED. A fault-tolerance has its role in improving the EED performance by reducing the wasted time in reconnecting the disjoin sensors to the network.

  1. (b)

    Influence of changing maximum velocity

In this section, the influence of changing the maximum velocity of the MSNs in aspects of AEE, throughput, and EED on the JNSMIC protocol compared with ARBIC, MACRO, CBR-mobile, and LEACH-M protocols. Thus, the network consists of 100 nodes and their velocity is varied from 1 to 10 m/s. Figure 9 shows that AEE for LEACH_M and CBR-Mobile increases with increasing the maximum velocity. Figure 9 shows that the throughput of LEACH-M decreases sharply and EED increases exponentially with increasing the MSNs velocity. That is because joint the frequency and duration of the disjoint periods increase in LEACH-M. Thus, the packet wastes time in waiting in a queue during these periods. However, the CBR-Mobile has more improvement in AEE, throughput, and EED than LEACH-M due to the possibility of assigning each timeslot to multiple sensors which enables the disjoint nodes to connect with a new cluster in a short time. It is observed from the figure that MACRO protocol outperforms LEACH-M and CBR-Mobile protocols in both throughput and EED but it expands more energy. It guarantees the reliability of the route by utilizing the new cross-layer approach.

Fig. 9
figure 9

Changing the velocity of MSNs in proposed JNSMIC, ARBIC, MACRO, CBR-mobile, and LEACH-M protocols in terms of a AEE, b throughput, c EED

The ARBIC protocol improves the AEE, throughput, and EED than the other protocols due to the possibility of adjusting the CHs transmission range depending on their velocity compared with their members. This idea sustains the connectivity of the network for more time even if the velocity of the sensors increased and reduces the number of disjoint sensors. The proposed JNSMIC protocol outperforms all the previously mentioned protocol in aspects of AEE, throughput, and EED. It spreads the load between nodes and reduces the expended energy by moving the sink node to the best position around the regions of the field. Considering MF, LCT, coverage ratio, and expended energy during the construction of the clusters reduces the number of disjoint sensors. Moreover, the proposed JNSMIC protocol guarantees the connectivity of the sensors with the CH and reduces the packet loss by assigning a DCH that operates when the CH fails.

6 Conclusion

This paper proposed Joint Nodes and Sink Mobility based Immune routing-Clustering protocol (JNSMIC) depending on the multi-objective Immune Algorithm (MOIA) to deal with the mobility of sink and sensor nodes together. The JNSMIC protocol utilized the mobile sink to solve the hot spot problem and the MOIA algorithm to cluster the network and to find the temporary location of the mobile sink. Different objectives were considered in the clustering process; the expended energy, network coverage, link connection time, residual energy and mobility. In the JNSMIC protocol, the CHs were selected through two phases; forming the candidate CHs set and using the MOIA algorithm to find the final CHs. The clustering operation only operated if the remaining energy is less than a certain threshold to reduce the overhead control packets and computational time. Moreover, each cluster head assigned a deputy CH to take its position in case of CH failing and this avoids the packets dropping. Furthermore, a fault tolerance process was occurred at the end of each frame to ensure the stability of the links and improve throughput. Two different simulation scenarios were considered to measure the performance of the proposed protocol compared to the other protocols. Simulation results showed that the JNSMIC protocol can effectively ameliorate the throughput while simultaneously giving lower energy expenditure and end-to-end delay compared with E2 R2, ARBIC, MACRO, CBR-mobile, and LEACH-M protocols. The proposed protocol has the ability to optimize the trade-off between the consumption energy and the packet delivery ratio.