# LoRa Architecture for V2X Communication: An Experimental Evaluation with Vehicles on the Move
## 4 Communication Algorithms of Proposed System
```
while Serial reading available do VehicleData\(\leftarrow\) SensorData If radio available then Broadcast to wait 'Hello' to OBUs Receive ACKs from OBUs \(R_{1}\ldots R_{N}\leftarrow\) Kalman filtered RSSI of \(OBU_{1}\ldots OBU_{N}\) \(R_{1}\ldots R_{M}\leftarrow\)\((R_{1}\ldots R_{N})>-35\) (\(M\) number of OBU has RSSI greater than \(-35\)) Send to wait VehicleData to OBU\({}_{1}\ldots OBU_{M}\) Receive ACKs from OBU\({}_{1}\ldots OBU_{M}\) else print Can't find any OBUs endif endwhile
```  
**Algorithm 2** Sending Data from OBU to another OBU  
It is also worth mentioning that RSSI measurement in a mobile environment is less trustworthy and fluctuates from the actual value. The Kalman filter is an optimal estimator which is also recursive to process the new measurements as they are received. It is ideal for any dynamic environment where the received values are continuously changing. Moreover, it is also quite fast which makes it suitable for real-time embedded systems. A Kalman filter is comprised of two main steps: (i) prediction step and (ii) update step. The prediction step does the prediction of the next RSSI from the earlier value whereas the update step estimates the current RSSI value from the value received at that step. Equations (1) and (2) shows the prediction step and the update step of the Kalman filter, respectively [69]. Here, X is the mean estimation of the RSSI, P is the prediction error covariance, A is the transition matrix, Q is the noise covariance matrix, B is the input effect vector and U is the control input. One of the benefits of the Kalman filter is that it only needs the memory of the previous state which makes it very light on memory, so the Kalman filter is suitable for stabilizing the RSSI values removing the outliers. Many researchers have also used the Kalman filter to stabilize the RSSI values where precise value is required for the applications:  
\[X_{\overline{K}}=A_{K-1}X_{K-1}+B_{K}U_{K} \tag{1}\]  
\[P_{K}=A_{K-1}P_{K-1}A_{K-1}^{T}+Q_{K-1} \tag{2}\]  
The Kalman filter is computationally heavier in comparison to calculating the raw RSSI value. Few researchers have also used a moving average filter for stabilizing the RSSI values. A performance test has been carried out for finding the accuracy and stabilizing capability of the Kalman filter and moving average filter in comparison to the absolute RSSI values as in Figure 3. The average of 50 RSSI values taken at static state has been taken as the absolute RSSI value whereas the moving average filter takes 5 RSSI readings at a time for stabilizing any outlier fluctuation. The test has been carried out in a 100 m space at a speed of 5-10 kmph taking the reading in every 10 m of interval. Figure 2 shows the comparison of the moving average and Kalman filtered values with respect to the absolute values (Mean of 50 values). The results show that the Kalman filtered values get much closer to the absolute values in comparison to the moving average filter thus it stabilizes more perfectly. This is because the RSSI values change very fast for any mobile object and the moving average filter always calculates the dynamic average of any given number of points. So, with moving average filter RSSI values get update slowly and move away from the absolute value. On the contrary, the Kalman filter adapts to this dynamic environment more precisely with the prediction and update step. Thus, the Kalman filter is adopted in the proposed algorithms for better stabilization of RSSI values which is one of the factors for ensuring better reliability.