## 3 Proposed Solutions
### Follow-Up Clock Synchronization and Optimization of Listening Window's Size
#### 3.2.2 Algorithms Controlling the Selection of the Listening Window Length  
* Window size adjustment algorithm based on the transmitter deviation (W1) The initial size of the window is determined based on empirical experience, and is then gradually increased or decreased according to the following relationships:
* if the deviation of the next 10 (current + last 9) consecutive packet reception times (relative to the expected packet arrival time) is less than 30% of half of the current listening window length, then the window length is reduced by 30%;
* if the deviation of the reception time of the last packet relative to its expected time of arrival is greater than 70% of half of the length of the current listening window, then the length of the window is increased by 30%;
* if the packet is not received then the window length is increased by 30%.
* Window size adjustment algorithm based on the transmitter's clock deviation with the continuously calculated probability of the window elongation (W2) The initial window size is determined by empirical experimentation, and then gradually increased or decreased according to the relationships presented in the algorithm (W1) with the following change:
* if at the moment \(\widetilde{t}_{i}\) we denote the number of correctly received packets by \(cR\), and the number of transmitted packets \(R\), then with the probability of \(\frac{cR}{R}\) we extend the length of the listening window. We also introduce a threshold \(D_{min}\) of the calculated value \(\frac{cR}{R}\), which is a minimum size of the window.
* Window size adjustment algorithm based on the statistics from the N most recent received transmissions (W3) The size \(W\) of the window is calculated from the formula \(W=2\cdot A_{i}\cdot(t_{i+1}-\widetilde{t}_{i})\cdot\widehat{B}\) taking into account the following dependencies:
* if a packet is received then the next listening window length parameter is \(A_{i+1}=A_{i}\cdot 0.9\), with condition \(A_{i+1}\geq A_{min}\), where \(A_{min}\) is empirically determined;
* if no packet was received then the next listening window length parameter is \(A_{i+1}=A_{i}\cdot 1.2\);
* the N-element average is calculated from the Equation (2) presented in algorithm (A2), with the condition \(\widehat{B}\geq\widehat{B}_{min}\), where the value \(\widehat{B}_{min}\) is established empirically.  
We have chosen a 30 percent value (and proportionally \(100\%-30\%=70\%\) value) based on the experiments conducted via simulations. Figure 4 shows the different percentage values (namely 20 and 40% and their proportional counterparts) for two sizes of packet loss (5 and 25%). In both cases, we can observe that setting the value of the algorithm (W1) window length parameter to 30% keeps the desired balance between the average number of packets outside a listening window and the energy cost value (or the average window length value associated with energy consumption). Setting the value to 20% results in a significant increase in energy consumption, whilst the 40% value doubles or even triples the number of packages outside of a listening window to an unacceptable level.