Vehicle-mounted CAN network offset distribution optimization method and device under PAE mechanism

By optimizing the offset allocation method of the vehicle CAN network under the PAE mechanism, the problem of WCRT extension of low-priority messages is solved, and a balance between network real-time performance and security is achieved. It is suitable for single-node and multi-node global synchronization scenarios.

CN121509939APending Publication Date: 2026-02-10NANJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511671031.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-14
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing offset algorithms fail to effectively optimize the real-time performance of onboard CAN networks under the PAE mechanism, especially the WCRT extension of low-priority messages, and lack multi-node global collaborative optimization.

Method used

By receiving the vehicle CAN network message set and system parameters, the system overcycle is calculated based on the authentication frequency and the normal message period. A release array is generated, and offsets are allocated according to the message order. The optimization effect is verified by using time series analysis methods to ensure that the authentication message is released after the normal message and to reasonably set the time discretization granularity to avoid conflicts.

Benefits of technology

It effectively reduces WCRT of low-priority messages, improves the overall real-time performance of the network, is highly adaptable, balances security and scheduling performance, and supports single-node and multi-node global synchronization scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121509939A_ABST
    Figure CN121509939A_ABST
Patent Text Reader

Abstract

The invention discloses a vehicle-mounted CAN network offset distribution optimization method and device under a PAE mechanism, and relates to the technical field of vehicle-mounted network security and real-time scheduling, and the method comprises the steps: receiving a vehicle-mounted CAN network message set and system parameters; determining the period of the authentication message based on the authentication frequency and the period of the common message, and calculating a system over-period according to the period of the common message and the period of the authentication message; generating a release array based on the system super cycle and the time discretization granularity; based on the period of the common message and the period of the authentication message, sorting the messages from small to large, and allocating offset to the common message and the authentication message according to a sorting result, and respectively calculating worst case response time for the common message and the authentication message before the offset is allocated and the common message and the authentication message after the offset is allocated by adopting a time sequence analysis method, and verifying an offset allocation optimization effect according to comparison of the worst case response time before and after the worst case response time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of vehicle network security and real-time scheduling technology, specifically a method and apparatus for optimizing offset allocation in vehicle CAN network under the PAE mechanism. Background Technology

[0002] With the development of intelligent connected vehicles and autonomous driving technologies, the in-vehicle CAN network, as the core communication link connecting sensors, controllers (ECUs), and actuators, undertakes the task of real-time transmission of critical control commands and status data. The CAN protocol, with its low cost, high reliability, and priority arbitration mechanism, is widely used in key subsystems such as powertrain systems and chassis control. However, its initial design did not fully consider information security, exhibiting security shortcomings such as broadcast communication lacking authentication, message frames lacking encryption fields, and lacking time validity verification. This makes it vulnerable to attacks such as tampering, forgery, and replay attacks, seriously threatening vehicle driving safety. To address these security risks, researchers proposed the PAE mechanism, which periodically appends authentication messages (carrying hash values ​​or encrypted tags) to ordinary messages to achieve message integrity and authenticity verification. However, the authentication messages introduced by the PAE mechanism increase bus load, leading to increased message time overlap and prolonged message WCRT (Write-in-Time), especially for low-priority messages, which are more susceptible to interference and may violate the real-time constraints of the in-vehicle network.

[0003] Offset allocation, a classic real-time scheduling optimization technique, can reduce message time overlap and lower WCRT by reasonably setting the first release time (offset). Existing offset algorithms are mostly designed for single-type ordinary messages, without considering the dependency relationship of "ordinary authentication messages" under the PAE mechanism (authentication messages need to be released after ordinary messages), and lack multi-node global collaborative optimization, resulting in poor real-time optimization effect under the PAE mechanism. Summary of the Invention

[0004] To address the shortcomings mentioned in the background section, the present invention aims to provide a method and apparatus for optimizing offset allocation in a vehicle CAN network under the PAE mechanism.

[0005] Firstly, the objective of this invention can be achieved through the following technical solution: a method for optimizing offset allocation in a vehicle CAN network under the PAE mechanism, the method comprising the following steps: The system receives a set of vehicle CAN network messages and system parameters. The set of vehicle CAN network messages includes ordinary messages and authentication messages corresponding to the ordinary messages. The system parameters include time discretization granularity and authentication frequency. The ordinary messages include period, priority, transmission time, offset, and the dependency relationship between the ordinary messages and the corresponding authentication messages. The period of the authentication message is determined based on the authentication frequency and the period of the ordinary message. The system supercycle is calculated based on the period of the ordinary message and the period of the authentication message. A release array is generated based on the system supercycle and the time discretization granularity. Messages are sorted in ascending order based on the period of ordinary messages and the period of authentication messages. Offsets are assigned to ordinary messages and authentication messages according to the sorting results. The worst-case response time is calculated using time series analysis methods for ordinary messages and authentication messages before and after the offsets are assigned. The effect of offset allocation optimization is verified by comparing the worst-case response times before and after the offsets are assigned.

[0006] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the dependency relationship between the ordinary message and the corresponding authentication message is that the offset of the authentication message is greater than the offset of the corresponding ordinary message.

[0007] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: setting the time discretization granularity: Based on the assigned message offset, the message offset is set to an integer multiple of the time discretization granularity g, and the time discretization granularity g is greater than the maximum transmission time of a standard CAN message.

[0008] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the initial state of the release array is all elements of 0, and it is updated gradually as the message offset allocation is carried out, recording the message load changes at each time granularity within the supercycle.

[0009] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the process of allocating offsets to ordinary messages and authentication messages according to the sorting result, comprising: Find candidate continuous load intervals; filter the optimal continuous load intervals within the candidate continuous load intervals; determine and set the offset; update the release array R according to the set offset; The continuous load interval is defined as a continuous time granularity interval on the release array R where the load is the same.

[0010] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the process of selecting the optimal continuous load interval within the candidate continuous load interval includes: Iterate through all the found load contiguous intervals, set the initial offset to the middle position of the load contiguous interval, calculate the worst-case interference count of the message within the supercycle under the offset distribution, and select the interval with the smallest worst-case interference count as the best load contiguous interval after traversal.

[0011] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: the timing analysis method is based on a hypercycle model, considering the release time of message instances, the first release time of high-priority messages, the blocking time, and the number of interferences, iteratively calculating the queuing delay and determining the worst-case response time (WCRT).

[0012] In conjunction with the first aspect, in some implementations of the first aspect, the method further includes: a calculation process for the first release time of the high-priority message, comprising: For high-priority messages First through Determine the smallest positive integer n, then substitute it into... The first release time was obtained, among which The release time of the kth instance of the target message; The iterative calculation formula for queuing delay is as follows: ,initial The iteration termination condition is ,in For high-priority message sets, For high priority messages Transmission time.

[0013] Secondly, in order to achieve the above objectives, this invention discloses an onboard CAN network offset allocation optimization device under the PAE mechanism, characterized in that it includes: The data receiving module is used to receive vehicle CAN network message sets and system parameters. The vehicle CAN network message set includes ordinary messages and authentication messages corresponding to the ordinary messages. The system parameters include time discretization granularity and authentication frequency. The ordinary messages include period, priority, transmission time, offset, and the dependency relationship between the ordinary messages and the corresponding authentication messages. The periodic confirmation module is used to determine the period of authentication messages based on the authentication frequency and the period of ordinary messages, calculate the system over-period based on the period of ordinary messages and the period of authentication messages, and generate a release array based on the system over-period and time discretization granularity. The verification optimization module sorts messages in ascending order based on the period of ordinary messages and the period of authentication messages. It assigns offsets to ordinary messages and authentication messages according to the sorting results. It then uses time series analysis to calculate the worst-case response time for ordinary messages and authentication messages before and after offset assignment. The optimization effect of offset assignment is verified by comparing the worst-case response times before and after offset assignment.

[0014] In another aspect of the present invention, to achieve the above-mentioned objective, a terminal device is disclosed, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor. The memory stores the computer program capable of running on the processor. When the processor loads and executes the computer program, it employs a vehicle CAN network offset allocation optimization method under a PAE mechanism as described above. The beneficial effects of this invention are: This invention can effectively reduce WCRT of low-priority messages, improve the overall real-time performance of the network, support single-node and multi-node global synchronization scenarios, is highly adaptable, balances security and scheduling performance, provides scheduling guarantee for the engineering application of PAE mechanism, and ultimately improves the real-time optimization effect under PAE mechanism. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a schematic diagram of the workflow of the present invention; Figure 3 This is a schematic diagram of the offset allocation method of the present invention; Figure 4 This is a schematic diagram of the device structure of the present invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] Example 1: like Figure 1 As shown, an optimization method for offset allocation in an onboard CAN network under the PAE mechanism is presented. The method includes the following steps: S101: Receive vehicle CAN network message set and system parameters, wherein the vehicle CAN network message set includes ordinary messages and authentication messages corresponding to the ordinary messages, and the system parameters include time discretization granularity and authentication frequency; wherein the ordinary messages include period, priority, transmission time, offset, and the dependency relationship between ordinary messages and corresponding authentication messages; The dependency relationship between a regular message and its corresponding authentication message is that the offset of the authentication message is greater than the offset of the corresponding regular message.

[0018] Setting the time discretization granularity: Based on the assigned message offset, the message offset is set to an integer multiple of the time discretization granularity g, and the time discretization granularity g is greater than the maximum transmission time of a standard CAN message.

[0019] Specifically, the messages in the CAN network under the PAE mechanism are divided into two categories: ordinary messages: the original messages of the CAN network, which are responsible for transmitting control commands, sensor data and other tasks; and authentication messages: sent periodically at the authentication frequency α, carrying the hash value or encrypted tag (such as HMACSHA256, AESGCM generated) of the ordinary messages, which are used to verify the integrity and authenticity of the ordinary messages.

[0020] Define the message parameters as ( The meanings of each parameter are as follows: Priority ( ): Uniquely identified by the message identifier, with smaller values ​​indicating higher priority; authentication messages have a slightly lower priority than their corresponding regular messages, and their priority levels are adjacent to ensure that authentication messages and regular messages arrive at similar times; period ( ): The sending cycle of ordinary messages; the authentication message cycle is α times the corresponding ordinary message cycle, because one authentication message needs to be appended for every α ordinary messages sent; transmission time ( ): Calculated according to the worst-case transmission time formula for CAN messages. ,in Bit transmission time (when CAN bandwidth is 500kbps) =2μs), For message payload; the authentication message payload defaults to 8 bytes (worst case), corresponding to the maximum transmission time; deadline ( ):default = This means the message must be transmitted before the start of the next cycle; offset ( ): The time when the message is first released on the bus, which is 0 by default before allocation; the offset of the authentication message must be greater than the offset of the corresponding ordinary message to ensure that the receiving node can verify the ordinary message.

[0021] S102: Determine the period of the authentication message based on the authentication frequency and the period of the ordinary message; calculate the system supercycle based on the period of the ordinary message and the period of the authentication message; generate a release array based on the system supercycle and the time discretization granularity. The initial state of the release array is that all elements are 0. As the message offset is allocated, it is gradually updated to record the message load changes at each time granularity within the supercycle.

[0022] Regarding some of the assumptions: 1. Assumption of periodic harmonic relationship: The vehicle message period contains only a few different values, and the period is an integer multiple (harmonic relationship). The greatest common divisor of all message periods is the minimum period, and the least common multiple is the maximum period; 2. Time Discreteness Assumption: Time is discretized at a granularity of g, and the message offset is a multiple of g; g is greater than the maximum transmission time of a standard CAN message to avoid conflicts between adjacent message transmissions; 3. Ideal network assumptions: The CAN network is a non-preemptive priority queue, where the highest priority message wins the arbitration first, and message release is jitter-free; schedulability is satisfied before message offset allocation, and offset allocation only optimizes WCRT.

[0023] The supercycle H is the least common multiple of all message cycles ( The time relationships of messages within the supercycle are repetitive; therefore, only the load and scheduling within the supercycle need to be analyzed. A release array R is constructed to record the message load at each time granularity within the supercycle H: array length: This refers to the total number of time granularities within the supercycle; array elements: Represents the i-th time granularity (corresponding to time point). The number of messages released, initially all elements are 0; array update: after allocating an offset for each message, update the release time of all instances of that message within the supercycle to R, and increase the number of messages at the corresponding position.

[0024] S103: Sort messages in ascending order based on the period of ordinary messages and the period of authentication messages. Assign offsets to ordinary messages and authentication messages according to the sorting results. Calculate the worst-case response time for ordinary messages and authentication messages before and after offset assignment using time series analysis. Verify the offset assignment optimization effect by comparing the worst-case response times before and after the offset assignment.

[0025] The process of allocating offsets to ordinary messages and authentication messages based on the sorting results includes: Find candidate continuous load intervals; filter for the optimal continuous load interval within the candidate continuous load intervals; determine and set the offset; update the release array R according to the set offset; The continuous load interval is defined as a continuous time granularity interval on the release array R where the load is the same.

[0026] The process of selecting the optimal continuous load interval within the candidate continuous load interval includes: Iterate through all the found load contiguous intervals, set the initial offset to the middle position of the load contiguous interval, calculate the worst-case interference count of the message within the supercycle under the offset distribution, and select the interval with the smallest worst-case interference count as the best load contiguous interval after traversal.

[0027] The timing analysis method is based on a supercycle model, taking into account the release time of message instances, the first release time of high-priority messages, blocking time, and the number of interferences, iteratively calculating the queuing delay and determining the worst-case response time (WCRT).

[0028] The calculation process for the first release time of the high-priority message includes: For high-priority messages First through Determine the smallest positive integer n, then substitute it into... The first release time was obtained, among which The release time of the kth instance of the target message; The iterative calculation formula for queuing delay is as follows: ,initial The iteration termination condition is ,in For high-priority message sets, For high priority messages Transmission time.

[0029] Specifically, offsets are assigned to each message in the order of "normal messages first, then authentication messages" (because authentication messages have a longer cycle time). The specific process is as follows: Message sorting Sort all messages by period from smallest to largest. Since the period of the authentication message is α times that of the corresponding ordinary message, it is naturally placed after the ordinary message. This ensures that the offset of the ordinary message is allocated first, providing a basis for the dependency constraints of the authentication message.

[0030] Finding continuous intervals of candidate load 1. Determine the target load: Traverse the release array R in Find the minimum load value among the elements of the interval (the time granularity range corresponding to the message cycle). ; 2. Extract the continuous load interval: Extract Load within the interval equals All continuous intervals, i.e., load continuous intervals; 3. Filter dependency constraints (authentication messages only): If the current message is an authentication message, it is necessary to further filter the interval where "the time corresponding to the middle position of the interval is greater than the offset of the corresponding ordinary message" to ensure that the authentication message is released after the ordinary message; 4. Increased load threshold: If no candidate interval is found after filtering, the target load value is increased to [value missing]. +1, repeat the above steps until a candidate interval that meets the conditions is found.

[0031] Filtering the optimal continuous load range 1. Calculate the number of interferences: For each candidate interval, take the middle position of the interval (rounded down) as the candidate offset value. Calculate the worst number of disturbances to the message within the time limit under the candidate value (the number of times the high-priority message disturbs the current message); 2. Select the optimal interval: Compare the number of disturbances of all candidate intervals and select the interval with the fewest disturbances as the optimal continuous load interval; if the number of disturbances is the same, prioritize the longer interval to improve the balance of load distribution.

[0032] Determine and set the offset Let the starting position of the optimal interval be B and the ending position be E. Set the offset to the time corresponding to the middle position of the interval: = ⌊(B+E) / 2⌋ × g, where ⌊·⌋ represents rounding down to ensure that the offset is an integer multiple of the time granularity g.

[0033] Update the release array Based on the determined offset Calculate the array indices corresponding to the release times of all instances within the timeout period: For each eligible condition ,Will Increment the value by 1 to complete the array update and provide the latest load data for the offset allocation of subsequent messages.

[0034] To accurately calculate the WCRT with offset messages under the PAE mechanism, a timing analysis model is designed, and the specific steps are as follows: Calculate the number of target message instances Target message Number of instances within supercycle H It is necessary to analyze the response time of each instance and take the maximum value as the message's WCRT.

[0035] Determine blocking time Blocking time refers to the maximum interference time of a low-priority message on the current message. Because the CAN network is non-preemptive, a high-priority message may be blocked by a low-priority message that is currently being transmitted. The calculation formula is: ,in For all priorities lower than The message set, For the message Transmission time.

[0036] Calculate the release time and the first release time of high-priority messages. 1. Instance release time: Message The release time of the kth instance is ; 2. First release time for high-priority messages: For each high-priority message ( , For higher priority (message set), first through Determine the smallest positive integer n (avoiding negative n), then substitute it. ,get exist The first release time after that.

[0037] Iterative calculation of queuing delay and WCRT 1. Initial value setting: Initial value of queuing delay (Includes only its own transmission time); 2. Iterative calculation: Update the queuing delay based on interference from high-priority messages: like , right The kth instance is free from interference; otherwise, the number of interferences is... The queuing delay update formula is: 3. Iteration Termination: When When the iteration converges, at this time... The queuing delay for the kth instance; 4. Calculate WCRT: Messages The WCRT is the sum of the maximum queuing latency of all instances and its own transmission time, i.e. .

[0038] Specifically, the present invention will be further illustrated below through embodiments: Step 1: Define message classification and parameter constraints under the PAE mechanism. First, classify messages into ordinary messages and authentication messages. Ordinary messages serve as the basic data carrier of the CAN network, undertaking the transmission of control commands between ECUs (such as throttle opening and steering angle) and sensor data (such as millimeter-wave radar and camera perception results). Their generation frequency is consistent with the control cycle of the corresponding subsystem. Authentication messages provide security verification support for ordinary messages and are generated periodically at a preset authentication frequency α (i.e., for every α ordinary messages transmitted, one corresponding authentication message is attached). The message body carries an encrypted verification tag for the ordinary message (such as an HMAC hash value or an AES-GCM encryption tag) to ensure that the receiving end can verify that the ordinary message has not been tampered with.

[0039] The parameter constraints are defined as achieving a "balance between security and real-time performance." The core parameters of both types of messages must satisfy period constraints, priority constraints, offset constraints, and transmission time constraints. Period constraints: The period of the authentication message is α times the period of the corresponding ordinary message, ensuring that the authentication frequency matches the transmission rhythm of the ordinary message. Priority constraints: The priority of the authentication message is slightly lower than that of the corresponding ordinary message, and their priority levels are adjacent (e.g., the ordinary message priority is k, and the authentication message priority is k+1), which avoids the authentication message preempting the ordinary message transmission resources and ensures the time correlation between the authentication message and the ordinary message. Offset constraints: The first release time (offset) of the authentication message must be greater than the offset of the corresponding ordinary message, ensuring that the receiver receives the ordinary message first and then completes the verification through subsequent authentication messages, avoiding verification failure caused by timing discrepancies. Transmission time constraints: Because the authentication message carries an encrypted tag, its payload length is fixed at the worst-case scenario (compliant with the CAN bus message payload specification), and its transmission time is calculated according to the worst-case transmission time formula for CAN messages, ensuring sufficient transmission resources are reserved.

[0040] Step 2: System Assumptions for Adapting to In-Vehicle Scenarios. To ensure that the method of this invention is consistent with the characteristics of actual in-vehicle CAN networks, the following three assumptions must be met, and all assumptions must conform to industry-standard design specifications. The assumptions include: Periodic Harmonic Relationship: In the vehicle CAN network, the message periods of the same subsystem are usually integer multiples (e.g., powertrain message periods are mostly 2ms, 4ms, and 8ms), i.e., "harmonic relationship." This assumption ensures the repeatability of time patterns within the super-cycle (the least common multiple of all message periods), simplifying optimization complexity by only analyzing the load and scheduling within the super-cycle. The time discretization assumption involves discretizing time at a fixed time granularity g. The message offset must be an integer multiple of g, and g must be greater than the maximum transmission time of all messages. This avoids message transmission conflicts within adjacent time granularities and ensures that the message scheduling logic matches the non-preemptive transmission characteristics of the CAN bus. The ideal network scheduling assumption is that the CAN network uses a non-preemptive priority arbitration mechanism (the highest priority message gains bus control first), and message release is jitter-free (i.e., messages are released precisely according to a preset period). Simultaneously, all messages satisfy schedulability (WCRT ≤ deadline) before offset allocation. Offset allocation is only used to further optimize WCRT, avoiding the optimization effect being masked by basic schedulability issues.

[0041] Step 3: Construction of the Super-Cycle and Release Array. The super-cycle is defined as H, which is the least common multiple of all message cycles. Its core function is to "cover the time repeatability of all messages." Since the vehicle message cycles exhibit harmonic relationships, the transmission timing of all messages within the super-cycle will completely repeat. Therefore, optimization only needs to be performed on the message load and offset within the super-cycle to cover the scheduling scenarios of the entire network.

[0042] A release array R is constructed to record the message load distribution within a time period in real time. Its length is determined by the ratio of the time period H to the time granularity g (i.e., the array contains...). (There are 1, 2, 3 elements), each element corresponding to a time granularity (e.g., the i-th element corresponds to the time). ); array elements This represents the number of messages released within the corresponding time granularity. Initially, all elements are 0 (no messages released). After allocating an offset for each message, the release time of all instances of that message within the supercycle needs to be calculated (calculated as "offset + k × cycle", where k is a non-negative integer), and the array element value corresponding to the release time is incremented by 1. This allows for real-time feedback on load changes at each time granularity within the supercycle, providing a "low-load interval priority" decision basis for subsequent message offset allocation.

[0043] Step 4: Phased Offset Allocation. Offsets are allocated in the order of "regular messages first, then authentication messages" (since the authentication message period is α times that of regular messages, it is naturally placed later). This ensures that the offset constraint for authentication messages (greater than the corresponding regular message offset) can be implemented. The specific process is as follows: First, all messages are sorted by period from smallest to largest. Regular messages, with smaller periods, are placed first, and authentication messages, with larger periods (α times the regular message period), are placed later. This sorting ensures that the offset allocation for regular messages is completed first, providing a prerequisite for the "offset constraint" of authentication messages. Then, candidate load contiguous intervals are filtered. For each message to be allocated, the time granularity interval from 0 to the message period (i.e., [0, message period / g]) in the release array R is traversed. The filtering rules are as follows: First, find the minimum load value in the interval, and extract all contiguous intervals with loads equal to the minimum value (i.e., "low load contiguous intervals"). Prioritizing low load intervals can reduce time overlap between messages and reduce interference from high-priority messages to the current message. If the message to be allocated is an authentication message, it is necessary to further filter the intervals from the low load contiguous intervals where "the time corresponding to the middle position of the interval is greater than the offset of the corresponding ordinary message" to ensure that the authentication message is released after the ordinary message, thus meeting the verification timing requirements. If no interval meets the conditions after filtering, the target load value is increased by 1 unit, and the above filtering process is repeated until an available interval is found.

[0044] The candidate intervals are traversed, and the best interval is selected through "worst-case interference count evaluation". The middle position of each candidate interval is used as the candidate offset value, and the number of high-priority message interferences received by the message within the supercycle under this candidate value is evaluated (the fewer the interference counts, the greater the potential for message WCRT optimization). The interval with the fewest interference counts is selected first. If there are multiple intervals with the same number of interference counts, the longer interval is selected first (to improve load distribution balance). The time corresponding to the middle position (rounded down) of the best interval is set as the message offset, and this time must be an integer multiple of the time granularity g to ensure consistency with the time discretization assumption.

[0045] After allocating the offset for a message, the release array R is updated immediately. Based on the message offset and period, the array indices corresponding to the release times of all instances within the over-period are calculated, and the element values ​​at these indices are incremented by 1 to provide the latest data support for filtering the load range of the next message.

[0046] Step 5: Adapting the WCRT calculation model to the PAE mechanism. To accurately evaluate the real-time optimization effect after offset allocation, a timing analysis model is designed to calculate the message WCRT. First, the number of instances of the target message within the supercycle H is determined by the ratio of the supercycle to the message period. Then, the response time of each instance is analyzed sequentially. Finally, the maximum value of the response time of all instances is taken as the WCRT of the message (because the timing repeats within the supercycle, the maximum value can represent the worst case in the entire network operation).

[0047] The steps for calculating the WCRT for each instance are as follows: First, calculate the blocking time, which is set to the maximum interference time of low-priority messages on the current message. Since the CAN network is non-preemptive, if a low-priority message is being transmitted when the current message (high priority) is released, it must wait for the low-priority message to finish transmitting before it can preempt the bus. Therefore, the blocking time is the maximum value of the transmission time of all low-priority messages. Then, calculate the instance release time: the release time of the kth instance of the target message = message offset + k × message period, ensuring consistency with the offset allocation result; then, for each high-priority message of the target message, calculate its first release time after the release of the kth instance of the target message (to avoid interference from historical instances of high-priority messages), specifically determined by "rounding up to calculate the smallest positive integer n", ensuring that the first release time is not earlier than the release time of the target message instance. Finally, the WCRT is calculated iteratively using queuing delay. The initial queuing delay is set to the message's own transmission time (without considering any interference). Then, based on the interference of high-priority messages, the queuing delay is iteratively updated. If a high-priority message is transmitted after the target message instance is released, its interference time (number of interferences × high-priority message transmission time) is accumulated, along with the blocking time. When the queuing delay results of two adjacent iterations are consistent, the iteration converges, and the queuing delay at this point is the final queuing delay for that instance. The final WCRT of the message = the maximum queuing delay of all instances + the message's own transmission time, ensuring coverage of the worst-case scenario.

[0048] Step 6: Algorithm Validation. Based on the standard message set commonly used in automotive CAN networks (simulating the message characteristics of actual automotive subsystems, covering ordinary messages and authentication messages of different priorities and periods), the optimization effect is verified in three typical scenarios: single-node, multi-node global asynchrony, and multi-node global synchronization. Experiments are conducted using a message set generated by the open-source tool NETCARBENCH. This message set is suitable for a typical 500k / bps powertrain network, with a workload of 47.80%, 6 ECUs, and 41 messages (82 messages including authentication messages). The authentication frequency is set to 2, and the time granularity is set to 1000μs. Experiments are conducted using VS Code on an AMD Ryzen 5 5600H with Radeon Graphics 3.30GHz six-core processor.

[0049] In a single-node scenario, offsets are allocated to all messages of a single ECU node, and the changes in WCRT before and after allocation are compared. The final result is that "the WCRT of low-priority messages is optimized the most significantly", breaking the linear law of "the lower the priority, the larger the WCRT" in traditional scheduling. This proves that offset allocation can specifically alleviate the interference problem of low-priority messages.

[0050] In a multi-node globally asynchronous scenario, offsets are allocated independently only for messages within each node, with no coordination between nodes. The final result is that "WCRT is reduced compared to when no offset is allocated, but there are local peaks." This indicates that single-node optimization can improve local real-time performance, but the lack of global coordination will limit the overall effect.

[0051] In multi-node global synchronization scenarios, messages from all nodes are uniformly incorporated into the offset allocation system to achieve global coordination. Experiments were conducted to calculate the sum of the WCRTs of all messages. In the case of node asynchrony, the sum of the WCRTs of all messages was 166,850 µs, while in the case of global synchronization between nodes, it was 82,680 µs, a reduction of approximately 50% compared to the node asynchrony scenario. The final result is "a more uniform WCRT distribution with no obvious peaks, and a significant improvement in overall real-time performance compared to the asynchronous scenario," demonstrating that global synchronization optimization can maximize the value of offset allocation and achieve a balance between security and real-time performance under the PAE mechanism.

[0052] Example 2: To achieve the above objectives, based on Example 1, this invention discloses an onboard CAN network offset allocation optimization device under the PAE mechanism, characterized in that it includes: The data receiving module 11 is used to receive the vehicle CAN network message set and system parameters. The vehicle CAN network message set includes ordinary messages and authentication messages corresponding to the ordinary messages. The system parameters include time discretization granularity and authentication frequency. The ordinary messages include period, priority, transmission time, offset, and the dependency relationship between the ordinary messages and the corresponding authentication messages. The period confirmation module 12 is used to determine the period of the authentication message based on the authentication frequency and the period of the ordinary message, calculate the system supercycle based on the period of the ordinary message and the period of the authentication message, and generate a release array based on the system supercycle and the time discretization granularity. The verification optimization module 13 is used to sort messages in ascending order based on the period of ordinary messages and the period of authentication messages. Based on the sorting results, offsets are assigned to ordinary messages and authentication messages. The worst-case response time is calculated using time series analysis methods for ordinary messages and authentication messages before and after offset assignment. The offset assignment optimization effect is verified by comparing the worst-case response times before and after the assignment.

[0053] Based on the same inventive concept, this invention also provides a computer device, comprising: one or more processors, and a memory for storing one or more computer programs; the programs include program instructions, and the processor executes the program instructions stored in the memory. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, used to implement one or more instructions, specifically for loading and executing one or more instructions stored in a computer storage medium to implement the above-described method.

[0054] It should be further explained that, based on the same inventive concept, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, performs the above-described method. This storage medium can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0055] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0056] The foregoing has shown and described the basic principles, main features, and advantages of this disclosure. Those skilled in the art should understand that this disclosure is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of this disclosure. Various changes and modifications can be made to this disclosure without departing from its spirit and scope, and all such changes and modifications fall within the scope of this disclosure as claimed.

Claims

1. A method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism, characterized in that, The method includes the following steps: The system receives a set of vehicle CAN network messages and system parameters. The set of vehicle CAN network messages includes ordinary messages and authentication messages corresponding to the ordinary messages. The system parameters include time discretization granularity and authentication frequency. The ordinary messages include period, priority, transmission time, offset, and the dependency relationship between the ordinary messages and the corresponding authentication messages. The period of the authentication message is determined based on the authentication frequency and the period of the ordinary message. The system supercycle is calculated based on the period of the ordinary message and the period of the authentication message. A release array is generated based on the system supercycle and the time discretization granularity. Messages are sorted in ascending order based on the period of ordinary messages and the period of authentication messages. Offsets are assigned to ordinary messages and authentication messages according to the sorting results. The worst-case response time is calculated using time series analysis methods for ordinary messages and authentication messages before and after the offsets are assigned. The effect of offset allocation optimization is verified by comparing the worst-case response times before and after the offsets are assigned.

2. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 1, characterized in that, The dependency relationship between the ordinary message and the corresponding authentication message is that the offset of the authentication message is greater than the offset of the corresponding ordinary message.

3. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 1, characterized in that, The setting of the time discretization granularity: Based on the assigned message offset, the message offset is set to an integer multiple of the time discretization granularity g, and the time discretization granularity g is greater than the maximum transmission time of a standard CAN message.

4. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 1, characterized in that, The initial state of the release array is that all elements are 0. As the message offset is allocated, it is gradually updated to record the message load changes at each time granularity within the supercycle.

5. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 1, characterized in that, The process of allocating offsets to ordinary messages and authentication messages based on the sorting results includes: Find candidate continuous load intervals; filter the optimal continuous load intervals within the candidate continuous load intervals; determine and set the offset; update the release array R according to the set offset; The continuous load interval is defined as a continuous time granularity interval on the release array R where the load is the same.

6. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 5, characterized in that, The process of selecting the optimal continuous load interval within the candidate continuous load interval includes: Iterate through all the found load contiguous intervals, set the initial offset to the middle position of the load contiguous interval, calculate the worst-case interference count of the message within the supercycle under the offset distribution, and select the interval with the smallest worst-case interference count as the best load contiguous interval after traversal.

7. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 1, characterized in that, The timing analysis method is based on a supercycle model, taking into account the release time of message instances, the first release time of high-priority messages, blocking time, and the number of interferences, iteratively calculating the queuing delay and determining the worst-case response time (WCRT).

8. The method for optimizing offset allocation in a vehicle-mounted CAN network under a PAE mechanism according to claim 7, characterized in that, The calculation process for the first release time of the high-priority message includes: For high-priority messages First through Determine the smallest positive integer n, then substitute it into... The first release time was obtained, among which The release time of the kth instance of the target message; The iterative calculation formula for queuing delay is as follows: ,initial The iteration termination condition is ,in For high-priority message sets, For high-priority messages Transmission time.

9. A vehicle CAN network offset allocation optimization device under the PAE mechanism, employing the vehicle CAN network offset allocation optimization method under the PAE mechanism as described in any one of claims 1 to 8, characterized in that... include: The data receiving module is used to receive vehicle CAN network message sets and system parameters. The vehicle CAN network message set includes ordinary messages and authentication messages corresponding to the ordinary messages. The system parameters include time discretization granularity and authentication frequency. The ordinary messages include period, priority, transmission time, offset, and the dependency relationship between the ordinary messages and the corresponding authentication messages. The periodic confirmation module is used to determine the period of authentication messages based on the authentication frequency and the period of ordinary messages, calculate the system over-period based on the period of ordinary messages and the period of authentication messages, and generate a release array based on the system over-period and time discretization granularity. The verification optimization module sorts messages in ascending order based on the period of ordinary messages and the period of authentication messages. It assigns offsets to ordinary messages and authentication messages according to the sorting results. It then uses time series analysis to calculate the worst-case response time for ordinary messages and authentication messages before and after offset assignment. The optimization effect of offset assignment is verified by comparing the worst-case response times before and after offset assignment.

10. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, The memory stores a computer program that can run on the processor. When the processor loads and executes the computer program, it employs a vehicle CAN network offset allocation optimization method under the PAE mechanism according to any one of claims 1 to 8.