Method, device and vehicle for detecting CAN message anomaly
By splitting the CAN bus communication system into multiple subsystems and calculating information entropy, the problems of low efficiency and insufficient accuracy in CAN message loss detection are solved, and efficient and accurate anomaly detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2026-03-20
AI Technical Summary
Existing technologies for detecting lost CAN messages are inefficient and inaccurate, especially when the CAN bus is interfered with, they are prone to false detections.
By obtaining the transmission period of each type of message received by the CAN bus communication system, the communication system is divided into multiple sub-communication systems. The detection window of each sub-communication system is determined, and the information entropy of the message set is calculated to determine whether there are abnormal messages in the sub-communication system.
It improves the accuracy and sensitivity of CAN message anomaly detection, achieving efficient and accurate anomaly detection.
Smart Images

Figure CN119484347B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the CAN bus communication technology field, and particularly relates to a CAN message abnormality detection method and device and a vehicle. BACKGROUND
[0002] The controller area network (CAN) bus is the most widely used bus in a vehicle and is a communication network at the bottom layer of the vehicle. Different controllers of the vehicle can communicate with each other through the CAN bus.
[0003] In actual applications, controllers communicate with each other by sending messages to the CAN bus. However, in the process of sending messages by the controllers through the CAN bus, there is a case of message loss.
[0004] Currently, the detection of message loss is generally achieved by detecting whether some important message IDs of the controller are timed out. The above method is not only low in detection efficiency, but also causes the message to be timed out when the CAN bus is interfered. According to the above method, the message loss is detected, and therefore the above detection method is not accurate. SUMMARY
[0005] The present application provides a CAN message abnormality detection method and device and a vehicle to solve the technical problem that the detection of message loss in the prior art is not only low in detection efficiency, but also inaccurate in detection efficiency.
[0006] In a first aspect, the present application provides a CAN message abnormality detection method. The controller area network (CAN) message is received by a communication system corresponding to a CAN bus. The method comprises the following steps.
[0007] Obtaining a sending period of each type of message received by the communication system, and splitting the communication system into a plurality of sub-communication systems based on the sending period;
[0008] For each sub-communication system, determining a detection window of the sub-communication system;
[0009] Obtaining a message set corresponding to the detection window, and determining an information entropy corresponding to the message set;
[0010] In a case where the information entropy is not within a preset range, determining that there is an abnormal message in the sub-communication system.
[0011] As a possible implementation manner, the splitting of the communication system into a plurality of sub-communication systems based on the sending period comprises the following steps.
[0012] The communication system is split into a plurality of sub-communication systems by the following manner:
[0013] assigning the different types of messages with the same sending period to the same sub-communication system;
[0014] and / or,
[0015] evenly assigning different types of messages of the same controller to different sub-communication systems.
[0016] As a possible implementation, the method further comprises:
[0017] determining a target period range according to the sending period of each type of message; wherein the interval of the target period range is less than a preset value;
[0018] determining a target message if the sending period of the message is not within the target period range;
[0019] determining a sending time period of the target message according to the sending period of the target message;
[0020] determining that the target message is abnormal if the target message is not received within the sending time period.
[0021] As a possible implementation, the determining the detection window of the sub-communication system comprises:
[0022] determining a correction parameter corresponding to the sub-communication system according to the vehicle type of the vehicle where the CAN bus is located;
[0023] determining the number of types of messages received by the sub-communication system;
[0024] determining the detection window of the sub-communication system according to the correction parameter, the number of types of messages, and the sending period of each type of message received by the sub-communication system.
[0025] As a possible implementation, the determining the detection window of the sub-communication system according to the correction parameter, the number of types of messages, and the sending period of each type of message received by the sub-communication system comprises:
[0026] determining an average period of messages received by the sub-communication system according to the sending period of each type of message received by the sub-communication system;
[0027] determining the period difference between the sending period of each type of message received by the sub-communication system and the average period;
[0028] determining a target period difference from the plurality of period differences;
[0029] The correction parameter, the category number, the average period, and the target period difference are pre-designed to obtain a detection window of the sub-communication system.
[0030] As a possible implementation, the pre-designing of the correction parameter, the category number, the average period, and the target period difference to obtain the detection window of the sub-communication system comprises:
[0031] A target period of a reference message and a standard duration of message abnormality are determined.
[0032] The target period, the standard duration, the correction parameter, the category number, the average period, and the target period difference are input into a preset formula to obtain an initial detection window of the sub-communication system; wherein the preset formula is as follows:
[0033]
[0034] Wherein, the C is the initial detection window, the A is the correction parameter, the N is the category number, the T1 is the standard duration, the T2 is the target period, the T Q is the average period, and the T P is the target period difference.
[0035] The initial detection window is rounded to obtain the detection window of the sub-communication system.
[0036] As a possible implementation, after the determination of the abnormal message in the sub-communication system, the method further comprises:
[0037] The message set is divided into two sub-message sets.
[0038] The relative entropy of each sub-message set and a preset message set is determined, wherein the preset message set is a set without abnormal messages.
[0039] Based on the relative entropy corresponding to each sub-message set, the abnormal message in the message set is determined.
[0040] As a possible implementation, the determination of the abnormal message in the message set based on the relative entropy corresponding to each sub-message set comprises:
[0041] It is determined whether the relative entropy corresponding to each sub-message set is within a preset range.
[0042] For the sub-packet set whose relative entropy is not in the preset range, the sub-packet set is continuously split into two new sub-packet sets, and a new relative entropy of each new sub-packet set with the preset packet set is determined;
[0043] For the new sub-packet set whose new relative entropy is not in the preset range, in a case that the new sub-packet set cannot be split, the packets included in the new sub-packet set are determined as abnormal packets;
[0044] For the new sub-packet set whose new relative entropy is not in the preset range, in a case that the new sub-packet set can be continuously split, the new sub-packet set is taken as a sub-packet set to perform the step of continuously splitting the sub-packet set into two new sub-packet sets, and a new relative entropy of each new sub-packet set with the preset packet set is determined, until the abnormal packets are determined.
[0045] In a second aspect, the present application provides a CAN packet anomaly detection device, CAN packets are received by a communication system corresponding to a CAN bus, and the device comprises:
[0046] An acquisition module is configured to acquire a sending period of each type of packet received by the communication system, and split the communication system into a plurality of sub-communication systems based on the sending period;
[0047] A first determination module is configured to determine a detection window of each sub-communication system;
[0048] A second determination module is configured to acquire a packet set corresponding to the detection window, and determine an information entropy corresponding to the packet set;
[0049] A third determination module is configured to determine that there is an abnormal packet in the sub-communication system in a case that the information entropy is not in a preset range.
[0050] In a third aspect, the present application provides a vehicle, comprising a processor and a memory, the processor is configured to execute a CAN packet anomaly detection program stored in the memory to implement the CAN packet anomaly detection method in any one of the first aspect.
[0051] In a fourth aspect, the present application provides a storage medium, the storage medium stores one or more programs, the one or more programs can be executed by one or more processors to implement the CAN packet anomaly detection method in any one of the first aspect.
[0052] The technical scheme provided in the embodiment of the application comprises the following steps: obtaining a sending period of each type of message received by a communication system, splitting the communication system into a plurality of sub-communication systems based on the sending period, determining a detection window of each sub-communication system, obtaining a message set corresponding to the detection window, determining information entropy corresponding to the message set, and determining that there is an abnormal message in the sub-communication system when the information entropy is not within a preset range. This technical scheme splits the communication system into a plurality of sub-communication systems according to the sending period of the message in the communication system corresponding to the CAN bus, and determines the information entropy of the message set to be detected of each sub-communication system after determining the detection window of each sub-communication system, so as to determine whether there is an abnormal message in the sub-communication system according to the information entropy. The information entropy is calculated to detect whether the CAN message is abnormal, which is more efficient and accurate than detecting whether the message is abnormal by timeout. Furthermore, the communication system is split into a plurality of sub-communication systems according to the sending period of each type of message, and a detection window is determined for each sub-communication system, so as to further improve the accuracy and sensitivity of the CAN message abnormality detection, and to efficiently and accurately detect whether the CAN message is abnormal. BRIEF DESCRIPTION OF DRAWINGS
[0053] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.
[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the drawings required to be used in the embodiments or the prior art text will be briefly introduced below. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0055] One or more embodiments are exemplarily illustrated by pictures in the drawings corresponding thereto, and these exemplary illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, unless otherwise specified. The drawings in the drawings do not constitute a proportional limitation.
[0056] Figure 1 An embodiment flowchart of a CAN message abnormality detection method provided in the embodiment of the application;
[0057] Figure 2 An embodiment flowchart of another CAN message abnormality detection method provided in the embodiment of the application;
[0058] Figure 3 An embodiment flowchart of still another CAN message abnormality detection method provided in the embodiment of the application;
[0059] Figure 4 An embodiment block diagram of a CAN message abnormality detection device provided by an embodiment of the present application is provided.
[0060] Figure 5 A structural schematic diagram of a vehicle provided by an embodiment of the present application is provided. DETAILED DESCRIPTION
[0061] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the following will clearly and completely text the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the embodiments in the text are part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0062] The following disclosure provides many different embodiments, or examples, for implementing different structures of the present application. For the purpose of simplifying the present application, the components and settings of specific examples are texted in the following. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeatedly refer to numbers and / or letters in different examples. Such repetition is for the purpose of simplification and clarity, and does not indicate the relationship between the various embodiments and / or settings discussed.
[0063] To solve the technical problem that the detection of message loss in the prior art is generally realized by detecting whether the message ID is timed out, the above method is not only low in detection efficiency, but also can cause the message to be timed out when the CAN bus is disturbed, and the message loss will be detected according to the above method, so the above detection method is also inaccurate. The present application provides a CAN message abnormality detection method, device and vehicle, which can split a communication system into multiple sub-communication systems according to the sending period of messages in the communication system corresponding to the CAN bus, determine the information entropy of a message set to be detected of each sub-communication system after determining the detection window of each sub-communication system, and determine whether there is an abnormal message in the sub-communication system according to the information entropy, wherein the information entropy is calculated to detect whether the CAN message is abnormal, which is more efficient and accurate than detecting whether the message is abnormal by timeout. Further, the communication system is split into multiple sub-communication systems according to the sending period of each type of message, and a detection window is determined for each sub-communication system, which can further improve the accuracy and sensitivity of CAN message abnormality detection, and realizes efficient and accurate detection of whether the CAN message is abnormal.
[0064] The CAN message abnormality detection method provided by the present application will be further explained and described with specific embodiments in combination with the drawings. The embodiments do not constitute a limitation on the embodiments of the present application.
[0065] Referring to Figure 1 An embodiment flowchart of a CAN message abnormality detection method provided by embodiments of the present application is shown. In an embodiment, the CAN message involved in embodiments of the present application is received by a communication system corresponding to a CAN bus in a vehicle. As shown in Figure 1 The flowchart can include the following steps:
[0066] Step 101: Obtain the sending period of each type of message received by the communication system, and split the communication system into multiple sub-communication systems based on the sending period.
[0067] The sending period refers to the corresponding sending period of each type of message (for ease of description, the "CAN message" is referred to as "message" below) sent to the communication system.
[0068] In actual application, different domain controllers of a vehicle communicate through a CAN bus, and the CAN bus can correspond to a communication system, which is used to receive and send CAN messages of different domain controllers. Further, the communication system can detect the CAN message in a timely or real-time manner after receiving the CAN message sent by the domain controller, to determine whether there is an abnormal message, where the abnormal message can be a lost message.
[0069] Further, the CAN bus of the vehicle generally includes periodic messages and event-triggered messages, and the CAN message abnormality detection method provided by the present application can detect the periodic messages. Therefore, each type of CAN message herein has a corresponding sending period.
[0070] In embodiments of the present application, the sending period of each type of message received by the communication system can be obtained, and the communication system can be split into multiple sub-communication systems based on the sending period.
[0071] As an optional implementation, messages of different types with the same sending period can be allocated to the same sub-communication system. In the present application, the message is detected based on information entropy, and information entropy has maximum uncertainty. When the probabilities of all messages are the same, information entropy has a maximum value. Thus, as long as there is an abnormal message (for example, a lost message), the degree of reduction of information entropy is large, which can improve the sensitivity of the message abnormality detection, and the threshold of information entropy when there is no abnormal message is also better determined.
[0072] As another optional implementation, messages of different types with sending periods within a preset range can be allocated to the same sub-communication system, where the difference between the sending periods of any two types of messages in the messages with sending periods within the preset range is less than a preset value.
[0073] As another optional implementation, different types of messages of the same controller can be evenly distributed to different sub-communication systems. In this way, when the message loss and the information entropy exceed the threshold, the overall impact of the system can be avoided, the accuracy of the message anomaly detection can be improved, and the false detection can be reduced.
[0074] As another optional implementation, different types of messages of the same controller can be evenly distributed to different sub-communication systems. In this way, when the message loss and the information entropy exceed the threshold, the overall impact of the system can be avoided, the accuracy of the message anomaly detection can be improved, and the false detection can be reduced.
[0075] In addition, for the messages with a large difference in the sending period from other types of messages, in order to prevent the overall impact on the message anomaly detection caused by the large difference in the sending period between the messages and other types of messages, the execution subject of the embodiment of the application can perform anomaly detection on the messages alone.
[0076] Further, for the messages with a large difference in the sending period from other types of messages, since the types of the detected messages are less, in order to save the computing resources, the existing timeout detection method can be used to perform anomaly detection on the messages.
[0077] Based on this, in the embodiment of the application, the target period range can be determined according to the sending period of each type of message, wherein the interval of the target period range is less than a preset value, that is, the sending periods of the messages in the target period range have a small difference.
[0078] For example, assuming that there are five types of messages, and the sending periods of the five types of messages are 1, 4, 5, 6, and 10 respectively, since the difference between 1 and 10 and 4 / 5 / 6 is large, the target period range can be determined as [4, 6].
[0079] Then, it can be determined whether there is a message not in the target period range, if there is, it indicates that the sending period of the message has a large difference from other types of messages, and thus the message not in the target period range can be determined as a target message.
[0080] Based on this, the sending time period of the target message can be determined according to the sending period of the target message, wherein the sending time period is the time period in which the message sending is determined to be timeout. For example, the time period of 1s exceeding the period of the message can be determined as the timeout of the message, and thus the sending period of the message plus the timeout time (i.e. 1s) can be obtained as the sending time period of the target message.
[0081] Then, when the target message is detected, if the target message is not received within the sending time period, it can be determined that the target message is abnormal, that is, the target message is lost.
[0082] Step 102, determining a detection window of each sub-communication system.
[0083] Step 103, obtaining a message set corresponding to the detection window, and determining information entropy corresponding to the message set.
[0084] The following describes steps 102 and 103:
[0085] The detection window can be used to perform CAN message anomaly detection, that is, a window for collecting a message set to be detected. The detection window can be represented by a number of messages or a time period.
[0086] The message set refers to a set of messages received by the CAN bus in the vehicle to be detected for anomalies.
[0087] In actual applications, the size of the detection window can affect the accuracy and sensitivity of the detection. When the detection window is large, the detection sensitivity can be reduced. When the detection window is small, the detection accuracy can be reduced, resulting in false detection results.
[0088] To this end, in the embodiments of the present application, a detection window corresponding to each sub-communication system can be determined to improve the sensitivity and accuracy of anomaly detection of messages in the sub-communication system. It can be understood that different sub-communication systems can correspond to different detection windows or the same detection window, and the embodiments of the present application do not limit this.
[0089] Further, the execution subject of the embodiments of the present application can determine the detection window corresponding to the sub-communication system based on the sending period of the messages received by the sub-communication system.
[0090] As to how to determine the detection window corresponding to the sub-communication system, the following flowchart can be used for illustration, which will not be described in detail here. Figure 2
[0091] In an embodiment, after determining the detection window corresponding to each sub-communication system, the execution subject of the embodiments of the present application can obtain a message set to be detected corresponding to the detection window.
[0092] As an optional implementation, when the detection window is represented by the number of messages, it is explained that CAN message anomaly detection is started when the CAN bus receives a number of messages corresponding to the detection window. Therefore, the number of messages corresponding to the detection window can be obtained to obtain the current message set to be detected.
[0093] As another optional implementation, when the detection window is expressed by a time period, it is expressed that the probability value of each type of message is determined every time the preset time period is reached, and the messages received in the preset time period are detected. Therefore, when the current time interval from the last time of message anomaly detection reaches the time period corresponding to the detection window, the messages received in the time period corresponding to the detection window are obtained, and the current message set to be detected is obtained.
[0094] After the message set is determined, the message set can be subjected to anomaly detection. In the embodiment of the application, whether there is an abnormal message in the message set can be determined according to the information entropy of the message set. Therefore, the subject of the embodiment of the application can first determine the information entropy of the message set.
[0095] As an optional implementation, when the information entropy corresponding to the message set is determined, the probability value of each type of message in the message set can be first determined.
[0096] As an exemplary implementation, when the probability value of each type of message in the message set is determined, the detection window of the sub-communication system corresponding to the message set and the sending period of each type of message in the message set can be calculated according to the preset formula in the following formula (I), and the probability value of each type of message is obtained:
[0097]
[0098] wherein, the P i is the probability value of the i-th type of message, the C is the detection window, the T i is the sending period of the i-th type of message, and the n is the number of types of messages in the message set.
[0099] Further, the following formula (II) can be obtained by the formula (I):
[0100]
[0101] wherein, the P i is the probability value of the i-th type of message, the T i is the sending period of the i-th type of message, and the N is the correction value determined according to the sending period of each type of message in the message set.
[0102] Thus, the probability value of each type of message in the message set can be obtained.
[0103] Based on the determined probability value of each type of message, the subject of the embodiment of the application can calculate the probability value of each type of message according to the preset formula in the following formula (III), and obtain the information entropy of the message set:
[0104]
[0105] wherein H(S) is the information entropy, n is the number of types of messages in the message set, and P i is the probability value of the i-th type of message.
[0106] Step 104: If the information entropy is not within the preset range, it is determined that there is an abnormal message in the sub-communication system.
[0107] The preset range refers to the range of the information entropy of the message set when there is no abnormal message (e.g. no lost message) received by the CAN bus.
[0108] As can be seen from the above description, when determining the information entropy of the message set, the calculation is performed according to formula (three), and the sending period of each type of message is a constant value as shown in formula (two), so the probability value of each type of message is generally also a constant value. Therefore, when there is no abnormal message in the message set received by the CAN bus, the information entropy of the message set is generally also within the preset range.
[0109] In the embodiments of the present application, after the information entropy of the message set is determined, it can be determined whether the information entropy is within the preset range.
[0110] Optionally, if it is determined that the information entropy is within the preset range, it can be determined that there is no abnormal message in the message set at this time.
[0111] On the contrary, if it is determined that the information entropy is not within the preset range, it can be determined that there is an abnormal message in the message set at this time.
[0112] In addition, when it is determined that there is an abnormal message in the message set, the subject of the execution of the embodiments of the present application can determine the abnormal message in the message set according to the relative entropy of the message set. As for how to determine the abnormal message from the message set, it will be described below through the flowchart shown in Figure 3 , which will not be described in detail here.
[0113] The technical scheme provided by the embodiments of the present application comprises the following steps: obtaining the sending period of each type of message received by a communication system, splitting the communication system into a plurality of sub-communication systems based on the sending period, determining the detection window of each sub-communication system, obtaining the message set corresponding to the detection window, determining the information entropy corresponding to the message set, and determining that there is an abnormal message in the sub-communication system when the information entropy is not within a preset range. This technical scheme splits the communication system into a plurality of sub-communication systems according to the sending period of the message in the communication system corresponding to the CAN bus, and determines the information entropy of the message set to be detected of each sub-communication system after determining the detection window of each sub-communication system, so as to determine whether there is an abnormal message in the sub-communication system according to the information entropy. The information entropy is calculated to detect whether the CAN message is abnormal, which is more efficient and accurate than detecting whether the message is abnormal by timeout. Furthermore, the communication system is split into a plurality of sub-communication systems according to the sending period of each type of message, and a detection window is determined for each sub-communication system, so as to further improve the accuracy and sensitivity of the CAN message abnormality detection, and to efficiently and accurately detect whether the CAN message is abnormal.
[0114] Referring to Figure 2 An embodiment flowchart of another CAN message abnormality detection method provided by the embodiments of the present application is shown. Figure 2 The flowchart is shown in Figure 1 Based on the flowchart shown in Figure 2 The flowchart can comprise the following steps:
[0115] Step 201: For each sub-communication system, determine the correction parameter corresponding to the sub-communication system according to the vehicle type of the vehicle where the CAN bus is located.
[0116] The vehicle type refers to the type of the vehicle, which can include the size type, brand type, engine type, etc. of the vehicle, and the embodiments of the present application do not limit the vehicle type.
[0117] In actual application, the sensitivity in the detection process is different for different types of vehicles when detecting message abnormality, and therefore, different correction parameters can be set for different vehicle types in the embodiments of the present application to correct the influence of the sensitivity of different vehicle types on the message abnormality detection process.
[0118] In an embodiment, the subject performing the embodiments of the present application can pre-store a corresponding relationship between different vehicle types and correction parameters, and based on this, when performing CAN message anomaly detection, the vehicle type corresponding to the current vehicle can be obtained, and the correction parameter corresponding to the vehicle type can be determined according to the vehicle type and the pre-stored corresponding relationship.
[0119] For the setting of the correction parameter, it can be set according to the current requirement, for example, if it is desired to improve the sensitivity of detection, the correction parameter can be set to any number less than 1; if it is desired to improve the accuracy and efficiency of detection, the correction parameter can be set to any number greater than 1.
[0120] Further, after determining the correction parameter corresponding to the sub-communication system, the subject performing the embodiments of the present application can further adjust the correction parameter according to the size of the sub-communication system.
[0121] As an optional implementation, when the sub-communication system contains a large number of message types, i.e., the sub-communication system is large, in order to improve the accuracy and efficiency of message anomaly detection, the subject performing the embodiments of the present application can increase the correction parameter by a preset value.
[0122] As another optional implementation, when the sub-communication system contains a small number of message types, i.e., the sub-communication system is small, in order to improve the sensitivity of message anomaly detection, the subject performing the embodiments of the present application can decrease the correction parameter by a preset value.
[0123] Step 202, determine the number of types of messages received by the sub-communication system.
[0124] Step 203, determine the detection window of the sub-communication system according to the correction parameter, the number of types, and the sending period of each type of message received by the sub-communication system.
[0125] The following uniformly describes step 202 and step 203:
[0126] The number of types refers to the total number of all types of messages received by the sub-communication system. Here, when distinguishing the types of messages, the message identifiers (such as message IDs) of the messages can be used for distinguishing. For example, assuming that the communication system X of the CAN bus has a finite set of possible states {X1, X2, …, Xm}, then X is the set of message identifiers ID, i.e., the message ID is X1 and the message ID is X2 belong to different message types.
[0127] In the embodiments of the present application, after determining the correction parameter corresponding to the sub-communication system and the number of types of received messages, the subject of the embodiments of the present application can determine the detection window of the sub-communication system according to the correction parameter, the number of types, and the sending period of each type of message received by the sub-communication system.
[0128] As an optional implementation, the average period of the messages received by the sub-communication system can be determined according to the sending period of each type of message received by the sub-communication system, and the period difference between the sending period of each type of message received by the sub-communication system and the average period is obtained to obtain a plurality of period difference values.
[0129] Then, the maximum target period difference value can be determined from the plurality of period difference values obtained, and the detection window of the sub-communication system can be obtained by further performing a pre-design calculation according to the correction parameter, the number of types, the average period, and the target period difference value.
[0130] As an optional implementation, the target period of the reference message and the standard duration of message abnormality can be determined. The reference message refers to a standard message preset for calculating the detection window, and the standard duration refers to the determination duration when the message sending is abnormal, for example, when the message loss exceeds 1s, the message loss can be determined.
[0131] Then, since the selection of the detection window is related to the period of the message in the sub-communication system, the inconsistency of the period of the message in the sub-communication system, and the number of types of messages in the sub-communication system: the shorter the period of the message, the same window, the limited detection time, so a larger window should be selected; the larger the period difference of the message, the larger window must be selected, otherwise the message with a large period will be misreported due to slight deviation; the more the number of messages, the larger the window should be, otherwise the message time period for detection is very limited. Therefore, the subject of the embodiments of the present application can input the target period, the standard duration, the correction parameter, the number of types, the average period, and the target period difference value into a preset formula to obtain the initial detection window of the sub-communication system. The preset formula can be as shown in the following formula (four):
[0132]
[0133] Wherein, the C is the initial detection window, the A is the correction parameter, the N is the number of types, the T1 is the standard duration, the T2 is the target period, the T Q is the average period, and the T P is the target period difference value.
[0134] For example, assuming a message period of 10ms is used as the base message calculation window, and further assuming that the current CAN bus communication standard generally requires that a message loss of 1s is defined as a communication loss, substituting the above period and 1s into the above formula (iv), we can obtain the following formula (v):
[0135]
[0136] Wherein, C is the initial detection window, A is the correction parameter, N is the number of types, and T is... Q For the above average period, the above T P This is the difference between the aforementioned target periods;
[0137] Furthermore, in formula (v) above, 10 divided by T Q This is because a shorter message cycle requires a larger window to ensure detection efficiency. P Divide by T Q This is because a larger message deviation requires a larger window; otherwise, the detection accuracy will decrease due to message changes with large message cycles.
[0138] Finally, for ease of calculation, the initial detection window can be rounded down to the nearest multiple of 10 to obtain the detection window of the sub-communication system.
[0139] The technical solution provided in this application determines the calibration parameters corresponding to each sub-communication system based on the vehicle type of the vehicle where the CAN bus is located, determines the number and types of messages received by the sub-communication system, and determines the detection window of the sub-communication system based on the calibration parameters, the number and types of messages received, and the transmission period of each type of message received by the sub-communication system. This technical solution determines the detection window of each sub-communication system by comprehensively considering the calibration parameters corresponding to the vehicle type, the number and types of messages received by the sub-communication system, and the transmission period of each type of message received by the sub-communication system. The calibration parameters can improve the sensitivity of message anomaly detection, and by considering the transmission period and the number and types of messages, the efficiency and accuracy of message anomaly detection can be improved. This achieves efficient and accurate determination of the detection window of the sub-communication system, thereby enabling efficient and accurate message anomaly detection of the sub-communication system.
[0140] See Figure 3 This is a flowchart of an embodiment of another CAN message anomaly detection method provided in this application. Figure 3 The process shown is in Figure 1 Based on the illustrated process, the specific method for identifying abnormal packets within the packet set is described. For example... Figure 3 As shown, the process may include the following steps:
[0141] Step 301, obtaining a sending period of each type of message received by a communication system, and splitting the communication system into multiple sub-communication systems based on the sending period.
[0142] Step 302, determining a detection window of each sub-communication system.
[0143] Step 303, obtaining a message set corresponding to the detection window, and determining an information entropy corresponding to the message set.
[0144] Step 304, determining that there is an abnormal message in the sub-communication system in a case where the information entropy is not in a preset range.
[0145] For detailed description of steps 301 to 304, refer to the description of steps 101 to 104, which will not be repeated here.
[0146] Step 305, dividing the message set into two sub-message sets.
[0147] Step 306, determining a relative entropy of each sub-message set and a preset message set, the preset message set being a message set without abnormal messages.
[0148] Step 307, determining an abnormal message in the message set based on the relative entropy corresponding to each sub-message set.
[0149] The following uniformly describes steps 305 to 307:
[0150] In the embodiment of the application, in a case where it is determined that there is an abnormal message in the message set, a bisection method and a relative entropy of the message set can be used to determine the abnormal message in the message set.
[0151] As an optional implementation, the message set can be first divided into two sub-message sets.
[0152] As an exemplary implementation, the message types in the message set can be evenly split into two sub-message sets.
[0153] As another exemplary implementation, the message set can be randomly split into two sub-message sets.
[0154] Then, a relative entropy of each sub-message set and a preset message set can be determined, the preset message set being a message set without abnormal messages, which can be a message set without abnormal messages in a historical time period.
[0155] As an optional implementation, the sending probability of each sub-packet set relative to the packet set and the sending probability of the preset packet set relative to the packet set are determined respectively, and then the relative entropy of each sub-packet set relative to the preset packet set is determined through the following formula (six) and the following formula (seven) respectively:
[0156]
[0157] wherein, the D(P S1 ||P S ) is the relative entropy of the first sub-packet set relative to the preset packet set, the P S1 is the sending probability of the first sub-packet set relative to the packet set, and the P S is the sending probability of the preset packet set relative to the packet set.
[0158]
[0159] wherein, the D(P S2 ||P S ) is the relative entropy of the second sub-packet set relative to the preset packet set, the P S2 is the sending probability of the second sub-packet set relative to the packet set, and the P S is the sending probability of the preset packet set relative to the packet set.
[0160] As an exemplary real-time manner, for each sub-packet set, the probability values of all kinds of packets included in the sub-packet set are added to obtain a first probability value. Then, the probability values of all kinds of packets included in the packet set are added to obtain a second probability value. Finally, the first probability value is divided by the second probability value to obtain the sending probability of the sub-packet set relative to the packet set.
[0161] Finally, the abnormal packet in the packet set can be determined based on the relative entropy corresponding to each sub-packet set.
[0162] As an optional implementation, when the abnormal packet in the packet set is determined based on the relative entropy corresponding to each sub-packet set, it can be determined whether the relative entropy corresponding to each sub-packet set is within the second preset range.
[0163] Optionally, if the relative entropy corresponding to the sub-packet set is within the second preset range, it indicates that there is no abnormal packet in the sub-packet set.
[0164] Optionally, if the relative entropy corresponding to the sub-packet set is not within the second preset range, it indicates that there is an abnormal packet in the sub-packet set.
[0165] Further, for the sub-packet set whose relative entropy is not in the second preset range, the execution subject of the embodiment of the application can continue to split the sub-packet set into two new sub-packet sets, and determine the relative entropy (for the sake of distinction, referred to as new relative entropy) of each new sub-packet set with the preset packet set again.
[0166] Then, it can be determined again whether the new relative entropy is in the second preset range.
[0167] Optionally, if the new relative entropy is in the second preset range, it indicates that there is no abnormal packet in the new sub-packet set, and therefore the new sub-packet set can not be split again.
[0168] On the contrary, if the new relative entropy is not in the second preset range, it indicates that there is an abnormal packet in the new sub-packet set, and therefore the new sub-packet set can be split again.
[0169] Further, for the new sub-packet set whose new relative entropy is not in the second preset range, the execution subject of the embodiment of the application can determine whether the new sub-packet set can be split again, that is, whether the new sub-packet set includes two or more than two types of packets.
[0170] Optionally, if the new sub-packet set cannot be split, the packets included in the new sub-packet set are determined as abnormal packets, that is, the lost packets are the packets in the new sub-packet set.
[0171] On the contrary, if the new sub-packet set can be split, the new sub-packet set can be taken as a new sub-packet set to continue the step of splitting the sub-packet set into two new sub-packet sets until the abnormal packet is determined.
[0172] In addition, in the embodiment of the application, the packet set can also be split into more than two sub-packet sets, and the relative entropy of each sub-packet set with the preset packet set is determined, so as to continue to determine the abnormal packet according to the dichotomy. The number of sub-packet sets split from the packet set is not limited in the embodiment of the application.
[0173] In addition, in order to save computing resources, when it is determined that there is no abnormal packet in the packet set, the execution subject of the embodiment of the application can recalculate the relative entropy in the packet set.
[0174] The technical scheme provided by the embodiments of the present application comprises the following steps: obtaining the sending period of each type of message received by a communication system, and splitting the communication system into a plurality of sub-communication systems based on the sending period; determining the detection window of each sub-communication system, obtaining the message set corresponding to the detection window, and determining the information entropy corresponding to the message set; in the case that the information entropy is not within a preset range, determining that there is an abnormal message in the sub-communication system. The message set is divided into two sub-message sets, the relative entropy of each sub-message set and a preset message set is determined, the preset message set is a message set without abnormal messages, and the abnormal message in the message set is determined based on the relative entropy corresponding to each sub-message set. This technical scheme determines the abnormal message in the message set based on the relative entropy of the message set in the case that the information entropy of the message set is used to determine that there is an abnormal message in the message set, thereby achieving efficient and accurate determination of whether there is an abnormal message in the message set, and fast and accurate determination of the abnormal message in the message set.
[0175] Referring to Figure 4 , an embodiment block diagram of a CAN message abnormality detection device provided by the embodiments of the present application is shown. As an embodiment, the CAN message can be received by a communication system corresponding to a CAN bus. As shown in Figure 4 , the device can comprise:
[0176] The obtaining module 41 is configured to obtain the sending period of each type of message received by the communication system, and split the communication system into a plurality of sub-communication systems based on the sending period.
[0177] The first determining module 42 is configured to determine the detection window of each sub-communication system.
[0178] The second determining module 43 is configured to obtain the message set corresponding to the detection window, and determine the information entropy corresponding to the message set.
[0179] The third determining module 44 is configured to determine that there is an abnormal message in the sub-communication system in the case that the information entropy is not within a preset range.
[0180] As shown in Figure 5 , a structural diagram of a vehicle provided by the embodiments of the present application is shown, which comprises a processor 51, a communication interface 52, a memory 53 and a communication bus 54, wherein the processor 51, the communication interface 52 and the memory 53 complete mutual communication through the communication bus 54,
[0181] The memory 53 is configured to store a computer program.
[0182] In an embodiment of the present application, the processor 51, when executing the program stored in the memory 53, implements the CAN message anomaly detection method provided by any one of the foregoing method embodiments, wherein the CAN message is received by a communication system corresponding to a CAN bus, and the method comprises:
[0183] obtaining a sending period of each type of message received by the communication system, and splitting the communication system into a plurality of sub-communication systems based on the sending period;
[0184] determining a detection window of each of the sub-communication systems;
[0185] obtaining a message set corresponding to the detection window, and determining an information entropy corresponding to the message set;
[0186] in a case where the information entropy is not within a preset range, determining that there is an abnormal message in the sub-communication system.
[0187] The embodiment of the present application also provides a storage medium having a computer program stored thereon, and the computer program, when executed by a processor, implements the steps of the CAN message anomaly detection method provided by any one of the foregoing method embodiments.
[0188] The device embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple grid units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.
[0189] Through the foregoing embodiments, those skilled in the art can clearly understand that each embodiment can be realized by means of software plus a general hardware platform, or by hardware. Based on such understanding, the foregoing technical solutions, essentially or in terms of related art, can be embodied in the form of a software product, and the computer software product can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, or an optical disk, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a grid device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0190] It is to be understood that the terminology used herein is for the purpose of describing particular example embodiments only and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises", "comprising", "includes", "including" and "has" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order
[0191] The above description is merely that of the specific embodiments of the application and as such is not to be taken in a limiting sense. Various modifications and alterations of the embodiments described herein will become apparent to those skilled in the art from the foregoing description, which does not limit the generality presented by the foregoing description. Accordingly, the drawings and descriptions are illustrative embodiments only.
Claims
1. A method for detecting CAN message anomalies, characterized in that, The Controller Area Network (CAN) message is received by the communication system corresponding to the CAN bus, and the method includes: The transmission period of each type of message received by the communication system is obtained, and based on the transmission period, the communication system is divided into multiple sub-communication systems; For each of the sub-communication systems, a detection window for that sub-communication system is determined; Obtain the message set corresponding to the detection window, and determine the information entropy corresponding to the message set; If the information entropy is not within a preset range, it is determined that there is an abnormal message in the sub-communication system; The step of determining the detection window of the sub-communication system includes: Based on the vehicle type of the vehicle where the CAN bus is located, determine the calibration parameters corresponding to the sub-communication system; determine the number of message types received by the sub-communication system; and determine the detection window of the sub-communication system based on the calibration parameters, the number of message types, and the transmission period of each type of message received by the sub-communication system.
2. The method according to claim 1, characterized in that, The method of dividing the communication system into multiple sub-communication systems based on the transmission period includes: The communication system can be divided into multiple sub-communication systems in the following way: Dissimilar messages with the same sending period are assigned to the same sub-communication system; And / or, Different types of messages from the same controller are evenly distributed to different sub-communication systems.
3. The method according to claim 2, characterized in that, The method further includes: A target period range is determined based on the transmission period of each type of message; wherein the interval of the target period range is less than a preset value. Messages that are not within the target period range are identified as target messages; For the target message, the transmission time period of the target message is determined according to the transmission period of the target message; If the target message is not received within the specified sending time period, it is determined that the target message is abnormal.
4. The method according to claim 1, characterized in that, The step of determining the detection window of the sub-communication system based on the correction parameters, the number of types, and the transmission period of each type of message received by the sub-communication system includes: The average period of the messages received by the sub-communication system is determined based on the transmission period of each type of message received by the sub-communication system. Determine the period difference between the transmission period and the average period for each type of message received by the sub-communication system; From the multiple said period differences, determine the largest target period difference; The detection window of the sub-communication system is obtained by pre-calculating the correction parameters, the number of types, the average period, and the target period difference.
5. The method according to claim 4, characterized in that, The step of performing a preset calculation on the correction parameters, the number of types, the average period, and the target period difference to obtain the detection window of the sub-communication system includes: Determine the target period for the baseline message and the standard duration for message anomalies; The target period, the standard duration, the correction parameter, the number of types, the average period, and the target period difference are input into a preset formula to obtain the initial detection window of the sub-communication system; wherein the preset formula is as follows: Among them, the For the initial detection window, the For the correction parameters, the For the number of the aforementioned types, the For the standard duration, the For the target period, the For the average period, the The target period difference; The initial detection window is rounded down to obtain the detection window of the sub-communication system.
6. The method according to claim 1, characterized in that, After determining that an abnormal message exists in the sub-communication system, the method further includes: The message set is divided into two sub-message sets; Determine the relative entropy between each of the sub-message sets and a preset message set, wherein the preset message set is a set in which no abnormal messages exist; Based on the relative entropy corresponding to each of the sub-message sets, the abnormal messages in the message set are determined.
7. The method according to claim 6, characterized in that, The step of determining the abnormal packets in the packet set based on the relative entropy corresponding to each of the sub-packet sets includes: Determine whether the relative entropy corresponding to each of the sub-message sets is within a preset range; For the sub-packet set whose relative entropy is not within the preset range, the sub-packet set is further split into two new sub-packet sets, and the new relative entropy of each new sub-packet set with respect to the preset packet set is determined. For the new sub-message set whose new relative entropy is not within the preset range, if the new sub-message set cannot be split, the messages contained in the new sub-message set are determined to be abnormal messages; For a new sub-packet set whose new relative entropy is not within the preset range, if the new sub-packet set can be further split, the new sub-packet set is used as a sub-packet set to perform the step of further splitting the sub-packet set into two new sub-packet sets and determining the new relative entropy of each new sub-packet set with respect to the preset packet set, until the abnormal packet is identified.
8. A CAN message anomaly detection device, characterized in that, CAN messages are received by the communication system corresponding to the CAN bus, and the device includes: The acquisition module is used to acquire the transmission period of each type of message received by the communication system, and to divide the communication system into multiple sub-communication systems based on the transmission period; The first determining module is used to determine the detection window of each of the sub-communication systems; The second determining module is used to obtain the message set corresponding to the detection window and determine the information entropy corresponding to the message set; The third determining module is used to determine that there is an abnormal message in the sub-communication system when the information entropy is not within a preset range; The step of determining the detection window of the sub-communication system includes: Based on the vehicle type of the vehicle where the CAN bus is located, determine the calibration parameters corresponding to the sub-communication system; determine the number of message types received by the sub-communication system; and determine the detection window of the sub-communication system based on the calibration parameters, the number of message types, and the transmission period of each type of message received by the sub-communication system.
9. A vehicle, characterized in that, include: A processor and a memory, wherein the processor is configured to execute a CAN message anomaly detection program stored in the memory to implement the CAN message anomaly detection method according to any one of claims 1 to 7.
Citation Information
Patent Citations
CAN network anomaly monitoring and positioning method and system based on relative entropy and automobile
CN115396134A
CAN message anomaly detection method and device and vehicle
CN119341945A