A method, apparatus, device, and storage medium for simulating message delay.
By using a message delay simulation model, the problem of message period delay simulation in CAN networks was solved, achieving low-cost, high-efficiency, and high-accuracy message delay estimation, outputting the target delay, and improving design quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2026-04-03
AI Technical Summary
In the design and development of CAN networks, existing technologies lack effective simulation schemes for message cycle delay, which makes it impossible to accurately predict message delay and affects design quality.
A message delay simulation model is adopted. By determining the node to be processed and the message, the simulation model is called to estimate the delay and output the target delay, including single delay, average delay and maximum delay, to avoid errors in manual calculation.
It achieves low-cost, high-efficiency, and high-accuracy message delay simulation, and can automatically output the target message delay of multiple nodes, improving the accuracy and efficiency of the design.
Smart Images

Figure CN116647482B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle technology, and to, but is not limited to, a method, apparatus, device, and storage medium for simulating message delay. Background Technology
[0002] CAN (Controller Area Network) bus is currently widely used in automotive networks. During the design and development of CAN networks, large deviations or delays in the CAN message cycle are often encountered. Therefore, simulation analysis of CAN message cycle delay is performed during the design phase.
[0003] However, there is currently no solution for simulating message cycle delay during the design phase, and how to simulate message cycle delay urgently needs to be addressed. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for simulating message delay. The solution develops a message delay simulation model that can automatically obtain the target delay of messages from multiple nodes, and features low cost, high efficiency, and high accuracy.
[0005] The technical solution of this application is implemented as follows:
[0006] Firstly, this application provides a method for simulating message delay, the method comprising:
[0007] Determine M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; and M is greater than or equal to N.
[0008] The message delay simulation model is invoked to estimate the delay of the M messages, thereby obtaining the target delay of each of the M messages;
[0009] Output the target delay for each of the M messages.
[0010] Secondly, this application provides a device for simulating message delay, the device comprising:
[0011] A determining unit is configured to determine M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; and M is greater than or equal to N.
[0012] The calling unit is used to call the message delay simulation model, perform delay estimation on the M messages, and obtain the target delay of each of the M messages;
[0013] The output unit is used to output the target delay of each of the M messages.
[0014] Thirdly, this application also provides an electronic device, including: a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the program to implement the above-mentioned simulation method for message delay.
[0015] Fourthly, this application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the above-mentioned simulation method for message delay.
[0016] The message latency simulation method, apparatus, device, and storage medium provided in this application include: determining M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; where M is greater than or equal to N; calling a message latency simulation model to estimate the latency of the M messages, obtaining the target latency of each of the M messages; and outputting the target latency of each of the M messages.
[0017] For the scheme of this application, M messages from N nodes to be processed are determined; N is an integer greater than or equal to 1; each node includes at least one message; M is greater than or equal to N; a message delay simulation model is called to estimate the delay of the M messages, obtaining the target delay of each message in the M messages; the target delay of each message in the M messages is output. It can be seen that, on the one hand, using the message delay simulation model in this application for message delay estimation has the characteristic of low cost; on the other hand, the message delay simulation method of this application can output different target delays, has the characteristic of high simulation efficiency, and avoids errors caused by manual calculation, thus having the characteristic of high accuracy. Attached Figure Description
[0018] Figure 1 A schematic flowchart of an optional message delay simulation method provided in the embodiments of this application;
[0019] Figure 2 A schematic diagram of a first optional process for simulating message delay provided in an embodiment of this application;
[0020] Figure 3 A schematic diagram of a second optional simulation method for message delay provided in the embodiments of this application;
[0021] Figure 4 A schematic diagram of a third optional simulation method for message delay provided in the embodiments of this application;
[0022] Figure 5 A schematic diagram of a fourth optional simulation method for message delay provided in the embodiments of this application;
[0023] Figure 6 A schematic diagram of a fifth optional simulation method for message delay provided in the embodiments of this application;
[0024] Figure 7 A schematic diagram of a sixth optional simulation method for message delay provided in the embodiments of this application;
[0025] Figure 8 A schematic diagram of the seventh optional simulation method for message delay provided in the embodiments of this application;
[0026] Figure 9 A schematic diagram of an optional structure of the message delay simulation device provided in the embodiments of this application;
[0027] Figure 10 This is a schematic diagram of an optional structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of the application will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application.
[0029] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is 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.
[0030] In the following description, the terms "first," "second," and "third" are used only to distinguish different objects and do not represent a specific order of objects, nor are they constituting a chronological order. It is understood that "first," "second," and "third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0032] This application provides a method, apparatus, device, and storage medium for simulating message delay. In practical applications, the method for simulating message delay can be implemented by a device for simulating message delay. The functional entities in the device can be implemented collaboratively by the hardware resources of the electronic device, such as computing resources like processors and communication resources (such as those used to support various communication methods like optical fiber and cellular).
[0033] The message delay simulation method provided in this application embodiment is applied to electronic devices.
[0034] The electronic device is used to perform the following: determine M messages from N nodes to be processed; N is an integer greater than or equal to 1; a node includes at least one message; M is greater than or equal to N; call the message delay simulation model to estimate the delay of the M messages, and obtain the target delay of each message in the M messages; output the target delay of each message in the M messages.
[0035] The electronic device can be any electronic device with the capability to simulate relevant message delays. This application does not limit the specific type of electronic device; it can be configured according to actual circumstances. For example, the electronic device can be a server, a laptop, a desktop computer, etc.
[0036] The following describes various embodiments of the message delay simulation method, apparatus, device, and storage medium provided in the embodiments of this application.
[0037] Firstly, embodiments of this application provide a message delay simulation method, which is applied to a message delay simulation device. Exemplarily, this method is applied to an electronic device, and the functions implemented by this method can be achieved by the electronic device itself. Specifically, it is implemented by a processor within the electronic device calling program code. Of course, the program code can be stored in a computer storage medium. Therefore, the electronic device includes at least a processor and a storage medium.
[0038] The following describes the message delay simulation method provided in this application embodiment, using an electronic device as the execution subject as an example. This message delay simulation method is used to output the target delay of the message.
[0039] Figure 1 This is a flowchart illustrating the message delay simulation method according to an embodiment of this application, as shown below. Figure 1 As shown, the process may include, but is not limited to, S101 to S103 described below.
[0040] S101, The electronic device determines M messages from N nodes to be processed.
[0041] N is an integer greater than or equal to 1; a node includes at least one message; M is greater than or equal to N.
[0042] This application does not impose specific limitations on the number of nodes and the number of messages corresponding to each node, and can be configured according to actual conditions.
[0043] The messages in the embodiments of this application are messages sent via a serial bus. In one possible implementation, the M messages are CAN messages.
[0044] For example, N nodes include node 1, node 2, ..., node N; node 1 includes message 1, message 2, and message 3; node 2 includes message 4; and node N includes message 5, message 6, message 7, and message 8.
[0045] S102. The electronic device calls the message delay simulation model to estimate the delay of the M messages, and obtains the target delay of each of the M messages.
[0046] Message delay simulation models can be written using VBA (Visual Basic for Applications), C#, C++, VB (Visual Basic), JAVA, and other programming languages. Message delay simulation models designed using these languages feature open-source algorithms, high customizability, and customizable parameters, making them more convenient to use.
[0047] The message delay simulation model can include the following parameters: target delay type, simulation model runtime, etc. The target delay includes different types, specifically: single delay, average delay, maximum delay, and minimum delay. These parameters can be customized before calling the message delay simulation model.
[0048] The message delay simulation model can also include other elements, such as node name and message identifier.
[0049] S102 can be implemented as follows: the electronic device calls the message delay simulation model to estimate the delay of the M messages, and obtains at least one of the single delay, average delay, maximum delay and minimum delay of each of the M messages.
[0050] S103. The electronic device outputs the target delay of each of the M messages.
[0051] The embodiments of this application can adopt different output methods, such as using tables or text to output the target delay of each of the M messages.
[0052] In this embodiment, the messages corresponding to different nodes need to be arbitrated, and can only be sent after successful arbitration. A sufficient number of nodes and the number of messages corresponding to each node can ensure the accuracy of the message delay simulation results of this application.
[0053] The message delay simulation method provided in this application includes: determining M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; M is greater than or equal to N; calling a message delay simulation model to estimate the delay of the M messages, obtaining the target delay of each of the M messages; and outputting the target delay of each of the M messages. It can be seen that, on the one hand, using the message delay simulation model in this application for message delay estimation has the advantage of low cost; on the other hand, the message delay simulation method in this application can output different target delays, exhibiting high simulation efficiency, and avoids errors caused by manual calculation, thus possessing high accuracy.
[0054] In one embodiment, when the target delay includes different types, the target delay of the message includes different target delay types of the message.
[0055] When the target delay includes a single delay, the corresponding target delay of the message includes the single delay of the message.
[0056] For example, a single delay of a message can be one of the delays in at least one single delay during the message's runtime.
[0057] If the target delay includes an average delay, then the target delay of the message includes the average of all individual delays of the message during the runtime.
[0058] For example, if the target latency includes the average latency, then if the message is sent only once during the runtime, the average latency of the message is the single latency of the message; if the message is sent at least twice during the runtime, then the average latency of the message is the average of all single latencies of the message during the runtime.
[0059] If the target delay includes a first delay, then the target delay of the message includes: the minimum value of all single delays of the message during the running time.
[0060] For example, the first delay is the minimum value of a single delay during the running time. If the target delay includes the first delay, all single delays during the running time are compared to obtain the minimum value of all single delays, which is used as the target delay of the message.
[0061] If the target delay includes a second delay, then the target delay of the message includes the maximum value of all single delays of the message during the running time.
[0062] For example, the first delay is the maximum value of a single delay during the running time. If the target delay includes the first delay, all single delays during the running time are compared to obtain the maximum value of all single delays, which is used as the target delay of the message.
[0063] The message delay simulation model provided in this application allows for setting the running time of the simulation model. When the running time is reached, the simulation model stops running, thereby determining the target delay for each of the M messages during the simulation model's execution. Specifically, as shown... Figure 2 As shown, S102 includes, but is not limited to, S102A-S103C described below.
[0064] S102A, The electronic device sets the running time in the message delay simulation model.
[0065] The runtime of the message delay simulation model can be predefined by the user before it is invoked. The simulation model continues to simulate message transmission as long as the runtime is not over; it stops simulating message transmission when the runtime ends.
[0066] For example, the runtime in a message delay simulation model can be set using a timer. The timer's interval is set to the runtime of the message delay simulation model. When the timer overflows, it indicates that the runtime of the message delay simulation model has expired, and the simulation model stops running. For example, if the message delay simulation model is built using the VBA programming language, the runtime can be set by calling a timer function. If the message delay simulation model is built using another programming language, the corresponding timer function in that programming language can also be used to set the runtime.
[0067] S102B: The electronic device calls the message delay simulation model to estimate the single delay of each of the M messages for all cycles within the running time.
[0068] The single delay corresponding to all cycles of the message within the running time represents the transmission time of a message in two adjacent cycles within the running time. The transmission time of the later cycle and the transmission time of the previous cycle can determine the cycle of a message. The transmission time of the message determines the message delay, which is the single delay.
[0069] For example, if the message execution time is 60ms and the preset message period of a message is 10ms, it may result in 5 single-time delays for a message.
[0070] S102C: The electronic device determines the target delay of the message based on the single delay of the message in all cycles during the operating time; iterates through each of the M messages to obtain the target delay of each of the M messages.
[0071] For example, the delay, average delay, minimum delay, or maximum delay of a message can be determined based on the single delay of the message in all cycles. By traversing each of the M messages, the delay, average delay, minimum delay, or maximum delay corresponding to each of the M messages can be obtained.
[0072] In one embodiment, the first message is any one of the M messages, such as... Figure 3 As shown, in step S102B above, the single delay of the message corresponding to all cycles within the running time is estimated, including but not limited to S301-S304.
[0073] S301. When the first message meets the transmission conditions of the first period, the electronic device estimates the transmission time of the first message in the first period based on the current time.
[0074] For example, the sending condition of the first period of the first message refers to the arrival of the preset message period of the first message, and the first message is added to the arbitration list, and the arbitration result is the first message.
[0075] S301 can be implemented as follows: when the electronic device reaches the preset message period of the first message and the first message is added to the arbitration list and the arbitration result is the first message, the current time is determined as the transmission time of the first message in the first period.
[0076] S302. When the first message meets the transmission conditions of the second period, the electronic device estimates the transmission time of the first message in the second period based on the current time.
[0077] The second cycle is the cycle following the first cycle.
[0078] S302 can be implemented as follows: If the electronic device reaches the preset message period of the first message again and the first message is added to the arbitration list and the arbitration result is the first message, the current time is determined as the sending time of the first message in the second period.
[0079] S303. The electronic device estimates the single delay of the first message in the second period based on the transmission time of the first period, the transmission time of the second period, and the preset message period of the first message.
[0080] Based on the transmission time of the first cycle and the transmission time of the second cycle, the simulated message cycle of the first message can be determined. Based on the simulated message cycle of the first message and the preset message cycle of the first message, the single delay of the first message in the second cycle can be determined.
[0081] S304. The electronic device traverses all cycles within the operating time to obtain the single delay of the first message corresponding to all cycles within the operating time.
[0082] The electronic device iterates through all cycles within its operating time, determines the simulated message cycle for each cycle based on the transmission time of the first message in each current cycle and the transmission time of the previous cycle adjacent to the current cycle, and determines the single-time delay of the first message in all cycles based on the simulated message cycle for each current cycle and the preset message cycle of the first message.
[0083] In one embodiment, a method is provided for calculating the single-pass delay of the first message in the second period based on the transmission time of the first period, the transmission time of the second period, and a preset message period of the first message. For example... Figure 4 As shown, S303 includes, but is not limited to, S401 and S402 described below.
[0084] S401. The electronic device determines the difference between the transmission time of the second period and the transmission time of the first period as the simulated message period corresponding to the first message in the second period.
[0085] S401 can be implemented as follows: The electronic device subtracts the transmission time of the first cycle from the transmission time of the second cycle to obtain the difference between the transmission time of the second cycle and the transmission time of the first cycle, and determines it as the simulated message cycle corresponding to the first message in the second cycle.
[0086] S402. The electronic device determines the difference between the simulated message period corresponding to the first message in the second period and the preset message period of the first message as the single delay of the first message in the second period.
[0087] S402 can be implemented as follows: The electronic device subtracts the preset message period of the first message from the simulated message period corresponding to the second period of the first message to obtain the difference between the simulated message period corresponding to the second period of the first message and the preset message period of the first message, and determines it as the single delay of the first message in the second period.
[0088] In this embodiment of the application, the transmission conditions for the first message to satisfy the second cycle are described, such as... Figure 5 As shown, the message delay simulation method of this application also includes S501-S505.
[0089] S501, The electronic device starts a first timer when it estimates the transmission time of the first message in the first period based on the current time.
[0090] The timing duration of the first timer is the preset message period of the first message.
[0091] When the transmission time of the first cycle is determined, the first timer is started to prepare for the transmission of the first message again.
[0092] S502. When the electronic device reaches the set time of the first timer, it adds the first message to the arbitration list and arbitrates at least two messages in the arbitration list.
[0093] When the first timer reaches its set duration, the first message needs to be sent and added to the arbitration list. According to the message arbitration protocol on the CAN bus, at least two messages in the arbitration list are arbitrated.
[0094] The message arbitration protocol on the CAN bus states that if two or more nodes send messages simultaneously, a bus access collision will occur. This collision can be resolved by arbitrarily arbitrating the identifier bit by bit.
[0095] In one embodiment, a first message is added to an arbitration list, and arbitration is performed based on the identifier of the message in the arbitration list. The smaller the message identifier, the higher the priority of the message.
[0096] S503. If the arbitration result of the electronic device is the first message, then the first message is determined to meet the transmission conditions of the second cycle.
[0097] If the arbitration result is the first message, then the first message is determined to meet the sending conditions of the second cycle, that is, the time from the last sending of the first message to the current sending of the first message reaches the preset message cycle, and the arbitration of the first message is successful, so the simulated sending of the first message can be carried out.
[0098] S504. If the arbitration result of the electronic device is any message other than the first message, then after the first interval, at least two messages in the new arbitration list shall be re-arbitrated until the new arbitration result is the first message.
[0099] The first interval is the minimum message transmission interval, used to characterize the message transmission time.
[0100] For example, the minimum interval between sending messages with different identifiers from the same node must be greater than 1ms. This application embodiment does not limit the specific value of the first interval time, and it can be configured according to actual needs. Preferably, the first interval time is 1ms.
[0101] like Figure 6 As shown, the intervals between t0, t1, t2, t3, t4, t5, ..., the model runtime (Truntime), are all the message sending times Tmin. For example, Tmin = t1 - t0, or Tmin = t2 - t1.
[0102] If the arbitration result is any message other than the first message, it means that the arbitration of any message other than the first message was successful, the arbitration of the first message failed, the first message does not meet the sending conditions of the second cycle, the first message cannot be simulated to be sent, and the message arbitration continues until the new arbitration result is the first message.
[0103] S505. If the new arbitration result is the first message, the electronic device determines that the first message meets the transmission conditions of the second cycle.
[0104] If the new arbitration result is the first message, and the first message meets the transmission conditions for the second cycle, meaning that the simulated transmission of the first message can be performed, the transmission time of the first message in the second cycle can be estimated based on the current time.
[0105] In this embodiment, it is also necessary to determine the first message to be processed for the message delay simulation model. Specifically, if the first message is the first message processed by the message delay simulation model, such as... Figure 7 As shown, the message delay simulation method of this application also includes S701-S704:
[0106] S701. The electronic device uses a random algorithm to determine the target node from the N nodes.
[0107] A car contains multiple Electronic Control Units (ECUs), and the power-on, wake-up, and message transmission times of each ECU are not fixed. If the target node is determined sequentially from N nodes, only one scenario of the actual vehicle situation can be represented, and it cannot simulate most situations that the vehicle will encounter in real-world driving. To improve the simulation of the actual vehicle situation, this application uses a random algorithm to determine the target node from N nodes.
[0108] For example, the random algorithm of this application can be a random number generator.
[0109] S702. The electronic device searches for at least one target message included in the target node among the M messages.
[0110] Each of the N nodes contains a different number of messages, and each node contains at least one message. If the target node is found among the M messages and contains one target message, then execute S803; if the target node is found among the M messages and contains at least two messages, then execute S804.
[0111] S703. If the target node includes a target message, the electronic device determines the target message as the first message.
[0112] If the target node includes a target message, then the target message does not need to be arbitrated, and is determined to be the first message processed by the message delay simulation model.
[0113] S704. If the target node includes at least two target messages, the electronic device arbitrates the at least two target messages to obtain the first message.
[0114] For example, if the target node of an electronic device includes at least two messages, the electronic device can arbitrate the at least two target messages according to their message priorities to obtain the first message. Specifically, if the target node includes at least two messages, the message priority can be determined according to the identifiers in the at least two target messages, and the message with the higher priority can be determined as the first message processed by the message delay simulation model.
[0115] In one embodiment, the order of message transmission within the same node is as follows: the smaller the identifier, the higher the priority and the earlier the message is sent; if at least two messages need to be sent by the same node at the same time, the message identifiers are used for arbitration, with the smaller the identifier, the higher the priority and the earlier the message is sent.
[0116] This application provides a message delay record table, as shown in Table 1.
[0117] Table 1 Message Delay Record Table
[0118]
[0119] Table 1 lists a total of 6 nodes, namely Node1, Node2, Node3, Node4, Node5, and Node6; each node includes a different number of messages, for example, Node1 includes 3 messages, ... Node4 includes 5 messages, Node5 includes 4 messages, and Node6 includes 3 messages.
[0120] In one example, the algorithm of the message delay simulation model in this application includes, but is not limited to, A1-A8.
[0121] A1. Put all node names into a dictionary (remove duplicate nodes and keep unique nodes), and number the nodes from 1 to Nnode;
[0122] A2. Sort all nodes' messages according to the order in which they were sent within the same node;
[0123] A3. Use a random number function with a range of 1 to Nnode to generate a random number that corresponds to the first node that sent the message, Node_1st.
[0124] A4. Node_1st sends the message with sequence number 1 in sequence according to the order of the messages in A2, records the timestamp of the sending time, and calls the timer function Ttimer(), with the timer period being the period T1 of the message.
[0125] A5. Call the timer function Ttimer(), with the timer duration being the model runtime Truntime;
[0126] A6. Waiting time Tmin (minimum message sending interval): All nodes request to send messages simultaneously. The message ID is the first-order message ID of each node. Arbitration is carried out according to the message sending rules of different nodes. The message ID that wins the arbitration right is sent immediately. The timestamp of the sending time is recorded, and the timer function Ttimer() is called. The timer period is the period Tn of the message.
[0127] A7. Run loop (5) until timer Truntime overflows;
[0128] A8. By using the recorded message ID and its timestamp when it was sent, the minimum delay, average delay, and maximum delay of each message can be calculated.
[0129] Implementation of this application, for example Figure 8 As shown, and referring to the examples in Table 1, the specific process of the message delay simulation method may include, but is not limited to, S801-S803 below. It should be noted that the messages in each node in Table 1 have been arranged in order of priority.
[0130] S801. By using a random number method, it is determined that the first node to send a message is node 4.
[0131] As shown in Table 1, the messages of Node4 include: 0x1A2, 0x1C2, 0x5D4, 0x6AA, and 0x6CA. The five messages in Node4 are arbitrated according to their priority. The message ID with the highest priority is 0x1A2, so Node4 (0x1A2) is the first message sent.
[0132] S802. The determination of the second frame message is achieved by arbitrating the first-order IDs of each node {Node1(0x1C9), Node2(0x1A3), Node3(0x1E2), Node4(0x1C2), Node5(0x1B1), Node6(0x1F4)}. Based on the principle that the smaller the message ID, the higher the priority, Node2(0x1A3) is determined to have the highest priority and obtains the arbitration right. It should be noted that within the same node, the message identifier with the highest current priority is defined as the first-order message identifier.
[0133] S803 and the third frame message are consistent with the method in S802. The first priority ID of each node is: {Node1(0x1C9), Node2(0x1A5), Node3(0x1E2), Node4(0x1C2), Node5(0x1B1), Node6(0x1F4)}, and Node2(0x1A5) obtains the arbitration right.
[0134]
[0135] Repeat the above steps until the simulation model of message delay finishes running.
[0136] The default message period T1 for Node4 (0x1A2) is 10ms. Figure 8 From this, we can see that the transmission time t1 of Node4 (0x1A2) in the first period is 0s, and the transmission time t2 in the second period is 10.05s. Therefore, the simulated message period (i.e., the simulated actual message period) T2 of Node4 (0x1A2) is the difference between t2 and t1, that is, T2 = t2 - t1 = 10.05 - 0 = 10.05ms. Then, the difference between the simulated message period of Node4 (0x1A2) and the preset message period is determined as the single delay of Node4 (0x1A2) in the second period. The single delay of Node4 (0x1A2) in the second period is: T2 - T1 = 10.05 - 10 = 0.05ms.
[0137] Secondly, embodiments of this application provide a message delay simulation device 90, such as... Figure 9 As shown, the device includes:
[0138] The determining unit 901 is used to determine M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; and M is greater than or equal to N.
[0139] Calling unit 902 is used to call the message delay simulation model to estimate the delay of the M messages and obtain the target delay of each of the M messages;
[0140] Output unit 903 is used to output the target delay of each of the M messages.
[0141] In some embodiments, the calling unit 902 is specifically used for: setting the running time in the message delay simulation model; calling the message delay simulation model to estimate the single delay of each message in all periods within the running time for each of the M messages; determining the target delay of the message for the single delay of each message in all periods within the running time; and traversing each of the M messages to obtain the target delay of each of the M messages.
[0142] In some embodiments, where the target delay includes a single delay, the target delay of the message includes the single delay of the message.
[0143] In some embodiments, where the target latency includes an average latency, the target latency of the message includes the average of all single latencies of the message during the runtime.
[0144] In some embodiments, where the target delay includes a first delay, the target delay of the message includes the minimum value of all single delays of the message during the runtime.
[0145] In some embodiments, where the target delay includes a second delay, the target delay of the message includes the maximum value of all single delays of the message during the runtime.
[0146] In some embodiments, for the first message, the first message is any one of the M messages; the calling unit 902 is further configured to:
[0147] If the first message meets the transmission conditions of the first period, the transmission time of the first message in the first period is estimated based on the current time.
[0148] If the first message meets the transmission conditions of the second period, the transmission time of the first message in the second period is estimated based on the current time; the second period is the next period after the first period.
[0149] Based on the transmission time of the first period, the transmission time of the second period, and the preset message period of the first message, estimate the single delay of the first message in the second period;
[0150] By traversing all cycles within the specified runtime, the single delay of the first message corresponding to all cycles within the specified runtime is obtained.
[0151] In some embodiments, the calling unit 902 is specifically used for:
[0152] The difference between the transmission time of the second period and the transmission time of the first period is determined as the simulated message period corresponding to the first message in the second period;
[0153] The difference between the simulated message period corresponding to the first message in the second period and the preset message period of the first message is determined as the single delay of the first message in the second period.
[0154] In some embodiments, the message delay simulation apparatus further includes:
[0155] The startup unit is configured to start a first timer when the transmission time of the first message in the first period is estimated based on the current time; the timing duration of the first timer is a preset message period of the first message;
[0156] An arbitration unit is configured to add the first message to the arbitration list when the first timer reaches its set duration, and to arbitrate at least two messages in the arbitration list.
[0157] The determining unit 901 is further configured to determine that if the arbitration result is the first message, the first message satisfies the sending conditions of the second cycle;
[0158] The arbitration unit is also configured to, if the arbitration result is any message other than the first message, re-arbitrate at least two messages in the new arbitration list after the first interval, until the new arbitration result is the first message;
[0159] The determining unit 901 is further configured to determine, in the case that the new arbitration result is the first message, that the first message meets the transmission conditions of the second cycle.
[0160] In some embodiments, when the first message is the first message processed by the call message delay simulation model, the determining unit 901 is further configured to use a random algorithm to determine a target node among the N nodes; search for at least one target message included in the target node among the M messages; if the target node includes one target message, then determine the one target message as the first message; if the target node includes at least two target messages, then arbitrate the at least two target messages to obtain the first message.
[0161] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the program, it implements the steps in the message delay simulation method provided in the above embodiments.
[0162] The following is combined Figure 10 The electronic device 100 shown is illustrated with a structural diagram.
[0163] In one example, such as Figure 10 As shown, the electronic device 100 includes: a processor 1001, at least one communication bus 1002, at least one external communication interface 1003, and a memory 1004. The communication bus 1003 is configured to enable communication between these components. The external communication interface 1003 may include standard wired and wireless interfaces.
[0164] The memory 1004 is configured to store instructions and applications executable by the processor 1001, and can also cache data to be processed or already processed by the processor 1001 and various modules in the electronic device (e.g., image data, audio data, voice communication data and video communication data), which can be implemented by flash memory or random access memory (RAM).
[0165] Fourthly, embodiments of this application provide a storage medium, namely a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps in the message delay simulation method provided in the above embodiments.
[0166] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0167] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential 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 embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0168] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0169] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0170] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0171] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0172] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, read-only memory (ROM), magnetic disks, or optical disks.
[0173] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to related technologies, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0174] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for simulating message delay, characterized in that, The method includes: Determine M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; and M is greater than or equal to N. The message delay simulation model is invoked to estimate the delay of the M messages, thereby obtaining the target delay of each of the M messages; Output the target latency for each of the M messages; The step of calling the message delay simulation model to estimate the delay of the M messages and obtain the target delay of each of the M messages includes: setting a running time in the message delay simulation model; calling the message delay simulation model to estimate the single delay of each message in all periods within the running time for each of the M messages; determining the target delay of the message based on the single delay of each message in all periods within the running time; and traversing each of the M messages to obtain the target delay of each of the M messages. For the first message, which is any one of the M messages; estimating the single-time delay of the message corresponding to all cycles within the running time includes: estimating the transmission time of the first message in the first cycle based on the current time, provided that the first message meets the transmission conditions of the first cycle; estimating the transmission time of the first message in the second cycle based on the current time, provided that the first message meets the transmission conditions of the second cycle; the second cycle is the next cycle after the first cycle; estimating the single-time delay of the first message in the second cycle based on the transmission time of the first cycle, the transmission time of the second cycle, and the preset message cycle of the first message; traversing all cycles within the running time to obtain all cycles of the first message within the running time. The corresponding single-time delay; wherein, when the transmission time of the first message in the first period is estimated based on the current time, a first timer is started; the timing duration of the first timer is a preset message period of the first message; when the timing duration of the first timer is reached, the first message is added to the arbitration list, and at least two messages in the arbitration list are arbitrated; if the arbitration result is the first message, it is determined that the first message meets the transmission conditions of the second period; if the arbitration result is any message other than the first message, after a first interval, at least two messages in the new arbitration list are re-arbitrated until the new arbitration result is the first message; if the new arbitration result is the first message, it is determined that the first message meets the transmission conditions of the second period.
2. The method according to claim 1, characterized in that, When the target delay includes a single delay, the corresponding target delay of the message includes the single delay of the message; When the target delay includes the average delay, the target delay of the message includes the average of all single delays of the message during the running time. When the target delay includes a first delay, the corresponding target delay of the message includes: the minimum value of all single delays of the message during the running time; If the target delay includes a second delay, then the target delay of the message includes the maximum value of all single delays of the message during the running time.
3. The method according to claim 1, characterized in that, The step of estimating the single-pass delay of the first message in the second period based on the transmission time of the first period, the transmission time of the second period, and the preset message period of the first message includes: The difference between the transmission time of the second period and the transmission time of the first period is determined as the simulated message period corresponding to the first message in the second period; The difference between the simulated message period corresponding to the first message in the second period and the preset message period of the first message is determined as the single delay of the first message in the second period.
4. The method according to claim 1, characterized in that, If the first message is the first message processed by the call message delay simulation model, the method further includes: The target node is determined from the N nodes using a random algorithm; Search among the M messages for at least one target message included in the target node; If the target node includes a target message, then the target message is identified as the first message; If the target node includes at least two target messages, then the at least two target messages are arbitrated to obtain the first message.
5. A device for simulating message delay, characterized in that, The device includes: A determining unit is configured to determine M messages from N nodes to be processed; where N is an integer greater than or equal to 1; each node includes at least one message; and M is greater than or equal to N. The calling unit is specifically used to set the running time in the message delay simulation model; call the message delay simulation model, and for each of the M messages, estimate the single delay corresponding to all cycles of the message within the running time; for the single delay of the message within all cycles of the running time, determine the target delay of the message; and traverse each of the M messages to obtain the target delay of each of the M messages. Wherein, for the first message, the first message is any one of the M messages; the calling unit is further configured to, when the first message meets the sending conditions of the first period, estimate the sending time of the first message in the first period based on the current time; when the first message meets the sending conditions of the second period, estimate the sending time of the first message in the second period based on the current time; the second period is the next period after the first period; based on the sending time of the first period, the sending time of the second period, and the preset message period of the first message, estimate the single delay of the first message in the second period; traverse all periods within the running time to obtain the single delay of the first message in all periods within the running time; the starting unit is configured to, when estimating the first message based on the current time... If the message is sent within the first period, a first timer is started; the duration of the first timer is a preset message period for the first message; the arbitration unit is configured to add the first message to the arbitration list when the duration of the first timer is reached, and to arbitrate at least two messages in the arbitration list; the determining unit is further configured to determine that the first message meets the sending conditions of the second period if the arbitration result is the first message; the arbitration unit is further configured to re-arbitrate at least two messages in the new arbitration list after a first interval if the arbitration result is any message other than the first message, until the new arbitration result is the first message; the determining unit is further configured to determine that the first message meets the sending conditions of the second period if the new arbitration result is the first message; The output unit is used to output the target delay of each of the M messages.
6. An electronic device comprising a memory and a processor, the memory storing a computer program executable on the processor, the processor executing the program to implement the message delay simulation method according to any one of claims 1 to 4.
7. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the message delay simulation method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Simulation device, simulation method, computer program, and method of manufacturing relay device
JP2015089042A