# Broadband Power Line Communication for Integration of Energy Sensors within a Smart City Ecosystem
## 4 Theoretical Background and Simulation Methodology
### Choice of Approach to Channel Capacity Calculation
#### 4.1.2 Dynamic Spectrum Management by the Water-Filling Algorithm  
The Water-Filling method is based on adjusting the spectrum of the PSD transmission mask to achieve the most efficient use of the given frequency band. The principle consists in allocating a higher level of transmission power (its distribution) to subchannels with a high SNR value. Conversely, subchannels with a low signal-to-noise ratio can be eliminated by this system [76]. The power allocation is illustrated in Figure 2.  
The NS-3 simulator uses the Water-Filling algorithm as follows:  
1. Calculation of the required level for all available sub-channels.
2. Iterations through the performed areas triggered by changed PSD values.
3. For all subchannels belonging to one area characterized by the same value of transmission power, the total available power is determined.
4. Allocation of available power for all subchannels to the required level.
5. Calculation of the SNR value according to the updated allocated PSD.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Number of QAM \(M\) States** & **16** & **64** & **256** & **1024** & **4096** \\ \hline SNR for target BER \(10^{-3}\) dB) & 11 & 15 & 19 & 24 & 29 \\ SNR for target BER \(10^{-5}\) dB) & 13 & 18 & 22 & 27 & 33 \\ SNR for target BER \(10^{-7}\) (dB) & 15 & 20 & 25 & 30 & 35 \\ \hline \hline \end{tabular}
\end{table}
Table 6: SNR values with targets of BER considering M-QAM modulations.  
By obtaining the SNR value, it is possible to calculate the transmission capacity of the channel using the Shannon-Hartley theorem. Figure 3 shows a comparison of the dynamic bit allocation by BER and the dynamic spectrum management by the Water-Filling algorithm.  
According to the results, higher transmission capacity can be achieved by using the dynamic spectrum management method, especially in short-distance areas, which is close to real conditions. By the method of dynamic bit allocation by bit-error rate, it is possible to achieve the highest possible communication distance at the required BER value. This important for smart metering systems, which is why in the following text only dynamic bit allocation by BER will be assumed.  
The simulator allows simulation for the 25, 50 and 100 MHz frequency bands. For these values, the maximum level of the PSD transmitter according to ITU-T G.9964 [77] and OFDM parameters according to ITU-T G.9960 [22] are defined in the simulator.  
The throughput difference according to the communication band was also simulated. Achieved values served to demonstrate the correct trend with respect to the distance in the point-to-point topology. Comparison of both methods is presented in Figure 3.  
The communication speed (throughput) is shown in Figure 4 for a point-to-point communication where the PSD was decreased from the maximum allowed value for the 2-30 MHz frequency spectrum. For the highest set value of power \(-55\) dBm/Hz, the transmission speed began to decrease at a distance of approximately 300 m; for lower  
Figure 3: Dependence of transmission capacity on distance for different BER values with the method of dynamic bit allocation by bite-error rate and dynamic spectrum management by the Water-Filling algorithm (purple line).  
Figure 2: Principle of Water-Filling algorithm [76].  
values this decrease occurs earlier. It is important to note that in a real BPLC topology without repeaters, 300 m can be considered as the limit for stable communication [78; 79]. An analogy to reducing performance may be to increase the background noise level. In both cases, the SINR value changes, which in the simulator represents the signal to interference and noise ratio. These values are then used to calculate the capacity/throughput of the line.  
There are two methods to choose from for calculating the capacity. The first method is the dynamic bit allocation by bit-error rate (BER) and the second is the dynamic spectrum management by the Water-Filling algorithm.