# Receiver-Initiated Handshaking MAC Based on Traffic Estimation for Underwater Sensor Networks +
## 7 Traffic Estimation for TERI-MAC  
During the handshaking process, the receiver is informed of the average packet number within the time interval between two successive data requests, serving as input information for the traffic estimation. Now, let \(x_{i}\) denote the number of packets and \(\mathbf{X_{M}}=[x_{1},x_{2},\ldots,x_{M}]\) be the set of the samples, where \(M\) is the size of \(\mathbf{X_{M}}\). A standard method for an approximating distribution is the empirical distribution of the observed data from all of the historical records, e.g., the sample set \(\mathbf{X_{M}}\). We can get a better estimation as the sample size \(M\) increases. However, because of the traffic dynamics in the time domain and the constrained computation and memory capacity in the underwater nodes, we can only expect a sparse dataset for a rough traffic model approximation. On the one hand, a larger sample size leads to a more accurate traffic estimation and a more efficient channel allocation for the TERI-MAC. On the other hand, large datasets slow down the adaptation of the traffic model to the temporal variation of the link layer traffics and aggravate the computation overhead of underwater nodes. Instead of keeping all the history samples, \(\{x_{i}\},i=1,\ldots,M\), we utilize the CDF Inverse Sampling technique to generate a set of samples \(\{\hat{x}_{i}\},i=1,\ldots,M^{\prime}\) of a constant size \(M^{\prime}\) where \(M^{\prime}<M\) from the traffic distribution \(F(x)\) is a representation of the large dataset. * **CDF Inverse Sampling**[32]: Let \(G(x)\) be the cumulative distribution function (CDF) of a random variable \(x\) which has the probability density function (PDF) \(F(x)\). If random variable \(y\) comes from a uniform distribution \(U(0,1)\), then the random variable \(\hat{x}=G^{-1}(y)\) follows the same distribution as \(x\). In other words, a set of samples \(\{\hat{x}_{i}\}\) becomes a good representation of random variable \(x\) as they have the same distribution (\(F(x)\)). CDF Inverse Sampling is a simple but effective method when the distribution is univariate and the inverse CDF is easy to obtain. In many cases, when inverse CDF cannot be solved analytically, we can approximate the true CDF with a piecewise linear function based on the sample set from the distribution [33]. In order to determine the trend of traffic when it varies, the most recent \(K\) records \(\{x_{M-K+1},\ldots,x_{M}\}\) are used to approximate the traffic distribution together with samples \(\{\hat{x}_{1},\ldots,\hat{x}_{M^{\prime}}\}\). The sampling window of size \(K\) represents the most recent trend of the network's traffic, while the resampled data \(\{\hat{x}_{1},\ldots,\hat{x}_{M^{\prime}}\}\) from the preceding records presents the historical information of the traffic distribution. With the small dataset \(\{\hat{x}_{1},\ldots,\hat{x}_{M^{\prime}},x_{M-K+1},\ldots,x_{M}\}\), we can then estimate the traffic distribution by leveraging an affordable computation, e.g., the kernel density estimation method. When the new record \(x_{M+1}\) arrives, the sampling window moves forward and leaves the sample \(x_{M-K+1}\) out of the window. We also need to resample the historical records \(\{x_{M-K+1},\hat{x}_{1},\ldots,\hat{x}_{M^{\prime}}\}\) to keep a non-increasing dataset. To reduce the frequent resampling process in the traffic estimation, a simplified procedure is illustrated in Algorithm 1. A sampling window with a changing size is employed. The size of the sampling window \(S_{WIN}\) increases with the new arrival records. When \(S_{WIN}\geq K\), all the records in the sampling window are moved out and merged to the data set \(\{\hat{x}_{1},\ldots,\hat{x}_{M^{\prime}}\}\), and the set is resampled to get a new representation for the historical distribution.