## 4 Proposed Methods
### New Channel Access Mechanism  
Devices in WSNs follow the IEEE 802.15.4e standard channel access mechanism. In the existing CSMA/CA, all devices have equal probabilities for accessing the channel irrespective of their buffer status. However, it is more appropriate to allow the devices with higher buffer status to access the channel first so that the packet drop rate of the devices can be reduced. Besides, the CSMA/CA mechanism allows a limited contention window for which the probability of choosing the same number of random backoff periods is high. Hence, to solve this contention problem and to give priority to the devices having higher buffer status to access the channel, a new channel access mechanism is proposed. The buffer status of the devices is used to update the contention window. Initially, all devices have the same lower bound of the contention \(CW_{min}=0\) window based on the IEEE 802.15.4e standard. However, nodes can have different upper bounds based on their buffer status as calculated in the following equation. \[CW_{i}=CW_{MAX}*\frac{B_{i,Max}-B_{i,now}}{B_{i,Max}} \tag{2}\]  
where \(CW_{i}\), \(B_{i,Max}\), \(B_{i,now}\) and \(CW_{MAX}\) are the contention window, maximum buffer size, current buffer size of \(i\)-th device and the upper bound of the contention window as in the IEEE 802.15.4e standard, respectively. The IEEE 802.15.4 CSMA/CA mechanism proposes two times CCA to avoid the collision due to acknowledgment. However, in the modified superframe structure as discussed in Section 4.3, a separate time interval named the notice period is used for the purpose of acknowledgment. Hence, in our proposed channel access mechanism, we use only one CCA, which helps to decrease the energy consumption of the devices in the network. As given in Algorithm 1, let the \(i\)-th device attempt to transmit data during the CAP of the superframe. Accordingly, it initializes the variables \(NB\), \(CW_{i}\) and \(R_{trns}\). \(NB\) is the number of times the CSMA/CA mechanism requires the delay before attempting the current transmission, which is initialized to \"0\" in each new transmission. \(CW_{i}\) is the contention window length of the \(i\)-th device. \(R_{trns}\) is the number of retransmission attempts. The MAC layer waits for a backoff period, i.e., a random backoff period \((R_{bck})=random(0,CW_{i})\) units. After the backoff period is over, a device performs its CCA provided the remaining time \((R_{time})\) in the allotted period is sufficient to complete the transmission. Let the duration required to perform the CCA and data transmission be \(T_{cca}\) and \(T_{pkt}\), respectively. Two cases may arise during the CCA, which could be either channel idle or busy. The tagged device starts transmission if the channel is found idle. Otherwise, it goes for the \(random(0,T_{pkt})\) sleep period before the next attempt. The value of \(NB\) is incremented for each channel access failure up to maxMacBackoff \((NB_{max})\). The packet is discarded, if the value of NB crosses the value \(NB_{max}\) considering the channel access failure. Successful channel access does not guarantee the transmission success. The transmission failure may occur due to collisions or interference from the WiFi channels. Upon successfully receiving the data packets or decoding the addresses of the collided devices, the PAN coordinator sends the information during the notice period. It is to be noted that the upper bound of retransmission attempts due to collision or channel error is MaxFrameRetries\((MAX_{R_{trans}})\). Each transmission failure increases the value of \((R_{tms})\) by one. The packet is also discarded when the value of \(R_{tms}\) exceeds \((MAX_{R_{tms}})\). Otherwise, the retransmission attempts by the collided devices follow the same channel access mechanism as discussed earlier until they attain the maximum number of channel access failures or retransmission failures. ```
1:\(NB=0\), \(R_{tms}=0\), \(T_{cca}=8\)symbols, packet duration \(T_{pkt}\);
2: Transmission success/failure.