# Self-Learning Power Control in Wireless Sensor Networks
## 5 Simulations  
### Setup  
Our TPC protocol is implemented in the Network Simulator NS3, a modification of release ns3.23 ([[https://www.nsnam.org/ns-3-23/](https://www.nsnam.org/ns-3-23/)]([https://www.nsnam.org/ns-3-23/](https://www.nsnam.org/ns-3-23/))), considering different scenarios. We set up a WSN with a variable number of cells structured in a Manhattan grid topology (Figure 5). A cell of the grid contains two nodes, distributed horizontally, where the transmitter is the left node at a distance \(d\) from the receiver. The distance between the cells, \(D\), is referred to as the distance between the transmitters of the node couples. The transmitter generates a stream of packets with Poisson distribution and variable inter-arrival time \(\mu\). The size of the packets' payload is constant and equal to 50 bytes, over the maximum payload of 123 bytes allowed in the standard 802.15.4 [55]. A summary of all the parameters involved in the setup are listed in Table 1 with their related values. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Symbol** & **Value** \\ \hline Frequency channel & \(f\) & 26 \\ Distance of consecutive pair transmitters & \(D\) & 2 m \\ Distance transmitter-receiver & \(d\) & 2–4 m \\ Packets’ payload size & \(payload\) & 50 bytes \\ Inter-arrival time & \(\mu\) & 25, 50, 75, 100 ms \\ Number of packets in a window & \(N\) & 10 \\ \hline Number of transmission power levels & \(n_{ptx}\) & 20 \\ Minimum transmission power & \(P_{tx,min}\) & \(-\)35 dBm \\ Maximum transmission power & \(P_{tx,max}\) & 10 dBm \\ \hline Number of states & \(n_{s}\) & 68 \\ Reward quantization step size factor & \(\Delta\) & 5 \\ Number of reward quantization levels & \(m_{r}\) & 400 \\ Number of PRR quantization levels & \(m_{prr}\) & 20 \\ Number of maximum retransmissions & \(n_{retr}\) & 3 \\ Number of maximum CCA attempts & \(n_{CCA}\) & 4 \\ \hline Number of simulation runs & R & 10 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Parameters and settings used in the simulator. The devices are modelled as nodes of a low range wireless personal area network, using the 802.15.4 standard for PHY and MAC communication layers, and the 2.4 GHz Industrial, Scientific and Medical (ISM) unlicensed bandwidth over 16 channels of 2 MHz each. Channel 26 is used in this work. The interconnection architecture is modelled up to the MAC layer, so the communications are point-to-point. The MAC layer is modified in order to interact with QL-TPC and DBM. The environment is modelled with the site-general of ITU-R P.1238-7 for propagation loss in a building [56], and Nakagami for fast fading model [57]. The packets at reception are either accepted or discarded, depending on the implemented error model. In the latter, the Packet Error Rate (\(PER\)) is provided through the calculation of the Bit Error Rate (\(BER\)) as per the 802.15.4 standard [55]. The \(BER\) is dependent to the \(SINR\):  
\[BER=\frac{8}{15}\cdot\frac{1}{16}\cdot\sum_{k=2}^{16}-1^{k}\binom{ 16}{k}e^{20\cdot SINR\cdot(\frac{1}{k}-1)} \tag{10}\] \[PER=1-(1-BER)^{n_{bits}}, \tag{11}\]  
where \(n_{bits}\) is the number of bits received. A packet is dropped if the \(PER\) is lower than a random value uniformly distributed between 0 and 1. The \(SINR\) is calculated as the ratio of the received signal power and the sum of noise and interference. Both the elements are known to the physical model. The former is calculated based on the transmission power, the attenuation and the fading model, applied to the signal. Similarly, the interference is calculated as the sum of the interfering signals' power at the reception. Each interfering signal belongs to separate links, where the fading factor is random, following the Nakagami distribution, and the attenuation factor depends on the distance between the receiver and the interferer. Instead the noise is the Additive White Gaussian Noise (AWGN), whose power is equal to \(k_{B}\cdot 290\), as per the thermal noise. The physical layer is responsible for the management of the radio activity.