1 Introduction

There has been significant research on the traffic management system using WSNs to optimize the energy consumption and to ensure the priority for an emergency condition. Many researches aim to discuss MAC protocols that involve energy optimization and priority-based allocation. During the last few years, a high number of researches have been concentrated on improving energy consumption and reducing delay for WSNs [1,2,3,4]. Furthermore, data transmission management was also being a challenging task for the IEEE-802.15.4 to improve the quality of service (QoS) [5,6,7] by a new slot allocation scheme. The most research optimizes the CSMA/CA method of the IEEE-802.15.4 to improve the quality of service; this method is widely used and recently gained renewed attention. The QoS of IEEE 802.15.4 should be improved in terms of packet delivery ratio, reliability, congestion, etc., to prolong the network lifetime and to ensure an appropriate protocol of communications between nodes. The improvement of QoS enhances the energy consumption by choosing an appropriate value of duty cycle-based MAC that provides a good balancing between the active and the inactive period in the super-frame structure of the IEEE 802.15.4. Moreover, there are new techniques applied to schedule the communication and access the medium by using priority schemes. Those protocols optimize energy consumption and improving the QoS, but certainly, there are some expenses of something else.

Various MAC protocols have been developed and studied to improve power saving [8, 9]. In this work, a two-tiered communication between nodes and the personal area network (PAN) coordinator in the network is discussed. Two groups of priority are defined to give priority for nodes to access the channel before other nodes. The first group of nodes is characterized by emergency data in which devices are prioritized to send their data during the contention access period (CAP) period. Each transmission is managed by the PAN coordinator that provides information about the situation of the network, while the second group contains periodic traffic rate and periodic transmission during contention-free period (CFP). The main purpose of this work is to improve the energy consumption in WSNs under the MAC sub-layer. Sensors have a small size in which their batteries cannot be recharged or replaced; for this reason, improving their energy consumption can optimize their network lifetime. The motivation behind this work is to propose a dynamic mechanism to adapt nodes for different traffic conditions. This finding implements a new hybrid protocol that combines both the carrier sense multiple access with collision avoidance (CSMA/CA) and the time division multiple access (TDMA) methods to schedule the medium access control. We use a hybrid mechanism to schedule communication in the network depending on the traffic rate and data packet transmission delay of each node. The dynamic classification is used to perform communication in WSN and optimize energy consumption. This paper is structured as follows: Sect. 2 cites the recent related works to our work. Section 3 depicts the IEEE-802.15.4 standard overview. Then, Sect. 4 presents the control strategy of the dynamic adaptation mechanism for traffic (DAMT) algorithm. Sections 5 and 6 describe the TC-MAC-based algorithm of the GTS reallocation. Next, experimental results are developed in Sect. 7. Section 8 discusses the proposed finding. Finally, Sect. 9 concludes the paper.

2 Related works

WSN is a new research area created to offer economically attractive solutions, to facilitate their deployment, to remote monitoring and for data processing in complex and distributed environments. Many research works use the QoS parameter to improve the efficiency of the WSN, such as optimizing energy consumption. Furthermore, varying the inter-arrival time and allocate different levels of priority for nodes can really minimize energy consumption [10], where a priority scheme was developed by an arrival priority queue. A dynamic adjustment of data transmission delay was also studied to improve energy consumption and to prolong the network lifetime [11].

Optimizing energy by a modulation method based on computing the consumed energy was developed in [12]. This scheme was specified by the IEEE-802.15.4 to improve the network lifetime. Also, authors in [13, 14] were modified the sleep time to reduce energy consumption, in which they presented a cross-layer solution based on the combined use of duty-cycling MAC protocol. In [15] a hybrid CSMA/CA-TDMA scheme to evaluate the congestion and the collision problem in the network was proposed. They used a Markov decision process as transmission strategies to access both the CAP and the CFP period. The proposed method used a queue status to evaluate congestion and provide an offered traffic to do not go beyond the channel capacity.

The authors in [16] suggested an approach to evaluate the IEEE-802.15.4 standard during the CAP and the CFP period. These approaches looked forward to effectively allocate an adequate guaranteed time slot (GTS) for the desired node. Based on the packet data length, the slot duration will dynamically change. A Markov chain model is used to adjust the length and the start time of the GTS slot based on the packet length. In articles [17] and [18], the authors proposed a priority-based MAC protocol to evaluate the IEEE-802.15.4 performance. They dynamically allocated slots time based on traffic priority information to reduce effectively the access delays. Improving energy consumption was also achieved in [19] by introducing a priority level MAC to transmit data. In which, a priority bit was added in the beacon frame to decide the type of data transmission.

A MAC protocol algorithm [20] optimized both the energy consumption and the packet latency. Authors, in this work, proposed a crossing hybrid MAC scheme that dynamically switched the communication channel for MAC protocol between TDMA and CSMA. This algorithm is based on routing information of ad hoc on-demand distance vector (AODV). Authors alternate nodes that are not concerned in data transmission to schedule their data using the TDMA method. A backoff enhancement algorithm was developed in [21] to achieve less probability of identical backoffs and to improve the reliability of the received data at the coordinator node. The traffic adaptation algorithm was presented in [22] by an adaptation of the duty cycle using super-frame order (SO) and beacon order (BO) parameters of the super-frame. Therefore, paper [23] focused on how effectively manage the transmission in a network by an automatically hidden bypass concept. A mechanism that automatically creates or removes a hidden bypass was developed to improve the transmission delay and the throughput.

The concept of priority in WSN has become the famous idea that optimizes energy consumption based on the application requirements, many works such as [24] assign tow level of priority for nodes to balance energy consumption in a neighborhood and try to balance theirs to balance their activity. To reduce the contention delay, a priority scheme is settled to nodes that are more active by using adaptive cross-layer design. Several works are discussed in the literature to reduce energy consumption to increase battery life such as [25]. Authors, in this work, examine the idle listening of nodes by using a cross-layer design that has improved the efficiency of the WSN. Low power communication can be ensured also through radio frequency connectivity. Authors in [26, 27] deal with the radio frequency module to replenish the battery of a sensor node, through an experimental study; they demonstrate how the placement, the chosen frequency and several radio frequency energy transmitters impact the sensor charging time. These studies are elaborated to design a MAC protocol to deal with energy consumption and optimize the quality of service. Based on all these studies, the technical contributions proposed in this work aim to more optimize energy consumption and outperform problems that come across sharing functionality between nodes and have equitable energy consumed in the hole networks. Optimizing the energy consumption of sensor nodes is the most critical issue in WSN where many authors aim to prolong the network life time by optimizing this metric. Authors [28] use a hybrid approach to deal with energy efficiency of the networks using a prediction system for the data sampling requirement of sensor nodes in order to reduce unnecessary data transmission. Based on clustering and prediction, they optimize the energy consumption by collection some information collected from nodes. Another technique used to enhance the energy consumption [29] is to use a clustering concept using adaptive transmission power control for energy harvesting sensors in both clustered and non-clustered networks. Authors in this work prove the efficiency of this method in term of QoS to prolong the network lifetime.

From the literature review we notice that different techniques of energy saving were used, several contributions were discussed, but no one of them implements a hybrid transmission mechanism that combines CSMA/CA and TDMA method to schedule packet transmission using the IEEE-802.15.4 protocol based on priority classification. It is true that clustering method and prioritization technique were discussed previously in the literature, but our contribution presents something new using an adaptive MAC algorithm for traffic control and data packet transmission delay of each node.

3 GTS allocation scheme

The IEEE 802.15.4 standard allows the ability to optimize the QoS of the network by a slot reservation mechanism; however, the use of this mechanism is not suitable for all networks due to the limited number of the reserved GTS to seven. Any node wishing to communicate during the CAP must compete with the other nodes using the CSMA/CA mechanism. The communication is done through slots or time slots reserved during the CFP. The GTS mechanism allows a node to operate in a channel transmission according to the time that is allocated to it by the coordinator. A node must attempt to request and use a GTS if only it is listening for beacon frames. The GTS must be allocated by the PAN coordinator and must be used for communication between the node and the PAN coordinator. The GTS must be released at any time by the coordinator or by the node itself if it no longer wants to use it. For each GTS, the PAN coordinator must record the beginning of the slot, the length, the direction and the address of the node with which it is associated.

A node must request the allocation of a new GTS through a GTS request command with the characteristics provided by the upper layers. When the PAN coordinator receives this request, he must send an acknowledgment. The coordinator then checks if there is enough capacity on the super-frame based on the size of the CAP and on the length of the requested GTS. The super-frame has enough capacity if the maximum number of GTSs to be allocated is not reached or if the allocation of this GTS does not reduce the CAP size unless aMinCAPLength parameter. When the node receives the acknowledgment from the coordinator, it continues to monitor the beacon frames during aGTSDescPersistenceTime. When the PAN coordinator decides to allocate a GTS, he must generate a descriptor with the requested specifications and the address of the node that requested it and inform the upper layers. This descriptor indicates the length and the beginning of the super-frame. In the opposite case, the beginning of the slot must be reset, and the length must be reset to the length of the largest allowed GTS. This descriptor must be sent in aGTSPersistenceTime. Upon receipt of the super-frame, the node processes this descriptor and informs the upper layers of the GTS allocation. The node that wants to release the GTS that has been allocated to it must send a command of type “GTS request.” An acquittal is sent by the coordinator, and the latter must also begin the release process. The coordinator must ensure that there are no empty spaces in the CFP.

4 Control strategy of the hybrid mechanism

4.1 Traffic control mechanism

In this section, a brief description of the dynamic adaptation mechanism for traffic (DAMT) algorithm [28, 30] is described. The proposed works classify nodes into two cluster types; first, the author measured the traffic rate and calculated the time needed to transmit one data packet. Then, they assume that nodes which have high traffic rate and random data packet transmission delay are considered as emergency nodes in group one. Those types of nodes will have the priority to access to the medium immediately without reservation of any GTS slots, by scheduling their data transmission using the CSMA/CA method during the CAP period.

In our algorithm, we defined a parameter called current queue that instantaneously measures the queue length of each node. According to the value of this parameter Curq_, we define three level of priority and each level has different value of BE. For example, if Curq_ is less than a specific value the queue length is considered empty and this node does not have a priority to access the channel in the first transmission, so it has low priority and we modify the way to access to the channel according to the backoff exponent value and to the CCA. The use of fuzzy sets allocated with a priority level guarantees a deterministic power saving, consider the following:

figure a

In the fuzzy logic algorithm presented in [31], nodes are classified into three levels of priority according to their queue length and their traffic rate. This mechanism dynamically adjusts the backoff exponent (BE) value by increasing its value or decreasing it depending on the priority level of nodes. Whenever nodes have a full buffer size and a high traffic rate, the value of BE should be decreased to minimize the time needed to access the medium and vice versa. This mechanism is implemented in the CSMA/CA method of the NS-2 library. On the other hand, the rest of the nodes that do not satisfy the proposed condition are considered as normal nodes in the second group. The data transmission phase for the second type of nodes will be done only during the CFP period. The data transmission procedure is illustrated in Fig. 1. The hole communication between nodes in group one and the PAN coordinator is done only during the CAP period, otherwise for nodes in group two the channel access and the reservation of GTS slots are done during the CAP period; however, their data transmission is done during the CFP period using their reserved GTS slots. The PAN coordinator is the node in charge who broadcast beacon frames including all the necessary information including the priority type and the parameter presented the CAP length. After each operation, an acknowledgment frame is delivered from either the PAN coordinator or nodes; here, we use a cluster tree topology in which node 0 the top node is considered as the PAN coordinator.

Fig. 1
figure 1

Data transfer procedure

Hybrid use of both CSMA/CA and TDMA methods to transmit data is used to provide considerable guaranteed transmission. In the first step, we measured the traffic rate of each node and the time needed to transmit one data packet. This information will be sent to the PAN coordinator to be dealt with later, to decide which priority group it is. An indicator of the priority of nodes is appended by adding a one-bit field into the beacon frame to schedule communication; this will be explained in the next subsection. According to the measured information, the PAN indicates that urgent data are considered as a high priority data packet when the bit is set to 1 and non-critical data when it is set to 0. If this bit is set to 1, the transmission will be performed during the CAP period, and if it is set to 0 then the transmission will be performed during the CFP period. If the measured traffic is greater than 50 Kbps and the time needed to transmit data packet cannot be estimated and it is variable from one node to another, in this case, we mentioned that the data will be transmitted during the CAP period. When nodes are appreciated to have an unpredictable wake-up–sleep period, in case of having high traffic in the network, this may have more energy consumed in listening to the channel.

In step number two, the transmission is decided to be in the CAP period; nodes are classified one more time according to their queue size and their traffic rate in the network. As already said, the modified CSMA/CA method is used to transmit data by adjusting the BE value to provide nodes that may have lost packets. Then in step three, an incrementation of the CAP length period is done to prolong this period to support more slots. On the other hand, nodes with less priority will have a GTS slot reserved for data transmission, so we minimized the CAP length to avoid the problem that we cannot transmit data packet during the CFP. This adjustment can improve delay and energy consumption to not defer transmission in the next super-frame. The traffic adaptation algorithm is illustrated in Fig. 2.

Fig. 2
figure 2

Traffic adaptation algorithm

4.2 CAP length adjustment

The IEEE-802.15.4 is the most suitable MAC choice for optimizing the energy consumption where he is flexible for any changes. To get information about the slot times duration in a super-frame, the duration is regularly expressed in numbers of symbols, not in second. The 2.4 GHz PHY layer duration of 1 byte = 2 symbols = 32 µs [32]. A slot frame is a collection of timeslots repeated in time. We define the time needed to transmit a successful data packet as TD. The PAN coordinator stores information about the traffic rate and TD. For high priority nodes, data transmission is performed during the CAP period. The PAN coordinator should not reserve any GTS slot for nodes that will send data using the CSMA/CA mechanism and cancel any recommendation to send data during the CFP period. The total length of the super-frame is unchangeable, but a variation on the duty cycle is required to change the length of the active period. The active period depends on the SO parameter entered by the user, and then according to the traffic condition, it will be changed dynamically. The maximum size of packet length is fixed to 50. The CAP length is dynamic, and it should not be less than a certain parameter called aMinCaplength. This parameter is defined in the NS2 codes, and we can adjust it in the C++ codes. Each modification we done in the code should not violate the minimum CAP length. Nodes which transmit their data during the CAP period can increase the number of data packets transmitted due to the increase of the CAP length which can be calculated as given in Eq. 1:

$$L_{{{\text{CAP}}}} \left[ s \right] = {\text{Nb}}_{{{\text{slot}}}} - B_{{{\text{duration}}}} - \mathop \sum \limits_{n = 1}^{{{\text{Nb}}_{{{\text{GTS}}}} }} \frac{{L_{{{\text{GTS}}}} }}{{{\text{Slot}}_{{{\text{duration}}}} }}$$
(1)

where n ϵ (1; NGTS).

figure b

where Nbslot defines the number of slots in a super-frame, B duration defines the beacon frame duration, NbGTS defines the number of GTS generated in a super-frame, LGTS defines the duration of one GTS, and slot duration defines the duration time of one slot in the super-frame. To save more energy consumption, nodes can switch between active and dormant states periodically. This state is controlled by the SO and BO parameters defined in each network area. To update the CAP length, the duty-cycle parameters should be settled to get the new CAP length at each time slot. Figure 3 presents the duty cycle variation. Two types of data transfer transactions exist using the IEEE-802.15.4; they are direct and indirect transmission.

Fig. 3
figure 3

Set of super-frames using our hybrid scheme

In a beacon-enabled network, a device wishing to send data he should first listen to the network beacon. Let us assume that each time node i needs to transmit data, it should wait for a random BE period in the range of [0; 2BE-1] before performing the clear channel assessment (CCA) and assuming that other super frame parameters are defined as presented in Table 1. If the channel is found to be free, and if the backoff exponent BE is set to MacMinBE which has the default value of 3, then the access time can be computed as:

$$\begin{aligned} T_{{{\text{CA}}}} & = {\text{InitialBackoffPeriod}} + {\text{CCA}} \\ & = (2^{3} - 1) \times {\text{aUnitBackoffPeriod}} + {\text{CCA}} \\ & = 7 \times 320\,{\text{us}} + 128\,{\text{us}} = 2.37\,{\text{ms}} \\ \end{aligned}$$
(2)
Table 1 Super-frame parameters

Figure 4 shows the packet scheduling delay; we define then the total time needed to transmit one data packet in acknowledged transmission as follows:

$$T_{{\text{t}}} = \, T_{{\text{D}}} + \, T_{{{\text{ca}}}} + \, T_{{{\text{BE}}}} + \, T_{{{\text{ack}}}}$$
(3)
Fig. 4
figure 4

Packet scheduling delay

5 TC-MAC traffic classification

To ensure network stability, we are interested in the beacon mode of the IEEE-802.15.4. Indeed, the goal is to reserve network resources using the GTS mechanism. Nodes are classified according to their traffic rate and the data packet delay using a fuzzy logic rule mechanism. We have defined for this fuzzy system two sets of priority groups that will dynamically schedule data transmission during the contention active period or the contention-free period. A group of nodes with an emergency data transmission send data during the first active period of the super-frame using the modified CSMA/CA mechanism presented in our previous work [31]. However, during the CFP period, we are intended to develop dynamic management of GTS to ensure a fairness slot allocation between nodes. We have defined a rigorous fuzzy system that admits traffic rate measurement and the time needed to transmit successfully one data packet as fuzzy input parameters. At each super-frame, the PAN coordinator should collect information about all nodes to define a priority set group. The deadlocks situations that can be confronted here are like congestion, packet loss and conflict; here, we work with CSMA/CA with collision avoidance, means like each problem of deadlocks can be solved with the CSMA/CA using IEEE-802.15.4. Thanks to our TC-MAC the congestion and the packet loss are minimized due to the scheduling of packet transmission according different level of priority to each node. The input linguistic variable admits a triangular membership function; however, the output parameters will be presented using a singleton function.

$${\text{Traffic}}\_{\text{rate}}\epsilon \left\{ {{\text{emergency}},{\text{ on}}\;{\text{demand}},{\text{normal}}} \right\}$$
(4)
$${\text{Packet}}\_{\text{delay }}\epsilon \, \left\{ {{\text{random}},{\text{continuous}}} \right\}$$
(5)

A total number of possible combinations arranged as a pair of these states are 6. For each of them, we must establish an appropriate state for the output fuzzy variable where P designed priority and NP mean that there is no priority, as shown in Table 2:

Table 2 Fuzzy rules base

This TC-MAC traffic control-based MAC algorithm addresses the problem of IEEE-802.15.4 of the unfairness GTS allocation for high traffic network. However, the delay in the DAMT algorithm has not been well improved, so, for this reason, we have improved the GTS allocation for nodes according to several conditions. For the IEEE-802.15.4 standard, the PAN coordinator should  allocate seven GTS for seven nodes, then each node desire to allocate another GTS it will share the first GTS allocated for the first incoming node in a condition that they share the same specifications. This management is applicable for just 11 nodes in the network, more than 11 nodes the PAN coordinator decline every GTS reservation until all nodes accomplish their data transmission. The main aim of the TC-MAC algorithm is to reduce contention in the CFP period and provide a fair chance for a low traffic network. The classification of nodes is done for two groups of priority as presented in Fig. 5.

Fig. 5
figure 5

TC-MAC implementation

Nodes with high priority send their data during the CAP period; however, the second type of priority of nodes is intended to send their data during the CFP. During the contention access period, nodes are also classified into three groups of priority according to their traffic rate and their queue length as explained in our previous work. Besides, the second group of nodes transmits their data according to the TC-MAC proposed algorithm by a dynamic GTS request allocation for the PAN coordinator. In this method, priority is assigned for nodes with different status of traffic rate and data transmission delay in order to improve the IEEE-802.15.4 standard and ameliorate the network lifetime.

6 GTS allocation scheme

The IEEE-802.15.4 standard presents an unfairness GTS allocation for nodes; in this section, the proposed scheme tried to address this problem by a new reallocation of GTS slots duration. To address the problem of the average delay processed in the proposed algorithm described in Sect. 4, we address the CFP period by management in the GTS slot allocation and the slot duration time. However, the rest of the nodes are reorganized into two groups of priority according to the time needed to transmit one data packet. For periodic data transmission delay, we distinguished two range of the traffic rate as presented as follows:

$$P{1} = \left\{ {{\text{Medium}},{\text{ Periodic}}} \right\}{\text{ and }}\left\{ {{\text{Low}},{\text{ Periodic}}} \right\}$$
(6)
$$P{2} = \left\{ {{\text{Low}},{\text{ random}}} \right\}$$
(7)

The proposed scheme deals with periodic data transmission delay and low traffic rate where nodes constantly gather information at periodic slot times. Nodes in this group of priority frequently transmit data in a periodic interval. This proposed scheme is adequate for remote sensing applications where nodes periodically sense and transmit data to the PAN coordinator, so the main aim of this work is to allow more nodes in the network to share GTS and avoid the unfairness in slot allocation. The basic method used to allocate the GTS slot in the IEEE-802.15.4 standard is the method of first in first out (FIFO). The PAN coordinator allocates a maximum number of 7 GTS slot to nodes, and it gets quickly consumed in case of low traffic and hold them implicitly or explicitly deallocation. In several cases, most nodes do not have data to be sent in each super-frame in case that events transmission is uncommon. However, if the time of implicit deallocation expires then other nodes in the network may be prevented to not allocate GTS due to the unavailability of more slots in the contention-free period; this takes place for unfairness allocation in the GTS. According to the traffic rate information for each sensor node, the PAN coordinator of the network preserves a fairness distribution of GTS between nodes. Hence, every node should identify to the PAN coordinator and send him additional information about the traffic rate and time needed to transmit one data packet. This scheme addresses node that is allocated a GTS, and then, they abandon it by explicit or implicit deallocation.

In the IEEE-802.15.4 standard, the PAN coordinator awards a maximum number of seven GTS for nodes by using the mechanism FIFO; these seven nodes maintain each reserved slot until holding it. The desired achievement is to allow the PAN coordinator to assign more than seven GTS by a fairness distribution between nodes in the network and allow more than seven nodes to access the contention-free period. The goal of this scheme allows more nodes to share communication in the same super-frame. These groups of nodes have a low average packet arrival rate and they have not data to be transmitted in each super-frame; for this reason, we have chosen to reallocate the GTS for another node. In this way, the PAN coordinator provides the last GTS to be used by the first six nodes. This can be ensured by a GTS reallocation test if the considerable GTS can be reused or not. The flowchart presented in Fig. 6 explains the proposed scheme to reallocate GTS slots.

Fig. 6
figure 6

GTS reallocation scheme

After running this code, if the last node has been allocated a GTS to transmit its data return true at the end of the code, this last one will share the same GTS with one of the six nodes. Moreover, if the node number one was chosen to share the same GTS with the node number seven, then at each connection attempt of node number seven, the GTS reserved for node number one will be reallocated to the node number seven. After, the PAN coordinator reallocated the GTS reserved for node number seven, because this last one shares the same GTS of the node one and reserve a GTS for a new node wishing to transmit its data as explained in Fig. 1. Nodes that share the same GTS transmit their data during the contention-free period until they share the same average arrival time and the average time needed to transmit one data packet, else node number one hold the GTS. For the next n super-frame, this process is repeated, and the PAN coordinator checks the test with node number 8 until it satisfies the required condition as shown in the algorithm number 2. In the literature, the IEEE-802.15.4 super-frame contains three parts (CAP + CFP + inactive period). The contention-free period (CFP) contains 7 slots called guarantee time slots (GTS). So the CFP contains a variable number of GTS and this number can be at most 7 slots of time this is why we put 7 in the IF condition. This algorithm is tested in a topology with dense amount of sensors nodes and it gives better performance.

figure c

This proposed scheme behaves like a memory as presented in Fig. 7 where it deals with the unfairness GTS allocation to improve the average delay in the network by avoiding the wasted slots in the super-frame. Therefore, the PAN coordinator of the network allocates the GTS based on the average arrival information for all nodes to make the decision of a predictive model for GTS allocation based on the traffic rate and data delay transmission. This scheme is implemented using the NS-2 tool to evaluate the performance of the proposed scheme compared to the IEEE-802.15.4 standard. In the next section, an experimental result improves the efficiency of our algorithm.

Fig. 7
figure 7

The new CFP adjustment

7 Experimental results

7.1 Performance analysis

This paper models energy consumption for beacon-enabled time-slotted media accessing control cooperated with data scheduling in a cluster tree network formulation for IEEE-802.15.4 standard an initial energy equivalent to 1000j. The hybrid access control mentioned earlier has been tested by simulations using the ns2 tool. We developed the simulator using the C++ language to evaluate and compare the performance of the IEEE-802.15.4 in low power consumption. The performance of the proposed scheme based on the beacon-enabled MAC layer is compared with the IEEE-802.15.4 standard. The longest distance of the transmission range in one hop is 30 m. To evaluate the performance of the power consumption and the total number of dropped packets, parameters presented in Table 3 are used for the simulation model:

Table 3 Simulation parameters

7.2 Energy consumption

To enhance the energy consumption, we have proposed an algorithm that classifies also nodes into two categories. Nodes with emergency data send their data during the CAP period, and nodes with normal traffic should send their data during the CFP period. This classification is accomplished according to the packet transmission delay. Whenever the measured TD parameter is a random value, the transmission is performed during the CAP period. When the required time to transmit one data packet has a periodic value, the transmission should be done during the CFP period.

Suppose that data transmission is done only during the CAP period using our fuzzy proposed scheme. During the inactive period, sensor nodes turn off their radio which improves their energy consumption. In WSN, the acquired power of a receiver node is extremely less than the power consumption in the active period. In addition, it must be larger than the power consumption in the sleep state; we assume that:

$$P_{{{\text{tx}}}} > P_{{\text{a}}} > > P_{{{\text{rx}}}} > P_{{\text{s}}}$$
(8)

where Prx presents the power consumed by the receiver node, Pa defines the power wasted during the active period, Ptx is the power harvested during the transmission, and Ps presents the power consumed during the sleep state. Let us assume that the amount of the consumed energy in the active state is equal to the amount of the harvested energy during the period of the sleep state at the same round:

$$E_{{\text{a}}} \left( t \right) + E_{{{\text{tx}}}} \left( t \right) = E_{{\text{s}}} \left( t \right)$$
(9)

Ea and Etx define the amount of consumed energy during the active period. Es is the amount of charged energy in the sleep state. Therefore, we can derive the following equations from (8):

$$E_{{\text{a}}} \left( t \right) = P_{{\text{a}}} T_{{\text{a}}} \left( t \right){-}P_{{{\text{rx}}}} T_{{\text{a}}} \left( t \right)$$
(10)
$$E_{{{\text{tx}}}} \left( t \right) = P_{{{\text{tx}}}} T_{{{\text{tx}}}} \left( t \right) - P_{{{\text{rx}}}} T_{{{\text{tx}}}} \left( t \right)$$
(11)
$$E_{{\text{s}}} \left( t \right) = P_{{{\text{rx}}}} T_{{\text{s}}} \left( t \right) - P_{{\text{s}}} T_{{\text{s}}} \left( t \right)$$
(12)

From this equation, we can have

$$P_{{\text{a}}} - P_{{{\text{rx}}}} T_{{\text{c}}} \left( t \right) + P_{{{\text{tx}}}} - P_{{{\text{rx}}}} T_{{{\text{tx}}}} \left( t \right) = P_{{{\text{rx}}}} - P_{{\text{s}}} T_{{\text{s}}} \left( t \right)$$
(13)

Therefore, the duration of the sleep state can be estimated as a linear equation presented:

$$T_{{\text{s}}} \left( t \right) = aT_{{\text{a}}} \left( t \right) \, + bT_{{{\text{tx}}}} \left( t \right)$$
(14)

where

$$a = \frac{{P_{{\text{a}}} - P_{{{\text{rx}}}} }}{{P_{{{\text{rx}}}} - P_{{\text{s}}} }}$$
(15)
$$b = \frac{{P_{{{\text{tx}}}} - P_{{{\text{rx}}}} }}{{P_{{{\text{rx}}}} - P_{{\text{s}}} }}$$
(16)

Energy consumption is a critical issue in WSN. The comparison between the proposed algorithm and the DAMT algorithm and the IEEE-802.15.4 standard is shown in Fig. 8. This figure presented the energy consumption variation against the traffic load. It depicts that the energy rises gradually as a function of traffic load. For low traffic loads of 100 kbps, the maximum energy consumed is 10 J and this occurs in case of the unprioritized network. On the other hand, the prioritized network attains consumed energy of 2 J; however, the TC-MAC algorithm attaints a value of 3 J. As seen, the average energy consumption of the hybrid and the TC-MAC program are less compared to the IEEE-802.15.4 standard unless the hybrid consumes well the power consumption.

Fig. 8
figure 8

Average energy consumption

7.3 Throughput performance

Figure 9 presents the throughput variation under different values of BO and SO. We have fixed an equal value of the beacon order and the super-frame order to see the impact of the super-frame duration on the throughput. Form this figure when the beacon order increases the throughput increases too, this means that more the length of the active period rises this may have an unused channel for long super-frame duration. We notice in the upper curve that our proposed algorithm is more significant than the standard IEEE-802.15.4 in which he maximizes the throughput in the network.

Fig. 9
figure 9

Throughput versus BO

To evaluate our heuristic approach, we have used the Jain's fairness index to evaluate the fairness in the network. This metric is very important to improve the efficiency of an approach. Fairness of a protocol is its ability to allocate the channel bandwidth equally, and it is defined as follows:

$$F = \frac{{\left( {\mathop \sum \nolimits_{i = 1}^{n} x_{i} } \right) ^{2} }}{{n \times \mathop \sum \nolimits_{i = 1}^{n} x_{i}^{2} }};\quad 0 < F < 1$$
(17)

Here,

$$x_{i} = \frac{{{\text{Ratio}}\;{\text{of }}\;{\text{actual}}\;{\text{throughput}}}}{{{\text{Optimal}}\;{\text{throughput}}}}$$
(18)

where

$$x_{i} = \left\{ {\begin{array}{*{20}l} {\frac{{a_{i} }}{{b_{i} }}\quad {\text{if}}\;\;a_{i} < b_{i} } \hfill \\ {1\quad {\text{Otherwise}}} \hfill \\ \end{array} } \right\}$$
(19)

wherexi denote an allocated metric that may be throughput, throughput times hops or response time and n present the total number of flows. An index value of F equal to one is perfectly fair. From the curve, we have founded a fairness value equal to 0.8; this means that the useable bandwidth is better enhanced and well distributed between nodes.

7.4 Packet delivery ratio

We have evaluated the network performance in three metrics of packet delivery ratio (PDR), throughput and Jain’s index which presents the equality in terms of access to the channel of all the nodes in the network. The packet delivery ratio can be defined by the ratio of packets successfully received to packets correctly sent to the node as presented follow:

$${\text{PDR}} = \frac{{{\text{TotalPacketsReceived}}}}{{{\text{TotalPacketsGenerated }} \times 100}}$$
(20)

Figure 10 presents the PDR variation in the network concerning BO. For the low value of BO, we notice that the PDR increases due to the scheduling of short super-frame without collision. Whenever BO increases, the number of a packet generated will increase which leads to apparition of a collision between nodes. We notice that the DAMT program maximizes the PDR instead of the standard who still almost stable which exhibits poor performance. Almost most of the packet does not reach their destination; the cause is that the number of packets generated between two periods of activity is too large compared to the size of the active period, exceeding the capacity offered by the network.

Fig. 10
figure 10

PDR versus BO

7.5 End-to-end delay variation

The end-to-end delay in the ns-2 definition is the difference of time between the moment at which the node transmitter generates a packet and the moment at which the receiver node receives successfully the same packet. To evaluate the efficiency of our proposed TC-MAC algorithm, a simulation has been done to trace the delay variation under different traffic load in the network. As we can see in Fig. 11, the end-to-end delay variation has been well optimized using the TC-MAC algorithm in comparison with the IEEE-802.15.4 and the DAMT algorithm. For the DAMT curve in Fig. 11, the algorithm spent more time to generate packets between nodes as we can see there are odds ups and downs. For low traffic, this algorithm is not good maybe it spends more time in sending the control signals and after that it is well performed and it reduced the delay of packet transmission. The classification of the node to access the channel is well manipulated, and it has reduced the wasted time for the communication between nodes and the coordinator.

Fig. 11
figure 11

End-to-end delay variation

8 Discussion

Experimental results confirm that this finding well improved the QoS by using an adaptive mechanism to schedule access to the medium. The purpose of this dynamic classification of nodes according to their traffic rate and the time needed to transmit one data packet is to improve the energy consumption in the network. Therefore, this arrangement classifies nodes into two categories of priority to manage the access sequence to the medium. This scheme gives high priority for nodes that have a random flow of data and have a high traffic rate. In this condition, nodes must send their data during the first part of the super-frame using a fuzzy logic rule algorithm applied to the CSMA/CA [30, 31, 33]. Varying the backoff exponent value has been possible to reduce the energy consumption based on priorities. However, other nodes must send their data during the second active period of the super-frame.

Sensors' lifetime and energy consumption have become a critical aspect in WSN in which they influence on its design. The progress of technology in our days depends on the memory cells capable of the electronic devices and its lifetime duration as well as their cost. To implement an algorithm that satisfies those constraints, it is not a simple thing to do. Certainly, this finding performs the energy consumption better by using a classification of nodes. Besides, the dynamic modification of the length of the CAP duration has improved the QoS. Experimental results presented a rate difference between the present study and that of [20, 34]. Simulation results of the comparison between this finding and the IEEE-802.15.4 standard show an excellent improvement in energy consumption, better amelioration of the throughput and a significant reduction for the average delay and the packet loss probability. Simulation is tested for a cluster tree topology to evaluate energy consumption. Future research will be applied to the proposed scheme on another type of topology using mobile nodes. One subject that remains to be explored is the dynamic management of the GTS slots which imply the duration of the start and the end of the GTS length.

To compare our study on other works proposed in the literature, we found that this technique of classification of nodes has achieved a good performance in energy in which it has reduced the energy consumption to more than half of the energy consumed of the standard IEEE. Regarding the method of cross-layer applied in [13], our method improves a lot better the energy compared the cross-layer optimization. Also, the work presented in [35, 36] where authors propose a traffic-adaptive priority-based super-frame structure to improve the QoS present less improvement compared to our work from the energy consumption point of view. Finally, to highlight our work, here we present a tabular comparison between the proposed method and the IEEE-802.15.4 standard (Table 4).

Table 4 Comparison between the proposed work and the IEEE.802.15.4

9 Conclusions

Sensors' lifetime and energy consumption have become a critical aspect in WSN in which they influence on its design. The progress of technology in our days depends on the memory cells capable of the electronic devices and its lifetime duration as well as their cost. To implement an algorithm that satisfies those constraints, it is not a simple thing to do. Certainly, this finding performs the energy consumption better by using a classification of nodes. Besides, the dynamic modification of the length of the CAP duration has improved the QoS. Simulation results of the comparison between this finding and the IEEE-802.15.4 standard show an excellent improvement in energy consumption, better amelioration of the throughput and a significant reduction for energy efficiency which is a key issue in WSN; it is known that energy efficiency is a conflicting design objective. Hence, power control and rate adaptation that need to be carefully considered used to achieve energy efficiency. Traffic rate adaptation to achieve energy efficiency is particularly a challenging task in the MAC-based IEEE-802.15.4 protocol. In this paper, a novel scheduling mechanism for data transmission packet delay and traffic rate management has been proposed in order to optimize energy consumption in WSN. Various methods of improving the network lifetime by optimizing energy consumption in WSNs have been discussed so far. The self-reorganization of nodes has well improved the network performance and has archived good results for the QoS. This reorganization is primordially based on the traffic in the network and according to this condition a GTS management-based priority condition schedule the GTS allocation.