# TARS: A Novel Mechanism for Truly Autonomous Resource Selection in LTE-V2V Mode 4
## 4 System Model Assumptions and Proposed Mechanism
### TARS Mechanism
#### 4.4.4 Algorithm  
This section describes the TARS algorithm. The inputs for Algorithm 1 include local neighbor information \(l_{n}\), current local time \(t_{l}\), and channel information in terms of the signal-to-noise ratio \(ch(i)_{SNR}\). A successful algorithm execution gives the resource block, \(RB_{l}\), to be used by a vehicle for beacon transmission.  
Initially, a vehicle needs \(l_{n}\), \(t_{l}\), and \(ch(i)_{SNR}\). \(l_{n}\) is acquired through the received beacons from the neighbors and stored in a list. This information contains the unique MAC identifier for a neighbor. It was assumed that the time at every vehicle is perfectly synchronized. This is a reasonable assumption because of the prevalent time synchronization standards. \(ch(i)_{SNR}\) is the signal-to-noise ratio measurement of all the RBs. This information is stored in a table where every RB is recorded, along with its previous SNR value.  
Figure 10: Probabilities of the proposed selection counter; (**a**) For \(R_{s}\) = 0.4, (**b**) For \(R_{s}\) = 0.7.  
In Lines 6-7, if a vehicle has a beacon to transmit, it first selects a suitable RB. The algorithm uses a 64 bit crypto-hash function, which is pruned and mapped to an RB number. From Line 8 to Line 10, to avoid resource collision with neighbors, each vehicle tries to predict the RB selection by its neighbors. For each of its neighbors, a vehicle uses a seed that includes the MAC address of a neighbor and \(t_{l}\) to acquire a list of all the RBs selected by its neighbors. In Line 12 and Line 13, if the vehicle finds resource collision, then the vehicle selects an RB that has the least SNR value across all the RBs.  
From Lines 15-17, the process of counter selection is called. The value of the counter is determined via Line 22-25. If the value of \(\beta\) is less than 35%, then the standard value of counter \(S_{c}\) (Std) is used, which is [5-15]; otherwise, Equation (9) is used to set up the counter value. At Line 27, transmission is performed on the selected RB. RB reselection is carried out in Lines 30-34 when the counter value reaches zero. If the same RB is reassigned, transmission is established; otherwise, the process of acquiring a new RB is restarted via RB selection.  
Figure 11: Probabilities of reselection; (**a**) For \(R_{x}=5\), (**b**) For \(R_{x}=40\).  
```
1:\(l_{n},t_{l},ch(i)_{SNR}\)
2:\(RB_{l}\)
3:procedureMain
4:procedureRBSelection
5:\(Get\)Neighbor list \(\gets l_{n}\)
6:\(Get\)\(GNSS\)\(\leftarrow\)\(t_{l}\)
7:\(Get\)\(SNR_{ch(i)}\)\(\leftarrow\)\(ch(i)_{SNR}\)
8:\(Calculate\)\(hash_{l}\)\(\leftarrow\)\((l_{n}+t_{l})\)
9:\(Map\)\(hash_{l}\)\(\leftarrow\)\(RB_{l}\) using Equation \((8)\)
10:for (each \(i\) in \(ch(i)_{SNR}\)\(\geq\) 20%) do
11:\(Calculate\)\(hash_{l}\)\(\leftarrow\)\((l_{i}+t_{l})\)
12:\(Map\)\(hash_{l}\)\(\leftarrow\)\(RB_{l}\)
13:endfor
14:for (each \(i\) in \(ch(i)_{SNR}\)) do
15:if (\(RB_{l}==RB_{l}\)) then
16:\(Select\)\(RB_{l}\)\(ch(i)_{SNR}\)\(\leftarrow\)\(ch(i)_{SNR}\)
17:\(CounterSelection()\)
18:else
19:\(CounterSelection()\)
20:endif
21:endfor
22:endprocedure
23:procedureCounterSelection
24:if (\(\beta<\) 35%) then
25:\(counter==\)\(S_{c}(Std)\)
26:else
27:\(counter\)\(\leftarrow\)\(using\)\(Equation\) \((9)\)
28:endif
29:\(Transmit\)\(using\)\(RB_{l}\)
30:endprocedure
31:procedureReselection
32:\(RBreslection\)\(\leftarrow\)\(using\)\(Equation\) \((11)\)
33:if (\(RB_{new}==\)\(RB_{l}\)) then
34:\(Transmit\)\(using\)\(RB_{l}\)
35:else
36:\(RBselection()\)
37:endif
38:endprocedure
39:endprocedure
```  
**Algorithm 1** RB selection using TARS.