Patent Publication Number: US-2023137489-A1

Title: Method for detecting can bus intrusion of vehicle-mounted network based on gmm-hmm and system

Description:
CROSS REFERENCE TO RELATED APPLICATION(S) 
     This patent application claims the benefit and priority of Chinese Patent Application No. 202111287157.3, filed on Nov. 2, 2021, the disclosure of which is incorporated by reference herein in its entirety. 
     BACKGROUND 
     The present disclosure pertains to the field of vehicle intrusion detection technologies, and relates to a method for detecting controller area network (CAN) bus intrusion of a vehicle-mounted network based on a Gaussian mixture model-hidden Markov model (GMM-HMM) and a system. 
     In recent years, the Internet of vehicles has entered a period of rapid development. A vehicle-mounted device on a vehicle is connected to a network by using a wireless communication technology to obtain richer services and more powerful functions, which, however, may bring risks of network attacks. An attacker may attack a vehicle electronic system by various means, for example, by launching denial-of-service (DoS), blur, replay, tamper, and other attacks on a vehicle-mounted controller area network (CAN) bus, which may seriously affect vehicle driving safety and threaten personal safety and property safety of a driver and other traffic participant. Therefore, it is necessary to monitor a communication status and content of the CAN bus in real time, and report any anomaly in time, so as to ensure communication security of the CAN bus. 
     Existing methods for monitoring CAN bus intrusion are mostly based on deep learning and neural network machine learning. These methods have the disadvantages of poor interpretability, large amounts of calculation, and low practicality. In an anomaly detection method for a cycle feature of a CAN bus packet, usually only a cycle is considered, but changes in the relationship between different cycles are ignored. Consequently, detection accuracy of a multi-cycle packet decreases. 
     SUMMARY 
     Embodiments in accordance with the present invention aim to provide a method for detecting controller area network (CAN) bus intrusion of a vehicle-mounted network based on a Gaussian mixture model-hidden Markov model (GMM-HMM). The method utilizes an unsupervised statistical-based probability algorithm, so that different cycles in a packet sequence can be extracted, and a transition relationship between the different cycles is provided, that is, a probability of changing from a previous cycle to a next cycle. By calculating a likelihood probability of a tested packet sequence about the foregoing cycle feature, it may be determined whether the tested packet sequence is abnormal, so that attack behaviors of inserting packets into a bus such as DoS, blur, and replay can be found. 
     A principle of the method for detecting CAN bus intrusion of a vehicle-mounted network based on a GMM-HMM proposed in the present disclosure is as follows: Because a CAN bus packet has multiple sending manners such as a cycle type and an event type, the CAN bus packet has different transmission cycles. Due to a CAN bus arbitration mechanism and noise impact, an inter-frame interval of the packet fluctuates around a specific cycle, and it is found based on statistics that this fluctuation presents a form of Gaussian distribution. Therefore, a Gaussian mixture model (GMM) is used to fit this distribution, to restore a defined transmission cycle of the packet. In this case, the GMM represents a transmission cycle of the packet, and each GMM is used as one status. An HMI algorithm is used to count a transition relationship between statuses, and a transition relationship between cycles of the packet may be obtained. Therefore, the GMM-HMM can be used to model a cycle characteristic of the packet. A likelihood probability of generating a cycle sequence can be calculated based on the model. If there is a cycle that seriously deviates from an existing cycle or a transition relationship that should not occur in the sequence, a likelihood probability of the cycle sequence obviously decreases, so that an abnormal situation of the cycle sequence can be determined. 
     The method for detecting CAN bus intrusion of a vehicle-mounted network based on a GMM-HMM proposed in the present disclosure includes the following steps: 
     Step 1: Obtain a normal packet of a CAN bus of a vehicle-mounted network. 
     Information about the packet includes a timestamp, a CAN ID, a data length code (DLC), and data. 
     Step 2: Calculate, for each CAN ID, cycles of all packets of the CAN ID based on a time sequence, to form a cycle sequence as an input of a GMM-HMM algorithm. 
     Each of the calculated cycles is a time interval between any two consecutive packets of a same CAN ID; and said calculating a packet cycle includes: obtaining a difference by subtracting a timestamp of a packet of a previous frame from a timestamp of a packet of a last frame in two consecutive packets. 
     Step 3: Construct and train a GMM-HMM M id  for the cycle sequence of each CAN ID, and calculate a minimum likelihood probability score id  of a normal sequence of the CAN ID in the model. 
     Step 3 specifically includes the following substeps: 
     Step 3.1: Establish a GMM-HMM algorithm model, and a model structure is shown in  FIG.  2   . The algorithm model includes one or more GMM models. A GMM model structure is shown in  FIG.  3   , and an x-axis is a statistical object, and a y-axis is a statistical quantity. One GMM model is a combination of some Gaussian distributions. Each GMM model indicates one HMM model status. A probability transition relationship exists between every two of GMM models, namely, HMM statuses. The GMM-HMM corresponds to a cycle model of the CAN ID, and one GMM model corresponds to one type of cycle of the CAN ID. The GMM models are the HMM statuses. The transition relationship between every two of the HMM statuses corresponds to a transition relationship between packet cycles of the CAN ID. A cycle sequence as an input of the GMM-HMM is called an observation sequence. The observation sequence is randomly generated by using a hidden state sequence. A hidden state herein refers to a transmission cycle defined by each packet itself of the CAN ID. However, when being sent, the packet is affected by another packet of the bus and an environment. Consequently, an actually transmission cycle, that is, an observed cycle, may be different from the defined cycle. In the GMM-HMM, possible predefined cycles are obtained by fitting observation cycle distribution based on the GMM, and then a transition relationship between the possible predefined cycles is counted based on the HMM, so as to model cycles of the CAN ID. 
     Step 3.2: Set training parameters of the GMM-HMM algorithm, including a quantity c=10 of algorithm iterations, an iterative convergence threshold tol=0.01, a quantity n=4 of the GMM models, that is, HMM model statuses, a quantity K=2 of Gaussian components of each GMM model, an initial probability π of each of the HMM model statuses, a status transition matrix A, and an average μ, a variance Σ, and a weight w of each Gaussian component in each GMM model; and perform random initialization on the initial probability π of each of the HMI model statuses, the status transition matrix A, and the average μ, the variance Σ, and the weight w of each Gaussian component in each GMM model. The GMM model is p(x)=Σ k=1   K w k N(x|μ k , Σ k ), and an HMM model is λ=(π, A, B). A transmission probability B is a probability that an observation value is generated based on the hidden state, that is, a probability that observation cycles are generated based on the defined cycles, that is, a probability p(x) that the GMM model generates a sample point x. In a training process, an algorithm is required to have a good training effect, and a faster speed is better. An iteration ends if a set quantity of iterations or iterative convergence threshold is reached in an iterative process. In a common use scenario, default values, that is, the quantity of iterations c=10 and the iterative convergence threshold tol=0.01, are used. 
     Step 3.3: Divide the cycle sequence of each CAN ID into vectors Cycle id  constituted by cycle sequences with a length T=150, where T may be adjusted and set based on experience. If a setting value of T is too small, it is difficult to effectively extract a feature, or if a setting value of T is too large, impact of an abnormal cycle may be reduced, which can reduce detection ability. 
     Step 3.4: Divide each of the vectors Cycle id  into two parts of a training set Train id  and a verification set Verify id , where it is required that the training set and the verification set do not overlap, and a division ratio of the two is set to 9:1 based on experience. 
     Step 3.5: Train model parameters of the GMM-HMM according to a Baum-Welch algorithm by using Train id  as an input. 
     Assuming that an observation sample in Train id  is 0={o 1 , o 2 , . . . , o T }, {o 1 , o 2 , . . . , o t }t≤T. In addition, a probability α ti =P(o 1 , o 2 , . . . , o t , s t =i) that a t moment state s t  is i is calculated according to a forward algorithm as: 
       α ti   =πb   io     1    
 
       α ti =Σ j=1   n α (t−1)j α j   a   ji   b   io     t+1    
 
     Where α ji  refers to a probability that a j th  state in the status transition matrix A is transferred to an i th  state, and b io     t+1    refers to a probability that an observation value b o     t+1   , is generated based on an i th  state in a transmission probability B. A probability of generating an observation sequence 0 is: 
         P (0)=Σ i=1   n α Ti  
 
     A probability β ti =P(o t+i , o t+2 , . . . , o T , s t =i) that an observation sequence is i at a t moment state s t  and an observation sequence starting at a t+1 moment is {o t+1 , o t+2 , o T } is calculated according to a backward algorithm as: 
       β Ti =1
 
       β ti =Σ j=1   n β (t+1)j   a   ij   b   jo     t    
 
     A probability of generating the observation sequence 0 is: 
         P (0)=Σ i=1   n π i β 1i   b   io     1    
 
     A probability γ ti  that the observation sequence is i at a t moment state s t , and a probability that the observation sequence is i at the t moment state s t  and is j at a t+1 moment state s t+1  are calculated based on the following formulas: 
     
       
         
           
             
               γ 
               ti 
             
             = 
             
               
                 P 
                 ⁡ 
                 ( 
                 
                   
                     s 
                     t 
                   
                   = 
                   
                     i 
                     | 
                     O 
                   
                 
                 ) 
               
               = 
               
                 
                   
                     α 
                     ti 
                   
                   ⁢ 
                   
                     β 
                     ti 
                   
                 
                 
                   
                     ∑ 
                     
                       j 
                       = 
                       1 
                     
                     n 
                   
                   
                     
                       α 
                       ti 
                     
                     ⁢ 
                     
                       β 
                       ti 
                     
                   
                 
               
             
           
         
       
       
         
           
             
               
                 
                   
                     
                       ξ 
                       tij 
                     
                     = 
                     
                       P 
                       ( 
                       
                         
                           
                             s 
                             t 
                           
                           = 
                           i 
                         
                         , 
                         
                           s 
                           
                             
                               t 
                               + 
                               1 
                             
                             = 
                             j 
                           
                         
                       
                     
                   
                   
                     ❘ 
                     &#34;\[RightBracketingBar]&#34; 
                   
                 
                 ⁢ 
                 O 
               
               ) 
             
             = 
             
               
                 
                   α 
                   ti 
                 
                 ⁢ 
                 
                   a 
                   ij 
                 
                 ⁢ 
                 
                   β 
                   
                     
                       ( 
                       
                         t 
                         + 
                         1 
                       
                       ) 
                     
                     ⁢ 
                     j 
                   
                 
                 ⁢ 
                 
                   b 
                   
                     jo 
                     
                       t 
                       + 
                       1 
                     
                   
                 
               
               
                 
                   ∑ 
                   
                     i 
                     = 
                     1 
                   
                   n 
                 
                 
                   
                     ∑ 
                     
                       j 
                       = 
                       1 
                     
                     n 
                   
                   
                     
                       α 
                       ti 
                     
                     ⁢ 
                     
                       a 
                       ij 
                     
                     ⁢ 
                     
                       β 
                       
                         
                           ( 
                           
                             t 
                             + 
                             1 
                           
                           ) 
                         
                         ⁢ 
                         j 
                       
                     
                     ⁢ 
                     
                       b 
                       
                         jo 
                         
                           t 
                           + 
                           1 
                         
                       
                     
                   
                 
               
             
           
         
       
     
     Formulas for iterative training the parameters of the GMM-HMI are: 
     
       
         
           
             
               b 
               
                 io 
                 t 
               
             
             = 
             
               
                 ∑ 
                 
                   k 
                   = 
                   1 
                 
                 K 
               
               
                 
                   w 
                   ik 
                 
                 ⁢ 
                 
                   N 
                   ⁡ 
                   ( 
                   
                     
                       o 
                       t 
                     
                     
                       ❘ 
                       &#34;\[RightBracketingBar]&#34; 
                     
                     
                       μ 
                       ik 
                     
                     , 
                     
                       Σ 
                       ik 
                     
                   
                   ) 
                 
               
             
           
         
       
       
         
           
             
               μ 
               ik 
             
             = 
             
               
                 
                   ∑ 
                   
                     t 
                     = 
                     1 
                   
                   T 
                 
                 
                   
                     γ 
                     tik 
                   
                   ⁢ 
                   
                     o 
                     t 
                   
                 
               
               
                 
                   ∑ 
                   
                     t 
                     = 
                     1 
                   
                   T 
                 
                 
                   γ 
                   tik 
                 
               
             
           
         
       
       
         
           
             
               ∑ 
               ik 
             
             
               = 
               
                 
                   
                     ∑ 
                     
                       t 
                       = 
                       1 
                     
                     T 
                   
                   
                     
                       
                         γ 
                         tik 
                       
                       ( 
                       
                         
                           o 
                           t 
                         
                         - 
                         
                           μ 
                           ik 
                         
                       
                       ) 
                     
                     ⁢ 
                     
                       
                         ( 
                         
                           
                             o 
                             t 
                           
                           - 
                           
                             μ 
                             ik 
                           
                         
                         ) 
                       
                       T 
                     
                   
                 
                 
                   
                     ∑ 
                     
                       t 
                       = 
                       1 
                     
                     T 
                   
                   
                     γ 
                     tik 
                   
                 
               
             
           
         
       
       
         
           
             
               
                 w 
                 ik 
               
               = 
               
                 
                   
                     ∑ 
                     
                       t 
                       = 
                       1 
                     
                     T 
                   
                   
                     γ 
                     tik 
                   
                 
                 T 
               
             
             , 
             
               
                 w 
                 ik 
               
               = 
               
                 
                   w 
                   ik 
                 
                 
                   
                     ∑ 
                     
                       k 
                       = 
                       1 
                     
                     K 
                   
                   
                     w 
                     ik 
                   
                 
               
             
           
         
       
     
     Where w {ik} , μ ik , and E ik  are parameters of a k th  Gaussian component in an i th  state, that is, an i th  GMM model, γ tik =γ ti r ik  is a probability that an observation value of the observation sequence at the t moment belongs to the k th  Gaussian component in the i th  state, and 
     
       
         
           
             
               r 
               ik 
             
             = 
             
               
                 
                   w 
                   k 
                 
                 ⁢ 
                 
                   N 
                   ⁡ 
                   ( 
                   
                     
                       x 
                       i 
                     
                     , 
                     
                       μ 
                       k 
                     
                     , 
                     
                       Σ 
                       k 
                     
                   
                   ) 
                 
               
               
                 
                   ∑ 
                   
                     k 
                     = 
                     1 
                   
                   K 
                 
                 
                   
                     w 
                     k 
                   
                   ⁢ 
                   
                     N 
                     ⁡ 
                     ( 
                     
                       
                         x 
                         i 
                       
                       , 
                       
                         μ 
                         k 
                       
                       , 
                       
                         Σ 
                         k 
                       
                     
                     ) 
                   
                 
               
             
           
         
       
     
     is a probability that a sample in the i th  state belongs to the k th  Gaussian component. 
     Step 3.6: Calculate a likelihood probability of each cycle sequence sample with a length T in a same CAN ID according to a forward-backward algorithm by using Verify id  as an input based on the trained GMM-HMM. 
     Step 3.7: Count a minimum value of likelihood probabilities obtained in the previous step as score id . 
     Step 4: Calculate, by using the trained GMM-HMM, a likelihood probability of a cycle sequence of each CAN ID in a tested packet sequence, and determine whether the tested packet sequence is abnormal by comparing the likelihood probability with a score id  threshold. 
     Step 4 specifically includes the following substeps: 
     Step 4.1: Calculate, for each tested CAN ID, cycles of all packets of the CAN ID based on a time sequence, to form a cycle sequence. 
     Step 4.2: Divide the cycle sequence of each CAN ID into vectors Test id  constituted by cycle sequences with an equal length T, where T is set to 150 based on experience. The length T may be set to be the same as or different from a length set during model training. A better detection effect can be achieved when the length is the same. 
     Step 4.3: Calculate a likelihood probability of each cycle sequence of each CAN ID according to a forward-backward algorithm based on a GMM-HMM corresponding to each CAN ID by using Test id  as an input. 
     Step 4.4: Compare the calculated likelihood probability with the score id  threshold, and if the calculated likelihood probability is below the threshold, determine that the cycle sequence is abnormal, where the range of threshold is set to 
     
       
         
           
             
               score 
               id 
             
             2 
           
         
       
     
     based on experience. 
     Beneficial effects of the present disclosure are as follows: Based on the method for detecting CAN bus intrusion provided in the present disclosure, different transmission cycles of a packet and a transition relationship between the different cycles can be extracted, so that a cycle anomaly caused by inserting a packet into the CAN bus can be detected. Compared with a machine learning method for solving a same type of problem, the method has strong interpretability, considers more comprehensive characteristics, has faster training speed, requires less power, and is capable of dealing with an unknown attack mode. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG.  1    is a flowchart of a method for detecting intrusion according to the present disclosure; 
         FIG.  2    is a structural diagram of a GMM-HMI in a method according to the present disclosure; and 
         FIG.  3    is a structural diagram of a GMM model in a method according to the present disclosure. 
     
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
     The present disclosure will be further described in detail with reference to the following specific embodiments and accompanying drawings. The process, conditions, and experimental methods for implementing the invention disclosure, excluding the content specially mentioned below, are known in the art. The present disclosure imposes no special limitation on the content. 
     The present disclosure provides a method for detecting CAN bus intrusion of a vehicle-mounted network based on a GMM-HMM. Specific implementation steps are as follows: 
     Step 1: Obtain a normal packet of a CAN bus. 
     Step 2: Calculate, for each CAN ID, cycles of all packets of the CAN ID based on a time sequence, to form a cycle sequence. 
     Step 3: Construct and train a GMM-HMM for the cycle sequence of each CAN ID, and calculate a minimum likelihood probability score id  of a normal sequence. 
     Step 3.1: Establish a GMM-HMI algorithm model, where the algorithm model includes one or more GMM models, each GMM model indicates one HMI model status, and a probability transition relationship exists between every two HMI model statuses. 
     Step 3.2: Set training parameters of the GMM-HMM algorithm, including a quantity c=10 of algorithm iterations, an iterative convergence threshold tol=0.01, a quantity n=4 of the GMM models, that is, HMM model statuses, a quantity K=2 of Gaussian components of each GMM model, an initial probability π of the HMM model status, a status transition matrix A, and an average μ, a variance Σ, and a weight w of each Gaussian component in each GMM model; and perform random initialization on the initial probability π of the HMM model status, the status transition matrix A, and the average μ, the variance Σ, and the weight w of each Gaussian component in each GMM model; and the initial probability π of the HMM model status, the status transition matrix A, and the average μ, the variance Σ, and the weight w of each Gaussian component in each GMM model are parameters for iteration during model training. 
     Step 3.3: Divide the cycle sequence of each CAN ID into vectors Cycle id  constituted by cycle sequences with a length T=150, where a subscript indicates a CAN ID. 
     Step 3.4: Divide the vector Cycle id  into two parts of a training set Train id  and a verification set Verify id . 
     Step 3.5: Train model parameters of the GMM-HMM according to a python hmm learn library by using Train id  as an input. 
     Step 3.6: Calculate a likelihood probability of each cycle sequence sample according to the python hmm learn library by using Verify id  as an input based on the trained GMM-HMM. 
     Step 3.7: Count a minimum value of likelihood probabilities obtained in the previous step as score id . 
     Step 4: Calculate, by using the trained GMM-HMM, a likelihood probability of a cycle sequence of each CAN ID in a tested packet sequence, and determine whether the tested packet sequence is abnormal by comparing the likelihood probability with a score id  threshold. 
     Step 4.1: Calculate, for each tested CAN ID, cycles of all packets of the CAN ID based on a time sequence, to form a cycle sequence. 
     Step 4.2: Divide the cycle sequence of each CAN ID into vectors Test ed  constituted by cycle sequences with a length T=150, where a subscript indicates a CAN ID. 
     Step 4.3: Calculate, according to the python hmm learn library by using Test ed  as an input, a likelihood probability that each model generates each cycle sequence. 
     Step 4.4: Compare the calculated likelihood probability with the score id  threshold, set the threshold to 
     
       
         
           
             
               
                 score 
                 id 
               
               2 
             
             , 
           
         
       
     
     and if the calculated likelihood probability is below the threshold 
     
       
         
           
             
               
                 score 
                 id 
               
               2 
             
             , 
           
         
       
     
     determine that the cycle sequence is abnormal. 
     Example 1 
     A CANoe is connected to an on-board diagnostics (OBD) interface of a vehicle, and a 30-minute CAN bus packet is acquired and saved locally. The acquired packet is preprocessed to extract information, such as a timestamp, a CAN ID, a DLC, and data, and is used as an input packet based on this method to train a GMM-HMM of each CAN ID. Then, the model is deployed on a CAN bus gateway, to monitor a packet existing on a CAN bus. A time stamp of each CAN ID is recorded to calculate a cycle. Last 150 cycles are saved as a tested cycle sequence. A likelihood probability is calculated based on the model to determine whether the cycle sequence is abnormal. If the cycle sequence is abnormal, a warning is generated and displayed on a meter. 
     Protection content of the present disclosure is not limited to the described embodiments. Changes and advantages that can be easily figured out by persons skilled in the art without departing the spirit and scope of the present disclosure are included in the present disclosure and subject to the protection scope of the claims.