CAN message anomaly detection method and device and vehicle
By splitting the communication system according to the transmission cycle of the CAN bus message and determining the detection window, calculating the information entropy of the message collection to detect abnormalities, the problems of low efficiency and inaccurate detection of CAN message loss in the prior art are solved, and the problem of low and inaccurate detection of CAN message loss is realized Efficient and accurate abnormal detection.
Patent Information
- Application Number
- CN202411476386.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-22
AI Technical Summary
In the prior art, detection efficiency of CAN packet loss is low and inaccurate, especially when the CAN bus is disturbed, it is easy to cause false detection.
By obtaining the sending cycle of each type of message received by the communication system, the communication system is split into multiple sub-communication systems, and a detection window is determined for each sub-communication system to obtain the information entropy of the message collection, which is not in the pre-existing state. When the range is set, determine that there are abnormal messages in the sub-communication system.
It improves the accuracy and sensitivity of CAN packet abnormality detection, and is more efficient and accurate than the timeout detection method, and can more effectively identify packet loss situations.
Smart Images

Figure CN119484347A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of CAN bus communication technology, and in particular to a CAN message anomaly detection method, device and vehicle. Background Art
[0002] The Controller Area Network (CAN) bus is the most widely used bus in automobiles and is the underlying communication network of automobiles. Different controllers of a vehicle can communicate with each other through the CAN bus.
[0003] In actual applications, when controllers communicate with each other, they communicate by sending messages to the CAN bus. However, in the process of the controller sending messages through the CAN bus, there may be cases where the messages are lost.
[0004] At present, the detection of message loss is generally achieved by detecting whether some important message IDs of the controller have timed out. The above method not only has low detection efficiency, but also causes message timeout when the CAN bus is disturbed. Detection according to the above method will detect message loss, so the above detection method is also inaccurate. Summary of the invention
[0005] The present application provides a CAN message anomaly detection method, device and 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 method for detecting CAN message anomalies, wherein a controller area network CAN message is received by a communication system corresponding to a CAN bus, and the method comprises:
[0007] Acquire a 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;
[0008] For each of the sub-communication systems, determining a detection window of the sub-communication system;
[0009] Obtaining a message set corresponding to the detection window, and determining information entropy corresponding to the message set;
[0010] When the information entropy is not within a preset range, it is determined that an abnormal message exists in the sub-communication system.
[0011] As a possible implementation manner, splitting the communication system into multiple sub-communication systems based on the sending cycle includes:
[0012] The communication system is split into multiple sub-communication systems by:
[0013] Allocating different types of messages with the same sending period to the same sub-communication system;
[0014] and / or,
[0015] Different types of messages from the same controller are evenly distributed to different sub-communication systems.
[0016] As a possible implementation manner, the method further includes:
[0017] Determine a target cycle range according to the sending cycle of each type of message; wherein the interval of the target cycle range is less than a preset value;
[0018] Determine a message that is not within the target period range as a target message;
[0019] For the target message, determining a sending time period of the target message according to a sending cycle of the target message;
[0020] If the target message is not received within the sending time period, it is determined that an abnormality occurs in the target message.
[0021] As a possible implementation manner, the determining the detection window of the sub-communication system includes:
[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 and types of messages received by the sub-communication system;
[0024] The detection window of the sub-communication system is determined according to the correction parameter, the number of types, and the sending period of each type of message received by the sub-communication system.
[0025] As a possible implementation manner, determining the detection window of the sub-communication system according to the correction parameter, the number of types, and a sending period of each type of message received by the sub-communication system includes:
[0026] Determining an average period of messages received by the sub-communication system according to a sending period of each type of messages received by the sub-communication system;
[0027] Determine a period difference between a sending period of each type of the message received by the sub-communication system and the average period;
[0028] Determining a maximum target cycle difference from the plurality of cycle differences;
[0029] The correction parameter, the number of types, the average period, and the target period difference are calculated in a preset manner to obtain a detection window of the sub-communication system.
[0030] As a possible implementation manner, performing a preset calculation on the correction parameter, the number of types, the average period, and the target period difference to obtain the detection window of the sub-communication system includes:
[0031] Determine the target period of the benchmark message and the standard duration of message anomalies;
[0032] 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:
[0033]
[0034] Wherein, C is the initial detection window, A is the correction parameter, N is the number of types, T1 is the standard time length, T2 is the target period, and T Q is the average period, 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 manner, after determining that an abnormal message exists in the sub-communication system, the method further includes:
[0037] Dividing the message set into two sub-message sets;
[0038] Determine the relative entropy of each of the sub-message sets and a preset message set, where the preset message set is a set without any abnormal messages;
[0039] Based on the relative entropy corresponding to each of the sub-message sets, abnormal messages in the message set are determined.
[0040] As a possible implementation manner, determining the abnormal message in the message set based on the relative entropy corresponding to each of the sub-message sets includes:
[0041] Determining whether the relative entropy corresponding to each of the sub-message sets is within a preset range;
[0042] For the sub-message set whose relative entropy is not within the preset range, continue to split the sub-message set into two new sub-message sets, and determine a new relative entropy between each new sub-message set and the preset message set;
[0043] 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, determining the messages included in the new sub-message set as abnormal messages;
[0044] For the new sub-message set whose new relative entropy is not within the preset range, if the new sub-message set can be further split, the new sub-message set is used as a sub-message set to execute the step of continuing to split the sub-message set into two new sub-message sets, and determining the new relative entropy of each new sub-message set with the preset message set, until the abnormal message is determined.
[0045] In a second aspect, the present application provides a CAN message anomaly detection device, wherein the CAN message is received by a communication system corresponding to a CAN bus, and the device comprises:
[0046] An acquisition module, used for acquiring 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;
[0047] A first determining module, configured to determine, for each of the sub-communication systems, a detection window of the sub-communication system;
[0048] A second determination module is used to obtain a message set corresponding to the detection window and determine the information entropy corresponding to the message set;
[0049] The third determination module is used to determine whether there is an abnormal message in the sub-communication system when the information entropy is not within a preset range.
[0050] In a third aspect, the present application provides a vehicle, comprising: a processor and a memory, wherein the processor is used to execute a CAN message anomaly detection program stored in the memory to implement the CAN message anomaly detection method described in any one of the first aspects.
[0051] In a fourth aspect, the present application provides a storage medium storing one or more programs, and the one or more programs can be executed by one or more processors to implement the CAN message anomaly detection method described in any one of the first aspects.
[0052] The technical solution provided by the embodiment of the present application is to obtain the sending period of each type of message received by the communication system, and based on the sending period, the communication system is divided into multiple sub-communication systems, and for each sub-communication system, the detection window of the sub-communication system is determined, the message set corresponding to the detection window is obtained, and the information entropy corresponding to the message set is determined. If the information entropy is not within the preset range, it is determined that there is an abnormal message in the sub-communication system. This technical solution is to divide the communication system into multiple sub-communication systems according to the sending period of the message in the communication system corresponding to the CAN bus, and after determining the detection window of each sub-communication system, the information entropy of the message set to be detected in each sub-communication system is determined, so as to determine whether there is an abnormal message in the sub-communication system according to the information entropy, wherein, by calculating the information entropy to detect whether the CAN message is abnormal, it is more efficient and accurate than detecting whether the message is abnormal by timeout. Further, the communication system is divided 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, so that the accuracy and sensitivity of the abnormal detection of the CAN message can be further improved, and the efficient and accurate detection of whether the CAN message is abnormal can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art texts are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0055] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0056] Figure 1 A flowchart of an embodiment of a CAN message anomaly detection method provided in an embodiment of the present application;
[0057] Figure 2 A flowchart of another CAN message anomaly detection method provided in an embodiment of the present application;
[0058] Figure 3 A flowchart of another CAN message anomaly detection method provided in an embodiment of the present application;
[0059] Figure 4 A block diagram of an embodiment of a CAN message anomaly detection device provided in an embodiment of the present application;
[0060] Figure 5 A schematic diagram of the structure of a vehicle provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described in conjunction with the drawings in the embodiments of the present application. Obviously, the embodiments described in the text are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0062] The disclosure below provides many different embodiments or examples to implement different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0063] In order to solve the technical problem that the detection of message loss in the prior art is generally achieved by detecting whether the message ID has timed out, the above method not only has low detection efficiency, but also causes message timeout when the CAN bus is disturbed, and the detection according to the above method will detect message loss, so the above detection method is also inaccurate, the present application provides a CAN message abnormality detection method, device and vehicle, which can split the communication system into multiple sub-communication systems according to the message sending period in the communication system corresponding to the CAN bus, and after determining the detection window of each sub-communication system, determine the information entropy of the message set to be detected in each sub-communication system, so as to determine whether there is an abnormal message in the sub-communication system according to the information entropy, wherein, detecting whether the CAN message is abnormal by calculating the information entropy is more efficient and accurate than detecting whether the message is abnormal by timeout. Furthermore, 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, so that the accuracy and sensitivity of CAN message abnormality detection can be further improved, thereby realizing efficient and accurate detection of whether the CAN message is abnormal.
[0064] The CAN message anomaly detection method provided by the present application is further explained below with reference to specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0065] See also Figure 1 , is a flow chart of an embodiment of a CAN message abnormality detection method provided in an embodiment of the present application. In one embodiment, the CAN message involved in the embodiment of the present application is received by a communication system corresponding to the CAN bus in a vehicle. Figure 1 As shown, the process may include the following steps:
[0066] Step 101: Obtain a sending period of each type of message received by a communication system, and based on the sending period, split the communication system into a plurality of sub-communication systems.
[0067] The above-mentioned sending period refers to the sending period of each type of message (for the convenience of description, "CAN message" will be referred to as "message" below) to send the corresponding message to the communication system.
[0068] In actual applications, different domain controllers of a vehicle communicate with each other through the CAN bus, and the CAN bus may correspond to a communication system, which is used to receive and send CAN messages from different domain controllers. Furthermore, after receiving the CAN message sent by the domain controller, the communication system may detect the CAN message periodically or in real time to determine whether there is an abnormal message, where the abnormal message may be a lost message.
[0069] Furthermore, the vehicle CAN bus generally includes periodic messages and event-triggered messages. The CAN message anomaly detection method provided in the present application can detect periodic messages. Therefore, each type of CAN message here has a corresponding sending cycle.
[0070] In an embodiment 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 method, different types of messages with the same transmission period can be assigned to the same sub-communication system. Among them, since the message anomaly detection is performed based on information entropy in this application, and information entropy has the maximum uncertainty, when the probability of all messages occurring is the same, the information entropy has the maximum value, so as long as there is an abnormal message (such as message loss), the information entropy is reduced to a greater extent, which can improve the sensitivity of message anomaly detection, and the threshold of information entropy when there is no abnormal message is also better determined.
[0072] As another optional implementation, different types of messages with sending periods within a preset range may be allocated to the same sub-communication system, wherein, among the messages with sending periods within the preset range, the difference between the sending periods of any two types of messages is less than a preset value.
[0073] As another optional implementation method, different types of messages of the same controller can be evenly distributed to different sub-communication systems. According to the above distribution method, when messages are lost and the information entropy exceeds the threshold, the overall impact of the system can be avoided, the accuracy of message anomaly detection can be improved, and false detection can be reduced.
[0074] As another optional implementation, different types of messages with the same sending period may be allocated to the same sub-communication system, and different types of messages from the same controller may be evenly allocated to different sub-communication systems.
[0075] In addition, for messages whose sending period is significantly different from that of other types of messages, in order to prevent this type of message from having too large a difference in period from other types of messages, thereby causing an overall impact on message anomaly detection, the execution entity of the embodiment of the present application may perform anomaly detection on this type of message separately.
[0076] Furthermore, for the messages whose sending period differs greatly from the sending period of other types of messages, since the types of messages to be detected are relatively small, in order to save computing resources, the existing timeout detection method can be used to perform abnormal detection on such messages.
[0077] Based on this, in an embodiment of the present application, a target cycle range can be determined according to the sending cycle of each type of message, wherein the interval of the above target cycle range is smaller than a preset value, that is, the sending cycles of the messages within the target cycle range are not much different.
[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, then since the difference between 1 and 10 and 4 / 5 / 6 is large, the target period range can be determined to be [4, 6].
[0079] Afterwards, it can be determined whether there are messages that are not within the above target cycle range. If so, it means that the sending cycle of this type of message is significantly different from that of other types of messages. Therefore, the message that is not within the target cycle range can be determined as the target message.
[0080] Based on this, for the above target message, the target message sending time period can be determined according to the sending cycle of the target message, where the sending time period is the time period determined as the message sending timeout. For example, the message sending timeout can generally be determined when the message exceeds 1s within the cycle, so the sending cycle of such messages can be added with the timeout time (i.e., 1s) to obtain the sending time period of the target message.
[0081] Afterwards, when the target message is detected, if the target message is not received within the sending time period, it can be determined that an abnormality occurs in the target message, that is, the target message is lost.
[0082] Step 102: For each sub-communication system, determine a detection window of the sub-communication system.
[0083] Step 103: Obtain a message set corresponding to the detection window, and determine the information entropy corresponding to the message set.
[0084] The following is a unified description of step 102 and step 103:
[0085] The above detection window can be used to perform CAN message anomaly detection, that is, a window for collecting a set of messages to be detected, which can be represented by the number of messages or by a time period.
[0086] The above-mentioned message set refers to a set of messages received by the CAN bus in the vehicle that are to be detected for abnormality.
[0087] In practical applications, when performing anomaly detection on messages, the size of the detection window can affect the accuracy and sensitivity of the detection. When the detection window is large, it is easy to cause a decrease in detection sensitivity; when the detection condition is small, it is easy to cause a decrease in detection accuracy, thereby leading to erroneous detection results.
[0088] In this regard, in the embodiment of the present application, for each of the split sub-communication systems, a detection window corresponding to the sub-communication system can be determined to improve the sensitivity and accuracy of abnormal detection of messages in the sub-communication system. It is understandable that different sub-communication systems can correspond to different detection windows or the same detection window, and the embodiment of the present application does not limit this.
[0089] Furthermore, the execution subject of the embodiment of the present application may determine the detection window corresponding to the sub-communication system based on the sending period of the message received by the sub-communication system.
[0090] As for how to determine the detection window corresponding to the sub-communication system, it can be described below. Figure 2 The process shown is explained and will not be described in detail here.
[0091] In one embodiment, after determining the detection window corresponding to each sub-communication system, the execution subject of the embodiment of the present application may obtain a set of messages to be detected corresponding to the detection window.
[0092] As an optional implementation method, when the above-mentioned detection window is expressed by the number of messages, it means that whenever the CAN bus receives the number of messages corresponding to the detection window, the CAN message anomaly detection starts. Therefore, according to the above-mentioned detection window, the number of messages recently received corresponding to the number of the detection window can be obtained to obtain the current message set to be detected.
[0093] As another optional implementation method, when the above-mentioned detection window is represented by a time period, it means that every time a preset time period is reached, the messages received within the preset time period are detected. Therefore, when the current distance from the last time a message anomaly detection is performed reaches the time period corresponding to the above-mentioned detection window, the messages received in the time period corresponding to the detection window are obtained to obtain the current message set to be detected.
[0094] After determining the message set, anomaly detection can be started for the message set. In the embodiment of the present application, it can be determined whether there are abnormal messages in the message set according to the information entropy of the message set. Therefore, the execution subject of the embodiment of the present application can first determine the information entropy of the message set.
[0095] As an optional implementation, when determining the information entropy corresponding to the above message set, the probability value of each type of message in the message set being generated may be determined first.
[0096] As an exemplary implementation, when determining the probability value of each type of message generated in the message set, the detection window of the subcommunication system corresponding to the message set and the sending period corresponding to each type of message in the message set can be calculated according to the preset formula in the following formula (1) to obtain the probability value of each type of message generated:
[0097]
[0098] Among them, the above P i is the probability value of the i-th type of message, the above C is the above detection window, and the above T i is the sending period corresponding to the i-th type of message, and the above n is the number of types of messages in the above message set.
[0099] Furthermore, the following formula (II) can be obtained through the above formula (I):
[0100]
[0101] Among them, the above P i is the probability value of the i-th type of message, the above T i is the sending period corresponding to the i-th type of message, and the above N is the calibration constant value determined according to the sending period of each type of message in the message set.
[0102] At this point, the probability value of each message in the message set being generated can be obtained.
[0103] Based on the probability value of each type of message determined above, the execution subject of the embodiment of the present application may calculate the probability value of each type of message according to the preset formula in the following formula (III) to obtain the information entropy corresponding to the message set:
[0104]
[0105] Wherein, the above H(S) is the above information entropy, the above n is the number of types of messages in the above message set, and the above P i is the probability value of the i-th type of message.
[0106] Step 104: When the information entropy is not within a preset range, it is determined that an abnormal message exists in the sub-communication system.
[0107] The above-mentioned preset range refers to the range to which the information entropy of the above-mentioned message set belongs when there is no abnormality in the messages received by the CAN bus (for example, there is no lost message).
[0108] From the above description, it can be seen that when determining the information entropy of a message set, the calculation is performed according to formula (3), and as shown in formula (2), the sending period of each type of message is a constant, so the probability value of each type of message is generally also a constant. Therefore, when there is no abnormality in the message set received by the CAN bus, the information entropy of the message set is generally within the above preset range.
[0109] In the embodiment of the present application, after determining the information entropy of the above-mentioned message set, it can be determined whether the above-mentioned information entropy is within the above-mentioned preset range.
[0110] Optionally, when it is determined that the information entropy is within the preset range, it can be determined that no abnormal message exists in the message set at this time.
[0111] On the contrary, when it is determined that the information entropy is not within the preset range, it can be determined that an abnormal message exists in the message set at this time.
[0112] In addition, when it is determined that there are abnormal messages in the message set, the execution subject of the embodiment of the present application can determine the abnormal messages in the message set according to the relative entropy of the message set. As for how to determine the abnormal messages from the message set, it can be described below. Figure 3 The process shown is explained and will not be described in detail here.
[0113] The technical solution provided by the embodiment of the present application is to obtain the sending period of each type of message received by the communication system, and based on the sending period, the communication system is divided into multiple sub-communication systems, and for each sub-communication system, the detection window of the sub-communication system is determined, the message set corresponding to the detection window is obtained, and the information entropy corresponding to the message set is determined. If the information entropy is not within the preset range, it is determined that there is an abnormal message in the sub-communication system. This technical solution is to divide the communication system into multiple sub-communication systems according to the sending period of the message in the communication system corresponding to the CAN bus, and after determining the detection window of each sub-communication system, the information entropy of the message set to be detected in each sub-communication system is determined, so as to determine whether there is an abnormal message in the sub-communication system according to the information entropy, wherein, by calculating the information entropy to detect whether the CAN message is abnormal, it is more efficient and accurate than detecting whether the message is abnormal by timeout. Further, the communication system is divided 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, so that the accuracy and sensitivity of the abnormal detection of the CAN message can be further improved, and the efficient and accurate detection of whether the CAN message is abnormal can be achieved.
[0114] See also Figure 2 , which is a flow chart of an embodiment of another CAN message anomaly detection method provided in an embodiment of the present application. Figure 2 The process shown in Figure 1 Based on the process shown in FIG. 1 , it is described how to determine the detection window of each sub-communication system. Figure 2 As shown, the process may include the following steps:
[0115] Step 201: For each sub-communication system, a correction parameter corresponding to the sub-communication system is determined according to the vehicle type of the vehicle where the CAN bus is located.
[0116] The above-mentioned vehicle type refers to the type of vehicle, which may include the size, brand, engine type, etc. of the vehicle, and the embodiment of the present application does not impose any restrictions on this.
[0117] In actual applications, different types of vehicles have different sensitivities during the message anomaly detection process. Therefore, in an embodiment of the present application, different correction parameters can be set for different vehicle types to correct the impact of different vehicle types on the sensitivity of the message anomaly detection process.
[0118] In one embodiment, the executing entity of the embodiment of the present application may pre-store the correspondence between different vehicle types and correction parameters. Based on this, when performing CAN message abnormality detection, the vehicle type corresponding to the current vehicle can be obtained, and the correction parameters corresponding to the vehicle type can be determined based on the vehicle type and the above-mentioned pre-stored correspondence.
[0119] Among them, the setting of the correction parameters can be set according to current needs. For example, if you want to improve the sensitivity of detection, you can set the above correction parameters to any number less than 1; if you want to improve the accuracy and efficiency of detection, you can set the above correction parameters to any number greater than 1.
[0120] Furthermore, after determining the correction parameters corresponding to the above-mentioned sub-communication system, the execution subject of the embodiment of the present application may further adjust the above-mentioned correction parameters according to the size of the sub-communication system.
[0121] As an optional implementation method, when the sub-communication system contains many types of messages, that is, the sub-communication system is large, in order to improve the accuracy and efficiency of message anomaly detection, the execution entity of the embodiment of the present application may increase the above correction parameter by a preset value.
[0122] As another optional implementation, when the sub-communication system contains fewer types of messages, that is, the sub-communication system is small, in order to improve the sensitivity of message anomaly detection, the execution subject of the embodiment of the present application may reduce the above correction parameter by a preset value.
[0123] Step 202: Determine the number and 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 parameters, the number of types, and the sending period of each type of message received by the sub-communication system.
[0125] The following is a unified description of step 202 and step 203:
[0126] The number of types mentioned above refers to the total number of all types of messages received by the sub-communication system. Here, when distinguishing the message types, the message identifiers (such as message IDs) of the messages can be used for distinction. For example, assuming that the communication system X of the CNA bus has a finite set of possible states {X1, X2, ..., Xm}, then X is the set of message identifiers ID, that is, the message IDs X1 and X2 belong to different message types.
[0127] In an embodiment of the present application, after determining the correction parameters corresponding to the sub-communication system and the number of types of received messages, the executing entity of the embodiment of the present application can determine the detection window of the sub-communication system based on the above correction parameters, number of types, and the sending period of each type of message received by the sub-communication system.
[0128] As an optional implementation method, the average period of the messages received by the sub-communication system can be determined based on the sending period of each type of message received by the above-mentioned sub-communication system, and the period difference between the sending period of each type of message received by the sub-communication system and the above-mentioned average period can be determined to obtain multiple period differences.
[0129] Afterwards, the maximum target cycle difference may be determined from the multiple cycle differences obtained above, and a preset calculation may be further performed based on the correction parameters, number of types, average cycle, and target cycle difference to obtain the detection window of the sub-communication system.
[0130] As an optional implementation method, the target period of the reference message and the standard duration of the message abnormality can be determined. The reference message refers to a pre-set standard message for calculating the detection window, and the standard duration refers to the determination duration when the message is sent abnormally. For example, when the message loss exceeds 1s, it can be determined that the message is lost.
[0131] Afterwards, 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 more limited the detection time is for the same window, so a larger window should be selected; if the difference in the period of the message is large, a larger window must be selected, otherwise a slight deviation of the message with a large period will cause a false alarm; the more the number of messages, the larger the window should be, otherwise the time period of the message to be detected is very limited. Therefore, the execution subject of the embodiment of the present application can input the above-mentioned target period, standard duration, correction parameters, number of types, average period, and the above-mentioned target period difference into a preset formula to obtain the initial detection window of the sub-communication system. Among them, the above-mentioned preset formula can be shown as follows (IV):
[0132]
[0133] Among them, the above C is the above initial detection window, the above A is the above correction parameter, the above N is the number of the above types, the above T1 is the above standard time length, the above T2 is the above target period, and the above T Q is the above average period, and the above T P is the target period difference mentioned above;
[0134] For example, assuming that a message with a period of 10ms is used as the reference message calculation window, and continuing to assume that the current CAN bus communication specification generally requires that a message loss of 1s is defined as a communication loss, then substituting the above period and 1s into the above formula (IV), the following formula (V) can be obtained:
[0135]
[0136] Wherein, the above C is the above initial detection window, the above A is the above correction parameter, the above N is the number of the above types, and the above T Q is the above average period, and the above T P is the target period difference mentioned above;
[0137] Furthermore, in the above formula (V), 10 divided by T Q This is because the shorter the message cycle, the larger the window is needed to ensure detection efficiency. P Divide by T Q This is because the larger the message deviation, the larger the window is required, otherwise the detection accuracy will decrease due to the large message changes in the message period.
[0138] Finally, for the convenience of calculation, the initial detection window may be rounded to the nearest multiple of 10 to obtain the detection window of the sub-communication system.
[0139] The technical solution provided in the embodiment of the present application determines the correction parameters corresponding to each sub-communication system according to the vehicle type of the vehicle where the CAN bus is located, determines the number of types of messages received by the above-mentioned sub-communication system, and determines the detection window of the sub-communication system according to the above-mentioned correction parameters, the number of types, and the sending cycle of each type of message received by the sub-communication system. This technical solution is determined by comprehensively considering the correction parameters corresponding to the vehicle type, the number of types of messages received by the sub-communication system, and the sending cycle of each type of message received by the sub-communication system when determining the detection window of each sub-communication system. The correction parameters can improve the sensitivity of message anomaly detection, and by considering the sending cycle and the number of types, the efficiency and accuracy of message anomaly detection can be improved, and the detection window of the sub-communication system is efficiently and accurately determined, thereby realizing efficient and accurate message anomaly detection of the sub-communication system.
[0140] See also Figure 3 , which is a flow chart of an embodiment of another CAN message anomaly detection method provided in an embodiment of the present application. Figure 3 The process shown in Figure 1 Based on the process shown in FIG. 1 , the specific method of determining abnormal messages in a message set is described. Figure 3 As shown, the process may include the following steps:
[0141] Step 301: Obtain a sending period of each type of message received by a communication system, and based on the sending period, split the communication system into a plurality of sub-communication systems.
[0142] Step 302: For each sub-communication system, determine a detection window of the sub-communication system.
[0143] Step 303: Obtain a message set corresponding to the detection window, and determine the information entropy corresponding to the message set.
[0144] Step 304: When the information entropy is not within a preset range, it is determined that an abnormal message exists in the sub-communication system.
[0145] For a detailed description of steps 301 to 304 , please refer to the description of steps 101 to 104 , which will not be repeated here.
[0146] Step 305: Divide the above message set into two sub-message sets.
[0147] Step 306: Determine the relative entropy between each of the above sub-message sets and a preset message set, where the preset message set is a message set without any abnormal messages.
[0148] Step 307: Determine abnormal messages in the message set based on the relative entropy corresponding to each of the above sub-message sets.
[0149] The following is a unified description of steps 305 to 307:
[0150] In the embodiment of the present application, when it is determined that there are abnormal messages in the message set, the binary method and the relative entropy of the message set can be used to determine the abnormal messages in the message set.
[0151] As an optional implementation method, the above message set may be first divided into two sub-message sets.
[0152] As an exemplary implementation, the message types in the above message set may be evenly divided into two sub-message sets.
[0153] As another exemplary implementation, the above message set may be randomly divided into two sub-message sets.
[0154] Afterwards, the relative entropy between each sub-message set and a preset message set may be determined. The preset message set is a message set without abnormal messages, which may be a message set that has been determined to have no abnormal messages within a historical time period.
[0155] As an optional implementation, the sending probability of each sub-message set relative to the message set can be determined respectively, and the sending probability of the preset message set relative to the above message set can be determined, and then the relative entropy of each sub-message set and the preset message set can be determined by the following formula (six) and the following formula (seven) respectively:
[0156]
[0157] Among them, the above D(P S1 ||P S ) is the relative entropy of the first sub-message set and the preset message set, and the above P S1 is the sending probability of the first sub-message set relative to the message set, the above P S is the sending probability of the above preset message set relative to the message set.
[0158]
[0159] Among them, the above D(P S2 ||P S ) is the relative entropy of the second sub-message set and the preset message set, and the above P S2 is the sending probability of the second sub-message set relative to the message set, the above P S is the sending probability of the above preset message set relative to the message set.
[0160] As an exemplary real-time method, for each sub-message set, the probability values of all types of messages included in the sub-message set may be added to obtain a first probability value. Then, the probability values of all types of messages included in the message set may be added to obtain a second probability value. Finally, the first probability value may be divided by the second probability value to obtain the sending probability of the sub-message set relative to the message set.
[0161] Finally, based on the relative entropy corresponding to each sub-message set, the abnormal messages in the message set can be determined.
[0162] As an optional implementation, when determining abnormal messages in a message set based on the relative entropy corresponding to each sub-message set, it can be determined whether the relative entropy corresponding to each sub-message set is within the above-mentioned second preset range.
[0163] Optionally, if the relative entropy corresponding to the sub-message set is within the second preset range, it means that there is no abnormal message in the sub-message set.
[0164] Optionally, if the relative entropy corresponding to the sub-message set is not within the second preset range, it indicates that there are abnormal messages in the sub-message set.
[0165] Furthermore, for a sub-message set whose relative entropy is not within the second preset range, the executing entity of the embodiment of the present application may continue to split the sub-message set into two new sub-message sets, and again determine the relative entropy of each new sub-message set with the preset message set (hereinafter referred to as the new relative entropy for ease of distinction).
[0166] Afterwards, it may be determined again whether the new relative entropy is within the second preset range.
[0167] Optionally, if the new relative entropy is within the second preset range, it means that there are no abnormal messages in the new sub-message set, so the new sub-message set may no longer be split.
[0168] On the contrary, if the new relative entropy is not within the second preset range, it means that there are abnormal messages in the new sub-message set, so the new sub-message set can be split again.
[0169] Furthermore, for the new sub-message set whose new relative entropy is not within the second preset range, the executing entity of the embodiment of the present application can determine whether the new sub-message set can be split again, that is, whether the new sub-message set includes two or more types of messages.
[0170] Optionally, if the new sub-message set cannot be split, the messages included in the new sub-message set are determined to be abnormal messages, that is, the lost messages are the messages in the new sub-message set.
[0171] On the contrary, if the new sub-message set can be further split, the new sub-message set can be used as a new sub-message set to execute the step of continuing to split the sub-message set into two new sub-message sets until an abnormal message is determined.
[0172] In addition, in an embodiment of the present application, the message set can be split into more than two sub-message sets, and the relative entropy of each sub-message set and the preset message set can be determined, so as to continue to determine the abnormal messages according to the binary search method. The embodiment of the present application does not limit the number of sub-message sets into which the message set is split.
[0173] In addition, in order to save computing resources, when it is determined that there are no abnormal messages in the message set, the execution subject of the embodiment of the present application may recalculate the relative entropy in the message set.
[0174] The technical solution provided by the embodiment of the present application is to obtain the sending period of each type of message received by the communication system, and based on the sending period, the communication system is divided into multiple sub-communication systems, and for each sub-communication system, the detection window of the sub-communication system is determined, the message set corresponding to the detection window is obtained, and the information entropy corresponding to the message set is determined. When the information entropy is not within the preset range, it is determined that there are abnormal messages in the sub-communication system. The message set is divided into two sub-message sets, and the relative entropy of each of the above sub-message sets and the preset message set is determined. The preset message set is a message set without abnormal messages, and the abnormal messages in the message set are determined based on the relative entropy corresponding to each of the above sub-message sets. This technical solution, by determining that there are abnormal messages in the message set according to the information entropy of the message set, further locates the abnormal messages in the message set according to the relative entropy of the message set, so as to achieve efficient and accurate determination of whether there are abnormal messages in the message set, and quickly and accurately determine the abnormal messages in the message set.
[0175] See also Figure 4 , is a block diagram of an embodiment of a CAN message anomaly detection device provided in an embodiment of the present application. As an embodiment, the CAN message can be received by a communication system corresponding to the CAN bus. Figure 4 As shown, the device may include:
[0176] An acquisition module 41 is used to acquire a 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;
[0177] A first determining module 42, configured to determine, for each of the sub-communication systems, a detection window of the sub-communication system;
[0178] A second determination module 43 is used to obtain a message set corresponding to the detection window and determine the information entropy corresponding to the message set;
[0179] The third determination module 44 is configured to determine if an abnormal message exists in the sub-communication system when the information entropy is not within a preset range.
[0180] like Figure 5 As shown, it is a schematic diagram of the structure of a vehicle provided in an embodiment of the present application, including 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 communicate with each other through the communication bus 54.
[0181] A memory 53, for storing computer programs;
[0182] In one embodiment of the present application, the processor 51 is used to implement the CAN message anomaly detection method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 53, wherein the CAN message is received by a communication system corresponding to the CAN bus, and the method includes:
[0183] Acquire a 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;
[0184] For each of the sub-communication systems, determining a detection window of the sub-communication system;
[0185] Obtaining a message set corresponding to the detection window, and determining information entropy corresponding to the message set;
[0186] When the information entropy is not within a preset range, it is determined that an abnormal message exists in the sub-communication system.
[0187] An embodiment of the present application further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the CAN message anomaly detection method provided in any of the aforementioned method embodiments are implemented.
[0188] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, i.e., they may be located in one place, or may be distributed over multiple grid units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0189] Through the text of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology 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 ROM / RAM, a disk, an optical disk, etc., including a number of instructions for 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 embodiment.
[0190] It should be understood that the terms used in the text are only for the purpose of the specific example implementation of the text, and are not intended to be limited. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used in the text can also be represented to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of the stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or their combinations. The method steps, processes, and operations of the text in the text are not interpreted as necessarily requiring them to be performed in the specific order of the text or description, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps can be used.
[0191] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A CAN message anomaly detection method, characterized in that: The controller area network (CAN) message is received by a communication system corresponding to the CAN bus, and the method comprises: Acquire a 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; For each of the sub-communication systems, determining a detection window of the sub-communication system; Obtaining a message set corresponding to the detection window, and determining information entropy corresponding to the message set; When the information entropy is not within a preset range, it is determined that an abnormal message exists in the sub-communication system.
2. The method according to claim 1, characterized in that The step of dividing the communication system into a plurality of sub-communication systems based on the sending cycle includes: The communication system is split into multiple sub-communication systems by: Allocating different types of messages with the same sending period 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 comprises: Determine a target cycle range according to the sending cycle of each type of message; wherein the interval of the target cycle range is less than a preset value; Determine a message that is not within the target period range as a target message; For the target message, determining a sending time period of the target message according to a sending cycle of the target message; If the target message is not received within the sending time period, it is determined that an abnormality occurs in the target message.
4. The method according to claim 1, characterized in that: The determining the detection window of the sub-communication system comprises: Determining a correction parameter corresponding to the sub-communication system according to the vehicle type of the vehicle where the CAN bus is located; Determining the number and types of messages received by the sub-communication system; The detection window of the sub-communication system is determined according to the correction parameter, the number of types, and the sending period of each type of message received by the sub-communication system.
5. The method according to claim 4, characterized in that Determining 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 includes: Determining an average period of messages received by the sub-communication system according to a sending period of each type of messages received by the sub-communication system; Determine a period difference between a sending period of each type of the message received by the sub-communication system and the average period; Determining a maximum target cycle difference from the plurality of cycle differences; The correction parameter, the number of types, the average period, and the target period difference are calculated in a preset manner to obtain a detection window of the sub-communication system.
6. The method according to claim 5, characterized in that The step of performing a preset calculation on the correction parameter, 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 of the benchmark message and the standard duration of 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: Wherein, C is the initial detection window, A is the correction parameter, N is the number of types, T1 is the standard time length, T2 is the target period, and T Q is the average period, the T P is the target period difference; The initial detection window is rounded to obtain the detection window of the sub-communication system.
7. 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: Dividing the message set into two sub-message sets; Determine the relative entropy of each of the sub-message sets and a preset message set, where the preset message set is a set without any abnormal messages; Based on the relative entropy corresponding to each of the sub-message sets, abnormal messages in the message set are determined.
8. The method according to claim 7, characterized in that The determining, based on the relative entropy corresponding to each of the sub-message sets, an abnormal message in the message set includes: Determining whether the relative entropy corresponding to each of the sub-message sets is within a preset range; For the sub-message set whose relative entropy is not within the preset range, continue to split the sub-message set into two new sub-message sets, and determine a new relative entropy between each new sub-message set and the preset message set; 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, determining the messages included in the new sub-message set as abnormal messages; For the new sub-message set whose new relative entropy is not within the preset range, if the new sub-message set can be further split, the new sub-message set is used as a sub-message set to execute the step of continuing to split the sub-message set into two new sub-message sets, and determining the new relative entropy of each new sub-message set with the preset message set, until the abnormal message is determined.
9. A CAN message anomaly detection device, characterized in that: The CAN message is received by a communication system corresponding to the CAN bus, and the device comprises: An acquisition module, used for acquiring 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; A first determining module, configured to determine, for each of the sub-communication systems, a detection window of the sub-communication system; A second determination module is used to obtain a message set corresponding to the detection window and determine the information entropy corresponding to the message set; The third determination module is used to determine whether there is an abnormal message in the sub-communication system when the information entropy is not within a preset range.
10. A vehicle, characterized in that: include: A processor and a memory, wherein the processor is used 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 8.
Citation Information
Patent Citations
Network abnormality detection method and system based on information entropy and sliding window
CN103618651A
Vehicle-mounted CAN bus anomaly detection method based on a relative entropy
CN108848072A
Vehicle-mounted CAN bus network abnormity detection method and system
CN110275508A
Abnormal flow detection method for Internet of Things equipment
CN112583808A
Data period determination method and system for time series data
CN114880382A