# IoT-Based System for Improving Vehicular Safety by Continuous Traffic Violation Monitoring
## 4 Experiment and Results
### Speed Estimation Results  
We performed the experiments for speed estimation by driving a car on the Tulkarem-Nablus route of 15.1 Km, as shown in Figure 5. A car with a digital speed meter, shown in Figure 5 on the right side, is used to record the vehicle speed, which is used as a baseline for comparisons. The speed meter data can provide the best option for monitoring speed, but the inability to digitally read this speed in all vehicle brands and send it to the cloud motivated us to use an external speed estimation. The three smartphones listed in Table 2 were used to evaluate the speed of the vehicle. Figure 6 shows the results of the estimated speed. Although the devices can estimate speed at a higher frequency, the data in the figures are shown every minute to simplify the visual representation. The figure shows that there is a small difference between the actual speed, as measured by the vehicle speed meter, and the estimated speed. Smartphone 1 outperforms other devices in estimating the speed, while smartphone 3 provides the worst results. The performance of the smartphone's computations is what accounts for the accuracy difference. The speed of performing the Haversine method and retrieving data from memory are both impacted by the smartphone's performance. Due to the low performance, there is a delay in estimating the speed, which causes the predicted speeds to be lower or greater than the actual speeds. Thus, a fog layer needs to possess sufficient computational resources to achieve high accuracy. To evaluate the effect of the fog layer on the accuracy, we compare the results of speed estimation using the edge layer alone, as in [17], with speed estimation when the fog layer is added to the system. The approach with the edge layer alone, in [17], is used as a baseline for the comparison. We used smartphone 1, which had the highest accuracy, to compare both approaches. The results are shown in Figure 7. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Smartphones** & **CPU** & **GPU (Adreno)** & **Memory (GB)** \\ \hline s1 & \begin{tabular}{c} Octa-core (2 \(\times\) 2.3 GHz Kryo 465 Gold \\ 6 \(\times\) 1.8 GHz Kryo 465 Silver) \\ \end{tabular} & 618 & 128 \\ \hline s2 & \
\begin{tabular}{c} Octa-core (4 \(\times\) 2.2 GHz Kryo 260 Gold \\ 4 \(\times\) 1.8 GHz Kryo 260 Silver) \\ \end{tabular} & 512 & 64 \\ \hline s3 &
\begin{tabular}{c} Hexa-core (4 \(\times\) 1.4 GHz Cortex-A53 \\ 2 \(\times\) 1.8 GHz Cortex-A72) \\ \end{tabular} & 510 & 16 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The specifications of the smartphones used in the experiments. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Number of data centers & 1 \\ Number of hosts & 1 \\ Number of data center brokers & 1 \\ Number of virtual machines (VM) & 4 \\ Number of processing elements (PE) & 1 \\ MIPS of PE & 4000 \\ MIPS of each VM & 400 \\ VM RAM & 2048 MB \\ Data center scheduling & Space-shared \\ VM scheduling & Space-shared \\ Bandwidth & 1000 \\ Number of cloudlets & 10 \\ Cloudlet scheduling & Space-shared \\ CPU, RAM, BW & Full utilization \\ \hline \hline \end{tabular}
\end{table} 
Table 3: CloudSim simulation parameters. Additionally, we evaluated the root mean square error (RMSE) for the speed estimation with and without the fog layer in order to better understand the accuracy at a wider data range. The RMSE values are presented in Table 4 and show that the estimation with the added fog layer has a lower RMSE, which means higher accuracy. The reason for the higher accuracy of the approach with the fog layer is that the edge prepares the data for the fog computing via preprocessing and aggregation. This means that both edge and fog computing cooperate in improving the accuracy by sharing the computational load.