## 3 EQPD-MAC Protocol Development
### Algorithm  
The EQPD-MAC protocol design and development involves the whole protocol stack in each layer to facilitate communication. The three-layer protocol consisting of Application, Network, and MAC layers, is as represented in Figure 5.  
Priority of packets are implemented at the application layer of the network stack, as priority is determined by the particular application, e.g., emergency alert signal. In EQPD-MAC, an extra priority field have been added to the application, which ensures that all nodes are aware of the priority while transmitting the packet. The actual end-to-end latency of the packet can be accurately measured by assigning priority to application layer. Data fields such as source ID, destination ID, and sequence number are defined on the application layer. Subsequently, the application layer communicates with the network layer to transmit priority data packets. With the help of the network layer, packets can be routed to the sink node by establishing a topology of the network so that each node knows its own location and its neighbors. Following that, the packet is passed to the MAC layer by the network layer. The MAC layer is especially crucial to the proposed protocol since it manages the packet in accessing the channel and incorporates the technique of adaptive active/sleep time to lower the energy usage. It interacts with the network layer to transmit and receive data packets and also to identify whether the overheard packets are meant for the node. The communication process of the MAC layer is already shown in Figure 1. The nodes that could not synchronize with the sink node will go to sleep and wake up in the following round to detect the sink node's schedule by anticipating the reception of the SYNC packet. The sensor nodes will continue this process until it is able to synchronize with the sink node. When the MAC layer is in broadcast mode, it is important to obtain additional information from the upper layers so that a node may determine if each received packet is meant for itself or not. Decapsulating every received packet and transferring it to the network layer, the EQPD-MAC protocol employs a simple but effective cross-layer communication. If a packet has been overheard, the network layer reports to the MAC protocol that the packet  
Figure 4: Priority packet transmission. has been discarded. Upon receipt of an ACK packet from the destination node, the MAC layer forwards this information to the network layer, which subsequently forwards it back to the application layer. Multi-Hop Routing Communication  
The sensor nodes that are far away from the sink will select other sensor nodes to relay the data packet to the sink. The EQPD-MAC protocol uses the widely known AODV routing protocol to relay the packets. The routing protocol's essential activities include path discovery, routing table management, forward and reverse path configuration, path maintenance, and local connectivity management. At the beginning, AODV launches a route discovery operation for all the sensor nodes. AODV maintains the next hop routing information in a route table. Figure 6 shows the multi-hop topology of the proposed EQPD-MAC protocol. After each sensor node knows a route to the sink node, nodes will wake up and send their respective priority data packets to the sink using the path stored in the route table. For example, Sensor 15 will wake up and perform CCA to see if the medium is idle. The sensor node needs other sensor nodes which can relay the data packet. Sensor 15 checks the routing table to see if it has a path to the sink node. If it does not have a path, it launches  
Figure 5: Design of the Application, Network, and MAC layer levels. the route discovery operation, and finds that the sink is three hops away. In this case, Sensors 10 and 5 are the intermediate sensor nodes to relay the data packet to the sink. If the medium is idle, Sensor 15 transmits Tx-beacon and \(\mathrm{T_{w}}\) is stopped.