A message delay simulation method, device and equipment
By estimating the planned sending time and actual sending time of messages on the CAN bus, the target sending delay of messages is determined, and the problem of delay of messages on the CAN bus is solved, and a simple and reliable simulation solution is realized.
Patent Information
- Application Number
- CN202310779047.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-28
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2043-06-28
AI Technical Summary
The conflict and delay problems of packets on the CAN bus have not been effectively resolved, and there is a lack of specific simulation solutions.
By obtaining the bus transmission rate and the type, length and identification of the messages to be processed, the planned transmission time and transmission duration of each message in the first time period are estimated, and the target transmission delay of the message is determined.
It realizes the target sending delay of packets through simulation, and has the characteristics of simple and reliable implementation, solving the problem of message delay on the CAN bus.
Smart Images

Figure CN116684325B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vehicle technology, and relates to but is not limited to a message delay simulation method, device and equipment. Background Art
[0002] In recent years, the Controller Area Network (CAN) bus has become the most widely used communication standard in automotive electronic control systems. More and more network nodes are controlling and communicating on the CAN bus, which leads to conflicts and delays in messages on the CAN bus.
[0003] In order to solve these problems, a delay simulation of CAN bus messages is proposed, but there is no specific simulation solution at present. Summary of the invention
[0004] The present application provides a message delay simulation method, device, equipment and storage medium. The solution can obtain the target sending delay of the message through simulation, and has the characteristics of simple implementation and reliability.
[0005] The technical solution of this application is implemented as follows:
[0006] In a first aspect, the present application provides a message delay simulation method, the method comprising:
[0007] Obtaining a bus transmission rate and a message type, a message length and a message identifier of N messages to be processed; wherein N is an integer greater than 1;
[0008] At least based on the bus transmission rate, the message type and the message length of the N messages, estimate the planned transmission time of each of the N messages in all times within the first time period and the transmission duration of all times within the first time period;
[0009] estimating actual sending times of all the N messages in the first time period based at least on all sending durations of the N messages in the first time period and message identifiers of the N messages;
[0010] For each of the N messages, a target sending delay of the message is determined based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period.
[0011] In a second aspect, the present application provides a message delay simulation device, the device comprising:
[0012] An obtaining unit, used to obtain a bus transmission rate and a message type, a message length and a message identifier of N messages to be processed; wherein N is an integer greater than 1;
[0013] A first estimation unit, configured to estimate, based at least on the bus transmission rate, the message type and the message length of the N messages, all the planned transmission times of each of the N messages in a first time period and all the transmission durations in the first time period;
[0014] A second estimating unit, configured to estimate actual sending times of all the N messages in the first time period based at least on the sending durations of all the N messages in the first time period and the message identifiers of the N messages;
[0015] A determination unit is used to determine, for each of the N messages, a target sending delay of the message based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period.
[0016] In a third aspect, the present application further provides an electronic device, comprising: a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the above-mentioned message delay simulation method when executing the program.
[0017] In a fourth aspect, the present application also provides a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned message delay simulation method is implemented.
[0018] The message delay simulation method, device, equipment and storage medium provided in the present application include: obtaining a bus sending rate and a message type, a message length and a message identifier of N messages to be processed; wherein N is an integer greater than 1; estimating, at least based on the bus sending rate, the message type and the message length of the N messages, the planned sending time of all times of each of the N messages in a first time period and the sending duration of all times in the first time period; estimating, at least based on the sending duration of all times of the N messages in the first time period and the message identifier of the N messages, the actual sending time of all times of the N messages in the first time period; for each of the N messages, determining, based on the planned sending time of all times of the message in the first time period and the actual sending time of all times of the message in the first time period, the target sending delay of the message.
[0019] For the scheme of the present application, the N messages to be processed and the sending rate of the bus to be occupied when the message is sent can be determined first, and then the planned sending time and sending duration of the message are estimated based on the bus sending rate, the type and length of the message, and then the actual sending time of the message is estimated based on the sending duration and the message identifier, so as to determine the message delay based on the planned sending time and the actual sending time (in practice, all delays of N messages in a period of time can be counted). It can be seen that the whole process does not need to be actually sent through the bus, and the message delay can be estimated by simulation, which has the characteristics of simple implementation and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of a first optional flow chart of a message delay simulation method provided in an embodiment of the present application;
[0021] Figure 2 A second optional flow chart of the message delay simulation method provided in the embodiment of the present application;
[0022] Figure 3 A third optional flow chart of the message delay simulation method provided in the embodiment of the present application;
[0023] Figure 4 A fourth optional flow chart of the message delay simulation method provided in the embodiment of the present application;
[0024] Figure 5 A fifth optional flow chart of the message delay simulation method provided in the embodiment of the present application;
[0025] Figure 6 A sixth optional flow chart of the message delay simulation method provided in the embodiment of the present application;
[0026] Figure 7 A seventh optional flow chart of the message delay simulation method provided in the embodiment of the present application;
[0027] Figure 8 An optional structural diagram of a message delay simulation device provided in an embodiment of the present application;
[0028] Fig. 9 An optional structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.
[0030] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0031] In the following description, the terms "first\second\third" are used only as examples to distinguish different objects, and do not represent a specific order for the objects, nor do they have a limitation on the order of precedence. It is understandable that "first\second\third" can be interchanged with a specific order or order of precedence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0033] The embodiments of the present application provide a message delay simulation method, device, equipment and storage medium. In practical applications, the message delay simulation method can be implemented by a message delay simulation device, and each functional entity in the message delay simulation device can be collaboratively implemented by hardware resources of electronic equipment, such as computing resources such as processors, and communication resources (such as for supporting various communication methods such as optical cables and cellular).
[0034] The following describes various embodiments of the message delay simulation method, apparatus, device, and storage medium provided in the embodiments of the present application.
[0035] In a first aspect, an embodiment of the present application provides a message delay simulation method, which is applied to a message delay simulation device, and the message delay simulation device can be deployed in an electronic device. Specifically, the method is implemented by calling a program code by a processor included in the electronic device, and of course the program code can be stored in a computer storage medium. It can be seen that the electronic device at least includes a processor and a storage medium.
[0036] Below, taking an electronic device as an execution subject as an example, the message delay simulation method provided in an embodiment of the present application is explained.
[0037] Figure 1 Schematic diagram of the flow of the message delay simulation method of the embodiment of the present application, such as Figure 1 As shown, the process may include but is not limited to the following S101 to S104.
[0038] S101: The electronic device obtains a bus transmission rate and message types, message lengths and message identifiers of N messages to be processed.
[0039] An electronic device refers to an electronic device with relevant data processing capabilities. The specific type of the electronic device is not limited in the embodiments of the present application. For example, the electronic device may be a server, a laptop computer, a desktop computer, etc.
[0040] N is an integer greater than 1. The specific value of N is not limited in the embodiment of the present application and is configured according to actual needs.
[0041] The N messages to be processed refer to the messages whose delay needs to be simulated. In a possible implementation, the N messages to be processed may be CAN messages. It is understandable that they may also be other messages sent in a serial manner.
[0042] The bus refers to the bus when the N messages to be processed are actually sent. Exemplarily, the bus here can be a CAN bus.
[0043] The bus transmission rate refers to the amount of message data sent through the bus per unit time. It can also be replaced by bit time. Bit time refers to the time required to send one bit of data. Among them, the bus transmission rate can be a fixed value or a floating value within a period of time.
[0044] The message type may include but is not limited to one or more of the following: periodic messages, event-triggered messages.
[0045] The message length is used to indicate the number of bits occupied by the message data.
[0046] The message identifier is used to uniquely point to a message. The embodiment of the present application does not specifically limit the composition of the message identifier, and can be configured according to actual conditions. Among them, the message identifier can also be called a message ID.
[0047] S101 can be implemented as follows: the electronic device first determines N messages to be processed, and then determines the message type, message length and message identifier of each message; and determines the corresponding bus transmission rate according to the bus to which the N messages to be processed belong when they are sent.
[0048] S102. The electronic device estimates, based at least on the bus sending rate, the message type and the message length of the N messages, the planned sending time of all times of each of the N messages in the first time period and the sending duration of all times in the first time period.
[0049] The embodiment of the present application does not specifically limit the value of the first time period, and can be configured according to actual needs. For example, the first time period can be 10 minutes, or 1 day, etc.
[0050] A message may be sent multiple times in the first time period, and all times is the number of times a message is sent in the first time period.
[0051] Planned delivery time refers to the set delivery time; it can also be understood as the expected delivery time.
[0052] The sending duration of a message refers to the time required for a message to be transmitted on the bus.
[0053] S102 can be implemented as follows: the electronic device estimates the sending duration of each of the N messages all times in the first time period based at least on the message length of the N messages at the bus sending rate; and estimates the planned sending time of each of the N messages all times in the first time period based at least on the message type of the N messages and the sending duration of each message all times in the first time period.
[0054] S103: The electronic device estimates actual sending times of all the N messages in the first time period based at least on the sending durations of all the N messages in the first time period and the message identifiers of the N messages.
[0055] The actual sending time refers to the sending time after the actual sending process is affected by other messages.
[0056] S104: The electronic device determines, for each of the N messages, a target sending delay of the message based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period.
[0057] Sending delay refers to the difference between the actual sending time and the planned sending time.
[0058] The target sending delay may include but is not limited to: single sending delay and average sending delay.
[0059] S104 can be implemented as follows: the electronic device executes, for each of the N messages: based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period, determining the target sending delay of the message; and the electronic device traverses the N messages in the same manner to obtain the target sending delay of the N messages.
[0060] The message delay simulation method provided in the present application includes: obtaining a bus sending rate and a message type, a message length and a message identifier of N messages to be processed; wherein N is an integer greater than 1; estimating, at least based on the bus sending rate, the message type and the message length of the N messages, the planned sending time of all times of each of the N messages in a first time period and the sending duration of all times in the first time period; estimating, at least based on the sending duration of all times of the N messages in the first time period and the message identifier of the N messages, the actual sending time of all times of the N messages in the first time period; and determining, for each of the N messages, a target sending delay of the message based on the planned sending time of all times of the message in the first time period and the actual sending time of all times of the message in the first time period.
[0061] For the scheme of the present application, the N messages to be processed and the sending rate of the bus to be occupied when the message is sent can be determined first, and then the planned sending time and sending duration of the message are estimated based on the bus sending rate, the type and length of the message, and then the actual sending time of the message is estimated based on the sending duration and the message identifier, so as to determine the message delay based on the planned sending time and the actual sending time (in practice, all delays of N messages in a period of time can be counted). It can be seen that the whole process does not need to be actually sent through the bus, and the message delay can be estimated by simulation, which has the characteristics of simple implementation and reliability.
[0062] The following describes a process in which the electronic device estimates the actual sending times of all the N messages in the first time period based on at least the sending durations of all the N messages in the first time period and the message identifiers of the N messages in S103.
[0063] In one possible implementation, reference Figure 2 As shown in the content, the process may include but is not limited to the following S1031 to S1034.
[0064] S1031. The electronic device divides the first time period into multiple first step time periods based on a first duration, and for each of the multiple first step time periods, determines at least one message in each of the first step time periods based on all planned sending times of the N messages in the first time period.
[0065] The embodiment of the present application does not specifically limit the value of the first duration, and can be configured according to actual conditions. For example, the first duration can be 5 milliseconds.
[0066] S1031 can be implemented as follows: the electronic device divides the first time period into multiple first step time periods based on the first time length, and executes for each of the multiple first step time periods; based on all the planned sending times of N messages in the first time period, if the planned sending time is included in the first step time period, then the message is determined to be the message of the first step time period, and all the planned sending times of all messages in the first time period are traversed to obtain at least one message in each first step time period.
[0067] Exemplarily, the N messages include: message 1, message 2, message 3, message 4, message 5, message 6, message 7, and message 8. The first time period is from 1:00 to 1:10; and the first duration is 1 minute.
[0068] The corresponding multiple first step time periods may include: first step time period 1 (1:00-1:01), first step time period 2 (1:01-1:02), first step time period 3 (1:02-1:03), first step time period 4 (1:03-1:04), first step time period 5 (1:04-1:05), first step time period 6 (1:05-1:06), first step time period 7 (1:06-1:07), first step time period 8 (1:07-1:08), first step time period 9 (1:08-1:09), first step time period 10 (1:09-1:10).
[0069] The messages in the first step time period 1 (1:00-1:01) may include: message 1, message 3, message 7;
[0070] The messages in the first step time period 2 (1:01-1:02) may include: message 2, message 4;
[0071] The messages in the first step time period 3 (1:02-1:03) may include: message 1, message 5, message 8;
[0072] The messages in the first step time period 4 (1:03-1:04) may include: message 3, message 4, message 6;
[0073] The messages in the first step time period 5 (1:04-1:05) may include: message 1, message 7;
[0074] The messages in the first step time period 6 (1:05-1:06) may include: message 4, message 5;
[0075] The messages in the first step time period 7 (1:06-1:07) may include: message 1, message 3;
[0076] The messages in the first step time period 8 (1:07-1:08) may include: message 4, message 6;
[0077] The messages in the first step time period 9 (1:08-1:09) may include: message 1, message 5, message 7;
[0078] The messages in the first step time period 10 (1:09-1:10) may include: message 3 and message 4.
[0079] S1032: The electronic device arbitrates at least one message in each of the first step time periods based on a message identifier of the at least one message to obtain a message sending order in the first step time period.
[0080] Exemplarily, the messages are sorted in ascending order according to the message identifiers, and the sorting is determined as the message sending order.
[0081] S1033. The electronic device estimates the actual sending time of each of the at least one message at the current time based at least on the message sending order and the sending duration of each of the at least one message at the current time.
[0082] Exemplarily, if the message sending order includes: message 1, message 2, message 3, message 4; among which, the sending duration of message 1 is 10 seconds; the sending duration of message 2 and message 3 is 20 seconds; the sending duration of message 4 is 15 seconds; then the current sending time of message 1 is determined to be 1:00:00; the current sending time of message 2 is 1:00:10; the current sending time of message 3 is 1:00:30; and the current sending time of message 4 is 1:00:50.
[0083] For example, an interval time may be added to determine the first sending time. Assuming the interval is 2 seconds, the current sending time of message 1 is 1:00:00; the current sending time of message 2 is 1:00:12; the current sending time of message 3 is 1:00:34; and the current sending time of message 4 is 1:00:56.
[0084] S1034. The electronic device traverses at least one message in each of the first step time periods in the multiple first step time periods to obtain actual sending times of all the N messages in the first time period.
[0085] The electronic device executes the above S1032 and S1033 for at least one message in each first step time period, and obtains the actual sending time of all times of the N messages in the first time period.
[0086] Here, since arbitration will affect the order of messages, when a message arrives at the scheduled sending time, it may not be sent in time due to arbitration, that is, delayed sending; this situation corresponds to the scenario in the actual sending process, and when the actual sending time is obtained, it has a higher accuracy.
[0087] Below, the process of the electronic device in S102 estimating the planned sending time of all times of each of the N messages in the first time period and the sending duration of all times in the first time period based on at least the bus sending rate, the message type and the message length of the N messages is described.
[0088] refer to Figure 3 As shown in the content, the process may include but is not limited to the following S1021 and S1022.
[0089] S1021. The electronic device estimates, for each of the N messages, at least based on a message length and a bus transmission rate of the message, all transmission durations of the message within the first time period.
[0090] The embodiment of the present application does not limit the specific method of estimating the duration of all transmissions of the message within the first time period, and can be configured according to actual conditions.
[0091] For example, the bus transmission rate corresponding to one message in one transmission can be converted into a bit time, and then the product of the bit time and the message length is determined as the transmission duration.
[0092] S1022. The electronic device determines, based at least on the message type, all planned sending times of each of the N messages within the first time period.
[0093] Here, for different message types, the method of obtaining the planned sending time is different.
[0094] The following describes a process in which the electronic device estimates, for each of the N messages, at least based on the message length and bus transmission rate of the message, all transmission durations of the message within the first time period in S1021.
[0095] The process may include but is not limited to the following method A1 or method A2.
[0096] Mode A1: When the sending rate of the bus is a fixed value, the sending duration of all times of the corresponding message in the first time period is estimated;
[0097] Mode A2: When the sending rate of the bus corresponding to each sending is a floating value, the sending duration of all times of the message in the first time period is estimated accordingly.
[0098] Next, the process of estimating the duration of all transmissions of the message in the first time period when the transmission rate of the bus in mode A1 is a fixed value is described.
[0099] The process may include: the electronic device converts the fixed bus transmission rate into a fixed bit time, and determines the product of the bit time and the message length as the transmission duration of the message, that is, the transmission duration of all times of the message in the first time period is the transmission time.
[0100] It can be seen that method A1 is simple to implement.
[0101] Next, the process of estimating the duration of all transmissions of the message in the first time period when the transmission rate of the bus corresponding to mode A2 is a floating value each time is described.
[0102] refer to Figure 4 As shown in the content, the process may include but is not limited to the following S401 to S404.
[0103] S401. The electronic device obtains an average value and a fluctuation range of the bus transmission rate, and generates a bus transmission rate reference library in a positive distribution manner based on the average value and the fluctuation range of the bus transmission rate.
[0104] Exemplarily, a bus transmission rate reference library can be generated by matlab software. Specifically, the average value and fluctuation range of the bus transmission rate and the quantity (bus transmission rate) are input into matlab, and the bus transmission rate of the quantity is generated by ecological distribution.
[0105] S402: The electronic device generates a first random number based on the current message.
[0106] Here, one number corresponds to one first random number. For example, the current number can be input into a random algorithm, and the random algorithm generates a first random number according to the number.
[0107] The value range of the first random number is from 0 to the number of the bus sending rate.
[0108] S403: The electronic device determines the current bus sending rate in the bus sending rate reference library based on the first random number.
[0109] The electronic device searches for the bus transmission rate corresponding to the first random number in a bus transmission rate reference library, and uses the bus transmission rate as the current bus transmission rate.
[0110] In this way, different bus transmission rates can be obtained for different transmission times.
[0111] S404: The electronic device determines the current sending duration of the message based on the message length of the message and the current bus sending rate; and traverses all times within the first time period to obtain the sending duration of all times of the message within the first time period.
[0112] The electronic device converts the current bus sending rate of the message into bit time, and takes the product of the bit time and the message length as the current sending duration of the message. The electronic device traverses all bus sending rates of the message to obtain all sending durations of the message.
[0113] Since the actual bus transmission rate is not necessarily fixed and may be affected by interference, the actual bus transmission rate generally satisfies the law of normal distribution. Therefore, method A2 has the characteristics of high accuracy and high conformity with reality.
[0114] The following describes a process in S1022 where the electronic device determines all planned sending times of each of the N messages within the first time period based at least on the message type.
[0115] The process may include but is not limited to the following method B1 or method B2.
[0116] Method B1: for periodic messages, determine the planned sending time of all messages within the first time period;
[0117] Mode B2: for event-triggered messages, determine all planned sending times of the messages within the first time period.
[0118] Next, the process of determining all the planned sending times of the periodic message within the first time period in mode B1 is described.
[0119] In one possible implementation, reference Figure 5 As shown in the content, the process may include but is not limited to the following S501 to S503.
[0120] In the case where the N messages include O periodic messages of periodic type, O is an integer greater than or equal to 1, and for each of the O periodic messages, S501 to S503 are executed.
[0121] S501. The electronic device arbitrates the O periodic messages based on the message identifiers of the O periodic messages to obtain a first sending order of the O periodic messages.
[0122] Exemplarily, the O periodic messages are sorted in ascending order according to the message identifiers, and the sorting is determined as the first sending order of the O periodic messages.
[0123] S502. The electronic device determines the first sending time of each of the O periodic messages based at least on the first sending order and the first sending duration of the O periodic messages.
[0124] Exemplarily, if the first sending order includes: periodic message 1, periodic message 2, periodic message 3, periodic message 4; wherein, the sending duration of periodic message 1 is 10 seconds; the sending duration of periodic message 2 and periodic message 3 is 20 seconds; the sending duration of periodic message 4 is 15 seconds; then the first sending time of periodic message 1 is determined to be 1:00:00; the first sending time of periodic message 2 is 1:00:10; the first sending time of periodic message 3 is 1:00:30; and the first sending time of periodic message 4 is 1:00:50.
[0125] For example, an interval time may be added to determine the first sending time. Assuming the interval is 2 seconds, the first sending time of periodic message 1 is determined to be 1:00:00; the first sending time of periodic message 2 is determined to be 1:00:12; the first sending time of periodic message 3 is determined to be 1:00:34; and the first sending time of periodic message 4 is determined to be 1:00:56.
[0126] S503. The electronic device determines, for each of the O periodic messages, the planned sending time of all the periodic messages within the first time period, taking the first sending time of the periodic message as the starting point and at least based on all sending cycles of the periodic message within the first time period.
[0127] For example, for periodic message 1, assuming that the sending period of periodic message 1 is 100 seconds, the planned sending time of periodic message 1 in the first time period may include: 00 seconds, 100 seconds, 200 seconds, 300 seconds, 400 seconds, and 600 seconds.
[0128] For periodic message 2, assuming that the sending period of periodic message 2 is 200 seconds, the corresponding first sending time of periodic message 2 is: 10 seconds, then the planned sending time of periodic message 1 in the first time period may include: 10 seconds, 210 seconds, 410 seconds.
[0129] Below, the process of determining the planned sending time of all the periodic messages within the first time period by the electronic device in S503 with the first sending time of the periodic message as the starting point and at least based on all the sending cycles of the periodic message within the first time period is described.
[0130] In one possible implementation, reference Figure 6 As shown in the content, the process may include but is not limited to the following S5031 to S5034.
[0131] S5031. The electronic device obtains an average value and a fluctuation range of the periodic message sending cycle, and generates a sending cycle reference library in a positive distribution manner based on the average value and the fluctuation range of the sending cycle.
[0132] The implementation of S5031 can refer to the electronic device in S401 to obtain the average value and fluctuation range of the bus sending rate, and based on the average value and fluctuation range of the bus sending rate, a detailed description of the bus sending rate reference library is generated by a positive distribution method, which will not be repeated here.
[0133] S5032. The electronic device generates a second random number based on the current sending of the periodic message; and determines the current sending cycle of the periodic message in the sending cycle reference library based on the second random number.
[0134] The implementation of S5032 may refer to the detailed description of S402 and S403, which will not be described in detail here.
[0135] S5033: The electronic device takes the first sending time of the periodic message as a starting point and determines the current planned sending time of the periodic message based on the current sending cycle of the periodic message.
[0136] The electronic device determines that the current planned sending time of the periodic message is a time corresponding to the current sending period offset backward from the first sending time of the message.
[0137] S5034. The electronic device traverses all sending cycles in the first time period to obtain all planned sending times of the periodic message in the first time period.
[0138] In the same way, the times corresponding to all sending cycles in the first time period of the message are shifted backward by the first sending time of the message to obtain the corresponding planned sending time corresponding to the cycle.
[0139] Next, the process of determining all the planned sending times of the event-triggered message within the first time period in mode B2 is described.
[0140] refer to Figure 7 As shown in the content, the process may include but is not limited to the following S701 and S702.
[0141] In the case where the N messages include P event-triggered messages, where P is an integer greater than or equal to 1, the following S701 and S702 are performed for each of the P event-triggered messages.
[0142] S701. The electronic device divides the first time period into a plurality of second step time periods based on a second duration, and determines a triggering probability of the event-triggered message in each of the plurality of second step time periods.
[0143] The second duration is greater than the first duration.
[0144] The embodiment of the present application does not specifically limit the specific value of the second duration, and can be configured according to actual conditions. For example, the second duration can be 100 milliseconds.
[0145] Exemplarily, the electronic device first obtains a trigger probability curve of a time-triggered message in a first time period, and then divides the first time period into a plurality of second step times on the time axis based on a second duration, and then determines the trigger probability of winning the bet in each second step time period according to the value of the curve in each second step time period. For example, the middle value or average value in a second step time period can be determined as the trigger probability of the second step time period.
[0146] S702: The electronic device determines all the planned sending times of the event-triggered message within the first time period based on the triggering probabilities of all the second step time periods within the first time period.
[0147] The same method as in S701 can be used to obtain all the planned sending times of the event-triggered message in the first time period.
[0148] Next, the process of determining the target sending delay of the message by the electronic device in S104 based on all the planned sending times of the message in the first time period and all the actual sending times of the message in the first time period is described.
[0149] The process may include but is not limited to the following method C1 or method C2.
[0150] Mode C1: Target sending delay includes single sending delay, which determines the target sending delay of the message;
[0151] Mode C2: The target sending delay includes the average sending delay, and the target sending delay of the message is determined.
[0152] Next, the target transmission delay in mode C1 includes a single transmission delay, and a process of determining the target transmission delay of a message is described.
[0153] The process may include: the electronic device determines the single transmission delay of each time based on the planned transmission time and the actual transmission time of each time of the message in the first time period; traverses all times of the message in the first time period to obtain the single transmission delay of all times of the message in the first time period.
[0154] Next, the target sending delay in mode C2 includes the average sending delay, and the process of determining the target sending delay of the message is described.
[0155] The process may include: the electronic device determines each single transmission delay of the message based on each planned transmission time and each actual transmission time of the message in the first time period; and determines the average transmission delay of the message in the first time period based on all single transmission delays of the message in the first time period.
[0156] The message delay simulation method provided by the embodiment of the present application can also output the target delay of the message.
[0157] Specifically, the electronic device outputs, for each of the N messages, all single transmission delays of the message in the first time period in the form of a graph or a table; and / or outputs the average transmission delay of the message in the first time period in the form of a graph or a table.
[0158] It is understandable that the electronic device may also use other output formats.
[0159] Below, the message delay simulation method provided in the embodiment of the present application is explained through a specific complete process.
[0160] In simple terms, the delay of each message is estimated through statistical probability distribution and adjustment of various sending parameters, and a list and chart are formed.
[0161] Specifically, it may include but not be limited to the following steps 1 to 11.
[0162] Step 1: Analyze the vehicle usage scenario and manually assign trigger probabilities to each event-triggered message in the communication database;
[0163] Step 2: The program sorts the first transmission order of each message in this simulation according to the arbitration priority of the message ID of each periodic message in the communication database;
[0164] Step 3: According to the CAN bus rate and the communication database, the bus duration (equivalent to the above-mentioned sending duration) and the sending time point (equivalent to the above-mentioned planned sending time) occupied by each periodic message when it is first sent are determined using normal distribution;
[0165] Step 4: According to the rate of the CAN bus and the communication database, the sending time point calculated in the previous step is used as the offset, and the normal distribution is used to determine all sending time points, end time points and sending duration of each message in a given time length T (equivalent to the first time period) ignoring other interferences;
[0166] Step 5: Taking each unit time (such as 100ms) as the step length, step from 0 to the fixed time length T. Probability calculation is performed on each event-triggered message in each step. According to the rate of the CAN bus and the communication database, all sending time points (equivalent to the above-mentioned planned sending time), end time points and sending duration of the event-triggered message ignoring other interferences are given;
[0167] Step 6: Take each unit time (such as 5ms) as the step length, and step from 0 to the fixed time length T. Each step executes steps 7 and 8.
[0168] Step 7: Determine the message sending time point, end time point and sending duration generated in step 4 and step 5, and sort the messages falling within this step time period according to the arbitration priority of the message ID;
[0169] Step 8: After sorting, the actual sending time point of the relevant message is increased by an offset according to the sending time point and sending duration of the messages within the range;
[0170] Step 9: If the difference between the actual sending time point and the planned sending time point is greater than one message cycle, it is marked as the message sending loss, otherwise the offset is recorded;
[0171] Step 10, proceed to a given time T according to step 6;
[0172] Step 11: Output the offset of each message sent to a table file and draw a distribution graph. The program execution ends and the simulation results are output.
[0173] This embodiment uses a simple and direct method to perform CAN bus message delay simulation, making the control and communication of the vehicle more accurate and stable, while eliminating the need for complex algorithms and equipment, reducing costs and improving reliability.
[0174] In a second aspect, the present application embodiment provides a message delay simulation device, such as Figure 8 As shown, the message delay simulation device 80 includes an obtaining unit 801 , a first estimating unit 802 , a second estimating unit 803 and a determining unit 804 .
[0175] in:
[0176] The obtaining unit 801 is used to obtain the bus transmission rate and the message type, message length and message identifier of N messages to be processed; wherein N is an integer greater than 1;
[0177] A first estimating unit 802, configured to estimate the planned sending time of all times of each of the N messages in the first time period and the sending duration of all times in the first time period based at least on the bus sending rate, the message type and the message length of the N messages;
[0178] A second estimating unit 803, configured to estimate actual sending times of all the N messages in the first time period based at least on the sending durations of all the N messages in the first time period and the message identifiers of the N messages;
[0179] The determination unit 804 is used to determine, for each of the N messages, a target sending delay of the message based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period.
[0180] In some embodiments, the second estimation unit 803 is further configured to:
[0181] The first time period is divided into a plurality of first step time periods based on a first duration, and for each of the plurality of first step time periods, based on the planned sending times of the N messages all times within the first time period, at least one message within each of the first step time periods is determined; for at least one message within each of the first step time periods, the at least one message is arbitrated based on a message identifier of the at least one message to obtain a message sending order within the first step time period; and, based at least on the message sending order and the current sending duration of each of the at least one message, an actual sending time of each of the at least one message at the current time is estimated; and at least one message within each of the plurality of first step time periods is traversed to obtain the actual sending times of the N messages all times within the first time period.
[0182] In some embodiments, the first estimation unit 802 is also used to: for each of the N messages, estimate the duration of all transmissions of the message within the first time period based at least on the message length and bus transmission rate of the message; and determine the planned transmission time of all transmissions of each of the N messages within the first time period based at least on the message type.
[0183] In some embodiments, the first estimation unit 802 is further configured to:
[0184] Obtain an average value and a fluctuation range of the bus sending rate, and based on the average value and the fluctuation range of the bus sending rate, generate a bus sending rate reference library in a positive distribution manner; generate a first random number based on the current time of the message; determine the current bus sending rate in the bus sending rate reference library based on the first random number; determine the sending duration of the message at the current time based on the message length of the message and the current bus sending rate; traverse all times within the first time period to obtain the sending duration of all times of the message within the first time period.
[0185] In some embodiments, the first estimation unit 802 is further configured to:
[0186] In the case where the N messages include O periodic messages of periodic type, O is an integer greater than or equal to 1, and for each of the O periodic messages, the following processing is performed: the O periodic messages are arbitrated based on the message identifiers of the O periodic messages to obtain the first sending order of the O periodic messages; the first sending time of each of the O periodic messages is determined based at least on the first sending order and the first sending duration of the O periodic messages; for each of the O periodic messages, the planned sending time of the periodic message all times within the first time period is determined, taking the first sending time of the periodic message as the starting point and at least based on all sending cycles of the periodic message within the first time period.
[0187] In some embodiments, the first estimation unit 802 is further configured to:
[0188] Obtain an average value and a fluctuation range of the periodic message sending cycle, and based on the average value and the fluctuation range of the sending cycle, generate a sending cycle reference library in a positive distribution manner; generate a second random number based on the current sending times of the periodic message; and determine the current sending cycle of the periodic message in the sending cycle reference library based on the second random number; take the first sending time of the periodic message as the starting point, and determine the current scheduled sending time of the periodic message based on the current sending cycle of the periodic message; traverse all sending cycles within the first time period to obtain all the scheduled sending times of the periodic message within the first time period.
[0189] In some embodiments, the first estimation unit 802 is further configured to:
[0190] In the case where the N messages include P messages of event-triggered type, P is an integer greater than or equal to 1, and the following processing is performed for each of the P event-triggered messages: dividing the first time period into multiple second step time periods based on a second duration, and determining the triggering probability of the event-triggered message in each of the multiple second step time periods; the second time period is greater than the first time period; based on the triggering probabilities of all second step time periods within the first time period, determining the planned sending time of all times of the event-triggered message within the first time period.
[0191] In some embodiments, the determining unit 804 is further configured to:
[0192] In the case where the target sending delay includes a single sending delay, determining each single sending delay based on each planned sending time and each actual sending time of the message in the first time period; traversing all times of the message in the first time period to obtain all single sending delays of the message in the first time period;
[0193] And / or, when the target sending delay includes the average sending delay, the single sending delay is determined based on the planned sending time of the message each time and the actual sending time of each time in the first time period; and the average sending delay of the message in the first time period is determined based on all single sending delays of the message in the first time period.
[0194] In some embodiments, the message delay simulation device 80 may also include an output unit, which is used to: for each of the N messages, output all single transmission delays of the message in the first time period in the form of a graph or a table; and / or, output the average transmission delay of the message in the first time period in the form of a graph or a table.
[0195] It should be noted that the message delay simulation device provided in the embodiment of the present application includes the various units included, which can be implemented by a processor in an electronic device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU, Central Processing Unit), a microprocessor (MPU, MicroProcessor Unit), a digital signal processor (DSP, Digital Signal Processor) or a field programmable gate array (FPGA, Field-Programmable Gate Array), etc.
[0196] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0197] It should be noted that in the embodiments of the present application, if the above-mentioned message delay simulation method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0198] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps in the message delay simulation method provided in the above embodiment are implemented.
[0199] Combine the following Fig. 9 The electronic device 90 shown is a block diagram of the electronic device.
[0200] In one example, if Fig. 9 As shown, the electronic device 90 includes: a processor 901, at least one communication bus 902, at least one external communication interface 903 and a memory 904. The communication bus 903 is configured to realize connection and communication between these components. The external communication interface 903 may include a standard wired interface and a wireless interface.
[0201] The memory 904 is configured to store instructions and applications executable by the processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0202] In a fourth aspect, an embodiment of the present application provides a storage medium, that is, a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in the message delay simulation method provided in the above embodiment are implemented.
[0203] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0204] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0205] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0206] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0207] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0208] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0209] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0210] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0211] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A message delay simulation method, characterized in that: The method comprises: Obtaining a bus transmission rate and a message type, a message length and a message identifier of N messages to be processed; wherein N is an integer greater than 1; At least based on the bus transmission rate, the message type and the message length of the N messages, estimate the planned transmission time of each of the N messages in all times within the first time period and the transmission duration of all times within the first time period; At least based on the duration of all transmissions of the N messages in the first time period and the message identifiers of the N messages, the actual transmission time of all the N messages in the first time period is estimated; wherein, the transmission order of the N messages is obtained by arbitrating the message identifiers of the N messages, and the actual transmission time of all the N messages in the first time period is estimated at least based on the transmission order of the N messages and the duration of all transmissions of the N messages in the first time period; For each of the N messages, a target sending delay of the message is determined based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period.
2. The method according to claim 1, characterized in that The estimating, based at least on all sending durations of the N messages in the first time period and message identifiers of the N messages, actual sending times of the N messages in the first time period includes: Dividing the first time period into a plurality of first step time periods based on a first duration, and determining, for each of the plurality of first step time periods, at least one message in each of the first step time periods based on all planned sending times of the N messages in the first time period; For at least one message in each of the first step time period, arbitrate the at least one message based on the message identifier of the at least one message to obtain a message sending order in the first step time period; Furthermore, based at least on the message sending order and the current sending duration of each of the at least one message, an actual sending time of each of the at least one message in the current time is estimated; At least one message in each of the first step time periods in the multiple first step time periods is traversed to obtain actual sending times of all the N messages in the first time period.
3. The method according to claim 1, characterized in that The estimating, based at least on the bus transmission rate, the message type and the message length of the N messages, the planned transmission time of all times of each of the N messages in the first time period and the transmission duration of all times in the first time period, comprises: For each of the N messages, based at least on a message length and a bus transmission rate of the message, estimating a duration of all transmissions of the message within the first time period; The planned sending time of each of the N messages in the first time period is determined at least based on the message type.
4. The method according to claim 3, characterized in that The estimating, based at least on a message length and a bus transmission rate of the message, all transmission durations of the message within the first time period includes: Obtaining an average value and a fluctuation range of the bus sending rate, and based on the average value and the fluctuation range of the bus sending rate, generating a bus sending rate reference library in a positive distribution manner; Generate a first random number based on the current message; Determine the current bus transmission rate in the bus transmission rate reference library based on the first random number; The sending duration of the message at the current time is determined based on the message length of the message and the current bus sending rate; and all times within the first time period are traversed to obtain the sending duration of the message at all times within the first time period.
5. The method according to claim 3, characterized in that: The determining, at least based on the message type, all planned sending times of each of the N messages within the first time period includes: In the case where the N messages include O periodic messages of a periodic type, O is an integer greater than or equal to 1, and for each of the O periodic messages, the following processing is performed: Arbitrating the O periodic messages based on the message identifiers of the O periodic messages to obtain a first sending order of the O periodic messages; Determine the first sending time of each of the O periodic messages based at least on the first sending order and the first sending duration of the O periodic messages; For each of the O periodic messages, taking the first sending time of the periodic message as the starting point and at least based on all the sending cycles of the periodic message in the first time period, determine the planned sending time of all the periodic messages in the first time period.
6. The method according to claim 5, characterized in that The determining, taking the first sending time of the periodic message as the starting point and at least based on all sending cycles of the periodic message in the first time period, all planned sending times of the periodic message in the first time period includes: Obtaining an average value and a fluctuation range of the periodic message sending period, and generating a sending period reference library in a positive distribution manner based on the average value and the fluctuation range of the sending period; Generate a second random number based on the current sending of the periodic message; and determine the current sending period of the periodic message in the sending period reference library based on the second random number; Taking the first sending time of the periodic message as the starting point and based on the current sending cycle of the periodic message, determining the current planned sending time of the periodic message; All sending periods within the first time period are traversed to obtain all planned sending times of the periodic message within the first time period.
7. The method according to claim 3, characterized in that The determining, at least based on the message type, all planned sending times of each of the N messages within the first time period includes: In the case where the N messages include P messages of event-triggered type, where P is an integer greater than or equal to 1, the following processing is performed for each of the P event-triggered messages: Dividing the first time period into a plurality of second step time periods based on a second time period, and determining a triggering probability of the event-triggered message in each of the plurality of second step time periods; the second time period is greater than the first time period; Based on the triggering probabilities of all second step time periods within the first time period, all planned sending times of the event-triggered message within the first time period are determined.
8. The method according to claim 1, characterized in that The determining, based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period, a target sending delay of the message includes: In the case where the target transmission delay includes a single transmission delay, Determine a single transmission delay each time based on each planned transmission time and each actual transmission time of the message within the first time period; Traversing all times of the message in the first time period, and obtaining a single sending delay of all times of the message in the first time period; and / or, In the case where the target transmission delay includes an average transmission delay, Determine a single transmission delay each time based on each planned transmission time and each actual transmission time of the message within the first time period; Determine an average sending delay of the message in the first time period based on all single sending delays of the message in the first time period; The method further comprises: For each of the N messages, All single transmission delays of the message in the first time period are output in the form of a graph or a table; and / or, the average transmission delay of the message in the first time period is output in the form of a graph or a table.
9. A message delay simulation device, characterized in that: The device comprises: An obtaining unit, used to obtain a bus transmission rate and a message type, a message length and a message identifier of N messages to be processed; wherein N is an integer greater than 1; A first estimation unit, configured to estimate, based at least on the bus transmission rate, the message type and the message length of the N messages, all the planned transmission times of each of the N messages in a first time period and all the transmission durations in the first time period; a second estimating unit, configured to estimate the actual sending time of all the N messages in the first time period based at least on the sending duration of all the N messages in the first time period and the message identifiers of the N messages; wherein the sending order of the N messages is obtained by arbitrating the message identifiers of the N messages, and the actual sending time of all the N messages in the first time period is estimated based at least on the sending order of the N messages and the sending duration of all the N messages in the first time period; A determination unit is used to determine, for each of the N messages, a target sending delay of the message based on all planned sending times of the message within the first time period and all actual sending times of the message within the first time period.
10. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the message delay simulation method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Bus real-time synchronous control device
CN111381539A
CANFD bus delay rate calculation method and device, electronic equipment and storage medium
CN116319457A