# WLAN Aware Cognitive Medium Access Control Protocol for IoT Applications
## 4 System Model
### Performance Analysis of Energy Detection  
The performance of the energy detection procedure is evaluated in this portion by comparing simulation results with theoretical values. The energy detection technique relies on the energy of the received signal to detect primary users. The first step in energy detection is the filtering of the out-of-band frequency signals. In the next step, these signals are passed through a square block and an adder block. If the resulting output is greater than a threshold \((\gamma)\), a licensed node is detected [42].  
Received signal y(n) can be calculated from the following equation [43]:  
\[y(n)=s(n)+w(n), \tag{18}\]  
where \(s(n)\) is the input signal power, \(w(n)\) is the additive white Gaussian noise (AWGN) sample, and \(n\) is the sample's index. Then, the decision metric based on the energy of the received signal can be given as  
\[M=\frac{1}{N}\sum_{n=1}^{N}|y(n)|^{2}, \tag{19}\]  
where \(M\) is the decision metric, and \(N=(f_{s}*t_{s})\) is the number of samples. Comparing the decision metric \(M\) to a threshold \(\gamma\) corresponds to a selection between the following two hypotheses:  
\[H_{0}:y(n)=w(n), \tag{20}\]  
\[H_{1}:y(n)=s(n)+w(n), \tag{21}\]  
where \(H_{0}\) stands for detection of noise only, and \(H_{1}\) stands for detection of noise and transmitted signal.  
Receiver Operating Curve, or \(ROC\), is often used to assess the performance of a detector based on two metrics: first is the probability of false alarm, and second is the probability of detection. ROC plots the probability of detection \(P_{D}\) versus the probability of false alarm \(P_{FA}\) for a given value of \(SNR\).  
Probability of detecting a transmitted signal is given as  
\[P_{D}=P\left(M>\frac{\gamma}{H_{1}}\right). \tag{22}\]  
Probability of false alarm can be defined as the detection probability of the frequency band being occupied when, in fact, there is no transmitted signal and can be written as  
\[P_{FA}=P\left(M>\frac{\gamma}{H_{0}}\right). \tag{23}\]  
As per the definitions of both probabilities, it is noticeable that, for probability of detection, high value is desired, and for probability of false alarm, low value is desired.  
Figure 7 depicts the probability of detection of a WLAN user at different SNR values for a targeted value of probability of false alarm. \(P_{D}\) increases with the increase in received \(SNR\). The plot shows that the data obtained from simulation results closely match the theoretical values.  
Figure 8 depicts the probability of detection of a WLAN user for different values of probability of false alarm. It can be seen that increasing \(P_{FA}\) will result in increased chances of \(P_{D}\).  
Figure 9 depicts the probability of detection versus probability of false alarm for received \(SNR=-12\) dB. Results show that there is a greater chance of false detection at higher \(P_{D}\) values.  
Figure 8: Plot for probability of detection vs SNR for different probability of false alarm.  
Figure 7: Receiver Operating Curve (ROC) plot for probability of detection vs received Signal To Noise Ratio (SNR).  
Figure 9: ROC plot for probability of detection vs probability of false alarm.