# An Integrated Cognitive Radio Network for Coastal Smart Cities
## 2 Integrated Cognitive Hybrid Communications for a Coastal City
In a similar manner, the marine LC provides the route, either from its forwarding table or after receiving it from the SDN controller. The cars and the ships in these two networks periodically update their neighboring nodes or the LC (if within transmission range) to update each other with the current network state. Because of this exchange of data, all LCs in both networks are able to keep a local updated topology about the corresponding network. Figure 1 also represents a special scenario where a car's driver wants to know about the current status of a shipment on a cargo ship (i.e., the same destination ship in Figure 1). The car needs a stable path to the destination cargo ship, and therefore, it communicates with the nearest RSU requesting a stable path to the cargo ship. Because the destination belongs to the marine network, the RSU directly forwards the request to the SDN controller. The SDN checks its forwarding table to determine whether it can fulfill the user's demand. If so, it quickly sends a service provision message to the car. Otherwise, it obtains the service from the VNF of the marine network and provides a route for hybrid communications between the source car and the destination ship. As this is a hybrid communications route, the BG is used as a gateway between the vehicular and marine environments. Hence, the final route is:  
Figure 2: Flowchart representing vehicle-to-vehicle (V2V), ship-to-ship (S2S), and vehicle-to-ship (V2S) communications with integrated technologies. \[source\;car\rightarrow\;relay\;car\rightarrow\;destination\;car\to BG \to LC\rightarrow\;relay\;ship\rightarrow\;destination\;ship\]  
One might ask why the source car did not opt to have the nearest LC for relaying the packet to the BG more quickly. Yes, it can do so more rapidly, but the primary aim of the LCs in the proposed architecture is to maintain the local updated topology to directly communicate with the SDN controller. It only serves as a gateway between the querying node and the SDN controller. In rare cases, when the network is sparse, it can serve as a relay node. This is for the reason that we do not put the LCs out with information other than that needed for their role as a local controller, and also by reason of the cost, where we do not place large number of LCs in the network. The path is selected using a Q-learning algorithm, which is a reinforcement-learning algorithm which can be used to solve the routing problems [15]. Q-learning is based on the value of a state-action pair \(Q(s,a)\), which is an updating function given as:  
\[Q(s,a)=R+\gamma\sum_{s^{{}^{\prime}}\in S}P_{ss^{{}^{\prime}}}maxQ(s^{{}^{ \prime}},a^{{}^{\prime}}) \tag{1}\]  
where \(\gamma\) is the discount factor, \(maxQ(s^{{}^{\prime}},a^{{}^{\prime}})\) models the maximum expected future reward, and \(R\) is the expected immediate reward. Hence, the inquiring node opts the next relay node based on the following reward equation:  
\[R=\beta\times(1-\frac{1}{hello\_messages/t})+(1-\beta)\frac{1}{TD} \tag{2}\]  
where \(\beta\) is a weight factor, and as in our previous work [16], transmission delay, \(TD\), is defined as:  
\[TD=\frac{r\pm d_{ij}}{\Delta v}\times min(Ch_{1},Ch_{2},...,Ch_{M}) \tag{3}\]  
\(\Delta v=\sqrt{(v_{i}\cos\theta_{i}-v_{j}\cos\theta_{j})^{2}+(v_{i}\sin\theta _{i}-v_{j}\sin\theta_{j})^{2}}\), where \(v\) represents velocity, \(\theta\) is the angle, \(d_{ij}\) is the distance between two nodes, and \(r\) is the transmission range of nodes; \(min(Ch_{1},Ch_{2},...,Ch_{M})\) signifies the highest belief channel among all the idle channels between node \(i\) and node \(j\). Since the path between source and destination is a cognitive routing path, two communicating nodes can therefore only make a link with each other if the two have at least one common idle channel. In view of that, spectrum sensing is essential for these nodes.