## 3 Proposed Mathematical Model of a Switched Beam Antenna with Beam Steering Abilities
```
0:Input:choose_resource_selection(self, reselection_window)
0:
1:\(\textit{V2V\_P}\)
2:\(\textit{PDR\_threshold}\)
3:\(\textit{min\_PDR}=\frac{\text{len}(\textit{selection\_window})}{4.67}\)
4:\(\textit{PDR}\leftarrow\text{counter}\)
5:while\(\text{len}(\textit{PDR})<\text{min\_PDR}\)do
6:\(\textit{PDR}\leftarrow\text{counter}+1\)
7:forbeam_selection in \(\text{range}(\text{len}(\textit{selection\_window}))\)do
8:if\(\text{len}(\textit{PDR})=0.88\)then
9:\(\textit{V2V\_P}\gets\text{P}(\text{least\_urban})\)\(\triangleright\) Fine Power Beam
10:elseif\(0.92\leq\text{len}(\textit{PDR})\leq 0.99\)then
11:\(\textit{V2V\_P}\gets\text{P}(\text{moderate\_sub\_urban})\)
12:else
13:\(\text{counter}+1\)\(\triangleright\) Highway settings
14:endif
15:endfor
16:endwhile
17:\(\textit{sorted\_R\_PDR}\leftarrow\text{sorted}(\textit{PDR\_items}(0),\text{ key}=\lambda x:x[1])\)
18:\(\textit{min\_len}\leftarrow\text{min}(\text{min\_PDR},\text{len}(\textit{PDR}))\)
19:for\(k\) in \(\textit{sorted\_R\_PDR}\)do
20: sB.append(\(k\))
21:if\(\text{len}(sB)\geq\text{min\_len}\)then
22:break
23:\(\text{random\_choice}(sB)\)
24:endif\(\triangleright\) Real Time PDR Execution
25:endfor
```  
**Algorithm 1** Beam switching with PDR setting via a selection window  
```
0:\(\textit{def\_step}(\textit{self\_selection\_window})\) : \(\textit{param\_selection\_window}\) : \(\textit{action}=0\); if\(\textit{selection\_counter}!=0\)then  Use previous selected packet index and reduce reselection counter. \(\textit{Action}=\textit{V2V\_line}\); \(\textit{self\_reselection\_counter}--1\); elseif\(\textit{random}()<\textit{self\_prob\_resource\_keep}\); then \(\textit{action}!=\textit{V2V\_line}\); elseif\(\textit{action}=\textit{self\_choose}\textit{new\_resource}(\textit{selection\_window})\)then \(\textit{self\_prev\_action}=\textit{continue}\) else  The V2V link is inadequate due to a lack of resources. endif \(\textit{return\_action}\);
```  
**Algorithm 2** Real-time value upgradation and switching via RSSI values for a V2V link  
This research has algorithm settings as its central part. Integration of several tools has been carried out, including the Python Development Kit and NS3. Additionally, three significant developer stacks have been created: front-end, middle stack, and back-end. 1. The front end contains Doppler range selection according to the proposed mathematical model for various environments. 2. The middle stack contains beam switching based on power concentrations to maintain the V2V link quality to meet the standards. 3. A central management algorithm system is created to control the overall communication between different components. The in-depth structure can be illustrated in Figure 5. The parameter settings of the conducted research are shown in Table 1.  
Figure 4: Concept of the proposed algorithm in case of real-time PDR failure. Figure 5: Experimental and working structure of the algorithm. Synchronization errors in V2V communication systems can arise from several technical factors, leading to misalignment between the transmitting and receiving ends. These errors can have significant implications on the overall system performance:  
Propagation Delays: Propagation delays caused by the finite speed of electromagnetic waves can introduce synchronization errors. The variation in the distances between transmitting and receiving vehicles can result in different signal arrival times, leading to misalignment of beamforming and beam tracking operations. Clock Drift: Clock drift in the transmitting and receiving devices can introduce timing discrepancies, causing synchronization errors. Inaccurate clocks or drift over time can lead to misalignment of the beamforming intervals, resulting in reduced beamforming efficiency. Channel Estimation Inaccuracies: Inaccurate estimation of channel characteristics, such as channel gains and phases, can contribute to synchronization errors. Mismatches in channel estimation can lead to misalignment between the intended beamforming direction and the actual received signals.