# Design and Analysis of a Low Latency Deterministic Network MAC for Wireless Sensor Networks
## 4 Proposed MAC for LLDN
### Prediction Model for the Optimal Number of LLDN Retransmission Slots  
The LLDN superframe of the current IEEE 802.15.4e provides retransmission opportunities to the failed nodes. However, to use these retransmission opportunities, the number of failed nodes should be less than or equal to the number of available retransmission slots in the superframe. The random allocation of the slots for retransmission by the PAN coordinator depends on the number of nodes attached to the coordinator. Due to this random allocation, it is possible that the allocated retransmission slots may be less than the number of failed nodes. If so, there is no provision in the current standard for retransmissions, and those nodes that cannot get retransmission slots in the same superframe have to reject data transmissions. Once the superframe has started, the number of retransmission slots cannot be changed. It is necessary to choose prior the number of optimal retransmission slots as correctly as possible so that we can increase the reliability. In this section, based on the number of past failed data transmissions and the allocated number of retransmission slots, we would like to find the optimal number of retransmission slots by using regression analysis. It is noted that sensors/nodes are limited in processing capacity and memory and for which we want to develop one statistical model that is used to forecast the optimal values of retransmission slots.  
Let \(\mathbf{\Psi}_{1,j}\) and \(\mathbf{\Psi}_{2,j}\) be the average \(SINR\) and average waiting packets during the \(j\)-th LLDN superframe, respectively. The \(SINR\) value of the current superframe can be estimated by taking the mean of the lowest and highest value of the \(SINR\) that was received in the previous superframe. Let \(X_{j}\) be the number of required retransmission slots during the \(j\)-th LLDN superframe. Consideringthe value \(\{(X_{j},\ \Psi_{1,j},\ \Psi_{2,j}|j=1,2,...,n\}\) from the past \(n\) number of LLDN superframes for the prediction. We can design the regression model as:  
\[\hat{X}_{j}=\sum_{i=0}^{2}\hat{\sigma}_{i}\Psi_{i,j}+\delta \tag{3}\]  
where \(\hat{X}_{j}\) represents the predicted value of \(X\) for the \(j\)-th observation, \(\Psi_{0,j}=1\) for \(j=1,2,...,n\) and the error term \(\delta\) is added to reduce the number of packet rejections. It is to be noted that we want to minimize the error, which is the difference between the original and predicted value. In other words, we need to minimize the sum of the squared differences, i.e., \(\sum_{j=1}^{n}(X_{j}-\hat{X}_{j})^{2}\), where \(\hat{X}_{j}\) is the predicted value of \(X\) for the \(j\)-th observation. Thus, \(\sum_{j=1}^{n}(X_{j}-\sum_{i=0}^{2}\hat{\sigma}_{i}\Psi_{i,j}-\delta)^{2}\) needs to be minimized with three unknowns \(\hat{\sigma}_{i}\) for \(i=0,1,2\). Again, using the partial derivatives with respect to \(\hat{\sigma}_{i}\) and equating to zero for each \(i\), the following equation is obtained.  
\[\frac{\partial}{\partial\hat{\sigma}_{k}}(\sum_{j=1}^{n}(X_{j}-\sum_{i=0}^{2} \hat{\sigma}_{i}\Psi_{i,j}-\delta)^{2})=0,\ \ for\ k=0,1,2. \tag{4}\]  
Solving Equation (4), all three can be obtained. It is to be noted that the network coordinator can get the estimated number of retransmission slots required in the next superframe by using the value of \(\hat{\sigma}_{i}\) in (3). Then, the coordinator modifies the superframe structure with the newly estimated retransmission slots and broadcasts the information through beacon in the next superframe. This proposed estimation can help the coordinator to allocate the optimal number of retransmission slots, which ultimately reduces the retransmission delay and increases the network reliability.