# QoS Aware and Fault Tolerance Based Software-Defined Vehicular Networks Using Cloud-Fog Computing
## 4 Proposed Solution
### Qaft-SDVN Proposed Model  
The proposed model consists of vehicles that will communicate with each other during the journey, SDN nodes that are placed on fog nodes, main SDN control that is also placed on fog nodes, the cloud, which is for huge computation and storage, as shown in Figure 3. We have vehicles from \(V_{1}\), \(V_{2}\), \(V_{3}\), \(\cdots\), \(V_{n}\); furthermore, we have SDN nodes from \(SDN_{1}\), \(SDN_{2}\), \(SDN_{3}\), \(\cdots\), \(SDN_{m}\). We have Fog nodes from Fog1, Fog2, Fog3, \(\cdots\), Fogk, and cloud nodes from \(C_{1}\), \(C_{2}\), \(C_{3}\), \(\cdots\), \(C_{j}\). Vehicles send and receive messages such as \(M_{1}\), \(M_{2}\), \(M_{3}\), \(\cdots\), \(M_{s}\). The following Table 2 is used for the abbreviations used in the proposed model. Our proposed model first gets messages from vehicles through nearby gateways, which are placed into fog nodes. Messages are categorized into safety and non-safety according to the nature of messages and deadline, and size. The concerned SDN controller performs necessary action and returns the result to vehicles otherwise sent to the cloud for storage and necessary action. The following Algorithm 1 is used for messages receiving and giving priority to them. \begin{table}
\begin{tabular}{l l} \hline \hline
**Abbreviation** & **Standsfor** \\ \hline \(\ell\) & Successfulnessages \\ \(\varphi\) & Failedtasks/messages \\ \(M_{i}\) & Messagesofvehicles \\ \(Ack\) & Acknowledgment \\ \(SDVN\) & SoftwareDefinedVehicularNetwork \\ W1 \& W2 & Safetyandmon-safetypmessages \\ \(\Omega\) & Receivedmessagesforforwarding \\ \(SDN\) & SoftwareDefinedNetworking \\ \(M\) & Message \\ C & CloudComputing \\ \(Fog\) & FogComputing \\ \(\Re_{p}\) & Responsetime/ExecutionTime \\ QoS & QualityofService \\ VANET & VehicularAd-HocNetwork \\ \(F\) & TasksFailureRatio \\ \hline \hline \end{tabular}
\end{table} 
Table 2: List of abbreviation used in the proposed model. Figure 3: Qaft-SDVN Proposed Model. ```
Input: (Vehicles Messages) Output:\(W_{1}\) & \(W_{2}\) (Messages Priorities)
1. For 1 to n
2. \(\Omega=M_{s}\) //Receive Messages from \(V_{i}\) (\(i=1\) to n) and assign to \(\Omega\)
3. End of for loop
4. For 1 to n Find Weight of \(\Omega\) // according to message nature
5. if(\(\Omega==010\)or 011 or 012 or 013 or 014 or 015 or 016)
6. then assign \(W_{1}\) in ascending order
7. Else \(W_{2}\)
8. Return \(W_{1}\) & \(W_{2}\)
9. End of for loop
```  
**Algorithm 1**Vehicles Messages receiving and priority allocation based on message nature  
The following Algorithm 2 is used to calculate messages priority based on deadline and size:  
```
Input: (Vehicles Messages) Output:\(W_{1}\) & \(W_{2}\) (Messages Priorities)
1. For 1 to n
2. \(\Omega=M_{s}\) //Receive Messages from \(V_{i}\) (\(i=1\) to n) and assign to \(\Omega\)
3. End of for loop
4. For 1 to n Find Weight of \(\Omega\) according to message nature
5. \(\mathbf{W=Deadline}\) * Size
6. If\(\mathbf{W=<Deadline}\) * Size of the Table 1
7. then assign \(W_{1}\) in ascending order
8. Else \(W_{2}\)
9. Return \(W_{1}\) & \(W_{2}\)
10. End of for loop
```  
**Algorithm 2**Vehicles Messages receiving and priority allocation based on deadline and size  
Algorithm 1 input consists of vehicle messages, and the output consists of \(W_{1}\) & \(W_{2}\) (weighted priority). Algorithm 1 consists of nine steps in which we used two linear for loops. The first for loop is used for messages/data receiving at SDN Controller, then the second for loop is used for priority calculation of the received messages according to the messages nature, as provided in Table 1. The algorithm at the end returns two lists of messages and further forward the messages to vehicles and to the cloud for storage, which is provided in Algorithm 3. Algorithm two is used for messages received at SDN nodes placed on fog nodes; the input consists of vehicle messages, the output consists of two lists. One is of priority basis messages. The other list consists of normal messages.