Internet of vehicles trust management method based on improved Transform
By improving the Transformer neural network to evaluate the credibility of vehicle interaction information in the Internet of Vehicles environment, the problem of insufficient vehicle trust assessment in the existing technology is solved, more accurate trust management and malicious node identification are achieved, and the Internet of Vehicles is improved Safety and reliability.
Patent Information
- Application Number
- CN202411096857.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-12
AI Technical Summary
The existing trust management methods for Internet of Vehicles rely on encryption technology and cannot effectively deal with malicious behaviors within the vehicle network. They lack accurate assessment of node behavior, resulting in insufficient assessment of vehicle trust.
Adopt the improved Transformer neural network, by adding feedforward neural network and fully connected network layer after the encoder, combining traffic simulation simulator and discrete event simulation platform to collect data, build data sets and train neural networks, so as to achieve the ability to interact with vehicles. Reliability assessment, dynamically adjust vehicle trust values, identify and mark malicious nodes.
It improves the security and reliability of the Internet of Vehicles, accurately evaluates vehicle trust, recognizes and suppresses the spread of malicious messages, enhances the defense ability of internal attacks, and is suitable for scenarios with a large proportion of malicious nodes in vehicle trust management.
Smart Images

Figure CN118945615A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet of Vehicles trust mechanism, and in particular to an Internet of Vehicles trust management method based on an improved Transformer. Background Art
[0002] As an open information exchange environment, the in-vehicle network is vulnerable to internal attacks, leading to security risks. Trust between vehicles plays a vital role in addressing these challenges. In the past, trust management mainly relied on encryption methods, but these methods lacked precision in assessing vehicle trust and could not effectively deal with internal attacks within the vehicle network. Traditional encryption methods prevent external attacks by verifying message integrity, but are powerless against malicious behavior of internal nodes. Internal attackers may bypass encryption mechanisms by forging identities or tampering with information, affecting the judgment of other vehicles. Since encryption methods mainly focus on the security of the data transmission process and lack accurate assessment of node behavior, they are insufficient in assessing vehicle trust. To solve this problem, deep learning technology has been introduced into in-vehicle network trust management in recent years. Deep learning has powerful data processing and pattern recognition capabilities, and can extract effective features from a large amount of vehicle interaction data and accurately assess the trust between vehicles. By building a neural network model, deep learning can finely analyze vehicle behavior, identify potential malicious nodes, and suppress the spread of malicious messages, thereby improving the overall security of the in-vehicle network and preventing interference from malicious nodes. The use of deep learning technology to optimize trust management in vehicle networks not only makes up for the shortcomings of traditional encryption methods, but also can more accurately evaluate the trust between vehicles and improve the security and reliability of the Internet of Vehicles. Summary of the invention
[0003] The purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art, and proposes a trust management method for the Internet of Vehicles based on an improved Transformer. The method utilizes the Transformer structure, removes the decoder part, modifies its embedding layer, and adds a feedforward neural network and a fully connected network layer after the encoder to process the output of the encoder. This can improve the receptive field of the network. At the same time, the attention mechanism realizes selective learning of the input information, and ultimately can accurately distinguish the credibility of each piece of information, and can more accurately evaluate the trust between vehicles, thereby improving the security and reliability of the Internet of Vehicles.
[0004] To achieve the above purpose, the technical solution provided by the present invention is: a vehicle network trust management method based on an improved Transformer, comprising the following steps:
[0005] 1) Use the traffic simulation simulator SUMO and the discrete event simulation platform OMNet++ to simulate urban traffic, collect the interaction information between vehicles and the changes in vehicle trust values during the simulation process, and use them to construct a data set. The data set is preprocessed to obtain data with the same scale, and then the data is divided into a training set and a validation set;
[0006] 2) Input the training set into the improved Transformer neural network for training, use the data set Adam optimizer in the training set to continuously adjust and update the neural network parameters, and then use the validation set for validation to obtain the neural network with the best performance; wherein, the improvements of the Transformer neural network include: first, replace the original embedding layer with a fully connected neural network to map the discrete input message features into a continuous vector space, while expanding the input feature dimension so as to better capture the hidden relationship between features in the future; second, remove the decoder in the original Transformer neural network, because the goal of the improved Transformer neural network is to evaluate the credibility of the interactive information between vehicles without the need for the decoder to generate sequence outputs; third, introduce a feedforward neural network layer and a fully connected network layer after the encoder of the original Transformer neural network. The role of the feedforward neural network layer is to integrate the features learned by the encoder, perform nonlinear transformations through layer-by-layer transmission, and map high-dimensional data to low-dimensional representations. Subsequently, the fully connected network layer is used to convert the low-dimensional data into a single numerical value, which represents the credibility of a piece of interactive information;
[0007] 3) After the neural network with the best performance is deployed on the vehicle server, each vehicle is assigned an initial trust value. When a vehicle sends interactive information to other vehicles, the receiving vehicle will process the received interactive information and convert it into features that can be input into the improved Transformer neural network. The credibility of the interactive information is predicted by the neural network with the best performance. The predicted credibility is compared with the preset threshold to determine the change in the trust value. This change is used to adjust the trust value of the message sending vehicle on the RSU, thereby updating its trust value to achieve the goal of trust management. If the trust value of the vehicle is lower than the preset threshold, the vehicle will be regarded as malicious or dishonest.
[0008] Further, in step 1), the content carried by an interactive message Origin is: Origin = {id r ,id s ,t s ,id m ,lastTrust,ty m ,pos s ,spe s ,oris ,acc s}, the interaction information indicates that the number is id s The message is sent to the vehicle at t s Time, pos s The message sent by the location to the surrounding vehicles within the communication range. This interactive information is the main content of the dataset, where id r Indicates the vehicle that received the interactive information, id m Indicates the message number, lastTrust indicates the historical trust value of the vehicle sending the message, and ty m Indicates the type of message, spe s 、ori s and acc s Respectively represent the number id s The message is sent to the vehicle at t s The moving speed, moving direction and moving acceleration at the moment;
[0009] For n Origins, a data set D can be generated n Before dividing the data set, data preprocessing is required to obtain data with the same scale in order to reduce the deviation introduced by data measurement. The preprocessing operation is to apply z-score normalization to each field of the data set. The calculation formula is: Where X' represents the data after normalization of the z-score original data set, X represents each original data in the data set, μ represents the average value of all original data in each field in the data set, and σ represents the standard deviation of all original data in each field in the data set;
[0010] After preprocessing the original data set, it is randomly divided into a training set and a validation set according to a preset ratio;
[0011] In the preprocessed data set, each interactive message Origin corresponds to a label, which means: after the message sending vehicle sends the i-th interactive message Origin, the change in the trust value of the message sending vehicle is y i , if y i If it is a positive number, the corresponding label is 1, otherwise, the corresponding label is 0.
[0012] Further, in step 2), the entire neural network is divided into 6 parts, each of which is as follows:
[0013] a. Embedding layer: In order to convert the discrete data in the input interactive information Origin into a vector representation with semantic meaning, a fully connected neural network is used to replace the original embedding layer so as to map the data in the interactive information to a 512-dimensional vector e emb ;
[0014] b. Position encoding layer: transform the vector e emb Input to the position encoding layer to get the vector e pos , in order to retain the position information of the input data, capture the relationship between the previous and next data in the interactive information, and then transform the vector e emb and e pos Add them together to get the vector e with both position information and semantics data ;
[0015] c. Multi-head self-attention layer: vector e data Input to a network with 8 self-attention heads to capture features in the interaction information. This layer is responsible for calculating the attention weight of each feature and generating the attention vector e attention , which is designed to tell the neural network which features in the interactive information to pay attention to. These attention weights represent the influence of each feature on all other features in the interactive information. The implementation of the self-attention mechanism relies on three components: Query, Key, and Value. These three components are obtained from the input vector e through three independent linear transformations. data The calculation formulas for Query, Key, and Value are as follows:
[0016] Query = e data *W Q
[0017] Key=e data *W K
[0018] Value = e data *W V
[0019] Where W Q , W K and W V Represent three linear weights, which are independent of each other and obtained through training. After that, scaled dot product attention is performed on each head according to the following formula:
[0020]
[0021] in, is the dimension of the vector Key, which is used to scale the dot product to avoid the result being too large, then concatenate the outputs of all heads together, and then generate the final output vector e through a linear transformation attention :
[0022] MultiHead(Query,Key,Value)=Concat(h1,h2,...,h n )WO
[0023] In the formula, h1, h2 and h n They represent the output of the first head, the output of the second head, and the output of the nth head respectively. Concat is a concatenation algorithm that concatenates the outputs of all heads together to form a long vector, which is then transformed by a linear transformation W. O Convert the concatenated vector into the final output e attention ;
[0024] d. Layer normalization and residual connection layer: used to stabilize the training process and promote the effective propagation of gradients. The layer normalization and residual connection layer consists of layer normalization and residual connection layer; the residual connection layer is calculated as follows:
[0025] Add(X″,SubLayerOutput)=X″+SubLayerOutput
[0026] Where SubLayerOutput represents the output of the multi-head self-attention layer or the output of the feedforward neural network layer, and X″ represents the input of the multi-head self-attention layer or the feedforward neural network layer. The output vector e of the residual connection layer is obtained by adding the above two. add ;
[0027] The role of layer normalization is to normalize the output of the residual connection layer add After normalization, we get the vector e stand , so that the input of each neuron has the same mean and variance in layer normalization. Layer normalization helps to accelerate the convergence speed of the neural network and improve the stability of the neural network;
[0028] e. Feedforward neural network layer: The input is transformed nonlinearly to enhance the expression ability of the neural network. The feedforward neural network layer consists of two linear transformations and a nonlinear activation function. stand Both of them will go through these two linear transformations, and there is an activation function in the middle for nonlinear transformation. The formula is as follows:
[0029] FFN(e stand )=max(0,e stand W1+b1)W2+b2
[0030] Where W1 and W2 are two weight matrices, b1 and b2 are two bias vectors, max represents the ReLU activation function; vector e stand The intermediate representation is generated by the first linear transformation W1 and the bias b1, and the intermediate representation is linearly transformed by the ReLU activation function. The intermediate representation after the activation function is then transformed by the second linear transformation W2 and the bias b2 to generate the final output e ffn ;
[0031] f. Fully connected network layer: In order to obtain the credibility of the interactive information Origin, it is necessary to pass through another fully connected network layer to transform the vector e ffn Convert to a vector of length 1 and compress the dimension to obtain the credibility of the mutual information p out .
[0032] Furthermore, during the neural network training process, an interactive message Origin is transformed into a single value p after passing through the improved Transformer neural network. out , in order to evaluate the neural network after forward propagation p out The difference between the labels and the mean square error MSE is used as the loss function. The mean square error MSE is defined as P out The average of the squares of the differences from the labels is given by:
[0033]
[0034] Where n is the number of interactive information, y i is the label of the ith interactive information, is the credibility of the interactive information obtained by the forward propagation of the i-th message input into the neural network out , MSE is used to measure the prediction accuracy of the neural network. The smaller the MSE, the closer the network's prediction result is to the actual value. When training the network, the parameters of the neural network are optimized by minimizing the MSE so that the neural network's prediction result is as close to the actual value as possible.
[0035] Furthermore, in step 3), the trained neural network is deployed to the vehicle's server. The entire trust management steps are as follows:
[0036] 3.1) Initial evaluation and recording of trust value: Each vehicle is assigned an initial trust value. Whenever a message-sending vehicle sends interactive information in the network, the vehicle that receives the interactive information inputs the interactive information into the improved Transformer neural network for evaluation, obtains the credibility of the interactive information, compares it with the pre-set threshold, and obtains the change in the trust value of the message-sending vehicle. The change in the trust value is then fed back to the roadside unit RSU, which is responsible for recording the summary of the trust value changes of each vehicle in its jurisdiction.
[0037] 3.2) Dynamic adjustment of trust value: RSU dynamically adjusts the trust value of the message-sending vehicle based on the received trust value change and applies a reward and punishment mechanism. When the trust value change of the message-sending vehicle is positive, RSU increases the trust value of the message-sending vehicle. Conversely, if the trust value change is negative, RSU decreases the trust value of the message-sending vehicle.
[0038] 3.3) Dishonest node marking and broadcasting: If the trust value of a message-sending vehicle node is lower than the set threshold, the RSU marks the vehicle as a dishonest node, and then broadcasts the identification information of the dishonest node to all vehicles in the jurisdiction;
[0039] 3.4) Dishonest node message processing: The message receiver rejects the message from the dishonest node to prevent it from affecting the network. The receiver still needs to evaluate the message from the dishonest node and feedback the evaluation result to the RSU;
[0040] 3.5) Trust value recovery mechanism: If a dishonest node resends the correct interaction information, the trust value of the dishonest node will be continuously increased through the evaluation of these interaction information by the receiving vehicle. When the trust value of the dishonest node is higher than the set threshold again, the RSU cancels the mark of the node and restores its normal communication function.
[0041] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0042] 1. The present invention adopts an improved Transformer neural network instead of the traditional convolutional network to better identify the features in the interactive information and distinguish the authenticity of the interactive information. Compared with the traditional convolutional network, it effectively improves the accuracy of identifying malicious messages.
[0043] 2. Compared with traditional statistical models, the present invention can effectively cope with the situation where the proportion of malicious nodes in the Internet of Vehicles is greater than 50%, expands the application scenarios of the trust management mechanism, and improves accuracy.
[0044] 3. The present invention has broad application prospects and can be well applied to vehicles in the Internet of Vehicles environment to perform credibility judgment and calculation on nodes interacting with them, and further realize the detection of global malicious or dishonest nodes, and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 Schematic diagram of the method of the present invention.
[0046] Figure 2 A diagram of the structure of an improved Transformer neural network. DETAILED DESCRIPTION
[0047] The present invention is further described in detail below in conjunction with embodiments and drawings, but the embodiments of the present invention are not limited thereto.
[0048] like Figure 1As shown, this embodiment discloses a method for trust management of Internet of Vehicles based on an improved Transformer, which is a method for trust management of Internet of Vehicles on Internet of Vehicles datasets in combination with an improved Transformer neural network in deep learning, and includes the following steps:
[0049] 1) Use the traffic simulation simulator SUMO and the discrete event simulation platform OMNet++ to simulate urban traffic, collect the interaction information between vehicles and the changes in vehicle trust values during the simulation process, use them to construct a data set, and preprocess the data set to obtain data with the same scale, and then divide the data into training sets and validation sets. The specific situation is as follows:
[0050] First, collect the interaction information between vehicles and the changes in vehicle trust values during the simulation process. The main content of an interaction message Origin is: Origin = {id r ,id s ,t s ,id m ,lastTrust,ty m ,pos s ,spe s ,ori s ,acc s}, the interaction information indicates that the number is id s The message is sent to the vehicle at t s Time, pos s The message sent by the location to the surrounding vehicles within the communication range. This interactive information is the main content of the dataset, where id r Indicates the vehicle that received the interactive information, id m Indicates the message number, lastTrust indicates the historical trust value of the vehicle sending the message, and ty m Indicates the type of message, spe s 、ori s and acc s Respectively represent the number id s The message is sent to the vehicle at t s The moving speed, moving direction and moving acceleration at the moment;
[0051] For n Origins, a data set D can be generated n Before dividing the data set, data preprocessing is required to obtain data with the same scale in order to reduce the deviation introduced by data measurement. The preprocessing operation is to apply z-score normalization to each field of the data set. The calculation formula is: Where X' represents the data after normalization of the z-score original data set, X represents each original data in the data set, μ represents the average value of all original data in each field in the data set, and σ represents the standard deviation of all original data in each field in the data set;
[0052] After preprocessing, the original data set was randomly divided into a training set and a validation set in a ratio of 8:2;
[0053] In the preprocessed data set, each interactive message Origin corresponds to a label, which means: after the message sending vehicle sends the i-th interactive message Origin, the change in the trust value of the message sending vehicle is y i If y i If it is a positive number, the corresponding label is 1, otherwise, the corresponding label is 0.
[0054] 2) Input the training set into the improved Transformer neural network for training, use the data set Adam optimizer in the training set to continuously adjust and update the neural network parameters, and then use the validation set for validation to obtain the neural network with the best performance; Among them, the improvements of the Transformer neural network include: First, replace the original embedding layer with a fully connected neural network to map the discrete input message features to a continuous vector space, while expanding the input feature dimension to better capture the hidden relationship between features in the future; Second, remove the decoder in the original Transformer neural network, because the goal of the improved Transformer neural network is to evaluate the credibility of the interactive information between vehicles without the need for the decoder to generate sequence outputs; Third, introduce a feedforward neural network layer and a fully connected network layer after the encoder of the original Transformer neural network. The role of the feedforward neural network layer is to integrate the features learned by the encoder, and perform nonlinear transformations through layer-by-layer transmission, as well as map high-dimensional data to low-dimensional representations. Subsequently, the fully connected network layer is used to convert low-dimensional data into a single value, which represents the credibility of a piece of interactive information. The specific situation is as follows:
[0055] The entire neural network is divided into 6 parts, such as Figure 2 As shown, the functions and calculation processes of each part of the network are as follows:
[0056] a. Embedding layer: In order to convert the discrete data in the input interactive information Origin into a vector representation with semantic meaning, a fully connected neural network is used to replace the original embedding layer so as to map the data in the interactive information to a 512-dimensional vector e emb ;
[0057] b. Position encoding layer: transform the vector e emb Input to the position encoding layer to get the vector epos , in order to retain the position information of the input data, capture the relationship between the previous and next data in the interactive information, and then transform the vector e emb and e pos Add them together to get the vector e with both position information and semantics data ;
[0058] c. Multi-head self-attention layer: vector e data Input to a network with 8 self-attention heads to capture the features in the interaction information. This layer is mainly responsible for calculating the attention weight of each feature and generating the attention vector e attention , which is designed to tell the neural network which features in the interactive information to pay attention to. These attention weights represent the influence of each feature on all other features in the interactive information. The implementation of the self-attention mechanism relies on three components: Query, Key, and Value. These three components are obtained from the input vector e through three independent linear transformations. data The calculation formulas for Query, Key, and Value are as follows:
[0059] Query = e data *W Q
[0060] Key=e data *W K
[0061] Value = e data *W V
[0062] Where W Q , W K and W V Represent three linear weights, which are independent of each other and obtained through training. After that, scaled dot product attention is performed on each head according to the following formula:
[0063]
[0064] in, is the dimension of the vector Key, which is used to scale the dot product to avoid the result being too large, then concatenate the outputs of all heads together, and then generate the final output vector e through a linear transformation attention :
[0065] MultiHead(Query,Key,Value)=Concat(h1,h2,...,h n )W O
[0066] In the formula, h1, h2 and h nThey represent the output of the first head, the output of the second head, and the output of the nth head respectively. Concat is a concatenation algorithm that concatenates the outputs of all heads together to form a long vector, which is then transformed by a linear transformation W. O Convert the concatenated vector into the final output e attention ;
[0067] d. Layer normalization and residual connection layer: used to stabilize the training process and promote the effective propagation of gradients. The layer normalization and residual connection layer consists of layer normalization and residual connection layer; the residual connection layer is calculated as follows:
[0068] Add(X″,SubLayerOutput)=X″+SubLayerOutput
[0069] Where SubLayerOutput represents the output of the multi-head self-attention layer or the output of the feedforward neural network layer, and X″ represents the input of the multi-head self-attention layer or the feedforward neural network layer. The output vector e of the residual connection layer is obtained by adding the above two. add ;
[0070] The role of layer normalization is to normalize the output of the residual connection layer add After normalization, we get vector e stand , so that the input of each neuron has the same mean and variance in layer normalization. Layer normalization helps to accelerate the convergence speed of the neural network and improve the stability of the neural network;
[0071] e. Feedforward neural network layer: The input is transformed nonlinearly to enhance the expression ability of the neural network. The feedforward neural network layer consists of two linear transformations and a nonlinear activation function. stand Both of them will go through these two linear transformations, and there is an activation function in the middle for nonlinear transformation. The formula is as follows:
[0072] FFN(e stand )=max(0,e stand W1+b1)W2+b2
[0073] Where W1 and W2 are two weight matrices, b1 and b2 are two bias vectors, max represents the ReLU activation function; vector e stand The intermediate representation is generated by the first linear transformation W1 and the bias b1, and the intermediate representation is linearly transformed by the ReLU activation function. The intermediate representation after the activation function is then transformed by the second linear transformation W2 and the bias b2 to generate the final output e ffn ;
[0074] f. Fully connected network layer: In order to obtain the credibility of the interactive information Origin, it is necessary to pass through another fully connected network layer to transform the vector e ffn Convert to a vector of length 1 and compress the dimension to obtain the credibility of the mutual information p out .
[0075] During the neural network training process, an interactive message Origin is transformed into a single value p after passing through the improved Transformer neural network. out , in order to evaluate the neural network after forward propagation p out The difference between the labels and the mean square error MSE is used as the loss function. The mean square error MSE is defined as P out The average of the squares of the differences from the labels is given by:
[0076]
[0077] Where n is the number of interactive messages, y i is the label of the ith interactive information, is the credibility of the interactive information obtained by the forward propagation of the i-th message input into the neural network out , MSE is used to measure the prediction accuracy of the neural network. The smaller the MSE, the closer the network's prediction result is to the actual value. When training the network, the parameters of the neural network are optimized by minimizing the MSE so that the neural network's prediction result is as close to the actual value as possible.
[0078] 3) Deploy the trained neural network to the vehicle’s server. The entire trust management process is as follows:
[0079] 3.1) Initial evaluation and recording of trust value: Each vehicle is assigned an initial trust value. Whenever a message-sending vehicle sends interactive information in the network, the vehicle that receives the interactive information inputs the interactive information into the improved Transformer neural network for evaluation, obtains the credibility of the interactive information, compares it with the pre-set threshold, and obtains the change in the trust value of the message-sending vehicle. The change in the trust value is then fed back to the roadside unit RSU, which is responsible for recording the summary of the trust value changes of each vehicle in its jurisdiction.
[0080] 3.2) Dynamic adjustment of trust value: RSU dynamically adjusts the trust value of the message-sending vehicle based on the received trust value change and applies a reward and punishment mechanism. When the trust value change of the message-sending vehicle is positive, RSU increases the trust value of the message-sending vehicle. Conversely, if the trust value change is negative, RSU decreases the trust value of the message-sending vehicle.
[0081] 3.3) Dishonest node marking and broadcasting: If the trust value of a message-sending vehicle node is lower than the set threshold, the RSU marks the vehicle as a dishonest node, and then broadcasts the identification information of the dishonest node to all vehicles in the jurisdiction;
[0082] 3.4) Dishonest node message processing: The message receiver rejects the message from the dishonest node to prevent it from affecting the network. The receiver still needs to evaluate the message from the dishonest node and feedback the evaluation result to the RSU;
[0083] 3.5) Trust value recovery mechanism: If the dishonest node resends the correct interactive information, the trust value of the dishonest node will be continuously increased through the evaluation of the interactive information by the receiving vehicle. When the trust value of the dishonest node is higher than the set threshold again, the RSU will cancel the mark of the node and restore its normal communication function. The threshold can generally be set to 0.5.
[0084] In summary, the present invention mainly realizes the following functions: using the traffic simulation simulator SUMO and the discrete event simulation platform OMNet++ to simulate urban traffic, collect the interaction information between vehicles and the changes in the trust value of vehicles during the simulation process, and construct a data set; using the training set to train the improved Transformer neural network, and deploy the trained neural network to the vehicle server; using the improved Transformer neural network to conduct credibility assessment on the received interactive information, and map it to the changes in the trust value of the vehicle, so as to realize dynamic trust management in the Internet of Vehicles environment. Based on deep learning technology, the present invention can be effectively applied to the judgment and calculation of the credibility of vehicles to interactive nodes in the Internet of Vehicles environment, thereby realizing the detection of malicious or dishonest nodes on a global scale, and has broad application prospects and is worthy of promotion.
[0085] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. The vehicle network trust management method based on improved Transformer is characterized by: The following steps are involved: 1) Use the traffic simulation simulator SUMO and the discrete event simulation platform OMNet++ to simulate urban traffic, collect the interaction information between vehicles and the changes in vehicle trust values during the simulation process, and use them to construct a data set. The data set is preprocessed to obtain data with the same scale, and then the data is divided into a training set and a validation set; 2) Input the training set into the improved Transformer neural network for training, use the data set Adam optimizer in the training set to continuously adjust and update the neural network parameters, and then use the validation set for validation to obtain the neural network with the best performance; wherein, the improvements of the Transformer neural network include: first, replace the original embedding layer with a fully connected neural network to map the discrete input message features into a continuous vector space, while expanding the input feature dimension so as to better capture the hidden relationship between features in the future; second, remove the decoder in the original Transformer neural network, because the goal of the improved Transformer neural network is to evaluate the credibility of the interactive information between vehicles without the need for the decoder to generate sequence outputs; third, introduce a feedforward neural network layer and a fully connected network layer after the encoder of the original Transformer neural network. The role of the feedforward neural network layer is to integrate the features learned by the encoder, perform nonlinear transformations through layer-by-layer transmission, and map high-dimensional data to low-dimensional representations. Subsequently, the fully connected network layer is used to convert the low-dimensional data into a single numerical value, which represents the credibility of a piece of interactive information; 3) After the neural network with the best performance is deployed on the vehicle server, each vehicle is assigned an initial trust value. When a vehicle sends interactive information to other vehicles, the receiving vehicle will process the received interactive information and convert it into features that can be input into the improved Transformer neural network. The credibility of the interactive information is predicted by the neural network with the best performance. The predicted credibility is compared with the preset threshold to determine the change in the trust value. This change is used to adjust the trust value of the message sending vehicle on the RSU, thereby updating its trust value to achieve the goal of trust management. If the trust value of the vehicle is lower than the preset threshold, the vehicle will be regarded as malicious or dishonest.
2. The vehicle network trust management method based on improved Transformer according to claim 1 is characterized in that: In step 1), the content carried by an interactive message Origin is: Origin = {id r ,id s ,t s ,id m ,lastTrust,ty m ,pos s ,spe s ,ori s ,acc s }, the interaction information indicates that the number is id s The message is sent to the vehicle at t s Time, pos s The message sent by the location to the surrounding vehicles within the communication range. This interactive information is the main content of the dataset, where id r Indicates the vehicle that received the interactive information, id m Indicates the message number, lastTrust indicates the historical trust value of the vehicle sending the message, and ty m Indicates the type of message, spe s 、ori s and acc s Respectively represent the number id s The message is sent to the vehicle at t s The moving speed, moving direction and moving acceleration at the moment; For n Origins, a data set D can be generated n Before dividing the data set, data preprocessing is required to obtain data with the same scale in order to reduce the deviation introduced by data measurement. The preprocessing operation is to apply z-score normalization to each field of the data set. The calculation formula is: Where X' represents the data after normalization of the z-score original data set, X represents each original data in the data set, μ represents the average value of all original data in each field in the data set, and σ represents the standard deviation of all original data in each field in the data set; After preprocessing the original data set, it is randomly divided into a training set and a validation set according to a preset ratio; In the preprocessed data set, each interactive message Origin corresponds to a label, which means: after the message sending vehicle sends the i-th interactive message Origin, the change in the trust value of the message sending vehicle is y i , if y i If it is a positive number, the corresponding label is 1, otherwise, the corresponding label is 0.
3. The vehicle network trust management method based on improved Transformer according to claim 1 is characterized in that: In step 2), the entire neural network is divided into 6 parts, each of which is as follows: a. Embedding layer: In order to convert the discrete data in the input interactive information Origin into a vector representation with semantic meaning, a fully connected neural network is used to replace the original embedding layer so as to map the data in the interactive information to a 512-dimensional vector e emb ; b. Position encoding layer: transform the vector e emb Input to the position encoding layer to get the vector e pos , in order to retain the position information of the input data, capture the relationship between the previous and next data in the interactive information, and then transform the vector e emb and e pos Add them together to get the vector e with both position information and semantics data ; c. Multi-head self-attention layer: vector e data Input to a network with 8 self-attention heads to capture features in the interaction information. This layer is responsible for calculating the attention weight of each feature and generating the attention vector e attention , which is designed to tell the neural network which features in the interactive information to pay attention to. These attention weights represent the influence of each feature on all other features in the interactive information. The implementation of the self-attention mechanism relies on three components: Query, Key, and Value. These three components are obtained from the input vector e through three independent linear transformations. data The calculation formulas for Query, Key, and Value are as follows: Query=e data *W Q Key=e data *W K Value=e data *W V Where W Q , W K and W V Represent three linear weights, which are independent of each other and obtained through training. After that, scaled dot product attention is performed on each head according to the following formula: in, is the dimension of the vector Key, which is used to scale the dot product to avoid the result being too large, then concatenate the outputs of all heads together, and then generate the final output vector e through a linear transformation attention : MultiHead(Query,Key,Value)=Concat(h1,h2,...,h n )W O In the formula, h1, h2 and h n They represent the output of the first head, the output of the second head, and the output of the nth head respectively. Concat is a concatenation algorithm that concatenates the outputs of all heads together to form a long vector, which is then transformed by a linear transformation W. O Convert the concatenated vector into the final output e attention ; d. Layer normalization and residual connection layer: used to stabilize the training process and promote the effective propagation of gradients. The layer normalization and residual connection layer consists of layer normalization and residual connection layer; the residual connection layer is calculated as follows: Add(X″,SubLayerOutput)=X″+SubLayerOutput Where SubLayerOutput represents the output of the multi-head self-attention layer or the output of the feedforward neural network layer, and X″ represents the input of the multi-head self-attention layer or the feedforward neural network layer. The output vector e of the residual connection layer is obtained by adding the above two. add ; The role of layer normalization is to normalize the output of the residual connection layer add After normalization, we get vector e stand , so that the input of each neuron has the same mean and variance in layer normalization. Layer normalization helps to accelerate the convergence speed of the neural network and improve the stability of the neural network; e. Feedforward neural network layer: The input is transformed nonlinearly to enhance the expression ability of the neural network. The feedforward neural network layer consists of two linear transformations and a nonlinear activation function. stand Both of them will go through these two linear transformations, and there is an activation function in the middle for nonlinear transformation. The formula is as follows: FFN(e stand )=max(0,e stand W1+b1)W2+b2 Where W1 and W2 are two weight matrices, b1 and b2 are two bias vectors, max represents the ReLU activation function; vector e stand The intermediate representation is generated by the first linear transformation W1 and the bias b1, and the intermediate representation is linearly transformed by the ReLU activation function. The intermediate representation after the activation function is then transformed by the second linear transformation W2 and the bias b2 to generate the final output e ffn ; f. Fully connected network layer: In order to obtain the credibility of the interactive information Origin, it is necessary to pass through another fully connected network layer to transform the vector e ffn Convert to a vector of length 1 and compress the dimension to obtain the credibility of the mutual information p out .
4. The vehicle network trust management method based on improved Transformer according to claim 3 is characterized in that: During the neural network training process, an interactive message Origin is transformed into a single value p after passing through the improved Transformer neural network. out , in order to evaluate the neural network after forward propagation p out The difference between the labels and the mean square error MSE is used as the loss function. The mean square error MSE is defined as P out The average of the squares of the differences from the labels is given by: Where n is the number of interactive messages, y i is the label of the ith interactive information, is the credibility of the interactive information obtained by the forward propagation of the i-th message input into the neural network out , MSE is used to measure the prediction accuracy of the neural network. The smaller the MSE, the closer the network's prediction result is to the actual value. When training the network, the parameters of the neural network are optimized by minimizing the MSE so that the neural network's prediction result is as close to the actual value as possible.
5. The vehicle network trust management method based on improved Transformer according to claim 1 is characterized in that: In step 3), the trained neural network is deployed to the vehicle's server. The entire trust management steps are as follows: 3.1) Initial evaluation and recording of trust value: Each vehicle is assigned an initial trust value. Whenever a message-sending vehicle sends interactive information in the network, the vehicle that receives the interactive information inputs the interactive information into the improved Transformer neural network for evaluation, obtains the credibility of the interactive information, compares it with the pre-set threshold, and obtains the change in the trust value of the message-sending vehicle. The change in the trust value is then fed back to the roadside unit RSU, which is responsible for recording the summary of the trust value changes of each vehicle in its jurisdiction. 3.2) Dynamic adjustment of trust value: RSU dynamically adjusts the trust value of the message-sending vehicle based on the received trust value change and applies a reward and punishment mechanism. When the trust value change of the message-sending vehicle is positive, RSU increases the trust value of the message-sending vehicle. Conversely, if the trust value change is negative, RSU decreases the trust value of the message-sending vehicle. 3.3) Dishonest node marking and broadcasting: If the trust value of a message-sending vehicle node is lower than the set threshold, the RSU marks the vehicle as a dishonest node, and then broadcasts the identification information of the dishonest node to all vehicles in the jurisdiction; 3.4) Dishonest node message processing: The message receiver rejects the message from the dishonest node to prevent it from affecting the network. The receiver still needs to evaluate the message from the dishonest node and feedback the evaluation result to the RSU; 3.5) Trust value recovery mechanism: If a dishonest node resends the correct interaction information, the trust value of the dishonest node will be continuously increased through the evaluation of these interaction information by the receiving vehicle. When the trust value of the dishonest node is higher than the set threshold again, the RSU cancels the mark of the node and restores its normal communication function.
