# LoRa Architecture for V2X Communication: An Experimental Evaluation with Vehicles on the Move
## 4 Communication Algorithms of Proposed System
OBU first finds and sorts vehicles and RSUs in its vicinity. Then the sender OBU collects, parse, and sends the data to the designated vehicles and RSUs. Depending on the application, the sender  
Figure 2: The proposed V2X communication architecture. OBU might also receive any necessary feedback along with the acknowledgment from the receiving units. For V2I communication, an OBU wants to reach the RSU with the best link quality instead of broadcasting the vehicle data for all the RSUs in its vicinity. This will make communication efficient and also reduce data overheads. Firstly, an OBU broadcasts a 'Hello' message in its transmission range. The RSUs in the vicinity receive the 'Hello' message and send an acknowledgment (ACK) back. Then, the OBU knows the RSSI values of all the RSUs in its vicinity. From the RSSI values, OBU knows which RSU has the better link quality to send the collected sensor data. The OBU chooses the RSU with maximum RSSI value to send the sensor data. The defined RSU sends an ACK upon receiving the vehicle data from the OBU. Upon receiving the ACK from the receiver RSU, OBU updates the RSSI thus checking the link quality again. The OBU keeps sending the data to that particular RSU until the RSSI value reaches a certain predefined threshold value. This threshold value depends on the distance up to which the transceiver can communicate perfectly with no packet drops under the usual traffic scenario. In this case, the LoRa transceiver that used could communicate reliably up to 160 m with no packet drops. Therefore, the RSUs are placed at a distance of 320 m from each other with a radius of 160 m each. The corresponding RSSI value at 160 m is noted as \(-\)60 dBm. Thus, the threshold RSSI is set to \(-\)60 dBm, so that OBU switches from this RSU to another as the communication becomes unreliable. When the RSSI from the receiving RSU crosses this threshold, the OBU broadcasts the 'Hello' message again to repeat the same procedure. By this algorithm, an OBU always remains connected to the most reliable RSU in its transmission range and it switches to another RSU only when the link quality degrades to a certain level to hamper communication link. The described V2I communication algorithm is depicted by Algorithm 1. ```
while Serial reading available do VehicleData \(\leftarrow\) SensorData If radio available then Broadcast to wait 'Hello' to RSUs Receive ACKs from RSUs \(R_{1}\ldots R_{N}\) \(\leftarrow\) Kalman filtered RSSI of \(RSU_{1}\ldots RSU_{N}\) \(R_{max}\leftarrow\) maximum RSSI value from \(R_{1}\ldots R_{N}\) \(RSU_{max}\leftarrow\) RSU with maximum RSSI else printCan't find any RSUs endif while\(R_{max}>-\)60 do Send to wait VehicleData to RSUmax Receive ACKs from RSUmax \(R_{max}\leftarrow\) Kalman filtered RSSI of \(RSU_{max}\) endwhile endwhile
```  
**Algorithm 1** Sending Data from OBU to RSU  
For V2V communication, an OBU broadcasts the 'Hello' message again for all the vehicles in transmission range as like in V2I communication. Upon receiving the data by other OBUs, they send the ACKs back and let the sender know the RSSI. When the sender OBU receives the RSSI values from other vehicles, it decides to which vehicles it will be sending the data to. OBU does not send the vehicle data to all the vehicles in the range which will make it inefficient, rather it sends the data to the closer vehicles only for making them aware of its location, direction, and acceleration. It is found that, with RFM69 HCW, the RSSI value reaches \(-\)35 dBm (approximately) when the sender and the receiver are at a distance of 40 m on a regular road with usual traffic. In the proposed architecture, OBU sends the data to the vehicles within a radius of 40 m making it coherent and efficient. OBU compares the RSSI values of other vehicles to check if they are greater than \(-\)35 dBm and send the vehicle data to other vehicles within that perimeter. Algorithm 2 presents the V2V communication protocol for the proposed architecture.