# Image Transmission over Cognitive Radio Networks for Smart Grid Applications
## 3 Proposed MAC Layer for Image Streaming over CRSNs
### The Proposed Method for Channel Ratings and Optimal Channel Selection: MOST  
At the sender node, before sending the packet with an estimated length \((\tau_{p}^{i})^{*}\), the MAC layer submits the request for the SS process to the physical layer. Here, it is assumed that the \(SS\) module in the physical layer is based on the energy detection approach (ED). Assuming AWGN channel, the received signal in the receiver in the case that channel is busy by a \(SU\) (\(H1\) mode) is \(y(n)=s(n)+w(n)\). If there is no sending (\(H0\) mode), the observed signal in the channel will be \(y(n)=w(n)\). In this regard, \(w(n)\) is the Additive White Gaussian Noise (AWGN) with a zero mean and variance \(\sigma_{w}^{2}\). In the ED spectrum sensing method, \(N\) samples are gathered from the channel, then the decision criterion \(M\) is calculated as the energy of the recorded samples \((M=\Sigma_{n=1}^{N}|y(n)|^{2})\). To evaluate the performance of the energy detector, two probabilities are used: \(P_{d}\) (probability of detection) and \(P_{f}\) (probability of false alarms). These two probabilities are defined as follows:  
\[P_{d} = Pr(M>\lambda_{E}|H_{1}) \tag{19}\] \[P_{f} = Pr(M>\lambda_{E}|H_{0}) \tag{20}\]  
In this work, we consider \(P_{d}=1\) and \(P_{f}=0.01\). When the physical layer performs spectral sensing based on energy detection, assuming that the channel is not saturated, S empty channels (not occupied by the primary users) are detected. In order to insure the channel not to be saturated and to provide service to secondary users, we need to have \(M\tau_{on}<S(\tau_{on}+\tau_{off})\), where \(M\) is the number of primary users (_PUs_). _PUs_ traffic is expressed by an exponential distribution with arrival rate \(\lambda_{i}\), average ON state \(\tau_{on}\) and OFF state \(\tau_{off}\). Additionally, the sender sensor node is assumed to be equipped with a single interface module that can switch opportunistically between the S traffic channel and also a CC common control channel. In order to increase the efficiency of the communication channel, the sender sensor node should have the ability to rate this S channel and select the best sub-channel for sending. To this end, we propose the following method in which the channel with the minimum overhead time \(E(\tau_{OH}^{J})\) is selected as the best channel. We named this channel selection method as MOTS (Minimum of Overhead Time Selection).  
\[E(\tau_{OH}^{J})=P_{f}^{*}e^{-\lambda_{f}l_{P}^{J}}\frac{1-(P_{f}^{*}e^{- \lambda_{f}l_{P}^{J}})^{X}}{1-P_{f}^{*}e^{-\lambda_{f}l_{P}^{J}}}T_{S}+\tau_{P }^{J}\frac{1-(P_{f}^{*}e^{-\lambda_{f}l_{P}^{J}})^{2X}}{1+P_{f}^{*}e^{-\lambda _{f}l_{P}^{J}}},J=1,2,3,\ldots,S \tag{21}\]  
In this way, the optimal sub-channel \((J^{*})^{(1)}\) is achieved using Equation (22):  
\[(J^{*})^{(1)}=Argmin(E(\tau_{OH}^{J})),S=\{1,2,3,\ldots,s\}\] \[J\in S \tag{22}\]  
Subsequently, the second optimal sub-channel is also obtained found on the Equation (23):  
\[(J^{*})^{(2)}=Argmin(E(\tau_{OH}^{J})), \tag{23}\] \[J\in S\&J\
eq(J^{*})^{(1)}\]  
The rest channels of the pool are ranked accordingly based on the proposed method. As a result, the transmitting node has knowledge about all available channels with their priorities \((\{(J^{*})^{(1)},(J^{*})^{(2)},\ldots(J^{*})^{(s)}\})\). The obtained data is named Sorted Channels Information (**SCI**). In fact, the proposed algorithm tries to enhance the system performance by engaging the channel with the least average time overhead.