# A Scalable and Trust-Value-Based Consensus Algorithm for Internet of Vehicles
## 4 C-PBFT Consensus Algorithm
### Reputation Calculation Using Multi-Weighted Subjective Logic Model
#### 4.2.2 Multi-Weight Local Opinions of Subjective Logic  
Local opinions using the subjective logic model are affected by different factors. When considering weighted operation, traditional subjective logic evolves to multi-weighted subjective logic. We consider the following weights to form a partial opinion:  
* Interaction Frequency: The higher the interaction frequency means that vehicle \(V_{i}\) has more prior knowledge of \(RSU_{j}\), so the calculation of \(V_{i}\)'s credit value to \(RSU_{j}\) is more accurate and reliable. The interaction frequency of \(V_{i}\) with \(RSU_{j}\) is the number of times \(V_{i}\) interacts with \(RSU_{j}\), the ratio of \(V_{i}\) to the number of times \(V\) interacts with \(RSU_{j}\) and other interactions in a time window. For distinction, the frequency of interaction between vehicle \(V_{i}\) and \(RSU_{j}\) in this step is expressed as \(IF_{i\to j}^{0}\): \[IF_{i\to j}^{0}=\frac{N_{i\to j}}{\sum_{z=1}^{N}N_{i\to z}}\] (3) \(N_{i\to j}=(\alpha_{i\to j}^{t_{x}}+\beta_{i\to j}^{t_{x}})\), where \(z\) is the set of all RSUs interacting with vehicle \(V_{i}\) in the time window, with \(N\) elements. The higher the interaction frequency, the higher the reputation expectation of vehicle \(V_{i}\) on \(RSU_{j}\). * Timeliness of Interaction: Recent behavioral events with a higher degree of freshness are weighted more heavily than past events. In order to reflect the effect of reaction time on reputation, a freshness decay function is defined to represent the freshness of a behavioral event: \(\psi(t_{x})=\psi_{x}=Y^{X-x}\), where \(Y\in(0,1)\) is a given decay parameter about the freshness of an event. In a time period \(X\), the local opinion vector of vehicle \(V_{i}\) on the evaluation of \(RSU_{j}\) is expressed as \[\left\{ \begin{array}{l}b_{i\to j}=\frac{\sum_{x-1}^{X}\left(\psi_{x}b_{i \to j}^{tx}\right)}{\sum_{x-1}^{X}\psi_{x}}\\ d_{i\to j}=\frac{\sum_{x-1}^{X}\left(\psi_{x}d_{i \to j}^{tx}\right)}{\sum_{x-1}^{X}\psi_{x}}\\ u_{i\to j}=\frac{\sum_{x-1}^{X}\left(\psi_{x}d_{i \to j}^{tx}\right)}{\sum_{x-1}^{X}\psi_{x}}\end{array} \right. \tag{4}\]  
where \(\psi_{x}\) represents the freshness attenuation function, \(b_{i\to j}^{tx}\), \(d_{i\to j}^{tx}\) and \(u_{i\to j}^{tx}\) are shown in Formula (1). * Interaction Effects: Positive interactions increase the reputation value of RSU nodes, while negative interactions decrease the reputation of RSU nodes. In general, the effects of negative events are much more serious in public opinion than positive effects, so the interaction effects of messages have higher weights on local opinions. The weight of positive interaction is \(\chi\), and the weight of negative interaction is \(\tau\), where \(\chi+\tau=1\), \(\chi<\tau\). Combining the interaction timeliness and the weight of the interaction effect, the positive and negative interaction effects of \(V_{i}\) and \(RSU_{j}\) are expressed as follows: \[V_{i\to j}^{\alpha}=\frac{\sum_{x-1}^{X}(\psi_{x}\chi u_{i \to j}^{tx})}{\sum_{x-1}^{X}\psi_{x}}\] (5) \[V_{i\to j}^{\beta}=\frac{\sum_{x-1}^{X}(\psi_{x}\tau\beta_{i \to j}^{tx})}{\sum_{x=1}^{X}\psi_{x}}\] (6) Among them, \(V_{i\to j}^{\alpha}\) represents the positive interaction between \(V_{i}\) and \(RSU_{j}\), while \(V_{i\to j}^{\beta}\) represents the negative interaction effect between \(V_{i}\) and \(RSU_{j}\). Therefore, according to Formulas (3), (5), and (6), the interaction frequency of \(V_{i}\) and \(RSU_{j}\) is updated as follows: \[IF_{i\to j}=\frac{V_{i\to j}^{\alpha}+V_{i \to j}^{\beta}}{\sum_{x=1}^{N}N_{i\to x}}\] (7) where \(IF_{i\to j}\) is the result of updating the \(IF_{i\to j}^{0}\) of formula (3). * Distance Factor: Considering the influence of the geographical location where the vehicle Vi sends the message, that is, the farther the geographical location where the message is generated is from the geographical location where the event occurs, the lower the event weight.