# Image Transmission over Cognitive Radio Networks for Smart Grid Applications
## 3 Proposed MAC Layer for Image Streaming over CRSNs
### Channel Negotiation Process between the Sender and Receiver  
Another problem that still remains is that the sender cannot decide alone on the final channel because the peer receiver does not necessarily have access to all of these detected channels \((\{(J^{*})^{(1)},(J^{*})^{(2)},\ldots(J^{*})^{(s)}\})\). To solve this problem, the architecture of the proposed MAC layer has been designed so that _SUs_ can use the common control channel \((CCC)\) to create an agreement (between a pair of secondary transmitter and receiver) on one of the available S traffic channels which were listed before. This MAC algorithm is deployed to solve this problem in order to negotiate the final traffic channels between _SUs_. With these explanations, the proposed channel negotiation mechanism is abstracted as follows:  
1. The node \(n_{Tx}\) who has the data to be sent in its transmission buffer implements the spectrum measurement algorithm and finds the best empty traffic channels, \(SCI=\{(J^{*})^{(1)},(J^{*})^{(2)},\ldots(J^{*})^{(s)}\}\), in accordance with the proposed algorithm.
2. \(n_{Tx}\) is set up on the common control channel \((CCC)\) and measures the carrier. If it is busy, it runs the backoff mechanism and waits for a random time.
3. After finding out the idle channel, it waits for the completion of the distributed inter frames space so called DIFS interval. Then, it attempts to send the \"request to send beacon\" \((C-RTS)\). In \(C-RTS\), in addition to transmitter and receiver identifiers \((n_{Tx}^{ID}\quad and\quad n_{Rx}^{ID})\), information on spectral sensing and \(SCI=\{(J^{*})^{(1)},(J^{*})^{(2)},\ldots(J^{*})^{(s)}\}\) with the header \(H\) and footer \(F\) are sent as follows:
\begin{tabular}{|c|c|c|c|} \hline H & \(n_{Tx}^{ID}\) & \(n_{Rx}^{ID}\) & SCI & F \\ \hline \end{tabular}
4. While the receiver node, \(n_{Rx}\), completes receiving the \(C-RTS\) beacon signal, it begins to inspect its channel access status which can take \(T_{S}\) seconds. After this time, the node \(n_{Rx}\) will gain the necessary information about the current status of the channel from its point of view. Now, with applying the MOTS algorithm, it is capable to select the best available channel, \((J^{*})^{(k)}\), which is in common with the peer sender \((n_{Tx})\).
5. To confirm the channel availability, \(n_{Rx}\) should send the \(C-CTS\) beacon to the \(n_{Tx}\) after the expected time, so named short interframe space (SIFS ). The \(C-CTS\) is defined as below:
\begin{tabular}{|c|c|c|c|c|} \hline H & \(n_{Rx}^{ID}\) & \(n_{Tx}^{ID}\) & \((J^{*})^{(k)}\) & ack & F \\ \hline \end{tabular} Now, it should adjust all initiations needed for the \((J^{*})^{(k)}\) channel.
6. When the node \(n_{Tx}\) receives the \(C-CTS\) from the \(n_{Rx}\), it also will tune itself to the admitted channel \(((J^{*})^{(k)})\).
7. At this moment, both the sender and receiver nodes have been set up on the negotiated channel, \((J^{*})^{(k)}\), for data transmission. At the final step, \(n_{Tx}\) waits for DIFS and then it will transmit its data frame with length \((\tau_{P}^{i})^{*}\) with \(X^{*}\) iterations (recalling the description given in the previous section) on the admitted channel \(((J^{*})^{(k)})\)  
According to the described procedure, the negation time between two nodes, \(\tau_{n}\), can be written as below:  
\[\tau_{n}=t_{DIFS}+t_{RTS}+T_{s}+t_{SIFS}+t_{CTS}+t_{DIFS} \tag{24}\]Due to the fact that the number of channels and the number of secondary users are limited, the CTS and RTS frames will have only a few bytes of data. On the other hand, the DIFS and SIFS frames are also very small, therefore in comparison with very large image data, it can be discarded. Subsequently, in this work, we did not consider the overhead of negation in our model.