1 Introduction

Recently, wireless sensor networks (WSNs) have played an important part in monitoring and surveillance [1]. WSNs always consist of a base station (BS) and hundreds of sensor nodes. However, sensor nodes are often deployed in hard-to-reach locations. So, the replacement of the node battery becomes impossible [2]. Designing an energy efficient routing protocol is one of the best methods to solve this problem.

Cluster routing is an energy efficient routing protocol which can reduce the energy consumption. In cluster-based routing protocols, the sensor nodes are divided into cluster heads (CHs) and cluster members (CMs). CMs transmit the sensor data to cluster head. Then, CHs aggregate the sensor data and transmit the aggregation data to BS. The method of aggregating sensor data reduces the among of data which are transmitted to BS. This way reduces the energy consumption in sensor nodes [3].

In cluster-based routing protocols, CHs always consume more energy than CMs. The unbalanced energy consumption between sensor nodes makes the energy hole in WSNs. This is the hotspot problem in cluster routing [4]. Mobility BS technology is one way which can resolve the hotspot problem efficiently. In mobile BS-based cluster routing, BS moves freely in the network and CHs transmit the aggregation data when BS comes within its proximity.

As mentioned above, mobile BS-supported cluster routing can reduce the energy which is consumed in CHs. Mobile BS can move to the area with less energy, which alleviates the hotspot problem [5,6,7]. With the easing of the hotspot problem, the energy of the network is balanced and the lifetime of the network is enhanced. There are two main challenges in the mobile BS-based cluster routing. Firstly, it is difficult to design the optimal BS sojourn locations which considers the energy consumption and latency in the network simultaneously. Secondly, it is complex to calculate the shortest traversal path of the mobile BS [8, 9].

In most of the distributed cluster routing protocols, each sensor node needs to collect the information of other nodes in order to set up the network routing [10]. Apart from that, the routing is also calculated in sensor nodes. As for large network, it is hard for an edge node to find the routing to BS when it uses a distributed routing protocol [11]. In large network, sensor nodes need more control messages so that they can establish the connection to BS. Therefore, distributed routing protocols need more routing overhead and computation overhead for sensor nodes in the routing setup phase [12].

Software-defined wireless sensor network (SDWSN) is a network which uses the software-defined technologies for measuring, sensing and routing tasks in WSNs [13]. SDWSN separates the network into control plane and data plane. Sensor nodes are in the data plane which only need to transmit the information of itself to the controller. All the routing computation are processed in the controller. Sensor nodes can obtain the routing to BS easily from the controller. So, software-defined networking (SDN) based routing protocols reduce the routing overhead and energy consumption in sensor nodes [14].

Recently, many optimization algorithms are used for cluster routing protocol. It includes the genetic algorithm (GA), whale optimization algorithm (WOA), particle swarm optimization (PSO), artificial bee colony (ABC) algorithm and et al. GA and WOA converge speedily. However, these two algorithms are not good at local search [15]. The parameters in PSO are less than GA and it can achieve easily in cluster routing protocol. Comparing to GA and WOA, ABC algorithm is superior in global searching and convergence rate. Therefore, the PSO and ABC can perform well in the cluster routing protocol.

According to the problems listed above, we propose the PSO and ABC algorithm for clustering and mobile based software-defined wireless sensor networks (PACMSD). Contributions of this article are listed as follows.

  1. 1.

    The SDN framework is designed in the proposed protocol. This methodology reduces the energy consumption in sensor nodes and enhances the network lifetime. Sensor nodes need less energy for routing setup and controller is responsible for designing the routing of the whole network.

  2. 2.

    The PSO-based cluster routing algorithm is used to determine the CHs and sojourn locations of the BS. This algorithm considers the CHs election and the BS’s sojourn locations in an integrated manner. Residual energy, distance to the next hop, the number of CMs in each cluster and distance between each of sojourn locations are all considered in this protocol. This method reduces the energy consumption in CHs and indirectly reduces the travel length of BS.

  3. 3.

    The ABC-based traversal path algorithm is used to calculate the move path of the BS. The method reduces the length of the moving track when it is compared to the random mobility model and the fixed mobility model. Sensor nodes can transmit the sensor data to BS quickly and the latency of the network is reduced.

The organization of the rest part is listed as follows. Section 2 discusses the mobile BS-based cluster routing and SDN-based routing protocols. Section 3 lists the network assumptions and the energy model of the proposed protocol. Section 4 introduces the proposed protocol in details. It consists the SDN framework of the proposed protocol, PSO-based cluster routing algorithm and ABC-based traversal path algorithm. Section 5 analyses the time complexity and the hardware complexity of PACMSD. Section 6 simulates and analyses the proposed protocol with other relevant routing protocols. Section 7 concludes the article.

2 Related works

Nowadays, the design of the mobile BS-based cluster routing and SDN-based routing protocols in WSNs have gained more and more attention [16]. The related works of these two parts are listed as follows.

2.1 SDN-based routing protocol

Guo et al. [12] combined reinforcement learning (RL) with SDN. The proposed protocol improves the performance of network lifetime and network convergence rate. Liao et al. [17] proposed an energy-efficient algorithm based multi-energy-space (MES) in SDWSN. This protocol balances the energy consumption of the sensor nodes and prolongs the lifetime of the network. Li et al. [18] used game theoretic in order to improve the network lifetime performance in SDWSN. This protocol increases the energy consumption in sensor nodes.

Shabbir et al. [19] proposed an SDN-based routing solution for internet of things (IoT). It uses in the mesh and cluster topological scenario. Singh et al. [20] designed a cloud-based environment parameter monitoring system. The sensor nodes are developed with capabilities of data acquisition. Hawbani et al. [13] used the SDN technology for WSNs and proposed an SDN-based architecture which is named mini software-defined networking (MINI-SDN). The protocol improves the performance and scalability of the network.

Jurado-Lasso et al. [21] proposed a model-based SDWSN architecture. The proposed model concludes of the neighbor discovery functioning, neighbor advertisement functioning, network configuration functioning and data collection functioning. The proposed protocol is adapted in the static SDWSNs. Results show the protocol reduces the control overhead and prolongs the network lifetime.

Software-defined and fuzzy-based multi-hop unequal cluster routing (SDFMUCR) [22] uses an SDN framework to reduce the routing overhead and computation overhead in sensor nodes. Fuzzy logic (FL) based unequal cluster routing is used to balance the energy consumption of the CHs. This protocol reduces the energy consumption as well as the latency of the network.

Hu et al. [23] used the PSO algorithm for designing the unequal cluster routing protocol in SDWSN. It improves the energy efficiency and extends the network lifetime. It suggests SDWSN can implement the heuristic algorithm. Heuristic algorithm can improve the network performance in SDWSN.

2.2 Mobile BS-based cluster routing

Improved ant colony optimization-based approach with mobile sink (IACO-MS) [24] uses the mobile sink to balance the energy consumption between sensor nodes. IACO-MS reduces the path length and prolongs the lifetime of the network. Wang et al. [3] proposed an energy efficient cluster routing with mobile sink. The network is divided into sectors and a cluster head (CH) is elected in each sector. This proposed protocol reduces the energy consumption in cluster heads. Energy efficient clustering scheme (EECS) [1] simultaneously considers the distance, residual energy and the data overhead to select the CHs. It performs well in the network lifetime and throughput.

Energy centers searching using particle swarm optimization (EC-PSO) [25] uses the geometric method to select the CHs. It uses an improved PSO to search the energy center and elect the CHs. The mobile data collector is used for balancing the network energy consumption. Gharaei et al. [26] proposed a cluster routing protocol with mobile sink. Network is divided into multiple regions and a CH is selected in each area. CHs transmit the aggregation data to mobile sink by multi-hops and sink moves through the Fermat spiral path. This protocol enhances the network lifetime and balances the energy consumption of sensor nodes.

Particle swarm optimization-based selection (PSOBS) [27] uses the PSO algorithm to calculate the optimal rendezvous points of mobile sink. This protocol reduces the packet loss rate and enhances the throughput of the network. Jiang et al. [28] drew an inspiration from the foraging process about the single-celled organism-slime mold physarum polycephalum. They used the slime mold optimization to design the move path of the sink. Krishnan et al. [29] proposed an enhanced clustering methodology with multiple mobile sinks for collecting data. It uses multiple mobile sinks to collect the sensor data which prolongs the network lifetime and reduces the network latency.

Singh et al. [30] proposed multi-clustered energy efficient routing algorithm with randomly moving sink node (MERAM-R). In this protocol, the method to select the CH nodes is the same as low energy adaptive clustering hierarchy (LEACH) and the sink node randomly moves in the network. It reduces the energy consumption comparing to LEACH. However, it increases the path length of the mobile sink.

Krishnan et al. [31] proposed dynamic clustering approach with ant colony optimization (ACO)-based mobile sink for data collection protocol. It overall considers the residual energy, distance and the number of the neighbor nodes in order to select the CHs. The traversal path of the mobile sink is calculated by ACO. This protocol effectively relieves the hotspot problem as well as prolongs the lifetime of the network.

Ghosh et al. [32] proposed differential evolution (DE) and mobile sink based on demand clustering protocol. This protocol uses an on-demand based clustering, which reduces the energy consumption in the cluster formation phase. DE is used for calculating the set of the CHs and the sojourn locations of the mobile sink. The traversal path of the sink is fixed. This protocol prolongs the network lifetime efficiently.

According to the related works listed above, some conclusions can be drawn as follows. Firstly, some researches proposed the SDN-based architecture for WSN to improve the network performance. However, few studies combine the SDWSN with cluster routing which increases the transmission overhead for sensor nodes. Secondly, in most of the mobile BS-based cluster routing, the BS moves near to CH for collecting the sensor data. This method increases the latency of the network. Thirdly, the related works usually used the distributed routing protocol. The routing is calculated in the sensor nodes which increase the computation overhead in sensor node.

The proposed protocol combines the SDN architecture with the heuristic algorithm. The routing is calculated in the controller which reduces the computation in the sensor node as well as improves the network performance. The proposed protocol designs the CHs and sojourn locations reasonably which reduces the length of traversal path.

3 System model

3.1 Network assumption

Fig. 1 is the system model of PACMSD. PACMSD adopts SDN technologies to reduce the routing overhead and computation overhead in the network. Sensor nodes work on the data plane and the PSO algorithm is used for designing cluster routing. BS works on the control plane and the ABC algorithm is used for calculating the moving track of the BS.

Fig. 1
figure 1

System model of the proposed protocol

Some assumptions of the proposed routing protocol are listed as follows:

  1. 1.

    Sensor nodes act as switches randomly distribute in the network and remain stationary after deployment.

  2. 2.

    BS can move within the network. BS contains a controller module which is used to calculate the routing of the entire network.

  3. 3.

    Sensor nodes have the same initial energy.

  4. 4.

    Network links are symmetrical and sensor nodes are homogeneous.

  5. 5.

    BS has sufficient energy and sensor nodes have limited energy.

  6. 6.

    The power of calculation speed and data transmission of the BS is stronger than those of sensor nodes.

3.2 Energy model

The energy consumed in WSNs includes the transmission, reception and aggregation. The energy model of the WSNs is the first-order radio model. This model is often used in the cluster routing protocols for calculating the energy consumption of the sensor nodes. PACMSD uses this model because it can compare with other protocols easily. The path loss exponent is 2 when the distance between the receiver and transmitter is less than \({d}_{0}\). The path loss exponent is 4 when the distance between two nodes is more than \({d}_{0}\).

In PACMSD, BS moves near to CH for collecting the aggregation data in each cluster. In order to reduce the energy consumption, the distance between BS and CH is designed less than \({d}_{0}\) in PACMSD. Therefore, the path loss exponent is fixed.

The energy required to transmit \(l\) bits message is given by Eq. (1).

$${E}_{Tx}\left(l,d\right)=\left\{\begin{array}{c}l\cdot {E}_{elec}+l\cdot {\varepsilon }_{fs}\cdot {d}^{2}, d\le {d}_{0}\\ l\cdot {E}_{elec}+l\cdot {\varepsilon }_{mp}\cdot {d}^{4}, d>{d}_{0}\end{array}\right.$$
(1)

where \({E}_{elec}\) is the energy dissipated in the electronics, \({\varepsilon }_{fs}\) and \({\varepsilon }_{mp}\) denote the energy dissipated in free space and multipath fading respectively. The parameter \(d\) is the distance between the sender node and the receiver node, and \({d}_{0}=\sqrt{{\varepsilon }_{fs}/{\varepsilon }_{mp}}\) is the distance threshold.

The energy required to receive \(l\) bits message is given by Eq. (2).

$${\text{E}}_{Rx}\left(l\right)=l\cdot {E}_{elec}$$
(2)

The energy required to aggregate \(l\) bits message is given by Eq. (3).

$${\text{E}}_{DA}\left(l\right)=l\cdot {E}_{agg}$$
(3)

where \({E}_{agg}\) is the energy dissipated to aggregate 1 bit message.

4 Proposed protocol

This section, the PACMSD will be introduced in details. The SDN framework for the proposed protocol is introduced in Sect. 4.1. The PSO-based cluster routing algorithm is given by Sect. 4.2. The ABC-based traversal path algorithm is given by Sect. 4.3.

4.1 SDN framework for the proposed protocol

The proposed protocol uses the SDN technologies to calculate the network routing and the traversal path of the BS. The wireless sensor network (WSN) consists of a BS and sensor nodes. The controller module which is used to calculate the routing of the whole network is in the BS. Sensor nodes only need to transmit the topology information to the BS. This methodology reduces the energy consumption and computation overhead in sensor node.

Fig. 2 is the SDN architecture of the proposed protocol. This architecture consists of the data plane, control plane, southbound interface, northbound interface and application layer. Sensor nodes include the sensor module, sending module and receiving module. They work on the data plane. The node locations information and the residual energy information need to be transmitted to BS through sending module in order to calculate the routing of the network. Sensor module is responsible for sensing the environment. Receiving module is used to receive the control messages from BS. BS works on the control plane. It includes the topology information module, controller module, mobile module, flow table and data management module. Topology information module is used to manage the topology information of sensor nodes. Controller module uses the topology information to design the flow table of the sensor node and the traversal path of the BS. The sensor data is managed in the data management module. The application layer consists of many kinds of applications. Application layer gets the resource form underlying network through the northbound interface. Southbound interface is used to exchange data between the sensor node and BS.

Fig. 2
figure 2

SDN architecture of the proposed protocol

The proposed protocol consists of four phases. These four phases are the topology discovery phase, flow table generation phase, flow table delivery phase and the topology maintain phase. The detail introduction of these four phases is given as follows.

Topology discovery phase: Topology discovery phase aims at collecting the information from the sensor nodes. Then the information is used to calculate the routing of the entire network.

In the topology discovery phase, BS broadcasts the topology request \({Topo}_{req}\) message to the sensor nodes. After receiving the \({Topo}_{req}\) message, sensor node establishes a temporary one-way secure channel to BS. Then the sensor node rebroadcasts the \({Topo}_{req}\) message until this message gets to the edge of the network. Next, sensor node packets the residual energy and the node location information of itself into topology reply \({Topo}_{rep}\) message and transmits the \({Topo}_{rep}\) message through the secure channel. Sensor node discards the message when it receives the same \({Topo}_{req}\) message. This methodology avoids the message flooding in the network. After receiving the \({Topo}_{rep}\) message, BS records the information of the sensor node to the topology information module. So far, the topology discovery phase is finished.

Flow table generation phase: Flow table generation phase aims at calculating the routing of the sensor nodes and the traversal path of the base station. This phase is operated in the controller module within the BS. Firstly, controller module uses the information in topology information module to determine the CH nodes and the sojourn points of the BS. This process uses a PSO-based cluster routing algorithm which will be detail introduced in Sect. 4.2. Then controller calculates the traversal path of the BS according to the BS’s sojourn points. An ABC-based traversal path algorithm which is introduced in Sect. 4.3 is used in this process. Then, the mobile module in BS will get the sojourn locations and the traversal path from controller module. So far, the flow table generation phase is finished. These calculation processes are all operated in the controller module in BS, which reduces the computation overhead and the routing overhead in sensor nodes.

Flow table delivery phase: Flow table delivery phase aims at delivering the flow table \({Flow}_{tab}\) message to sensor nodes. So, the sensor nodes know the routing information of itself. The flow table consists of the CH flag \({Flag}_{CH}\), set of the CMs \({Set}_{CM}\), next hop \({H}_{next}\), number of the time-division multiple access (TDMA) time slot \({Slot}_{TDMA}\) and sojourn location of BS \({Loc}_{soj}\). The \({Flag}_{CH}\) indicates whether the sensor node is CH. If the sensor node is CH, the \({Flag}_{CH}\) is ‘1’. If the sensor node is cluster member (CM), the \({Flag}_{CH}\) is ‘0’. The \({Set}_{CM}\) is the set of the CMs for a CH. For CMs, the \({Set}_{CM}\) is \(\Phi\). Controller module generates the TDMA schedule for CMs in this phase and \({Slot}_{TDMA}\) is the number of the TDMA time slot for CMs. The \({Loc}_{soj}\) is the corresponding sojourn locations of BS for cluster heads.

In the flow table delivery phase, BS moves in the network according to the moving path which is calculated by controller module. In each sojourn location, BS establishes two-way secure channels to sensor nodes. Then, BS delivers the flow table to sensor nodes hop by hop. When sensor nodes receive the flow table from BS, they update the \({Flag}_{CH}\), \({Set}_{CM}\), \({H}_{next}\), \({Slot}_{TDMA}\) and \({Loc}_{soj}\) of itself. Then an acknowledge (ACK) message will be responded to BS. For cluster head, it will forward the flow table to CMs of itself. So far, the flow table delivery phase is finished.

Topology maintain phase: Topology maintain phase aims at collecting the sensor data from the network and detecting the information of the node in order to update the routing of the whole network. In the topology maintain phase, CMs transmit the sensor data packet along with its residual energy to CH in its own TDMA time slot. When it receives the whole data packets from CMs, CH aggregates the data packets to an aggregation data \({Data}_{agg}\) packet. If the \({Set}_{CM}\) changes, it means that at least one of sensor nodes in the network is dead. Then CH transmits the topology repair \({Topo}_{repa}\) message to BS.

BS moves according to the traversal path which is calculated in the controller module in the topology maintain phase. BS will stay for a while in each of sojourn locations. In each sojourn location, BS transmits the BS arrival \({Arv}_{BS}\) message to CH. After receiving the \({Arv}_{BS}\) message, CH transmits the \({Data}_{agg}\) packet to BS. Then BS moves to the next sojourn location. After receiving the \({Topo}_{repa}\) message from sensor nodes, BS returns to the topology discovery phase and recalculates the routing of the whole network. In addition, controller module will check the information of the sensor node in each round. If the network satisfies the conditions listed in Sect. 4.2, BS returns to the topology discovery phase. So far, the topology maintain phase is finished.

TDMA mechanism: In PACMSD, CMs transmit the sensor data to CH. The CH aggregates the data and transmits the aggregation data to BS. This method reduces the amount of data which is transmitted in the network. Meanwhile, this methodology reduces the bandwidth utilization of the sensor nodes. PACMSD uses the TDMA mechanism in which CHs transmit the aggregation data to BS in different slots. This mechanism avoids the collision of the message as well as provides enough bandwidth for data transmission. The transmission frequencies are different in each of clusters which avoids the interference between the clusters.

Secure channel: The channel in the proposed protocol includes the normal channel and the secure channel. Normal channel is used to transmit the data packet and secure channel is used to transmit the control message. These two channels work at different frequencies, which avoids the collision between the control message and the data message. Meanwhile, the traffic load in each channel is reduced. The secure channel aims at security, reliable and less energy consumption. Secure channel consists of the one-way secure channel and the two-way secure channel. The establishment of these two secure channels is given as follows.

The one-way secure channel is established in the topology discovery phase. After receiving the \({Topo}_{req}\) message from other nodes, sensor node establishes a temporary one-way secure channel between itself and the sender node. Then sensor node responses the \({Topo}_{rep}\) message to BS through this secure channel.

The two-way secure channel is established in the flow table delivery phase. When the controller module generates the routing of the whole network, it will first establish temporary two-way secure channels between BS and the sensor nodes. Then BS delivers the flow table to sensor nodes through secure channel. Receiving the flow table from BS, sensor nodes respond the ACK message to BS through this secure channel. Then, sensor node forwards the flow table to next hop and the routing of the whole network is established.

The flow table of the proposed protocol is simple, so the control overhead of the network is low. The topology of the WSNs is not stationary, which makes the secure channels not absolute secure. Therefore, the secure channels should be used as less as possible. Fig. 3 is flowchart of PACMSD protocol.

Fig. 3
figure 3

Flowchart of PACMSD protocol

4.2 PSO-based cluster routing algorithm

PSO algorithm is an intelligent heuristic algorithm which is derived from the birds swarming habit definition. In PSO, particles can move to the optimal location according to the position best and the global best. The process of the PSO algorithm is given as follow.

In the initial, \(M\) particles random distributed in D-dimensional space and the fitness value \({f}_{i}\left(t\right)\) of each particle is calculated, where \(i\) is the number of particles and \(t\) is the number of current iteration. Then the particle position best \({pb}_{i}\left(t\right)\) and the particle global best \(gb\left(t\right)\) are calculated, where \({pb}_{i}\left(t\right)\) is the particle position with the best \({f}_{i}\left(t\right)\) in each iteration and \(gb\left(t\right)\) is given by Eq. (4).

$$gb\left(t\right)=best\left\{{pb}_{1}\left(t\right),{pb}_{2}\left(t\right)\cdots {pb}_{M}\left(t\right)\right\}$$
(4)

Then the velocity of the particle \({v}_{i,d}\left(t+1\right)\) and the position of the particle \({x}_{i,d}\left(t+1\right)\) are updated by Eq. (5) and (6).

$$v_{i,d} \left( {t + 1} \right) = \omega \cdot v_{i,d} \left( t \right) + c_{1} r_{1} \cdot \left( {pb_{i} \left( t \right) - x_{i,d} \left( t \right)} \right) + c_{2} r_{2} \cdot \left( {gb\left( t \right) - x_{i,d} \left( t \right)} \right)$$
(5)
$$x_{i,d} \left( {t + 1} \right) = x_{i,d} \left( t \right) + v_{i,d} \left( {t + 1} \right)$$
(6)

where \(d\) is the number of particle dimension. The \(\upomega\) is the inertia weight of the particle. The parameters \({c}_{1}\) and \({c}_{2}\) are the learning factors. The \({r}_{1}\) and \({r}_{2}\) are two random numbers. Then particles enter to the next iteration until the iteration satisfies the convergence condition or reaches the maximum number of iterations.

The proposed protocol uses a PSO-based cluster routing algorithm to calculate the set of CHs and the sojourn locations of BS. This algorithm aims at reducing and balancing the energy consumption of sensor nodes as well as reducing the path length of BS. This protocol needs to meet the following conditions.

  1. 1.

    The residual energy of CHs should be as much as possible in order to transmit the aggregated data to BS.

  2. 2.

    The number of the CMs in each cluster should be as even as possible in order to balance the energy consumption in each cluster.

  3. 3.

    The distance between the CM and the CH should be less, so the energy consumption for intra cluster routing is low.

  4. 4.

    The distance between the CHs and the locations of BS should be less so the energy consumption for inter cluster routing is low.

  5. 5.

    The distribution of BS sojourn locations should be concentrated so the length of the BS’s traversal path can be reduced.

According to the conditions mentioned above, the fitness value of the proposed algorithm \(f\left(t\right)\) is related to the relative transmission overhead \({O}_{tran}\), the relative residual energy \({E}_{re}\), the discrete degree of the CMs in each cluster \({D}_{CM}\) and the discrete degree of the sojourn locations for BS \({D}_{soj}\).

Before introducing the relative transmission overhead, the energy consumed for transmitting the sensor data to BS \({E}_{total}\) in the whole network is given by Eq. (7).

$$E_{total} = \mathop \sum \limits_{i = 1}^{{N_{CH} }} E_{{CH_{i} }} + \mathop \sum \limits_{j = 1}^{{N_{CM} }} E_{{CM_{j} }}$$
(7)

where \({N}_{CH}\) is the number of CHs in the entire network and \({N}_{CM}\) is the number of CMs in the entire network. The energy consumed for each CH \({E}_{{CH}_{i}}\) is given by Eq. (8).

$$E_{{CH_{i} }} = N_{{CM_{i} }} \cdot E_{Rx} \left( k \right) + \left( {N_{{CM_{i} }} + 1} \right) \cdot E_{DA} \left( k \right) + E_{Tx} \left[ {k \cdot agg \cdot \left( {N_{{CM_{i} }} + 1} \right),d_{{BS_{i} }} } \right]$$
(8)

where \({N}_{{CM}_{i}}\) is the number of CMs in each cluster, \({d}_{{BS}_{i}}\) is the distance between CH and the corresponding sojourn location of BS, \(k\) is the size of each data packet and \(agg\) is the data aggregation rate. The energy consumed for each CM \({E}_{{CM}_{j}}\) is given by Eq. (9).

$${E}_{{CM}_{j}}={E}_{Tx}\left(k,{d}_{{CH}_{j}}\right)$$
(9)

where \({d}_{{CH}_{j}}\) is the distance between CM and the CH. According to Eq. (1), (2), (3), (7), (8) and (9), \({E}_{total}\) is given by Eq. (10). In order to balance the energy consumption, this equation assumes that the number of CMs in each cluster is equal.

$${E}_{total}=2{N}_{CM}\cdot k{E}_{elec} +k{N}_{total}\cdot \left({E}_{agg}+agg\cdot {E}_{elec}\right)+k{\varepsilon }_{fs}\cdot \left(\sum_{j=1}^{{N}_{CM}}{{d}_{{CH}_{j}}}^{2}+agg{N}_{total}\cdot \sum_{i=1}^{{N}_{CH}}{{d}_{{BS}_{i}}}^{2}\right)$$
(10)

Where \({N}_{total}\) is the total sensor nodes in the network. In Eq. (10), only the \({d}_{{CH}_{j}}\) and the \({d}_{{BS}_{i}}\) are variable and all the other parameters are invariable. Therefore, relative transmission overhead is the normalization of the sum of the squares of the distance to next-hop node for sensor nodes. The relative transmission overhead is given by Eq. (11), where \({d}_{i}\) is the distance between the sensor node and next hop node. The network with less \({O}_{tran}\) should have a larger \(f\left(t\right)\).

$$O_{tran} = \frac{{\mathop \sum \nolimits_{i = 1}^{{N_{total} }} d_{i}^{2} }}{{N_{total} \times d_{0}^{2} }}$$
(11)

According to Eq. (8) and (9), CH consumes more energy than CM. Therefore, the residual energy in CHs should be higher in the network. Relative residual energy is the normalization of the sum of the residual energy for CHs and is given by Eq. (12).

$${E}_{re}=\frac{\sum_{i=1}^{{N}_{CH}}{E}_{i}}{{N}_{CH}\times {E}_{max}}$$
(12)

where \({E}_{i}\) is the residual energy of the \(i\) th CH and \({E}_{max}\) is the maximum residual energy of the sensor nodes in the network. The network with more \({E}_{re}\) should have a larger \(f\left(t\right)\).

In order to balance the energy consumption in each cluster, the number of CMs in each cluster should be balanced. \({D}_{CM}\) indicates the discrete degree of the CMs in each cluster and is the normalization of the standard deviation for the number of CMs in the network. The discrete degree of the CMs in the network is given by Eq. (13).

$$\begin{aligned}&{D}_{CM}=\frac{1}{{N}_{{CM}_{max}}}\times \sqrt{\frac{\sum_{i=1}^{{N}_{CH}}{\left({N}_{{CM}_{i}}-\frac{{N}_{CM}}{{N}_{CH}}\right)}^{2}}{{N}_{CH}}} \\&{N}_{{CM}_{max}}=max\left({N}_{{CM}_{1}},{N}_{{CM}_{2}},\cdots ,{N}_{{CM}_{{N}_{CH}}}\right)\end{aligned}$$
(13)

Where \({N}_{{CM}_{max}}\) is the number of CMs in a cluster which has the maximum \({N}_{{CM}_{i}}\). The network with less \({D}_{CM}\) should have a larger \(f\left(t\right)\).

If the sojourn locations of BS are close to each other, the length of the BS traversal path will be shortened. If the length of the BS traversal path is short, the latency to transmit the data to BS for each sensor node can be reduced. Before defining the discrete degree of the sojourn locations for BS, the center of the sojourn locations is given by Eq. (14) and (15) at first.

$${x}_{C}=\frac{\sum_{i=1}^{{N}_{soj}}{x}_{i}^{Soj}}{{N}_{soj}}$$
(14)
$${y}_{C}=\frac{\sum_{i=1}^{{N}_{soj}}{y}_{i}^{Soj}}{{N}_{soj}}$$
(15)

where \({N}_{soj}\) is the number of sojourn locations. The \(\left({x}_{c},{y}_{c}\right)\) is the center location of the sojourn locations and the \(\left({x}_{i}^{Soj},{y}_{i}^{Soj}\right)\) is a sojourn location of BS. The distance between the center location and each sojourn location \({d}_{{C}_{i}}\) is given by Eq. (16) and \({d}_{{C}_{mean}}\) which is the mean value of \({d}_{{C}_{i}}\) is given by Eq. (17).

$${d}_{{C}_{i}}=\sqrt{{\left({x}_{i}^{Soj}-{x}_{C}\right)}^{2}+{\left({y}_{i}^{Soj}-{y}_{C}\right)}^{2}}$$
(16)
$${d}_{{C}_{mean}}=\frac{\sum_{i=1}^{{N}_{soj}}{d}_{{C}_{i}}}{{N}_{soj}}$$
(17)
figure d

The discrete degree of the sojourn locations for BS is given by (18).

$$\begin{aligned}&{D}_{soj}=\frac{1}{{d}_{{C}_{max}}}\times \sqrt{\frac{\sum_{i=1}^{{N}_{soj}}{\left({d}_{{C}_{i}}-{d}_{{C}_{mean}}\right)}^{2}}{{N}_{soj}}}\\ &{d}_{{C}_{max}}=max\left({d}_{{C}_{1}},{d}_{{C}_{2}},\cdots ,{d}_{{C}_{{N}_{soj}}}\right)\end{aligned}$$
(18)

Where \({d}_{{C}_{max}}\) is the maximum value of \({d}_{{C}_{i}}\). The network with less \({D}_{soj}\) should have a larger \(f\left(t\right)\).

The fitness function for this algorithm is given by Eq. (19).

$$f\left( t \right) = \alpha \left( {1 - O_{tran} } \right) + \beta E_{re} + \gamma \left( {1 - D_{CM} } \right) + \delta \left( {1 - D_{soj} } \right) \alpha + \beta + \gamma + \delta = 1$$
(19)

The PSO algorithm is adapt to solve the continuous problem, but the solve of the optimal set of CHs is a discrete problem. So, the proposed protocol improved the PSO algorithm in order to adapt the discrete problem.

In the PSO-based cluster routing algorithm, the particle location includes the set of CHs \({x}_{i}^{CH}\left(\mathrm{t}\right)\) and the set of the sojourn location \({x}_{i}^{Soj}\left(\mathrm{t}\right)\). Equation (20) represents the particle location.

$$\begin{aligned}&{x}_{i}^{CH}\left(t\right)=\left\{{F}_{1},{F}_{2},\cdots ,{F}_{{N}_{total}}\right\}\\ &{x}_{i}^{Soj}\left(t\right)=\{{x}_{1}^{Soj},{y}_{1}^{Soj},{x}_{2}^{Soj},{y}_{2}^{Soj},\cdots ,{x}_{{N}_{soj}}^{Soj},{y}_{{N}_{soj}}^{Soj}\}\end{aligned}$$
(20)

where \({F}_{i}\) is the flag of a sensor node, ‘1’ represents that the sensor node is CH and ‘0’ represents that the sensor node is CM.

The velocity of the particle may beyond the boundaries. Therefore, a velocity transformation function is proposed to keep the velocity of particles within a specified range. The velocity transformation function is given by Eq. (21).

$${v}_{i,d}\left(t\right)={v}_{min}+\frac{{v}_{i,d}\left(t\right)-{{v}_{min}}^{^{\prime}}}{{{v}_{max}}^{^{\prime}}-{{v}_{min}}^{^{\prime}}}\cdot \left({v}_{max}-{v}_{min}\right)$$
(21)

where \({v}_{max}\) and \({v}_{min}\) is the boundary of the particle. \({{v}_{max}}^{^{\prime}}\) is the maximum value of \({v}_{i,d}\left(t\right)\) and \({{v}_{min}}^{^{\prime}}\) is the minimum value of \({v}_{i,d}\left(t\right)\).

At the beginning of PSO, a large inertial weight is beneficial to global search. At the end of PSO, a small inertial weight is beneficial to local search. In order to implement the process mentioned above, a linearly decreasing inertia weight is used in the proposed algorithm. The inertia weight for each iteration \(\omega \left(t\right)\) is given by Eq. (22).

$$\omega \left(t\right)={\omega }_{min}+\left({\omega }_{max}-{\omega }_{min}\right)\times \frac{t}{T}$$
(22)

where \({\omega }_{max}\) and \({\omega }_{min}\) is the boundary of the inertia weight. The \(T\) is the maximum number of the iterations. The process of the PSO-based cluster routing algorithm is given by algorithm 1. The set of the CHs and the sojourn locations which are calculated by PSO-based cluster routing algorithm is given by Fig. 4

Fig. 4
figure 4

Network topology of the PACMSD

After determining the set of CHs, each CM will join the CH which is the closest of itself. Then, the controller module in BS generates the flow table for each sensor node. Finally, BS delivers the flow table to sensor nodes in the flow table delivery phase.

In most of the cluster routing protocols, the routing of the whole network is recalculated in each round. This methodology can balance the energy consumption between sensor nodes. However, it increases the control overhead in the entire network as well as reduces the network stability. The proposed protocol uses an on-demand clustering. The controller module in BS will only recalculate the routing when the network satisfies the conditions given as follows.

  1. 1.

    The number of alive nodes changes in the network.

  2. 2.

    The network has run more than the threshold value of the round \({r}_{max}\) after calculating the routing of the network.

  3. 3.

    The standard deviation of the residual energy in the network is more than threshold value \({E}_{th}\). When the network satisfies the inequality (23), controller module will recalculate the routing of the network, where \({E}_{mean}\) is the mean value of \({E}_{i}\) which is given by Eq. (24). This condition aims at balancing the residual energy of the sensor nodes and prolonging the lifetime of the network.

    $$\sqrt{\frac{\sum_{i=1}^{{N}_{total}}{\left({E}_{i}-{E}_{mean}\right)}^{2}}{{E}_{max}}}\ge {E}_{th}$$
    (23)
    $${E}_{mean}=\frac{\sum_{i=1}^{{N}_{total}}{E}_{i}}{{N}_{total}}$$
    (24)

4.3 ABC-based traversal path algorithm

ABC is inspired by the foraging behavior in bee colonies. The goal of the bee colonies is to find the optimal honey source in the search space. According to the divide of work, the colony of bees includes the employed bees, onlooker bees and scout bees. The operation of the ABC algorithm is divided into the initialization stage, the employed bee stage, the onlooker bee stage and the scout bee stage.

In the initialization stage, honey sources \(\left\{{X}_{1},{X}_{2},\cdots ,{X}_{N}\right\}\) random distribute in the search space according to Eq. (25).

$$\begin{aligned}&{X}_{ij}={X}_{min}+rand\left(\mathrm{0,1}\right)\cdot \left({X}_{max}-{X}_{min}\right)\\ &i\in \left\{\mathrm{1,2},\cdots ,N\right\}, j\in \left\{\mathrm{1,2},\cdots ,D\right\}\end{aligned}$$
(25)

where \(N\) is the number of honey sources and \(D\) is the dimensions of the search space.

In the employed bee stage, each employed bee searches a new neighboring honey source according to Eq. (26).

$${V}_{ij}={X}_{ij}+rand\left(-\mathrm{1,1}\right)\times \left({X}_{ij}-{X}_{kj}\right) k\in \left\{\mathrm{1,2},\cdots ,N\right\}, k\ne i$$
(26)

Where \({X}_{k}\) is a honey source except \({X}_{i}\). Then, the objective function \(f\left({X}_{i}\right)\) and \(f\left({V}_{i}\right)\) is calculated. If the solution of \(f\left({V}_{i}\right)\) is better than \(f\left({X}_{i}\right)\), the \({X}_{i}\) is replaced by \({V}_{i}\). Next, the fitness value function \(fit\left({X}_{i}\right)\) is calculated according to Eq. (27).

$$\mathrm{fit}\left({\mathrm{X}}_{\mathrm{i}}\right)=\left\{\begin{array}{c}\frac{1}{1+\mathrm{f}\left({\mathrm{X}}_{\mathrm{i}}\right)} , f\left({\mathrm{X}}_{\mathrm{i}}\right)\ge 0\\ 1+\left|\mathrm{f}\left({\mathrm{X}}_{\mathrm{i}}\right)\right| , f\left({\mathrm{X}}_{\mathrm{i}}\right)<0\end{array}\right.$$
(27)

In the onlooker bee stage, the onlooker bees use the greedy selection method to select the optimal honey source. An employed bee generates a random number \(r\) at first. Then \(r\) is compared to probability \({P}_{i}\). The calculation of \({P}_{i}\) is given by Eq. (28). If \(r\) is less than \({P}_{i}\), the employed bee will convert to onlooker bee. If \(r\) is greater the \({P}_{i}\), employed bee updates the honey source of itself according to Eq. (25).

$${\mathrm{P}}_{\mathrm{i}}=\frac{\mathrm{fit}\left({\mathrm{X}}_{\mathrm{i}}\right)}{\sum_{\mathrm{i}=1}^{\mathrm{N}}\mathrm{fit}\left({\mathrm{X}}_{\mathrm{i}}\right)}$$
(28)

In the scout bee stage, an onlooker bee may change to scout bee in order to avoid the local optimum. If a honey source of the onlooker bee doesn’t change after \({I}_{th}\) iterations, the onlooker bee will convert to scout and generate a new honey source according to Eq. (25). The \({I}_{th}\) is the threshold of the iterations.

figure e

The ABC-based traversal path algorithm aims at generating the shortest traversal path of the mobile BS. The BS must visit all the sojourn locations which are calculated in Sect. 4.2. The BS can only visit each sojourn location for one time. This is the traveling salesman problem (TSP) and it is a discrete problem.

The proposed protocol uses the ABC algorithm to solve the traveling salesman problem. Each honey source is an \({N}_{soj}\times {N}_{soj}\) matrix which has random numbers between 0 and 1. The first column and the diagonal of the matrix is 0. An example to process the random matrix into the traversal path is given as (29).

Assume \({N}_{soj}=4\) and the starting position of the path is ‘1’ which is represented as \({path\left({X}_{i}\right)}_{1}=1\). Then find the maximum number in the first row. The maximum number of this column is 3. So \({path\left({X}_{i}\right)}_{2}=3\) and the third column of the matrix is update to 0. Next, find the maximum number in the third row, which is 0.92. So \({path\left({X}_{i}\right)}_{3}=2\) and update the second column of the matrix to 0. Finally, \({path\left({X}_{i}\right)}_{4}=4\) and the traversal path of the mobile BS is 1–3-2–4. The \(f\left({X}_{i}\right)\) is the path length which is given as Eq. (30).

(29)
$$f\left( {X_{i} } \right) = \mathop \sum \limits_{j = 2}^{{N_{soj} }} \sqrt {\left( {x_{{path\left( {X_{i} } \right)_{j} }} - x_{{path\left( {X_{i} } \right)_{j - 1} }} } \right)^{2} + \left( {y_{{path\left( {X_{i} } \right)_{j} }} - y_{{path\left( {X_{i} } \right)_{j - 1} }} } \right)^{2} }$$
(30)

Fig. 5 is the traversal path of the mobile BS which is calculated by ABC-based traversal path algorithm. The process of the ABC-based traversal path algorithm is given by algorithm 2.

Fig. 5
figure 5

Traversal path of the mobile BS

5 Complexity analysis

5.1 Time complexity

The proposed protocol uses the SDN framework. The cluster routing of the network and the traversal path of the mobile BS are both calculated in the BS. The BS can be recharged, so the energy for BS is unlimited. So, the routing computation in BS cannot influence the network lifetime and the energy consumed in sensor nodes.

For the PSO-based cluster routing algorithm, the fitness function is calculated in the initialize phase. The time complexity is \(O\left(M\times n\right)\). The time complexity in the iteration process is \(O\left(M\times n\times {T}_{PSO}\right)\). Where \(n={N}_{total}+{N}_{soj}\), \(M\) is the number of particles and \({T}_{PSO}\) is the maximum iteration number. Therefore, the time complexity of the PSO-based cluster routing algorithm is \(O\left(M\times n\times {T}_{PSO}\right)\).

For the ABC-based traversal path algorithm, the time complexity is \(O\left(N\times {{N}_{soj}}^{2}\right)\) in the initialization stage. The time complexity is \(O\left(N\times {{N}_{soj}}^{2}\times {T}_{ABC}\right)\) for the other three phases. Where \({T}_{ABC}\) is the maximum iteration number and \(N\) is the number of bees. Therefore, the time complexity of the ABC-based traversal path algorithm is \(O\left(N\times {{N}_{soj}}^{2}\times {T}_{ABC}\right)\).

5.2 Hardware complexity

Table 1 is the complexity in implementing the PACMSD algorithm on hardware. Since PACMSD is an iterative procedure, we analysis only one single iteration because the same hardware resources can be reused for the next iterations [33].

Table 1 Hardware complexity of PACMSD

The PSO-based cluster routing algorithm consists of \(M\times \left(10{N}_{total}+26{N}_{soj}+3{N}_{CH}\right)+2\) addition operations, \(M\times \left(8{N}_{total}+18{N}_{soj}+{N}_{CH}\right)+2\) multiplication operations, \(M\times \left({N}_{soj}+2\right)\) square root operations and \(2M+4\) operations of take the maximum value.

The ABC-based traversal path algorithm consists of \(N\times \left(2{{N}_{soj}}^{2}+4{N}_{soj}-3\right)-1\) addition operations, \(N\times \left({{N}_{soj}}^{2}+2{N}_{soj}+1\right)\) multiplication operations, \(N\times \left({N}_{soj}-1\right)\) square root operations and \(N\times \left({N}_{soj}+2\right)\) operations of take the maximum value.

6 Simulation results

The proposed protocol PACMSD is compared with the MERAM-R [30], ACO-based protocol [31] and DE-based protocol [32]. The detail of these three protocols is introduced in Sect. 2. The simulation parameters are given by Table 2.

Table 2 Simulation parameters

The article aims at verifying the proposed protocol performs well both in small-scale network and large-scale network. Therefore, the network scale is different and other parameters are same in two scenarios. The proposed protocol and the comparison protocols are simulated in two different scenarios. In scenario 1, 100 sensor nodes randomly distribute in the 200 m \(\times\) 200 m network. In scenario 2, 400 sensor nodes randomly distribute in the 400 m \(\times\) 400 m network [31, 32, 34]. The initial energy of each sensor node is 0.5 J. The size of each data message and control message is 4000 bits and 32 bits respectively.

The \({E}_{elec}\), \({\varepsilon }_{fs}\), \({\varepsilon }_{mp}\), \({E}_{agg}\) and \(agg\) are the parameters in the first-order radio model. This paper selects the parameter values which are used in most of the articles [24].

We use the Matrix Laboratory (MATLAB) to simulate the performance of these protocols. Each scenario is simulated for 50 times and the average of these results is used to represent the performance of the protocols. This methodology reduces the error in the simulation process. The simulation results are shown as follows.

6.1 Energy consumption

In this article, the energy of sensor nodes is used for transmitting data, receiving data, aggregating data and calculating routing. The energy consumed in the idle phase and sleep phase is much less than other phases. Therefore, the energy consumed in these two phases are not considered. In the simulation, we evaluate the residual energy of each node according to the number of messages, the transmission distance and the complexity of the algorithm. In reality, the energy monitoring system and the circuit measuring equipment can be used to evaluate the residual energy of each node [35].

Figure 6 (a) is the total residual energy for sensor nodes in scenario 1 and Fig. 6 (b) is the total residual energy for sensor nodes in scenario 2. In these two figures, PACMSD consumes less energy than the comparison protocols. It shows the proposed protocol reduces the energy consumption both in the small network and the large network.

Fig. 6
figure 6

Total residual energy for sensor nodes

For MERAM-R and ACO-based protocol, sensor nodes need to calculate the network routing in each round. This method increases the energy consumption for calculating the routing and transmitting the control message. The DE-based protocol uses an on-demand clustering method which reduces the energy consumption for transmitting the control message. For PACMSD, it uses the SDN architecture in the WSNs. All the calculations are processed in the controller module within the BS. Sensor nodes only need to transmit the information of itself to BS. This method reduces the computation overhead and the control overhead in the routing setup phase. The proposed protocol also uses an on-demand clustering which overall considers the standard deviation of the residual energy and the threshold value of the round. Therefore, the proposed protocol reduces the energy consumption in network.

6.2 Lifetime of the network

Figure 7a is the number of alive nodes in scenario 1 and Fig. 7b is the number of alive nodes in scenario 2. In order to show the lifetime of the simulated protocols, three performance parameters are used. These three parameters are the first node dies (FND), half node dies (HND) and last node dies (LND). FND is the number of the round when the first sensor node dies. HND is the number of the round when half of the sensor nodes die. LND is the number of the round when all the sensor nodes die. Figure 8 is the statistics of FND, HND and LND in different scenarios.

Fig. 7
figure 7

Number of alive nodes in each scenario

Fig. 8
figure 8

Statistics of node death

The network connectivity is reduced when a node dies in the network. Some nodes cannot transmit the sensor data to BS. Therefore, FND is used to denote the network lifetime in this simulation. According to Fig. 78, PACMSD performs better than other protocols both in small network and large network. The FND, HND and LND of the proposed protocol are all performs well. This means PACMSD are suitable both in small-scale network and large-scale network.

The network lifetime of each of protocols in scenario 1 are 426 rounds, 465 rounds, 520 rounds and 734 rounds respectively. PACMSD performs better than MERAM-R by 72.3%, ACO-based protocol by 57.9% and DE-based protocol by 41.2%. The network lifetime for each of protocols in scenario 2 are 358 rounds, 427 rounds, 469 rounds and 493 rounds respectively. PACMSD performs better than MERAM-R by 37.7%, ACO-based protocol by 15.5% and DE-based protocol by 5.1%.

The CHs are randomly generated in MERAM-R and a node with less residual energy can become the CH. This makes the energy unbalanced in the network and reduces the network lifetime. ACO-based protocol and DE-based protocol consider the residual energy when select the set of CHs. This methodology balances the energy consumption and prolongs the lifetime of the network. However, they don’t consider the number of neighbor nodes and a cluster can be large. This will increase the energy consumption for these sensor nodes and reduce the network lifetime.

The proposed protocol overall considers the relative transmission overhead, the relative residual energy, the discrete degree of the CMs in each cluster and the discrete degree of the sojourn locations for BS. It also uses the PSO-based cluster routing algorithm to make these parameters balanced. The SDN architecture reduces the energy consumption in the topology discovery phase and the flow table generation phase. Therefore, the proposed protocol prolongs the network lifetime.

It can be seen that the number of alive nodes in Fig. 7 starts falling exactly after 700 rounds in both scenarios for PACMSD protocol. However, the simulation curves begin to fall for other protocols is different in differentiated scenarios. MERAM-R selects the CHs in each round randomly. The ACO-based protocol and the DE-based protocol only consider the residual energy and the distance to CHs in the CH selection phase. All the comparison protocols don't consider the number of CMs in each cluster which makes the energy consumption for each of CHs different. With the increasing of the network scale, the energy consumption for each sensor node is more and more unbalanced. Therefore, the simulation curve begins to fall earlier with the increasing of the network.

The proposed protocol overall considers the relative transmission overhead, the relative residual energy and the discrete of CMs in each cluster. Meanwhile, the PSO-based cluster routing algorithm is used to balance the energy consumption in the network. Beyond that, the mean of the node degreed is same in these two scenarios. So, the simulation curves begin to fall almost at the same round for PACMSD.

6.3 Length of the traversal path

Figure 9 is the average length of the BS traversal path in each round when the last node dies for different protocols. The proposed protocol aims at reducing the length of the traversal path for BS. The movement speed of the mobile BS for each protocol is same. If the path length is short, nodes can transmit the sensor data to BS quickly. So, the latency of the sensor nodes can be reduced.

Fig. 9
figure 9

Total length of the BS traversal path

In Fig. 9, The length of the traversal path for each of protocols in scenario 1 are 363.4 m, 305.7 m, 327.1 m and 272.1 m. It shows that PACMSD performs better than MERAM-R by 25.1%, ACO-based protocol by 11.0% and DE-based protocol by 16.8%. The length of the traversal path for each of protocols in scenario 2 are 3031.5 m, 1017.1 m, 1391.9 m and 947.5 m. It shows that PACMSD performs better than MERAM-R by 68.7%, ACO-based protocol by 6.8% and DE-based protocol by 31.9%.

In MERAM-R, the BS randomly move in the network. So, the path length of the mobile BS is the longest. In DE-based protocol, the network is divided into sub regions and the mobile BS passes these sub regions sequentially. It doesn’t use any method to reduce the travel length, so the performance of DE-based protocol is worse than ACO-based protocol and PACMSD. ACO-based protocol uses ACO to calculate the move path of BS, which reduces the length of the moving path.

In PACMSD, the PSO-based cluster routing algorithm considers the discrete degree of the sojourn locations for BS, which reduces the distance between each sojourn location. Meanwhile, the ABC-based traversal path algorithm is used to calculate the traversal path, which further reduces the length of the traversal path. Therefore, PACMSD reduces the length of the traversal path.

6.4 Control overhead

Figure 10 is the statistics of control overhead for each of protocols in different scenarios. Control overhead is the average number of control messages in each round. If the control overhead is low, the energy consumed for transmitting the control message is low. Reducing the control overhead can relieve network congestion as well as increase the network stabilization.

Fig. 10
figure 10

Statistics of control overhead

According to Fig. 10, PACMSD performs better than MERAM-R by 77.2%, ACO-based protocol by 76.6% and DE-based protocol by 89.4% in scenario 1. PACMSD performs better than MERAM-R by 60.8%, ACO-based protocol by 49.7% and DE-based protocol by 79.7% in scenario 2.

In MERAM-R, control messages are needed in the cluster formation phase. In ACO-based protocol, each sensor node needs control message to collect the information of neighbor nodes in order to elect the CH. Without using on-demand cluster routing, these two protocols need more control overhead than PACMSD. The DE-based protocol uses the on-demand cluster routing. However, it uses DE-based cluster routing in a distributed routing protocol and the DE algorithm requires iteration. Therefore, it needs more control message in order to determine the optimal set of CHs.

In PACMSD, sensor nodes only need transmit the information of itself to BS and all the calculation process is operated in the controller module within BS. This method reduces the control overhead in the topology discovery phase and the flow table generation phase. The proposed protocol also uses an on-demand cluster routing which reduces the control overhead similarly. Therefore, PACMSD reduces the control overhead of the network.

Table 3 lists the simulation results for different protocols. Thereinto, the energy consumption is the energy consumed for all sensor nodes within a round before the first node dies. It can be seen that PACMSD performs better than comparison protocols in all the network performance.

Table 3 Simulation results

7 Conclusion

In this paper, the proposed protocol uses SDN architecture in WSNs. The routing of the entire network is calculated in the controller module. It reduces the computation overhead and the control overhead in sensor nodes. The PSO-based cluster routing algorithm is used for determining the set of the CHs and the sojourn locations of BS. It balances the energy consumption in network. The ABC-based traversal path algorithm is used for calculating the traversal path of the mobile BS. This method reduces the length of the traversal path. According to the simulations, the proposed protocol performs better than MERAM-R, ACO-based protocol and DE-based protocol. It reduces the energy consumption, prolongs the network lifetime, reduces the control overhead and reduces the path length of the mobile BS.