Priority and Traffic-Aware Contention-Based Medium Access Control Scheme for Multievent Wireless Sensor Networks

The requirement of high quality of service (QoS) in multi-priority industrial and domestic sensor networks poses new challenges to the increasing adoption of Internet of Things (IoT). In Multi-event Wireless Sensor Networks (MWSNs), nodes generate different types of data packets i.e., urgent (high priority) or normal (low priority), with different traffic proportions. High priority packets require an assurance of faster transmission and higher reliability in the network. In the literature, the existing medium access control (MAC) protocols for MWSNs have limited consideration in supporting data priority with different traffic proportions. Therefore, this paper proposes an energy efficient MAC scheme that incorporates multi-priority of data packets with dynamic traffic proportion, called PriTraCon-MAC. PriTraCon-MAC supports multi-events by considering four different priority levels of data packets and uses a novel approach that adjusts the contention window adaptively. Due to that, Request-To-Send frame of higher priority data can be sent earlier in the contention window, resulting in the corresponding faster acceptance by the receiver. Furthermore, mathematical delay analysis with different priority traffic proportions has also been undertaken. In addition, PriTraCon-MAC has been implemented in OMNET++ Castalia and its performance has been evaluated in terms of packet delay, reliability, and energy consumption, and compared with the existing Timeout Multi-priority based-MAC (TMPQ-MAC) under various network conditions. The simulation results demonstrate that PriTraCon-MAC offers lower average delay and achieves significantly higher packet success rate, while reducing energy consumption by up to 80% when compared with TMPQ-MAC protocol.


I. INTRODUCTION
Recently, Internet of Things (IoT) and its related technologies have been rapidly developed and widely deployed all over the world. IoT enables interconnection of not only humans, but also physical devices based on low-cost sensors or smart objects, which may observe and interact with their The associate editor coordinating the review of this manuscript and approving it for publication was Zhenzhou Tang .
surrounding environments [1], [2], [3]. Despite the Covid-19 pandemic, the IoT market is still growing rapidly. It is predicted that by 2025, there will be more than 30 billion IoT connections and almost 4 IoT devices per person on average [4]. Thanks to the sensing, collecting, processing and exchanging abilities of Sensor Nodes (SN) or smart devices, IoT has gained substantial attention and been deployed in various applications such as smart-wearables, fire forest monitoring, healthcare monitoring, intelligent transportation, and VOLUME 10, 2022 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ automated industrial processes [5], [6], [7], [8]. The rapid growth of IoT applications has raised the demand for supporting multi-priority sensor data in multi-event wireless sensor networks (MWSN). This has posed several challenges and issues on the network performance due to the energy and computation limitations of smart sensors/devices [2], [5], [7]. Data from numerous sensing sources are expected to be transferred simultaneously and instantly to the selected receivers with varied quality of service (QoS) and reliability requirements [7]. For instance, data events such as warning messages (urgent) need to be transferred immediately with high reliably to meet QoS requirements while other data packets such as information and maintenance messages (normal) do not require immediate transmission. To deal with such new challenges, providing QoS-flexible, instantaneous, and reliable communication becomes necessary for IoTs to serve high priority data effectively [1], [2], [3], [4].
In the past, many research works have been developed to deal with the flexible QoS [9], [10] and various priority data transmission requirements, while still guaranteeing a certain energy efficiency in WSN [7], [11], [12], [13], [14]. They have separately or concurrently taken the priority and energy consumption requirements into account, and generally can be categorized into three major groups based on their approach: application layer, routing and queue priority, or MAC layer. Each group of approach has its own distinct advantages and disadvantages. For example, application layer and routing and queue priority based approaches can offer better end-to-end performance in terms of packet exchange and reliability but, these studies may encounter many difficulties in attaining high energy efficiency [11], [12]. Conversely, MAC layer based approach is able to reduce energy consumption while still ensuring the communication quality [9], [10], [12], [13], [14], [15]. This is because MAC protocol has direct control of the transceivers, which consume most of energy, with significant impact on the network lifetime [12]. Consequently, energy-efficient MAC protocols that enable high priority data to be sent in the quickest way from the source to the sink, need to be developed. These protocols will be able to support emergency situations, where multiple SN must transfer the appropriate data simultaneously and with the lowest possible delay to the sink node, in order to assess the situation's severity [12], [16]. The works of [13] and [14] use multi-priority backoff, in which [13] assigns the priority based on remaining energy, instead of the priority of data and also do not ensure the end-to-end packet latency. Also, the work conducted in [14] considers limited number of data priority levels, and do not cater for different traffic proportions. Therefore, there is a need to develop an energy-efficient MAC protocol that can incorporate different packet priorities effectively to ensure QoS in the network.
To the best of our knowledge, existing MAC protocols rarely meet all the emerging demands of present IoTs, especially for providing simultaneous and multiple priority data services [2], [5], [7], [12]. Recent research efforts have focused on the design of MAC protocols that can bring about QoS and/or priority requirements while separately or partially combined with minimizing either the system delay or the energy consumption for IoT sensor networks [12]. The IoT devices and wireless sensor nodes have similar features and share similar networking paradigm. Thus, existing MAC protocols for IoTs/MWSNs can be leveraged and inherited from existing MAC protocols for WSNs [12], [15], [16], [17], [18], [19], [20]. However, most of these protocols have limited considerations in supporting packet priority level, and the impacts of the contention window on average packet delay and energy consumption. On the other hand, various scheduling schemes have been presented for improving the performance of MAC protocol, especially by adjusting the size of the contention window size [21], [22]. These works imply that adjusting the contention window size adaptively can help to enhance network throughput and lessen the MAC overhead and retransmissions.
In this work, we propose a MAC scheme that supports multi-priority in multi event WSNs and considers trafficbased contention window, named as PriTraCon-MAC. The proposed protocol enhances the narrowband wireless sensor network performance in terms of end-to-end delay, packet success rate, and energy consumption. Furthermore, PriTraCon-MAC utilizes adaptive congestion windows based on priority and traffic proportion of different priority data to ensure reduced end-to-end data packet latency. It exploits the combination of the collision-avoidance and the event priority-based serving guarantee with four priority levels. The preliminary idea of this work was presented at an international conference [23]. In that, the initial idea of the adaptive collision avoidance scheduling scheme that utilizes both data prioritization and traffic adaptation and its performance in a basic simulation scenario are briefly introduced. In order to clarify the efficiency of the developed PriTraCon-MAC scheme, we not only add a mathematical analysis on the network performance in terms of packet delay but also extensively evaluate the network performance obtained by applying our proposed MAC scheme through exhaustive simulation experiments. The attained simulation results prove that our developed solution outperforms the notable comparative Timeout Multi-priority based-MAC (TMPQ-MAC) protocol.
The remainder of the paper is structured as follows. Section II provides a summary and discussion of the related works on QoS and traffic proportion-based MAC protocols for WSNs. Section III describes the proposed PriTraCon-MAC scheme and mathematical analysis of packet delay. Section IV presents details of the simulation implementation, extensive performance evaluation, results and discussion, and comparison to other MAC protocol. Finally, Section V provides the conclusion.

II. RELATED WORK
Generally, traditional works solve the two fundamental problems in WSNs, that are QoS and/or priority problem and that of energy efficiency, separately or partially combined. The importance of MAC protocols with respect to the delay has been a prevalent research topic for both WSNs and IoT [5], [12]. Authors in [15] targeted a significant reduction of idle listening period for senders and contention between receiver nodes by proposing an asynchronous duty-cycled MAC protocol for IoT devices, named RIVER-MAC. Additionally, in [16], an opportunistic channel selection scheme has been proposed that offers better channel utilization and goodput for cognitive radio and ad hoc sensor networks in IoT. However, these protocols do not consider priority-level events that can occur simultaneously in IoT networks. Moreover, the MAC protocol presented in [17], named QAEE MAC, has been designed to support priority levels of data packets. However, it considers only two priority levels (high or low) and there is not straightforward manner to extend it for provisioning more QoS/priority levels. Furthermore, average delay of higher priority packets is also subject to waiting timer that causes extra delay. Authors in [18] have proposed a noticeable priority-based energy-efficient MAC, that is called PRIN, which employs two priority classes. PRIN achieves good throughput by making use of the priority queues and different processing techniques for arriving packets. But under interference, this approach becomes less efficient in terms of throughput than the conventional low-performance MAC schemes like Sensor-MAC (S-MAC) [24] and T-MAC [25]. On the other hand, an effective approach for performance enhancement is to implement the contention windows adaptively [21], [22]. Authors in [21] offered an adaptive contention window backoff mechanism to improve the network performance by adjusting the backoff time according to the number of active stations in each access category. Similarly, the work in [22] introduced a MAC Adaptive Contention Window (ACW), that changes adaptively according to the node's active queue size and remaining energy. Although these works show a lot of potential for achieving better network performance, they have not taken the priority of data packets into account.
Existing MAC protocols such as MPQ-MAC [26] and Timeout Multi-priority-based MAC (TMPQ-MAC) [19], [20] consider multi-priority of data packets and QoS parameters in the network. In these protocols, a receiver node periodically wakes up and listen to the channel for a pre-determined time period, T g . After that, if the channel is idle, a Wake Up-Beacon is sent to inform sender nodes. All sender nodes that have data to send will initiate by transmitting the TxBeacons, during the specified waiting time duration, T w . Depending on the traffic category, the appropriate packet priority bits and the Network Allocation Vector (NAV) field will be added into the TxBeacons by the sender nodes. These sender nodes then wait for the receiver node's RxBeacon that includes the proper NAV field. If the receiver node gets multiple TxBeacons with various priority levels, it will choose the highest priority TxBeacon and send out the corresponding RxBeacon that consists of the selected sender's node address. Upon receiving its RxBeacon, the selected sender node has the permission to transfer its own data while other sender nodes must go to sleep during the NAV time. If a TxBeacon collision occurs, sender nodes will be on standby and keep competing until it reaches the maximum retransmission number for the permission from the receiver node. The resending of Request-To-Send (RTS) in this case works like constant backoff in which the T w is the constant backoff window. In fact, both conventional MAC protocols, MPQ-MAC and TMPQ-MAC, can deal with four priorities, that are urgent, most important, important, and normal. These MAC protocols can achieve a significant reduction in the delay of the highest priority packets thanks to accepting the first highest priority TxBeacon and immediately responding with the RxBeacon. In case, there is no highest priority packet TxBeacon before T w runs out, lower priority packets must still wait until the expiration of T w . Particularly, MPQ-MAC protocol employs a CSMA p-persistent scheduling scheme that is based on a factor, p, which is inversely proportional to the number of sender node, n s . Using this scheme, the TxBeacons from multiple sender nodes can be more evenly spread out, resulting in reduced collisions. However, MPQ-MAC and TMPQ-MAC protocols still suffer from several drawbacks. Firstly, if there is no TxBeacon with the highest priority packet, all senders must wait until the expiration of T w , which increases the delay. Moreover, the p value assignment is relatively rigid and may not be practical in real networks, especially when the number of sender varies substantially. Hence, development of an enhanced MAC protocol that is able to overcome these shortcomings is essential in order to improve the performance of IoT MWSNs. Furthermore, new proposals should carefully consider the QoS/priority requirements for various WSN application scenarios [27], [28], [29], [30], [31], [32] and practical network conditions such as a diverse traffic proportion.

III. PROPOSED PRIORITY AND TRAFFIC-AWARE CONTENTION-BASED MEDIUM ACCESS CONTROL SCHEME (PriTraCon-MAC) A. NETWORK MODEL
In this paper, we consider the network model that is similar to that of [33]. In the adopted network model, sensor nodes are assumed to be uniformly and randomly spread and to be located one-hop away from the sink node. The sink node is at the center of the network and is the only receiver for exchanging information with the sender nodes. The following assumptions are made: (1) Every sender node can generate and transfer multi-event packets with four different priority levels (i.e. urgent, most important, important, and best-effort) at the rate of one packet per second. (2) Each sender knows in advance the priority categories and the traffic proportion of its data. (3) There is no limitation on the initial energy of sensor nodes. Sender nodes are assumed to consume energy mainly for listening to the channel, receiving and sending SYNC, Request-To-Send (RTS)/Clear-To-Send (CTS) and data/Acknowledgment (ACK) packets [35]. It is important to note that PriTraCon-MAC is mainly optimized for the network where the number of sending nodes per receiver is small. Therefore, it is expected that in a larger network with one receiver, the PriTraCon-MAC uses the RTS/CTS scheme. However, this large network problem can also be resolved by dividing a large sized network into several smaller sized clusters with one receiver per cluster. In each cluster, only a limited number of sender nodes is communicating to the receiver. Clustering in a large sized network has many advantages including scalability, energy efficiency and reduced routing delay [34]. Similarly, multi-hop can be employed in the clustered network, where the first hop is from the sender nodes to the cluster head, followed by next hops from cluster head to cluster head and eventually to the sink. Nevertheless, the proposed scheme can be extended to the multi-hop scenario, by combining the proposed PriTraCon-MAC protocol and a routing protocol in the routing layer. However, due to the focus of the current work on MAC layer, only single-hop is considered, and the extension has been left for the future work. Furthermore, in an actual implementation, the information of traffic proportion of different priority packets must be shared by the receiver and the senders. The information of traffic proportion can be evaluated by the receiver and then communicated to senders periodically through the SYNC packet in the proposed scheme.

B. CONTENTION WINDOW MODEL
The proposed PriTraCon-MAC protocol employs a fixed duty cycle that describes the active and sleep periods of the node. Nevertheless, it can be adjusted according to the application requirements. To deal with the collision, overhearing or hidden terminal problem, an RTS/CTS handshaking mechanism is utilized. If a sender node needs to send a packet, it will create and transmit an RTS message to the sink node randomly in the contention window. The RTS message consists of the necessary one-round data transmission time, as denoted by the NAV. Upon its successful reception, other sender nodes will go to sleep throughout the NAV duration to avoid the energy drained from active waiting and reduce the total network energy consumption. The receiver node then chooses the sender node, generates and sends out the corresponding CTS message to the selected sender node, to grant the permission for sending its data. Right after receiving the proper CTS packet, the selected sender can start transmitting its data. Upon receiving the data successfully, a corresponding ACK packet will be sent from the receiver to the sender.
It may seem that the S-MAC protocol as mentioned in [20] also effectively saves the network energy and guarantees relatively low latency due to its small competitive window and by sending CTS as soon as the first RTS is received. However, it is important to note that S-MAC does not incorporate packet priority and treats all packets equally, resulting in all packets having the same latency and reliability. So, to accommodate different data transmission requirements, there is a need for a data differentiation mechanism to support low delay and high reliability for high priority data. Thus, in our proposed PriTraCon-MAC protocol, we inherit the idea of data prioritization of MPQ-MAC protocol [26].
We differentiate priority levels based on the traffic categories. Assume that the network will support N traffic categories, or in other words, up to N priority levels will be applied, and higher priority value is assigned to more important data category. For example, in a network with four traffic categories (N = 4), the urgent traffic has the priority of 4, the most important, important, and best-effort traffics have the priorities of 3, 2 and 1, respectively. Moreover, the contention window will be adaptively splitted into four portions according to the traffic categories. Fig. 1 shows the operation of PriTraCon-MAC for two consecutive cycles, in which the priority information of data packet generated at application layer is passed down to the MAC layer.
PriTraCon-MAC employs the following receiver-initiated approach. After waking up, the receiver node senses the shared medium for a guarantee time, T g , and broadcasts Wake-up Beacon to all potential sender nodes to notify its availability. A sender node could adjust its contention window size and position by its own data priority levels and traffic proportion. As illustrated in Fig. 1, the contention window is adaptive because the window will be closed right after the receiver successfully receives an RTS (with no collision). Subsequently, the receiver starts sending a CTS and waits to receive data from the selected sender. For instance, consider the case where the network consists of M contending senders called sender S i where i ranges from 1 to M , and at this time, there are three senders S x , S y and S z (1 ≤ x, y, z ≤ M ) holding the data packets with priority of L x , L y , and L z respectively, in which L x , L y , and L z satisfy 1 ≤ L x ≤ L z ≤ L y ≤ N . Among these three senders, sender S y possesses the highest priority data and as a result, it has a chance to send RTS earlier than senders S x and S z . Sender S y initiates an RTS packet and sends it to the receiver. After successfully receiving the RTS packet, the receiver will generate an appropriate CTS packet to be sent to the senders. Sender S y , then, can instantly send its data while the other senders go to sleep during that data transmission time. When the data transmission is completed, sender S y switches to sleep mode while the other senders, S x and S z wake up. Afterwards, sender S z will send its RTS in its contention window earlier than sender S x because S z 's RTS has higher priority (L x ≤ L z ). Such operations will continue until all senders have successfully sent their data.
In PriTraCon-MAC, RTS is sent from the senders with collision window varied by data priority level and traffic ratio. In this scheme, if a sender has data to send, first it listens to the medium to check if the medium is clear and sends its RTS frame randomly in its resized contention window. If the sender finds the medium busy, it will sense the medium again until it becomes free. The start time of sending RTS is randomized in order to avoid collision of the same priority level RTSs from other senders. The pseudo code for the procedure of sending RTS within its assigned contention window is presented in Fig.2. So, in PriTraCon-MAC, the RTS for the data packet with the highest priority level will have a chance to appear earlier than the other one with lower priority, VOLUME 10, 2022 so that the packet delay of the highest priority would be lower than those of lower priority. By doing so, PriTraCon-MAC protocol will shorten the waiting time for receiving CTS of senders, as compared to T w of MPQ-MAC and TMPQ-MAC protocols. In MPQ-MAC and TMPQ-MAC, the contention window closes when the receiver receives the Tx Beacon (or RTS) with the highest priority (the adaptive window with the priority of 4 only) or when T w runs out (fixed window with lower priority of level 1, 2, and 3). So, during the fixed window T w , all senders expend energy to stay awake and send their RTS which could lead to RTS collisions and wastage of energy.

C. MATHEMATICAL ANALYSIS OF ACCESS DELAY 1) ASSUMPTIONS AND NOTATIONS
In this paper, we study an IoT wireless sensor network that consists of one sink as the receiver at the network center and a pre-determined total number of sender nodes distributed randomly and uniformly. For simplicity, only one-hop transmission is considered in the network or in other words, the senders and receiver are assumed to be in each other's transmission range. The network is targeted to be applied for IoT and industrial applications in which the hidden and exposed terminal problems will not be taken into account. Hence, the paper scope and discussions will be restricted to small independent IoTs such as smart houses, smart gardens. Moreover, the main assumptions and notation are given as follows: (1) M is the number of contending senders.
(2) The maximum priority level applied is N , where, the probability of a frame which has the priority level of L j (1 ≤ j ≤ N ) is p j . In TMPQ-MAC protocol, all types of priority frames are assumed to have an equal probability, which means that p j = 1 N with j = 1, 2, . . . , N . For PriTraCon-MAC, p j can be changed adaptively according to the different traffic ratios. is denoted as CW j (CW = j 1 CW j ) while TMPQ-MAC's contention window size is different according to the priority level, the number of senders and also the probability p at the sending time. (6) In the considered network, the propagation delay is expected to be substantially less than the slot time and as a result, for simplicity, it can be neglected [36]. (7) The maximum RTS/TxBeacon retransmission value is restricted.

2) RTS/TXBEACON ACCESS DELAY ANALYSIS USING PRITRACON-MAC AND TMPQ-MAC PROTOCOLS
In the MAC layer, the delay difference between received packets with different priority principally relies on the access time for sending the RTS message [35]. Based on that observation, in this paper, we analyze and estimate the RTS access delay. Actually, the access delay strongly depends on several key factors, that are the RTS sending and accepting scheme applied, the size of RTS messages, the number of competing senders at the time, and the size of the contention window.
In order to investigate and analyze the differences between the two comparable MAC protocols, our developed PriTraCon-MAC and TMPQ-MAC, not only one sender-based network scenario but also multi-sender-based network scenario will be implemented for the analysis and comparison. Without the loss of generality and for the fair comparison with TMPQ-MAC, all the evaluation of PriTraCon-MAC will be performed with four priority levels (N = 4 and L 1 < L 2 < L 3 < L 4 ).
In practical scenarios, the proportion of the urgent packets is usually very small when compared to that of the other data categories, and it only increases when a sudden event occurs. In order to assess the effects of the proposed contention window approach on the average delay, we study different traffic category proportions (the traffic category along with the priority of L i has the corresponding probability of p i where i is the priority index ranging from 1 to N ). Here, four traffic proportion scenarios, that are normal (p 1 : p 2 : Besides, all MAC protocols include multi-priority values assigned to the data packets and consequently, RTSs will be treated differently with regards to their priority information categories. Let t j accessMETHOD denote the access delay with the priority L j where j is the priority index (j = 1..N ) and METHOD is the MAC protocol used (PriTraCon or TMPQ). Based on that, RTS can only be accepted if it arrives within the contention window time of its corresponding priority level. Note that, the contention window of PriTraCon-MAC protocol is adaptively assigned proportionally to the traffic priority proportion, and RTSs can be randomly generated and delivered inside its resizable designated window. With equal traffic proportion of different priority levels, the collision probability of multiple RTS will be the same in both schemes. In case when the division is fixed and two same priority packets appear, then collision probability of RTSes will increase. That is because the contention window size changes according to the traffic proportion. But if the traffic proportion is so small then its resized contention window should not be too small that it cannot contain at least one RTS. Nevertheless, this will not happen with these four traffic proportion scenarios.

D. ONE SENDER SCENARIO
Assume that there is one sender so that there is no collision and the starting time of the contention window is t start in Fig.3. The RTS access delay t accessMAC will be the summation of t start and time duration from the starting time t start to the time the RTS is accepted by the receiver. In PriTraCon-MAC, the numerical expression of RTS average access delay t j accessPriTraCon of priority L j is: Correspondingly, in TMPQ-MAC, the RTS with the highest priority level (L 4 ) is accepted as it arrives at the receiver while other lower priority RTS is accepted at the closing time of the contention window. Because there is one sender, M = 1 and the probability p j = 1, so RTS is sent immediately when the channel is free. Then, in the case of the only one sender, the RTS average access delay of TMPQ-MAC, t accessTMPQ , can be numerically expressed as follows, Let's take t = t start +t RTS , and consider four different traffic proportion scenarios (normal, incident, serious and emergency) for PriTraCon-MAC, then the detailed mathematical analysis of the RTS access delay is described in Table 1. From the analysis, it is demonstrated that the average delay of PriTraCon-MAC protocol is decreased when compared to that of TMPQ-MAC.

E. TWO-SENDER SCENARIO
In this subsection, we analyze the average delay under the condition in which there are two senders that need to send data simutaneously. With four priority levels, there will be 16 cases for sending RTSs. Because there is only one receiver, a maximum of one RTS can be accepted in each cycle. Let's consider the case with two RTS priority levels of p 4 and p 3 (as partly illustrated in Fig. 1) and to simplify the mathematical analysis, assume that there is no collision in both MAC protocols (since collisions occur with very low probability due to random transmission of RTS in PriTraCon-MAC and p-persistent in TMPQ-MAC, especially with small number of senders). In PriTraCon-MAC, in the first cycle, RTS with p 4 is accepted and has the average access delay t 4 accessPriTraCon of priority 4 as given by: In the second cycle, RTS with p 3 is accepted and has the average access delayt 3 accessPriTraCon of priority 3 as given by: However, in TMPQ-MAC, many possible cases may happen based on two sub-cases: RTS reaches the sender before the ending time of T w or not. The best case in this situation can be described as follows. RTS with p 4 is the first to reach the sink before the ending time of T w , then in the next cycle, RTS with p 3 reaches sink before T w runs out, and the sink sends CTS at the end of T w . So even with the best case, the numerical expression of TMPQ-MAC average access delay of priority 4 and 3 is respectively given by: 10,2022 in which t p is the probabilistic delay time which depends on the number of sows and in case M = 2 or p = 1/2 (as analyzed in [22] and [36].

F. MULTI-SENDER SCENARIO
When there are more senders that have data to send and only a maximum of one RTS is accepted in one cycle, other RTSs will be delayed to the next cycle, and so on. That is why average delay will be higher with the increasing number of senders.
In TMPQ-MAC protocol, when the sending node numbers is M , the probability of node #i, p i = 1/M (i = 1, . . . , M ), will be relatively small. This may cause some difficulty in the immediate transmission of RTS as the senders are only allows to transmit based on their probabilities. That is the reason why even RTSs with the highest priority will not be transmitted as soon as the window starts, as in the case of only one sender. In addition, RTSs of the lower priorities will be sorted at the end of the receiver's contention window, and have lower chances of being selected as only the RTS with the highest priority will be selected. This causes the average delay of lower priority RTSs to be even worse. Furthermore, the worst case could happen with TMPQ-MAC when senders sow and only have the chance to send RTS when T w is already closed, which results in them having to delay the sending of RTS until the next cycle.
The above simplified analysis implies that, the highest priority RTS will have the lowest delay, and when the number of senders is increased, the average delay becomes higher in both MAC protocols. Nevertheless, the anaysis clearly showed that PriTraCon-MAC is superior in providing the lower delay for priority data in case of multiple priority events.

A. SIMULATION PARAMETERS WITH THE DESIGN OF NODE LAYER LEVELS
In this section, the performance of PriTraCon-MAC protocol that exploits an adaptive contention window and different priority traffic proportion is evaluated through simulations in Castalia 3.3 [37] and OMNeT++ 4.6 [38]. The attained results of PriTraCon-MAC are also compared to that of TMPQ-MAC protocol. For a fair comparison, four traffic priority levels (N = 4) and the same network conditions will be applied for both comparative protocols. Table 2 summarizes the key parameters used in the simulation. The simulation uses MicaZ [39] and TelosB [40] sensor node for application related parameters; Castalia 3.3 [37], MPQ-MAC [26], and PMME-MAC [33] for MAC parameters; and CC2420 radio [41] for radio parameters, which is a widely used low-power RF transceiver in WSN hardware motes. To provide reliable wireless connectivity, the radio chipset uses the 2.4 GHz frequency spectrum to transmit data at 250 kbps over a distance of around 10 m. Each simulation runs for 1000s and is performed 5 times to ensure that at least 1000 packets are sent at every node, and to reduce the randomness of time deviations in packets sent by the application layer. In addition, Table 3 describes the four traffic proportion scenarios that have been implemented in the simulation. According to that, PriTraCon-MAC adaptively changes the values of priority contention window portions.  Figure 4 shows the simplified network model for all simulation scenarios (parameters changed are highlighted in thick blocks).
Three representative performance parameters investigated, are given as follows: • Average packet delay: The average of packet delays from the data generation time in sensors to the time it reaches the sink.
• Average energy consumption: The average energy consumption per every successfully transmitted data bit.
• Average packet success rate (PSR): It is defined as the ratio of the total number of successfully delivered packets to the sink to the sum of packets that have been sent from all sensor nodes.

1) AVERAGE END-TO-END DELAY OF PRIORITY PACKETS
The obtained performance of PriTraCon-MAC and TMPQ-MAC protocols under four different traffic priorities with respects to the number of sender nodes (M ) ranging from 1 to 15 is given in Fig. 5. It shows that PriTraCon-MAC provides significant reduction in the average packet delay for different priority levels. On the other hand, TMPQ-MAC has a higher delay in all cases except for the case of one sender. This is because a T w timer is utilized at the receiver node to receive RTSs and check their priority field. In the case of the received RTS with the highest priority level (i.e. L 4 ), the timer is stopped and the receiver will send a CTS back to the sender in order to grant it the permission to send the current data packets. During that time, the other senders must standby until the next cycle even if they have packets to be sent. Otherwise, if the receiver node hasn't found any TxBeacon with the highest priority level, L 4 , it must wait until the T w timer runs out and subsequently, collects and sorts incomming RTSs according to their priorities, and only permits the requested sender with the highest priority RTS to send its data. In constrast, the proposed PriTraCon-MAC scheme employs an adaptive contention window that can be closed upon the successful reception of the first RTS within its priority window. Thanks to that, an appropriate CTS can be instanly generated and sent right after. This helps to reduce the transmission delay of data packets. Moreover, Fig. 5 also demonstrates that, for TMPQ-MAC protocol, when the number of sensor nodes becomes greater, the probability p becomes smaller and as a result, sensor nodes need to wait longer to send their packets. Following the TMPQ-MAC priority receiver scheme, the highest priority packets are sent first, followed by lower priority packets. It shows that the average end-to-end packet delay of each traffic category is slightly raised as the number of sender nodes increases. Unlike that of TMPQ-MAC, the difference in delay according to the priority of the packets in PriTraCon-MAC is in the correct order of priority: a higher priority packet has lower delay than the lower priority one. This is consistent with the theoretical analysis. But for TMPQ-MAC, only the highest priority packets gets the lowest delay, packets of other priority levels suffer from significantly higher delays. This is because the priority packet L 3 will be sent before the other two lower priority packets and because the number of retransmissions is limited, p 3 will be received more than L 2 and L 2 will be received more than L 1 (see the later analysis results of the successful packet rate in Fig. 8). When calculating the delay, only packets that reach the destination are considered, so as L 3 packets have better success rate even though many of them will incur high delays (they are resent many times before reaching the destination), so the average delay also increases. This result reflects the trade-off between delay and the reliability of TMPQ-MAC.
To evaluate the effect of different traffic proportion on the latency, all four traffic proportion scenarios listed in Table 3 have been simulated and the obtained results are shown in Figs. 6 and 7. Fig. 6 illustrates that the average end-to-end delay, provided by applying PriTraCon-MAC for the highest priority packets, is dramatically decreased thanks to the adaptive adjustment of contention window size, especially when compared to that given by TMPQ-MAC protocol. All PriTraCon-MAC p 4 packets seem to have almost equal delay in the four scenarios and end-to-end packet delay is good enough to support real-time requirement (approximately 20 milliseconds per hop).   Fig. 7 shows the average end-to-end delay of all four priority packet categories with various traffic proportion scenarios. PriTraCon-MAC still retains better latency stability than TMPQ-MAC because it is able to adjust for both priority and priority traffic proportion. It also shows that the average delay of all higher priority (L 4 , L 3 , and L 2 ) packets using PriTraCon-MAC under simulated conditions is below 60 ms even for the case of 15 concurrent nodes, thus meeting the real-time requirements for many applications, even in the case of multi-hop communications. On the other hand, for TMPQ-MAC, the lower the highest priority traffic proportion, the higher the average latency because more proportions of lower priority packets (L 3 , L 2 , and L 1 ) have to wait until the T w timer expires.

2) AVERAGE PACKET SUCCESS RATE
The performance comparison, in terms of the average packet success rate (PSR), between PriTraCon-MAC and TMPQ-MAC protocols with different number of sending nodes under four traffic scenarios is shown in Fig. 8. It can be seen that PriTraCon-MAC has a higher and more stable packet transmission success rate than TMPQ-MAC. When the number of senders increases, TMPQ-MAC suffers from serious RTS contention situations. When compared to PriTraCon-MAC, only p 4 packets have nearly 100% PSR like PriTraCon-MAC, while other lower priority packets have lower PSR resulting in the average PSR of all packets being lower. This is because in TMPQ-MAC, the contention window is still open even though the receiver (sink) has received one or more RTS (except for p 4 RTS, the contention window will be immediately closed when the sink receives p 4 RTS without waiting for T w to expire) until the contention window is closed after T w expires. So, RTS collisions in TMPQ can continue to occur during the whole duration of T w , because the number of RTS sent is higher when compared to the proposed scheme, even though only one RTS is accepted. The retransmissions allow the packet to be sent and resent till the packet is successfully delivered. Because highest priority RTS has the privilege to be sent first, so it will have a higher transmission success rate, followed by the lowerpriority packet and finally the lowest-priority packet. If the number of RTS retransmission time is limited and smaller than the number of concurrent senders, the TxBeacon of lower priority packets are lost, so these data packets cannot reach the sink. Furthermore, we compare the average packet success rate offered by PriTraCon-MAC and TMPQ-MAC with the number of maximum retransmissions ranging from 1 to 10 in the four traffic scenarios and 10 concurrent senders. The corresponding results are shown in Fig. 9. These results imply that, in contrast with TMPQ-MAC protocol that needs significantly more retransmission times to improve the performance and suffers from a poor packet success rate as well as a relatively high delay. On the other hand, the developed PriTraCon-MAC protocol normally requires only one-time retransmission while still able to obtain a remarkably high packet success rate owing to the use of the adaptive and flexible priority-based window size adjustment.

3) ENERGY EFFICIENCY
In this part, the energy efficiency of our proposed PriTraCon-MAC and its comparative TMPQ-MAC, are investigated. The average energy consumptions, calculated in mJ per bit, attained by both protocols with respect to different number of sending nodes, while the maximum retransmission is set at 7, is shown in Fig. 10. The graphs show that the proposed PriTraCon-MAC can help to save a significant amount of energy compared to TMPQ-MAC. In addition to the energy savings, the difference between the energy consumption required by our solution and that of TMPQ-MAC, is obviously more enhanced when the sender node number becomes greater. In particular, up to 81.4% energy can be reduced for the case of 15 senders, where the average consumed energy is about 0.26 mJ/bit for PriTraCon-MAC compared to 1.40 mJ/bit for TMPQ-MAC. PriTraCon-MAC makes use of the adaptive adjustment of contention window with the flexible shutdown capability during T w , in permitting only the selected sender to be active for sendin0g data packets while allowing the other nodes to go to sleep during the current frame period. Differently, in TMPQ-MAC, all senders must be kept active because they need to sow and wait until they can send a TxBeacon, and even when no L 4 packet appears, all senders must still stay awake until the T w timer runs out. Therefore, in comparison to PriTraCon-MAC that enables the passive waiting status of sender nodes, TMPQ-MAC protocol requires its sender nodes to be awake for a significantly longer time and consequently, its energy consumption is greatly increased, particularly for higher number of sender nodes.
In addition, with more sender nodes, or in other words, when the competition in the network among the sender nodes becomes more severe, higher energy consumption is required. In this case, PriTraCon-MAC is greener than TMPQ-MAC, as the higher the number of sending nodes, the better the energy efficiency of PriTraCon-MAC when compared to TMPQ-MAC.
Finally, Fig. 11 illustrates the relation between energy consumption in mJ per bit and the maximum RTS retransmission times. As the maximum number of retransmissions increases, the probability of successful transmission of the packet increases, so the energy efficiency of successful bit transmission increases as reflected in the decrease in the energy consumed for successfully transmitting a data bit. The energy efficiency of PriTraCon-MAC is almost constant since the packet transmission success rate is almost 100% when the number of retransmission is 1 while the energy efficiency of TMPQ-MAC increases gradually as the number of retransmissions is increased, and reaches a fairly stable threshold when that number is around 5. After the threshold, the energy consumption does not improve further because while retransmission improves the PSR and increases the number of successful bits, it also increases the number of retransmissions which consumes more energy.

V. CONCLUSION
In this paper, a priority and traffic-aware contention-based MAC scheme, called PriTraCon-MAC, for MWSN has been successfully proposed. The developed scheme exploits the combination of the data prioritization and traffic proportion of different data priorities, to adaptively adjust the contention VOLUME 10, 2022 window for prioritizing more urgent and important data. Based on that, PriTraCon-MAC effectively enables collision avoidance while guaranteeing the priority-based provisioning simultaneously to improve the MWSN performance in terms of overall delay, energy utilization and packet success rate. The performance of the packet delay has also been mathematically analyzed. The performance of PriTraCon-MAC scheme has been evaluated and compared to that of the conventional protocol, TMPQ-MAC. Extensive simulation results under various network conditions and scenarios have been discussed. The obtained simulation results prove that PriTraCon-MAC protocol outperforms TMPQ-MAC. This implies that the developed protocol offers a relatively lower average data transmission delay while attaining a significant performance enhancement in terms of energy efficiency and packet success rate in the network.