#### Abstract

Rapid progress in technologies has led to the development of small sensor nodes. A wireless sensor network (WSN) is an interconnected collection of a large number of these small sensor nodes that is used to monitor and record the physical environment. WSNs have applications in diverse scenarios. They play an important role in tracking and monitoring in different domains, such as environmental research, military, and health care. In most of these applications, the WSN is composed of a large number of nodes deployed in an area of interest, and not all nodes are directly connected to the base station (BS). In some cases, batteries of nodes cannot be recharged or changed. For that, the most solution required to overcome these problems is to optimize energy consumed during communication. Data transmission in networks is maintained by routing protocols, which are responsible for discovering the required paths. This paper presents an improvement of the Geographic Adaptive Fidelity (GAF) routing protocol created on a smart actives node selection. The routing process works on cooperative agents communication where another node is activated in the same grid if the data collected are considered as important data, and a heuristic method is used to find an optimal path in terms of energy to transmit data collected until reaching the BS. Simulation results prove that the cooperative agents GAF (CAGAF) routing protocol proposed is more efficient compared to the basic version in terms of considering important data, energy consumed, and dead nodes.

#### 1. Introduction

Due to the rapid development in technology, wireless sensor networks (WSNs) [1] have been invented to make our daily lives easier. They have been applied in diverse domains [2], such as health care, military applications, and environmental studies, for extracting data, monitoring, tracking, and disaster prevention. In WSN, a large number of sensor nodes are deployed in an area of interest to sense physical parameters of the environment and send them to a central point called the base station (BS) or sink, which extracts them for analysis or storage. Despite their various advantages, WSNs [3] are still subject to some constraints. The most challenging issue is their limited energy [4]. For example, in some cases, it is not possible to change or recharge the large number of batteries needed to run such a network, especially one spanning a large area of interest. Sensors execute various tasks, such as sensing data, processing the data, and deciding where and when to send them; these processes of receiving and transmitting data are inherently energy consuming [5]. The energy consumed during WSN operation directly affects the performance of the network and degrades the network lifetime. Various techniques are used to decrease the energy consumption, reduce the total amount of data through methods of aggregation or compression [6], design efficient routing protocols, and activate sleep mode for unneeded nodes in the network. Diverse routing protocols [7] have been developed to ensure the communication in WSNs, and these protocols can be categorized into three families [8]: data-centric, hierarchical [9–11], and location-based [12, 13] protocols. In the last type, location information is already known by the use of geographic positions system (GPS) or other methods [14]; each node must know the location of its neighboring nodes that is one hop away from it. Moreover, the source must know the location of the destination node. For many wireless sensor network applications, location information is essential; it expects that each wireless sensor node in the network will be equipped with certain location devices. In this paper, we focus our goal to improve the existing studies by presenting a new Cooperative Agents Geographic Adaptive Fidelity (CAGAF) routing protocol created on a smart actives node selection by using some criteria of selection as maximum residual energy, data importance, and minimum distance to the base station. Also, the routing process in our approach is based on cooperative agents communication, where the agents are selected on the basis of the following parameters: the residual energy, the density, the defined position type of each sensor, and the importance of the information. Moreover, a heuristic approach is used to find optimal path in terms of energy. Many methods [15, 16] are used to reduce the total amount of data by the use of aggregation approach, compression methods, or operational research (OR) that has been used widely in a few areas to resolve optimization problems as augmenting network lifetime and improving sensors performance. Operational research comprises different techniques such as graph theory and linear programs for making better decisions. We have joined localization-based routing, active node selection method, and graph theory approach to find the optimal path to the base station. That helps in reducing energy consumed, therefore prolonging the network lifetime. A new GAF routing protocol is created on graph theory approach. The improved protocol can produce the optimal path and select the active node responsible for transmitting data collected, not as in the traditional GAF process which diffused their data to the neighboring grids, without considering remaining energy of active nodes, the importance of information transmitted, or if the next hop is near to the base station or not. This paper is organized as follows. In Section 2, related works are presented. Section 3 refers to the proposed approach that explains the process of active node selection and optimal path used. Section 4 presents simulation results and discussions. Finally, Section 5 concludes the paper.

#### 2. Related Work

In this section, we introduce the GAF routing protocol and previous studies [17] on data aggregation problems and cooperative schemes in WSNs. In a routing protocol based on location type [18], also known as geographic routing [19], sensor nodes are identified by their positions. The distance between a pair of neighbouring nodes can be calculated based on the received signal strength. The relative coordinates of neighbouring nodes can be obtained by exchanging information between neighbours. Alternatively, the locations of sensor nodes may be directly obtained by communicating with a satellite using the Global Positioning System (GPS) if each node is equipped with a small, low-power GPS receiver.

GAF for adaptive geographic fidelity [20] is a location-based method founded on an energy-aware routing protocol that is designed principally for mobile ad hoc networks and used for WSNs. In the GAF protocol, the network area is divided into virtual fixed grids, as shown in Figure 1. In each grid cell, nodes communicate with each other to play different roles, transitioning through three different states in Figure 2: the active state, where the node is responsible for routing data; the discovery state, in which the node tries to determine its neighbours in the grid; and the sleep state, in which the radio is turned off. Each node uses its GPS-indicated location to associate itself with a point on the virtual grid.

The advantage of the GAF routing protocol over other protocols is represented by the use of transition states that prolong the network lifetime. GAF can significantly decrease energy consumption since only one node is activated in each grid to be responsible for routing, while the other nodes in the same grid are into the sleep state for a certain time. Even though the GAF protocol was anticipated to solve the critical problem of energy, it remains limited in terms of some disadvantages such as that it allows communication between only adjacent grids, it does not consider energy of nodes or data importance to select active nodes, and it does not take into account the distance to the base station. For that, some improved versions appeared to overcome these limits, such as DGAF protocol, two-level GAF, optimized GAF, and GAFDG.

Diagonal GAF (DGAF) [21] routing protocol is an enhanced form of original GAF that permits a direct communication between two diagonal grids. In addition, it allows avoiding the problem of basic GAF, where forwarding packets arise only in two directions: vertical and horizontal way.

Two-level GAF (TGAF) routing protocol [22] is proposed in order to overcome the problem of communication between only neighboring grids. It helps in reducing the number of hop counts, to facilitate to the sensors in the same grid forwarding the data packets to the neighbor in its adjacent grids. This permits reducing the number of nodes responsible for routing data. The main goal of TGAF is based on using two levels for transmitting data using highest residual energy for selecting active nodes. Authors prove that this concept helps in minimizing the energy consumed and automatically extending the network lifetime.

Optimized GAF routing protocol is an improved version of the basic GAF [23]. The improvement achieved by this approach is related to the transitions states. The enhanced protocol also involves three states, as does the original GAF protocol. However, its process is performed differently as shown in Figure 3, with the main aim of the discovery phase being to define a sequence of nodes that will be selected as active nodes. This phase is executed only once. Hence, the energy consumed is minimized. The transitions between phases are implemented as follows:(i)Discovery phase: The purpose of this phase is to define a sequence of nodes that will be chosen to play the role of active nodes. The nodes are selected by considering the highest remaining energy. This phase is executed only once to reduce the energy consumed.(ii)Active phase: After Ta (time of activity for a node), the next active node is selected from the previously defined sequence without executing the discovery phase again.(iii)Sleep phase: After Ts (sleep time), the next node is activated as active node.

A new dislocated Grid GAF (GAFDG) [24] algorithm is proposed, based on the basic traditional GAF with aligned grid (GAFAG) to overcome the problem of limited energy in wireless sensor networks. The operating principle of this protocol permits dividing area of monitoring into dislocated grids and then, each node is affected in each grid according to its localization information and the side length of it. All nodes in the same grid constitute a cluster where a cluster head is selected based on two criteria, the node having the maximum residual energy compared to the average residual energy in each cluster and the closest to the center of the intracluster nodes. Each cluster head routes its data. The emulation results show that the energy consumption and the lifetime of the GAFDG network are better than those of GAFAG.

The main idea of network data aggregation [25] is that rather than transmitting individual data from the source sensor nodes to the destination nodes, multiple data elements can be aggregated for being transmitted on WSN.

Several works have focused on cooperative communication in various network applications. For example, in [26], the authors studied cooperative communication in wireless systems with multiple source nodes, multiple relay sensor nodes, and a single destination node.

The authors of [25] proposed a framework that combines data aggregation in the application layer and the Medium Access Control (MAC) layer based on sleeping mechanisms to reduce energy consumption in WSNs. In [27], a new approach was suggested for studying the energy efficiency problem by using cooperative communication with a structured topology based on aware trees in WSNs. This idea is centred on an algorithm that starts with a random aggregation tree to define the best transmission policy and to select a suitable corresponding time slot for each node to transfer the aggregated data to its father node.

A multiagent framework was proposed by the authors of [28] to help improve the performance of existing routing protocols in terms of energy consumption and packet relay. This framework permits each sensor node to construct a cooperative neighbour set on the basis of past routing experience. This allows the sensor nodes to successfully transmit packets in the future using the global view provided by the created set, which improves the quality of data reception during communication and helps to extend the network lifetime.

In [29], authors proposed an effective data aggregation method for finding the most informative route in a WSN. This technique considered energy efficiency based on a cost function and the information gain. A mobile agent migrates to its nearest first-hop node. Then, it moves to the next hop with the minimum cost as computed by a cost function that includes the information gain. This approach focuses on checking the information gain for the second hop and then allowing migration only if the difference in the information gain exceeds a predefined threshold. In such case, the current agent aggregates the available data, and this process is repeated to select the most informative agents with the minimal costs until the required node is reached. This work considered the following cost function for the migration of an agent from to :where is the information gain of node for agent migration, is the maximum value of information gain related to nodes, is the energy consumed to achieve agent migration from to , is the maximum energy value that necessitates agent migration, and is the number of times an agent visits node . , , and represent weight values associated with the information gain, the residual energy, and the energy required to achieve agent migration, respectively.

Due to the user Quality of Service (QOS) requirement, WSNs have been applied on different fields such as Flying Ad Hoc Sensor Networks (FASNETs). In [30], authors have designed a new clustering FASNET architecture based on Software Defined Networking (SDN) technique. This work aims to guarantee several QOS services as delay-sensitive and reliability where an efficient transmission prediction model is exploited.

Another work has been proposed in [31]. This work reviews the recent architectures suitable for 5G networks and presented a qualitative comparison of direct wireless connection (D-WCP) and indirect wireless connection (ID-WCP) schemes. In order to improve heterogeneous devices management in recent 5G networks, authors designed an effective framework based on direct and indirect WCP.

In [32], authors have proposed another scheme based on SDN paradigm. The main objective of this work is maximizing the network lifetime by reducing the number of active anchors. Anchor state is determined by SDN controller.

In [33], authors have designed an effective routing mechanism based on SDN paradigm. This novel approach aims to prolong network lifetime using a novel discovery routing mechanism and fuzzy decision routing algorithm. Moreover, authors improve the transmission phase where the routing path can be changed. For proving the routing scheme realistic application, the approach evaluation is conducted using Riverbed Modeler Software.

In order to provide a high-level authentication as well as simplifying the connectivity control of Wi-Fi devices authors in [34] proposed an SDN based connectivity control system that allows the administrator or the network owner to manage Wi-Fi devices through a remote service. No configuration information is required for the devices. Authors proved the feasibility of proposed approach through the real testbed and expect the suggested connectivity control system to be widely used to enhance the user and manufacture experience.

#### 3. Positioning of the Contribution

Previous reviewed works permit communication between diagonal grids, enhance the number of hop counts, make sorting nodes in terms of remaining energy to enhance transition states, replace the aligned grids with dislocated grids, use cooperation strategy to aggregate data, and so on. Even though several energy-efficient protocols have been proposed, no one takes into account the optimal path research for reducing the consumed energy. We propose an improved version of GAF that considers a smart active node selection and routing process based on cooperative agents communication. Agents are selected on the basis of the following parameters: the residual energy, the density, the defined position type of each sensor, and the importance of the information. To guarantee an extended lifetime of the whole network, proposed work helps in ensuring an optimal path to transmit data collected until reaching the base station. More details of the proposed work are given in the next sections.

#### 4. Proposed Mathematical Model

This paper studies the energy consumption problem on the basis of aggregated data communication based on cooperative agents in a WSN. Specifically, a sensor source node can use a cooperative agent as a relay to transmit its collected data without consuming more energy, such that the data reach the BS via cooperative communication, which will help to reduce the number of messages in the network, decrease the energy consumption, and extend the network lifetime.

We describe a general mathematical problem modeling the data communication. For that, we consider the graph defined with nonnegative edge weights , where is the set consisting of sensor nodes and a base station of the considered network, is the set of edges, and is the set of edge weights. We describe in the following the definitions and the constraints on the sets , , and . The base station is immobile and located at last virtual grid at position in the sensing area. The sensor nodes are immobile, homogeneous, and identical in terms of functionality, initial energy, and capability. Then, the coordinates of all nodes in the set are assumed available. The location information is known for each sensor by the use of localization devices and that of the base station is known for each source sensor node. So, we can evaluate the distance between two sensor nodes and or between a sensor node and the base station using the Euclidian distance and the location information, that is, The communication relation is bidirectional over the set of edges. For transmitting/receiving a -bits message over a distance , the energy model is calculated by the following equations: where means the energy of transmission, is the electronic energy, is the transmitter amplifier, and is the energy of reception of data of -bits above a distance . Hence, the total energy consumed is calculated byFor each edge , we design with the weight of the edge defined by the energy consumed for transmitting/receiving a message from to bySo, the routing cost of a spanning tree is defined aswhere we denote by a generic pair of nodes and by the set of all pairs of nodes and by the shortest path cost between two nodes on a tree .

The objective function (6) minimizes the total routing cost computed over all the arcs and all the commodities. The minimization problem can be formulated as a multicommodity flow problem, where each commodity corresponds to a pair of nodes. Let be the set of directed arcs obtained by adopting two directed arcs for each edge of in both directions. Therefore, two arcs and and commodity , equal to the flow which traverses the arc from to . In order to force the variable to be or , we add continuity constraints in a node for the commodity We made also the following constraint that guarantees the balance of the flow in the transit nodes for the pair .Let for be a binary variable which is equal to if the edge belongs to a tree, otherwise. To send the flow related to the commodity only on an edge of the tree, we introduce the constraintWith this notation and setting, the flow-based formulation is the following:

During the past few years there has been intensive activity aimed at showing that particular problems are NP-complete. Whenever a problem is found to be NP-complete, we know that it is not isolated or unique but instead is linked to a large number of classical hard problems. Such a discovery should lead all but the most confident and optimistic of us to despair of obtaining a polynomial-time algorithm for such a problem. The usual method of showing that a problem is NP-complete is to check that the problem is NP and then to show the reduction of the considered problem to a known NP-complete problem. The proposed model (10) belongs to the class of multicommodity flow problems as described previously. Thus, as proved in [35], we can show the reduction of the problem (10) to the satisfiability problem arising in elementary mathematical logic and known to be NP-complete (see [35] and the references therein).

Following the operating principle of GAF, we will consider that the nodes participating in the routing will take a flow value equal to 1, while the nodes in the sleep state will take the value 0. The following subsection describes this operating principle used in detail.

#### 5. Algorithms

Heuristic approaches have received great deal of attention in the literature, as in many applications a good solution has to be determined with very low computation times. Heuristic approaches are needed in these cases due to the complexity of the problem. This part describes some points including active node selection, data aggregation that is based on cooperative agents, and the time complexity of the proposed heuristic algorithm.

##### 5.1. Active Node Selection

In basic GAF, only one node in each grid cell is activated to behave as an active node. Active nodes are responsible for routing data to the BS via multihop data routing. The data importance is an essential criterion that should be considered for data routing. However, the GAF protocol activates only one node for each grid cell without considering the data importance. In our approach, the active node selection is based on the following:(i)Residual energy (E): This key parameter allows agents to maximize the lifetime of their network by participating in routing only if the value of this parameter is sufficiently high. We consider the ratio between the remaining energy at time and the maximum energy of the sensor at the time of its deployment, as illustrated in this equation:(ii)Information importance (I): This parameter depends on the type of application. We assume that information is more important if the difference between the new information and the old information exceeds a certain threshold.(iii)Minimum distance to the BS.

Thus, a network grid cell may have more than one active node: the principal active node and one or more active member nodes. This efficient selection process improves the network performance and allows important data to reach the BS. To improve the routing of the GAF protocol, we consider a cooperative agent method in which an active node or an active member node can be selected as a cooperative agent. We use Algorithm 1 to generate active nodes in each grid. Our proposed model is aimed for a whole class of this type of problems. In order to make it general, the weights and are arbitrarily chosen according to the decision maker considering his needs and objectives. Moreover, from a theoretical point of view, concerning the existence and the convergence of these algorithms, it is enough that these two constants are positive.

1: Import Data. | |

2: Initialize the constants , , and . | |

3: fordo | |

4: Initialize the list of the node of important Data . | |

5: Initialize | |

6: fordo | |

7: Compute | |

8: ifthen | |

9: | |

10: | |

11: end if | |

12: fordo | |

13: ifthen | |

14: | |

15: | |

16: | |

17: end if | |

18: end for | |

19: end for | |

20: | |

21: end for |

Algorithm 1 returns the set of active nodes in each grid and then we can define the set of edges of the graph as given in Figure 4 and Table 1.

The second step consists of the optimal cooperation process. We use a heuristic algorithm based on the identification of a set of nodes around where the solution can be built. This end is called the core of the network [36]. Based on opportunely weighted-out degree values, we classify the nodes in several levels. The external levels represent the outlying nodes and the internal levels represent the core nodes, that is, the central nodes of the tree to be reconstructed. Once the nodes have been assigned to the different levels, a network reduction is operated to build the core of the network. A successive phase builds a tree starting from the core. The algorithm adds the nodes belonging to the successive levels to the current core at each iteration. The tree solution thus determined is finally optimized by a local search procedure. The main phases of the algorithm and the related procedures are described as follows.

##### 5.2. Data Aggregation Based on Cooperative Agents

In this subsection, we present a data aggregation approach based on cooperative agents. This approach will be applied in the GAF routing protocol. The amount of energy consumed during communication is higher than that consumed for the sensing and processing tasks. To overcome this problem, we propose a new technique to reduce the number of packets communicated in the sensor network. Our novel approach aims to perform local data processing before the data are transmitted to the BS. The main aim of this work is to propose an efficient data aggregation approach based on a multiagent system. Thus, a large data volume can be transmitted to the BS on the basis of a global view of the sensing area. In this work, an agent is implemented in each sensor node to exploit routing information to establish a local view and thus maintain a knowledge base. Each agent can decide, in accordance with a given strategy and in a completely decentralized way, whether it wants to cooperate with another agent. When a sensor senses information about its environment, its agent decides whether that information is important. If so, it initiates aggregation by sending a cooperation request packet to its direct neighbours to invite them to participate in the current aggregation session. Each neighbour agent decides to cooperate or not in accordance with the strategy described in the next section. If an agent decides to participate in the cooperation process, it sends the information collected by its sensor node to the agent that sent the cooperation request. If the agent receiving the cooperation request is selected to be used as a gateway by the requester, then it directly sends a request for cooperation to its immediate neighbours while waiting to receive the data aggregated by the requesting agent. When the requesting node receives information from its direct neighbours, it concatenates that information and eliminates redundancies before sending the result to its gateway. This procedure is repeated until the aggregated data reach the BS.

We propose a data routing protocol with partial aggregation, meaning that only active nodes or active member nodes can participate in data aggregation. Before making the data transmission decision, each active node requests routing cooperation when necessary. The following steps are used to accomplish the objective of finding the optimal path.

*Phase 1 (cooperation strategy and core generation). *We define the cooperation strategy by considering several parameters of the decision-making process, such as the level of importance of the collected information, the residual energies, and positions of nodes in the network and the degrees of the nodes. The cooperation decision depends on the values of these parameters. For example, when a node has only a small amount of power, it may refuse to participate in the routing of certain information or any information when its battery level is critical. Thus, it saves its energy to be used only for sensing and transmitting its own information. The considered cooperation parameters are described as follows: (i)Density (D): This parameter enables the identification of dense areas in the network and areas where there are few sensors. When a node has a very large number of neighbours, it consumes energy very quickly, and it is assigned a higher priority for finding a cooperating neighbour than that of another node with a lower degree.(ii)Position (P): We define three position types for the sensor nodes in the network: normal, border, and critical. We consider that the position of a sensor node is critical if it serves as a relay between two parts of the network. In addition, it represents a gateway in our gridded network. In this case, active nodes will be critical nodes. A sensor has a border position if it is located at an extremity of its grid cell. The remaining nodes have normal positions because they have more neighbours and do not represent network gateways.We compute the shortest path tree for each node in the graph using one of the well-known algorithms (see, for example, Dijkstra’s and Prim’s shortest path algorithms [37, 38]). Then, on the basis of these shortest path trees, we build a directed network where is the set of nodes of network and is the set of directed arcs, so that two arcs and exist for each edge in . We compute the weights and of the origin/destination pairs that use the edge in all the shortest path trees, going from to or from to using the following equations:Equation (12) represents the cooperation coefficient as calculated using the parameter values , , , and , where these parameter values are associated with the weights , , , and , respectively. These parameters constitute the set of new arc weights of . If , then the arc does not exist. If has a low value, the corresponding arc is used by few o/d pairs. If has a high value, the corresponding arc is in many o/d pair paths. Each node in has an indegree (resp., outdegree), i.e., the number of arcs entering (resp., exiting) a node. These degrees can be weighted with the parameter , thus generating the weighted indegree and outdegree for a node : The nodes with a low weighted outdegree can be assumed as candidates to be leaves of the tree. The nodes with a high weighted outdegree can be assumed as candidates to be core nodes of the tree.

We use these quantities to classify the nodes in successive levels with an increasing weighted outdegree. On the basis of this classification the algorithm removes from all the nodes with the lowest and all the arcs entering and exiting them, thus generating a reduced network . The same reduction is performed on thus generating a new reduced network, until a core node or a set of core nodes with the same weighted outdegree is determined. We use Algorithm 2 for the network reduction to find the core node.

1: Initialize . | |

2: fordo | |

3: Compute the shortest path tree . | |

4: fordo | |

5: Compute using the equations (12). | |

6: end for | |

7: end for | |

8: fordo | |

9: | |

10: end for | |

11: | |

12: repeat | |

13: | |

14: fordo | |

15: | |

16:end for | |

17: | |

18: | |

19: | |

20: fordo | |

21: | |

22: end for | |

23: until | |

24: |

*Phase 2 (tree building [36]). *The tree building starts from the core node. We add nodes to it using the node classification defined above. We select the node of the level adjacent to the core that has the maximum weighted indegree, and we connect it to the core, using an edge corresponding energy consumed as a selection criterion. We repeat this procedure for all the nodes of the same level. In this way the core is enlarged with the nodes of this level. The procedure continues, adding the nodes of the successive levels, adjacent to the current enlarged core, following the same selected rule above. The procedure is repeated until the nodes of all the levels have been added to the initial core thus generating a tree. The tree building operation is effectuated using Algorithm 3. A local minimization procedure has been developed to improve the obtained solution. In order to explain it we have to define the following settings. Let be the tree solution obtained in Phase 2 and let be the core of , which is a node or a set of nodes. As is a node of there is only one chain connecting to the core . Therefore, we can remove the edge , , incident in and belonging to this chain to split the tree into two subtrees, and , where and are two node subsets constituting a partition of such that and . Recall that indicates the set of nodes belonging to the generic level , sorted by decreasing value of the weighted indegree, and that is the core level. Starting from the first node in , indicated as , we perform the splitting of related to , as described above, and we consider all the edges connecting to the nodes of able to restore the connection of the tree. Each edge generates a different tree with its related tree objective function value. If is the best tree obtained by adding the edge to restore the connection, if we update our solution substituting the removed edge with the edge . This operation is repeated for all the nodes in the level , following the above defined ranking. The procedure is repeatedly iterated from level to level and then from level to , until no solution improvement can be achieved. This procedure is attained by using Algorithm 4.

1: Initialize , , . | |

2: repeat | |

3: | |

4: | |

5: repeat | |

6: fordo | |

7: | |

8: ifthen | |

9: | |

10: else | |

11: fordo | |

12: ifthen | |

13: | |

14: | |

15: | |

16: end if | |

17: end for | |

18: ifthen | |

19: Break | |

20: end if | |

21: end if | |

22: end for | |

23: | |

24: until | |

25: | |

26: | |

27: | |

28: ifthen | |

29: | |

30: end if | |

31: until T=V |

1: | |

2: repeat | |

3: fordo | |

4: fordo | |

5: Remove the edge . | |

6: Set the tree containing . | |

7: Set the tree containing the core nodes. | |

8: fordo | |

9: fordo | |

10: | |

11: ifthen | |

12: | |

13: end if | |

14: end for | |

15: end for | |

16: end for | |

17: end for | |

18: | |

19: until |

##### 5.3. Time Complexity of the Proposed Algorithms

In this subsection, let us denote by the number of edges in the network and by the number of vertices. In the following results, we describe the time complexity of the proposed algorithms.

Lemma 1. *The time complexity of Algorithm 2 is .*

*Proof. *Algorithm 3 is engendered by two fundamental steps: (i)The computation of the shortest path tree for each point . Using, for example, the Dijkstra Algorithm, it is well known that the execution time of this method is . We refer to [37–42] for more details about this and other methods.(ii)Finding the argument of minimal weighted indegree and classification of the vertices in different levels. For typical serial sorting algorithms good behavior is , with parallel sort in , and bad behavior is . Other instructions of the algorithm are executed in in the first iteration, and this estimate decreases in the next iterations. For sufficiently large, we get the desired estimate.

Lemma 2. *The time complexity of Algorithm 3 is .*

*Proof. *Let for the number of vertices in the level . The time complexity to enlarge the core to the nodes of the level adjacent is since this operation includes sorting rules. In the same way for the successive levels for , the time complexity is . By definition of the level , for , we have . This achieves the demonstration.

Lemma 3. *The time complexity of Algorithm 4 is .*

*Proof. *For each edge to be removed, let be the number of edges in and as given in Algorithm 4. We define . Since (see Table 1), we have . Let be the new tree constructed by removing the edge and replacing it by an edge as described in Algorithm 4. If , it is easy to check that decreases by at least 1 at each iteration. Taking into account the execution of the conditions , the desired estimate is achieved.

Finally, we get the time complexity of the proposed method.

Theorem 4. *The time complexity of the combination of Algorithms 2, 3, and 4 is .*

#### 6. Simulations and Results

To evaluate the performance of our cooperative agents GAF (CAGAF) protocol, we compared it with basic GAF. The comparison was evaluated on the basis of the energy consumed, the data importance, and the number of dead nodes. Table 2 shows the simulation parameters.

Figure 5 shows the solution obtained after the refinement of the local search. Figures 5(b), 5(d), and 5(f) are given to illustrate the importance of data in different cases which shows the significant move of data during the run of our programs in order to reach the BS while Figures 5(a), 5(c), and 5(e) show the corresponding optimal path selection, where another node is activated in the same grid if the data collected are considered as important data.

**(a)**

**(b)**

**(c)**

**(d)**

**(e)**

**(f)**

The simulation results in terms of the energy consumption, data importance, and the number of dead nodes are shown below. Figures 6, 7, and 8 show, respectively, the comparison graphs of the energy consumption, the number of dead nodes, and the important data collected between the basic GAF (BGAF) and our proposed CAGAF protocol. Figure 6 shows the impact of the cooperative agents on energy consumption. It seems clear from this figure that, with the smart selection of active nodes with considering maximum residual energy, distance to the base station and the data importance as criteria of interest help in decreasing the energy consumption. Our cooperative strategy is based on the following parameters. The residual energy allows agents to participate in routing only if their energy is sufficiently high, unlike in the previous version considered for comparison, namely, basic GAF. The density enables the identification of dense areas in the network to minimize the traffic routing in our proposed protocol relative to that in basic GAF. The definition of the position type for each sensor allows our approach to achieve a global view of the normal, border, and critical zones, allowing other agents to be activated if necessary. The information importance is also an important parameter in our CAGAF protocol. And the heuristic method is used to find an optimal path in terms of energy to transmit data collected until reaching the BS. The consideration of these parameters in our new enhanced version of the GAF protocol has a direct impact on energy consumption, as shown in Figure 6, which proves that our protocol is very efficient compared with basic GAF. Our enhanced CAGAF protocol permits the optimization of energy consumption during communication, thus extending the network lifetime.

Figure 7 shows the number of dead nodes as a function of the total number of nodes. We observe that the number of dead nodes decreases in CAGAF protocol. The number of dead nodes is higher in the GAF protocol because the network nodes consume more energy due to the routing process between adjacent grid cells. Packets are routed through all adjacent grid cells, which increases the number of active nodes responsible for data routing. Therefore, the number of dead nodes has the highest value. By contrast, CAGAF results in a decreased number of dead nodes compared to GAF because of its improvement; our approach achieves a further reduction in the number of dead nodes due to the efficient active node selection process, which considers the factors of energy level and data importance. In this protocol, each network grid cell may have more than one active node to account for the network density. Each grid cell may thus exploit additional active member nodes for data cooperation. Moreover, the proposed approach is based on a cooperative agents strategy in which data packets are aggregated efficiently.

Figure 8 shows the important data collected by the basic GAF (BGAF) and the CAGAF protocol. It seems clear that the CAGAF protocol detects all the important data during the execution of the simulation, which explains the apparition of the CAGAF protocol graph close to 100%, compared to the basic version BGAF that does not consider this parameter.

#### 7. Conclusion

In this paper, we have proposed the enhanced energy-efficient routing protocol CAGAF, which improves data aggregation through the use of cooperative agents in a WSN. Unlike in the previously proposed protocol in which the active node selection process is based on random selection, in our approach, active nodes are selected based on the information importance, the maximum remaining energy, and the minimum distance to the BS. The routing process in our approach is based on cooperative agents communication, where the agents are selected on the basis of the following parameters: the residual energy, the density, the position type of each sensor, and the importance of the information. Then, a heuristic method is used to design an optimal routing path to transmit data collected until reaching the BS. Simulation results prove that our protocol is more efficient than basic GAF in terms of energy consumption, data importance, and the number of dead nodes.

#### Data Availability

The datasets analysed during the current study are available from the corresponding author on reasonable request.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.