# 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.1 Dynamic Bit Allocation by Bit-Error Rate  
This is a method of adaptive bit-loading used in multi-carrier transmission systems, where it is necessary to assign a different type of modulation to each subcarrier. This method makes it possible to reduce the BER for individual subcarriers based on the signal-to-noise ratio by using a lower degree of modulation for modulating the subcarrier at a lower SNR value. (i.e., from 256-QAM to 64-QAM) [70; 71]. Higher throughput is possible with a higher number of modulation states, but with a higher probability of bit and symbol errors. The theoretical bit-error rate \(P_{b}\) is defined by the SNR and \(M\) states of the modulation technique. It is possible to calculate the AWGN channel by the equation [72; 73]:  
\[BER\approx P_{b}=\frac{\sqrt{M}-1}{\sqrt{M}\log_{2}\sqrt{M}}erfc\Bigg{(}\sqrt{ \frac{3\log_{2}M}{2(M-1)}\times\frac{S}{N}}\Bigg{)}[-], \tag{1}\]  
where \(erfc\) is an additional error function related to the Gaussian error function \(erf\) ([PERSON], 2011) [74]:  
\[erfc(x)=1-erf(x)=\frac{2}{\sqrt{\pi}}\int_{x}^{\infty}e^{-t^{2}}dt. \tag{2}\]  
Theoretical verification of the QAM-\(M\) modulations with target bit-error rates is shown in Table 6. The SNR values with defined targets of the \(P_{b}\) were simulated in NS-3.  
Figure 1: Transmission power regulation according to specification G.9964.  
The dynamic bit allocation method uses the algorithm based on a defined limit value of BER (\(P_{T}\)). The algorithm examines reaching the limit of this error rate using a specific QAM modulation. The following equation is used to assess the bit error rate:  
\[P=\frac{\sum_{k=0}^{N-1}q[k]c[k]}{\sum_{k=0}^{N-1}q[k]}\leq P_{T}, \tag{3}\]  
where \(k\) defines the examined subcarrier; \(q[k]\) is the possible number of bits for the subcarrier based on the modulation type (i.e., 256-QAM allows transfer of 8 bits); and \(c[k]\) defines the bit-error rate of the current subcarrier calculated according to the equation:  
\[c[k]=\frac{(q[k])-C}{q[k]-1}, \tag{4}\]  
where \(C\) is the capacity of one sub-channel by the Shannon-Hartley theorem [75]. The calculation algorithm for the bit allocation table is described in [70] as follows:  
1. Initialization--modulation type assigning for all available sub-carriers.
2. Determine the number of modulation bits \([k]\) and BER \([k]\) values for all available subcarriers.
3. Calculation and comparison of \(P\) and \(P_{T}\) by Equation (3). If \(P\) is less then \(P_{T}\), the current allocation is left, and the algorithm is done. Otherwise, it continues.
4. Find the \(k\)-th subcarrier with the highest BER value and reduce the modulation of \(k\) by one level which decreases the total value of \(P\).
5. Recalculation of \([k]\) and \([k]\) for all subcarriers where the allocation was changed, and then loop from the third step until \(P\leq P_{T}\).  
To ensure a lower value of the bit-error rate, the simulator necessarily reduces the modulation of the subcarriers. Mapping data of bit-error rates and setting of BER values and coding schemes are used for achieving actual values of the bit-error rate BER.