## 3 EQPD-MAC Protocol Development
### Method
#### 3.1.1 Communication of EQPD-MAC  
The EQPD-MAC protocol uses \(p\)-persistent Carrier Sense Multiple Access (CSMA) technique and a synchronized approach for the data packet transmission, with QoS and multi-hop routing features. It uses an adaptive active/sleep time to limit idle listening in order to reduce the energy consumption. It is capable of maintaining an optimal activation time (TA), which is set dynamically under a wide range of loading situations. The proposed EQPD-MAC protocol has the ability to extend or terminate the TA whenever needed. If the sensor nodes are idle for a specific time, the nodes simply go to sleep in order to conserve energy. It can also handle up to four levels of packet priority, although the number of levels can be extended to any value. The EQPD-MAC protocol's communication process is shown in Figure 1. The sensor nodes start listening to the channel as soon as they wake up. After a certain amount of time, all sensor nodes broadcast a SYNC packet that provides the start schedule time of the next frame. The sensor nodes will adopt both schedules if the sink delivers another SYNC packet that differs from the sensor node schedule. As soon as the synchronization with the sensor nodes is complete, TA will be initiated by the sink. It will wait for the Tx-beacon from the sensor node at its scheduled time for the transmission of the data packet until the waiting timer (\(T_{w}\)) ends. If the sink receives a sudden Tx-beacon with P\({}_{4}\) priority from a different sensor, the sink node will cancel the waiting timer and broadcast an Rx-beacon with the address of the selected sensor. The sink will wait for the intended packet after transmitting the Rx-beacons and will go to sleep if it does not receive a Tx-beacon at the end of \(T_{w}\). Meanwhile, Tx-beacon will be sent to the sink node once the sensor node has completed Clear Channel Assessment (CCA) and the medium is idle for the transmission. After that, the node will expect an Rx-beacon from the sink. When the sensor node receives Rx-beacon, it examines the beacon and checks whether it contains the sensor's address. The priority packet will be transmitted if Rx-beacon includes the address, and if it does not, the sensor will go directly to sleep to save energy. After dispatching the priority packet, the sensor will wait for an acknowledgement packet (ACK) as a receipt for the successful \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Protocol** & **Multi-Hop** & **Priority** & **Energy Efficient** \\ \hline QAEE-MAC [31] & No & Yes & No \\ \hline MPQ-MAC [30] & No & Yes & No \\ \hline PMME-MAC [32] & No & Yes & No \\ \hline RMP-MAC [33] & No & Yes & Yes \\ \hline EAMP-AIDC [28] & Yes & Yes & No \\ \hline SPEECH-MAC [36] & Yes & Yes & No \\ \hline MDA-SMAC [35] & Yes & No & Yes \\ \hline EDS-MAC [37] & Yes & Yes & No \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparative analysis of MAC protocols in WSNs. transmission of the packet, goes to sleep, and cancels the TA. The TA can be renewed automatically if the data packet transmission is not completed, and the node receives either a Tx-beacon or an Rx-beacon, whose packet formats are shown in Figure 2.  
Referring to Figure 1, the operation of EQPD-MAC when several sensors attempt to deliver data packets to the sink, is described as follows. Each of the sensor nodes have adopted the sink's schedule after the synchronization. Sensor 1 will send its packet in frame 1, Sensor 2 will send its packet in frame 2 and so on. Sensor 1 will execute CCA and transmit Tx-beacon for the data packet transmission. After that, Sensor 1 will expect Rx-beacon from the sink, and upon receiving it, the node will inspect the beacon to see if it has been chosen to send the data packet. Since it is chosen, Sensor 1 will send its data packet and wait for an ACK packet before returning to sleep. TA will be automatically terminated  
Figure 1: The communication process of EQPD-MAC. Figure 2: Packet format of Rx-beacon and Tx-beacon (**a**) Rx-beacon format. (**b**) Tx-beacon format.