Instruction validity verification method, apparatus, equipment and storage medium
By obtaining the timestamps of each stage during instruction transmission and calculating the dynamic time consumption, the accuracy problem of cross-device instruction transmission timeliness verification is solved, achieving high-precision timeliness judgment that does not depend on system time. It is applicable to fields such as industrial automation control, financial transaction systems, and intelligent transportation systems.
Patent Information
- Application Number
- CN202511485336.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2045-10-17
AI Technical Summary
In existing technologies, the timeliness verification of cross-device command transmission relies on system time, which is susceptible to time synchronization deviations and malicious tampering, causing the verification mechanism to fail.
By obtaining the timestamps of each stage during instruction transmission, calculating the dynamic time consumption, and determining the remaining validity period of the instruction, the system avoids relying on system time and uses relative time based on dynamic time consumption calculation to verify the timeliness of the instruction.
It achieves accurate instruction timeliness determination unaffected by system time modifications, ensuring the accuracy and reliability of the verification mechanism, and is suitable for complex network environments.
Smart Images

Figure CN120956632B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of time synchronization technology, and in particular to a method, apparatus, device and storage medium for verifying instruction timeliness. Background Technology
[0002] Device operation commands generally have a time limit, meaning they have a certain validity period. For commands that have exceeded this period, the device will not allow the corresponding operation to be executed. In existing technologies, for cross-device command transmission, the timeliness of the command is generally verified using system time. This typically involves first synchronizing the system time of the cross-device systems using NTP (Network Time Protocol) or other methods, and then comparing the command's start time and validity period with the receiving time of the receiving device to determine if the command has expired. However, because conventional solutions rely on system time comparisons, discrepancies in time synchronization between devices in the cross-device system, or manual modification of the system time by the user or malicious program tampering, will directly affect the receiving device's timeliness judgment, easily leading to the failure of the verification mechanism. Summary of the Invention
[0003] This application aims to provide a method, apparatus, device, and storage medium for verifying instruction timeliness, which can accurately determine the timeliness of instructions without relying on system time.
[0004] The instruction timeliness verification method according to the first aspect of this application, applied to an instruction sending device, includes:
[0005] The sending instruction is generated by the application layer of the sending end, and the first timestamp of the generation of the sending instruction is obtained;
[0006] The first message data is sent to the instruction receiving device through the sending network card. The first message data includes the first timestamp, the second timestamp, the total lifespan of the sending instruction, and the instruction content data. The total lifespan is the effective time data of the sending instruction. The second timestamp is used to indicate the time when the first message data was sent.
[0007] Specifically, when the receiving network card of the instruction receiving device receives the first message data, it obtains the network transmission time and the third timestamp of receiving the first message data, and adds the network transmission time and the third timestamp to the first message data to obtain the second message data. The network transmission time is the time consumed for the first message data to travel from the sending network card to the receiving network card. When the receiving application layer of the instruction receiving device receives the second message data, it obtains the fourth timestamp of receiving the second message data. When the receiving application layer obtains the fourth timestamp, it obtains the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp.
[0008] An instruction timeliness verification apparatus according to a second aspect embodiment of this application includes:
[0009] The generation module is used to generate a sending command through the sending application layer and obtain the first timestamp of the generation of the sending command;
[0010] The sending module is used to send first message data to the instruction receiving device through the sending end network card. The first message data includes a first timestamp, a second timestamp, the total lifespan of the sending instruction, and instruction content data. The total lifespan is the effective time data of the sending instruction. The second timestamp is used to indicate the time when the first message data was sent.
[0011] Specifically, when the receiving network card of the instruction receiving device receives the first message data, it obtains the network transmission time and the third timestamp of receiving the first message data, and adds the network transmission time and the third timestamp to the first message data to obtain the second message data. The network transmission time is the time consumed for the first message data to travel from the sending network card to the receiving network card. When the receiving application layer of the instruction receiving device receives the second message data, it obtains the fourth timestamp of receiving the second message data. When the receiving application layer obtains the fourth timestamp, it obtains the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp.
[0012] The instruction timeliness verification method according to a third aspect embodiment of this application, applied to an instruction receiving device, includes:
[0013] The receiving end network card receives first message data, obtains network transmission time and third timestamp of receiving the first message data, and adds the third timestamp and network transmission time to the first message data to obtain second message data; wherein, the network transmission time is the time consumed for the first message data to travel from the sending end network card of the instruction sending device to the receiving end network card; wherein, the first message data is sent from the sending end network card of the instruction sending device to the instruction receiving device, wherein, the first message data includes a first timestamp, a second timestamp, the total lifetime of the sending instruction, and instruction content data, wherein the total lifetime is the effective time data of the sending instruction, the first timestamp is used to indicate the time when the sending end application layer of the instruction sending device generates the sending instruction, and the second timestamp is used to indicate the time when the sending end network card of the instruction sending device sends the first message data;
[0014] The receiving end application layer receives the second message data and obtains the fourth timestamp of receiving the second message data. Based on the second message data and the fourth timestamp, the sending instruction and the timeliness information of the sending instruction are obtained.
[0015] According to some embodiments of this application, obtaining the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp includes:
[0016] Based on the second message data, the first timestamp, the second timestamp, the third timestamp, the total lifetime, and the instruction content data are parsed to obtain the data.
[0017] The sending instruction is reconstructed based on the instruction content data;
[0018] The total time consumed is obtained based on the first timestamp, the second timestamp, the network transmission time, the third timestamp, and the fourth timestamp.
[0019] The timeliness information is obtained based on the total lifecycle and the total consumption time.
[0020] According to some embodiments of this application, obtaining the total consumed time based on the first timestamp, the second timestamp, the network transmission time, the third timestamp, and the fourth timestamp includes:
[0021] The first elapsed time is obtained based on the difference between the first timestamp and the second timestamp;
[0022] The second time consumed is obtained based on the difference between the third timestamp and the fourth timestamp;
[0023] The total consumption time is obtained by summing the first consumption time, the network transmission time, and the second consumption time.
[0024] According to some embodiments of this application, obtaining the timeliness information based on the total lifecycle and the total consumption time includes:
[0025] If the total lifecycle is greater than the total consumption time, the timeliness information indicates that the sending instruction is valid;
[0026] If the total lifecycle is less than or equal to the total consumption time, the timeliness information indicates that the sending instruction is invalid.
[0027] According to some embodiments of this application, after the receiving application layer obtains the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp, it further includes:
[0028] If the timeliness information indicates that the sending instruction is valid, the receiving application layer executes the corresponding instruction operation;
[0029] If the timeliness information indicates that the sending instruction is invalid, the receiving application layer performs an expiration processing operation.
[0030] An instruction timeliness verification apparatus according to a fourth aspect embodiment of this application includes:
[0031] A receiving module is configured to receive first message data via a receiving end network card, obtain the network transmission time and a third timestamp of receiving the first message data, and add the third timestamp and the network transmission time to the first message data to obtain second message data; wherein, the network transmission time is the time consumed for the first message data to travel from the sending end network card of the instruction sending device to the receiving end network card; wherein, the first message data is sent from the sending end network card of the instruction sending device to the instruction receiving device, wherein the first message data includes a first timestamp, a second timestamp, the total lifetime of the sending instruction, and instruction content data, wherein the total lifetime is the effective time data of the sending instruction, the first timestamp is used to indicate the time when the sending end application layer of the instruction sending device generates the sending instruction, and the second timestamp is used to indicate the time when the sending end network card of the instruction sending device sends the first message data;
[0032] The module is used to receive the second message data through the receiving end application layer, obtain the fourth timestamp of receiving the second message data, and obtain the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp.
[0033] An electronic device according to a fifth aspect embodiment of this application includes a processor and a memory, the memory storing a program or instructions executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the instruction timeliness verification method as described in any one of the first and third aspect embodiments above.
[0034] A computer-readable storage medium according to a sixth aspect embodiment of the present application stores computer-executable instructions for performing the instruction timeliness verification method as described in any one of the first and third aspect embodiments above.
[0035] In this embodiment, the verification scheme that relies on system time is abandoned. Instead, the time of instruction validity is verified by relative time calculated dynamically. Instead of directly transmitting the start and end times of the instruction determined by system time, the total lifecycle of the instruction is preset. During the transmission of the instruction, the timestamps before and after each processing step are obtained. The time consumed by each step can be calculated using the timestamps to determine the remaining validity period of the sent instruction. Ultimately, the receiving end can determine the true validity information of the instruction and accurately judge whether the instruction has expired. Since the judgment process does not depend on system time, it can avoid the influence of system time modification and ensure the accuracy of the verification mechanism.
[0036] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing this application. Attached Figure Description
[0037] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:
[0038] Figure 1 This is a flowchart illustrating an embodiment of the instruction validity verification method of this application;
[0039] Figure 2 This is a schematic diagram of the instruction transmission process in this application;
[0040] Figure 3 This is a schematic diagram of an embodiment of the instruction validity verification device according to an embodiment of this application;
[0041] Figure 4 This is a flowchart illustrating an embodiment of the instruction validity verification method according to another embodiment of this application;
[0042] Figure 5 This is a schematic diagram of an embodiment of the instruction validity verification device according to another embodiment of this application;
[0043] Figure 6 This is a schematic diagram of the hardware structure of an embodiment of the electronic device of this application. Detailed Implementation
[0044] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0045] In the description of this application, the use of terms such as "first," "second," etc., is for the purpose of distinguishing technical features only and should not be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated or the order of the technical features indicated.
[0046] In the description of this application, it should be understood that the orientation descriptions, such as up, down, etc., are based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application.
[0047] In the description of this application, it should be noted that, unless otherwise explicitly defined, terms such as "setup," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this application in conjunction with the specific content of the technical solution.
[0048] The technical solution of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are some embodiments of this application, not all embodiments.
[0049] Figure 1 This is a flowchart illustrating an embodiment of the instruction validity verification method of this application; Figure 2 This is a schematic diagram of the instruction transmission process in this application; Figure 3 This is a schematic diagram of an embodiment of the instruction validity verification device according to an embodiment of this application; Figure 4 This is a flowchart illustrating an embodiment of the instruction validity verification method according to another embodiment of this application; Figure 5 This is a schematic diagram of an embodiment of the instruction validity verification device according to another embodiment of this application; Figure 6 This is a schematic diagram of the hardware structure of an embodiment of the electronic device of this application.
[0050] See below. Figures 1 to 2The embodiments of this application will be further described below. This application proposes a method for verifying the validity of an instruction, applied to an instruction sending device. The method includes the following steps:
[0051] Step 101: Generate a sending command through the sending application layer and obtain the first timestamp of the generated sending command;
[0052] Step 102: Send the first message data to the instruction receiving device through the sending end network card. The first message data includes a first timestamp, a second timestamp, the total lifetime of the sending instruction, and instruction content data. The total lifetime is the effective time data of the sending instruction, and the second timestamp is used to indicate the time when the first message data is sent.
[0053] Specifically, when the receiving network card of the command receiving device receives the first message data, it obtains the network transmission time and the third timestamp of receiving the first message data, and adds the network transmission time and the third timestamp to the first message data to obtain the second message data. The network transmission time is the time consumed when the first message data travels from the sending network card to the receiving network card. When the receiving application layer of the command receiving device receives the second message data, it obtains the fourth timestamp of receiving the second message data. Based on the second message data and the fourth timestamp, the receiving application layer obtains the sending command and the timeliness information of the sending command.
[0054] In this embodiment, the verification scheme that relies on system time is abandoned. Instead, the time of instruction validity is verified by relative time calculated dynamically. Instead of directly transmitting the start and end times of the instruction determined by system time, the total lifecycle of the instruction is preset. During the transmission of the instruction, the timestamps before and after each processing step are obtained. The time consumed by each step can be calculated using the timestamps to determine the remaining validity period of the sent instruction. Ultimately, the receiving end can determine the true validity information of the instruction and accurately judge whether the instruction has expired. Since the judgment process does not depend on system time, it can avoid the influence of system time modification and ensure the accuracy of the verification mechanism.
[0055] The aforementioned instruction sending device, acting as the instruction sending end, includes a sending end application layer and a sending end network interface card (NIC); the aforementioned instruction receiving device, acting as the instruction receiving end, includes a receiving end application layer and a receiving end NIC. The aforementioned instruction is generated by the instruction sending device and transmitted across devices to the instruction receiving device. After receiving the instruction, the instruction receiving device determines whether the instruction needs to be executed based on the timeliness information of the sent instruction.
[0056] The aforementioned total lifecycle refers to the effective time data for sending instructions. This data can be preset in advance, based on the total time consumed by regular instruction transmission and the duration of instruction validity determined manually according to actual circumstances.
[0057] It is understandable that the entire transmission process of a command from the command sending device to the command receiving device can be divided into three stages: from the sending end's application layer to the sending end's network interface card (NIC), from the sending end's NIC to the receiving end's NIC, and from the receiving end's NIC to the receiving end's application layer, such as... Figure 2 As shown, by obtaining the time consumed in each step, the total time consumed in instruction transmission can be determined. For the time consumed in a certain step, the start and end points of the step can be timestamped using technical means, and the time consumed can be calculated using the timestamps. Alternatively, the total process time consumed in a certain step can be obtained directly.
[0058] In the first stage, the time elapsed from the sending application layer to the sending network card, i.e., the processing time of the instruction within the sending end, can include the time spent constructing the instruction at the application layer, system calls, processing in the kernel protocol stack, and waiting in the network transmission queue. The aforementioned acquisition of the first timestamp for generating the transmission instruction refers to the first timestamp corresponding to the sending application layer generating the transmission instruction as the starting point of the first stage. It is understood that there are still specific steps in the process of generating the transmission instruction. The specific time when the first timestamp is acquired, whether before or after a specific step, can be determined based on the actual situation, requirements, and acquisition methods. Similarly, the aforementioned second timestamp indicates the moment when the sending network card sends the first packet data, and is considered the end point of the first stage. Likewise, the specific time when the second timestamp is acquired can also be determined based on the actual situation, requirements, and acquisition methods.
[0059] For example, the first link from the sending application layer to the sending network card can be the time spent in the socket buffer, from constructing instructions at the sending application layer to sending them through the sending network card. The socket buffer, as a memory buffer allocated by the operating system kernel for each socket connection, is used to temporarily store network data to be sent or received.
[0060] Specifically, the calculation method for the time taken in the first stage includes recording the starting point T1 and the ending point T2 of the first stage.
[0061] The starting point T1 of the first stage can be defined as the immediate acquisition of a monotonic clock timestamp, i.e., the first timestamp T1, when the application layer business code generates the instruction object. The monotonic clock timestamp is a tool specifically designed for accurate and reliable measurement of time intervals. Its monotonicity and independence from system time interference make it indispensable in fields requiring high-precision timing and a stable time base. In this scenario, this clock generally refers to the running time after the device is powered on and will not be affected by user modifications or NTP synchronization.
[0062] The endpoint T2 of the first stage can be recorded as the moment the data packet is about to leave the sending network card hardware. The second timestamp T2 is also recorded. It's understandable that this process is difficult to obtain precisely at the user level, thus requiring kernel support. This process can be implemented using ePBF (extended Berkeley Packet Filter) hooks. Before the packet is sent through the network card, a timestamp is added to the end of the packet using the eBPF TC egress (Traffic Control egress) hook. Specifically, an eBPF program can be mounted on the network packet's egress path. When the instruction packet passes through this path, the eBPF program can write the current high-precision monotonic timestamp T2 to the end of the packet or in a specific field. eBPF is a programmable network packet filtering and processing mechanism in the Linux kernel, allowing users to dynamically inject custom logic to monitor, filter, or modify network traffic without modifying the kernel code; TC (Traffic Control) is a powerful network traffic control framework in the Linux kernel. eBPF programs can attach to the egress and ingress hooks of TC. egress refers to the path point before a data packet leaves the protocol stack and is about to be sent to a network device such as a network card. ingress refers to the path point after a data packet enters the protocol stack from the network device.
[0063] Therefore, the first message data sent by the aforementioned instruction sending device through the sending end network card includes basic information such as the total lifecycle of the sending instruction and the instruction content data, as well as time information such as the first timestamp and the second timestamp, which can be used to calculate the time consumed in the first stage, that is, from the sending end application layer to the sending end network card.
[0064] In addition, in some cases, to ensure the correctness of the message, verification can be added to the message, and a custom verification method can be defined, such as XOR verification.
[0065] In the second stage, the time taken from the sending network card to the receiving network card, i.e., the network transmission time, can be the pure transmission time of the data packet on the network from the sending network card to the receiving network card. It can be understood that this time period does not include the time spent queuing in the receiving kernel socket buffer.
[0066] Specifically, the calculation method for the time consumed in the second stage can be to directly obtain and record the network transmission time T. n .
[0067] Obtain and record network transmission time T n When the receiving network interface card (NIC) of the aforementioned command receiving device receives the first packet data, it obtains the network transmission time, which directly determines the time consumed in the second stage. This process can be achieved by using eBPF kernel reflection to obtain the transmission time of the data packet between the two NICs. It's important to understand that this method doesn't require entering the socket buffer but directly reflects the data; therefore, the network transmission time obtained in this event does not include the socket buffer time. Specifically, eBPF / XDP (eXpress Data Path) reflection can be used to obtain the transmission time of the data packet between the two NICs. eBPF / XDP reflection refers to directly intercepting and reflecting data packets within the kernel network stack via an eBPF program, i.e., returning along the original path without user-space processing, and can be used to calculate data network transmission time.
[0068] In the third stage, the time elapsed from the receiving network card to the receiving application layer, i.e., the processing time of the instruction within the receiving end, can include the time it takes for the data packet to be processed in the receiving kernel protocol stack, wait in the network receiving queue, and be retrieved by the application. The aforementioned acquisition of the network transmission time and the third timestamp of receiving the first packet data refers to the third timestamp corresponding to the receiving network card receiving the first packet data as the starting point of the third stage. Similarly, the aforementioned acquisition of the fourth timestamp of receiving the second packet data refers to the fourth timestamp corresponding to the receiving application layer receiving the second packet data as the ending point of the third stage. It is understandable that the specific timing of acquiring the third and fourth timestamps can be determined based on the actual situation, requirements, and acquisition methods.
[0069] For example, the third link from the receiving end's network card to the receiving end's application layer can be the time from when the first packet data enters the receiving end's kernel socket buffer through the receiving end's network card and is queued until it is retrieved by the receiving end's application.
[0070] Specifically, the calculation method for the time taken in the third stage includes recording the starting point T3 and the ending point T4 of the third stage.
[0071] The starting point T3 of the third stage can be defined as follows: when the receiving network card receives the first data packet, it immediately acquires a monotonic clock timestamp, i.e., the third timestamp T3. Specifically, this can be achieved through the eBPF TC egress hook, recording the time when the data packet enters the network card, i.e., the third timestamp T3, and recording the acquired network transmission time T. n The third timestamp T3 is written into the first message data to obtain the second message data.
[0072] The endpoint T4 of the third stage can be recorded as a monotonic timestamp, i.e., the fourth timestamp T4, when the receiving application successfully receives the instruction data from the system call. Specifically, the application obtains the data packet time through system calls (read(), recv()).
[0073] It should be noted that T1, T2, T3, and T4 are actually time points, and T... n The actual timestamps are time intervals. T1 and T2 are monotonic clock timestamps recorded by the instruction sending device, while T3 and T4 are monotonic clock timestamps recorded by the instruction receiving device.
[0074] The instruction timeliness verification method provided in this application can be executed by an instruction timeliness verification device 200. This application uses the instruction timeliness verification device 200 executing the instruction timeliness verification method as an example to illustrate the instruction timeliness verification device 200 provided in this application.
[0075] Please see Figure 3 This is a schematic diagram of the structure of an instruction timeliness verification device 200 provided in an embodiment of this application. Figure 3 As shown, the instruction validity verification device 200 includes:
[0076] The generation module 201 is used to generate a sending command through the sending application layer and obtain the first timestamp of the generated sending command;
[0077] The sending module 202 is used to send first message data to the instruction receiving device through the sending end network card. The first message data includes a first timestamp, a second timestamp, the total lifespan of the sending instruction, and instruction content data. The total lifespan is the effective time data of the sending instruction, and the second timestamp is used to indicate the time when the first message data is sent.
[0078] Specifically, when the receiving network card of the command receiving device receives the first message data, it obtains the network transmission time and the third timestamp of receiving the first message data, and adds the network transmission time and the third timestamp to the first message data to obtain the second message data. The network transmission time is the time consumed when the first message data travels from the sending network card to the receiving network card. When the receiving application layer of the command receiving device receives the second message data, it obtains the fourth timestamp of receiving the second message data. Based on the second message data and the fourth timestamp, the receiving application layer obtains the sending command and the timeliness information of the sending command.
[0079] Since the instruction timeliness verification device 200 adopts all the technical solutions of the instruction timeliness verification method of the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, and will not be described in detail here.
[0080] See below. Figure 4 This application further describes another embodiment of the present application. Another embodiment of the present application also proposes an instruction timeliness verification method, applied to an instruction sending device, which includes the following steps:
[0081] Step 301: Receive the first message data through the receiving end network card, obtain the network transmission time and the third timestamp of the received first message data, and add the third timestamp and the network transmission time to the first message data to obtain the second message data; wherein, the network transmission time is the time consumed for the first message data to travel from the sending end network card of the instruction sending device to the receiving end network card; wherein, the first message data is sent from the sending end network card of the instruction sending device to the instruction receiving device, wherein, the first message data includes a first timestamp, a second timestamp, the total lifecycle of the sending instruction, and instruction content data, the total lifecycle being the effective time data of the sending instruction, the first timestamp being used to indicate the time when the sending end application layer of the instruction sending device generates the sending instruction, and the second timestamp being used to indicate the time when the sending end network card of the instruction sending device sends the first message data;
[0082] Step 302: Receive the second message data through the receiving end application layer and obtain the fourth timestamp of the received second message data. Based on the second message data and the fourth timestamp, obtain the sending instruction and the timeliness information of the sending instruction.
[0083] In this embodiment, the verification scheme that relies on system time is abandoned. Instead, the time of instruction validity is verified by relative time calculated dynamically. Instead of directly transmitting the start and end times of the instruction determined by system time, the total lifecycle of the instruction is preset. During the transmission of the instruction, the timestamps before and after each processing step are obtained. The time consumed by each step can be calculated using the timestamps to determine the remaining validity period of the sent instruction. Ultimately, the receiving end can determine the true validity information of the instruction and accurately judge whether the instruction has expired. Since the judgment process does not depend on system time, it can avoid the influence of system time modification and ensure the accuracy of the verification mechanism.
[0084] In some implementations, the sending instruction and its timeliness information are obtained based on the second message data and the fourth timestamp, including:
[0085] Based on the second message data, the first timestamp, second timestamp, third timestamp, total lifecycle, and instruction content data are obtained through parsing.
[0086] Based on the instruction content data, the sending instruction can be reconstructed;
[0087] The total time consumed is obtained based on the first timestamp, the second timestamp, the network transmission time, the third timestamp, and the fourth timestamp.
[0088] Timeliness information is obtained based on the total lifecycle and total consumption time.
[0089] In this embodiment, by parsing the second message data, the first, second, and third timestamps, total lifetime, and instruction content data carried by it can be obtained. Based on the first, second, and third timestamps, the network transmission time, the third, and fourth timestamps, the total time consumed by the three stages of the entire instruction transmission process can be obtained. Then, by comparing it with the preset total lifetime of the instruction, the actual timeliness of the instruction can be determined. Since the judgment process does not depend on the system time, it can avoid the influence of system time modification and ensure the accuracy of the verification mechanism.
[0090] In some implementations, the total elapsed time is obtained based on a first timestamp, a second timestamp, a network transmission time, a third timestamp, and a fourth timestamp, including:
[0091] The first elapsed time is obtained based on the difference between the first and second timestamps;
[0092] The second time consumed is obtained based on the difference between the third and fourth timestamps;
[0093] The total time consumed is obtained by summing the first consumption time, network transmission time, and second consumption time.
[0094] In this embodiment, the first time consumed from the sending application layer to the sending network card can be obtained based on the difference between the first timestamp and the second timestamp. The time consumed from the sending network card to the receiving network card can be obtained based on the network transmission time. The second time consumed from the receiving network card to the receiving application layer can be obtained based on the difference between the third timestamp and the fourth timestamp. The total time consumed by the three stages of the entire instruction transmission process can be obtained by summing the first time consumed, the network transmission time, and the second time consumed.
[0095] In some implementations, timeliness information is obtained based on the total lifecycle and total consumption time, including:
[0096] If the total lifecycle is greater than the total consumption time, the timeliness information indicates that the sending instruction is valid;
[0097] If the total lifecycle is less than or equal to the total consumption time, the timeliness information indicates that the sending instruction is invalid.
[0098] In this embodiment, the total time consumed is compared with the total lifecycle to determine the remaining validity period of the sent instruction. Ultimately, the receiving end can determine the true validity information of the instruction and accurately judge whether the instruction has expired. Since the judgment process does not depend on the system time, it can avoid the influence of system time modification and ensure the accuracy of the verification mechanism.
[0099] In some implementations, the difference between the total lifetime and the total time consumed can be obtained and determined as the remaining lifetime. Based on the value of the remaining lifetime, it can be accurately determined whether the instruction has expired or become invalid.
[0100] In some implementations, after the receiving application layer obtains the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp, it further includes:
[0101] If the timeliness information indicates that the sending instruction is valid, the receiving application layer executes the corresponding instruction operation;
[0102] If the timeliness information indicates that the sending instruction is invalid, the receiving application layer performs an expiration processing operation.
[0103] In this implementation, when the receiving application layer determines that the instruction is valid, it will execute the corresponding operation according to the instruction's requirements, ensuring that the system can operate normally based on the instruction. Expiration handling can take various forms, such as directly discarding the instruction data to avoid invalid instructions occupying and interfering with system resources, or recording relevant information about the expired instruction, such as the instruction content, sending time, and expiration time, for subsequent analysis and troubleshooting, facilitating monitoring and evaluation of the system's operational status. This series of operations further improves the instruction validity verification mechanism, making the entire system more rigorous and efficient in processing instructions, better able to handle various complex situations, and ensuring stable system operation.
[0104] In some implementations, the core of this application's solution lies in converting the absolute time validity period of the instruction, such as "valid before 13:00:00", into a relative time budget, such as "valid within 500 milliseconds after generation". Then, by accurately measuring the actual time consumed by the instruction at each stage of the transmission path and deducting it from the total time budget, the receiving end determines whether the instruction is valid by checking whether the remaining time budget is greater than zero. This instruction validity verification method based on dynamic time consumption calculation has higher accuracy and reliability compared to traditional verification schemes that rely on system time. It completely eliminates the dependence on high-precision clock synchronization between various devices and prevents verification failure caused by system time tampering. It is suitable for instruction transmission scenarios across devices.
[0105] In real-world applications, system time may be modified for various reasons, such as manual adjustment by the user or NTP synchronization failures. This can lead to errors or even misjudgments in verifying the timeliness of instructions that rely on system time. The solution in this application, however, uses relative time for verification, avoiding these problems and enabling more accurate determination of instruction timeliness.
[0106] Furthermore, this solution maintains good adaptability under different network environments and equipment conditions. Whether in an environment with good network conditions and stable data transmission, or in a complex network environment with high latency and frequent fluctuations, it can accurately record the timestamps of each step, calculate the time consumption of each step, and thus determine the true timeliness information of the instruction.
[0107] In subsequent applications and development, this method and device for verifying the timeliness of instructions can be applied to more fields with high requirements for instruction timeliness, such as industrial automation control, financial trading systems, and intelligent transportation systems. For example, in industrial automation control, the timely and accurate execution of instructions is related to production safety and efficiency. This solution can ensure that control instructions are accurately executed within their validity period, avoiding production accidents caused by expired instructions. For example, in financial trading systems, the timeliness of trading instructions directly affects the success or failure of transactions and the safety of funds. This solution can effectively guarantee the timeliness of trading instructions, improving the success rate and security of transactions. For example, in intelligent transportation systems, the timely transmission and execution of traffic control instructions are crucial for ensuring smooth and safe traffic flow. This solution can provide reliable support for verifying the timeliness of traffic instructions.
[0108] The instruction timeliness verification method provided in another embodiment of this application can be executed by an instruction timeliness verification device 400. This application uses the instruction timeliness verification device 400 executing the instruction timeliness verification method as an example to illustrate the instruction timeliness verification device 400 provided in this application embodiment.
[0109] Please see Figure 5 This is a schematic diagram of the structure of an instruction timeliness verification device 400 provided in an embodiment of this application. Figure 5 As shown, the instruction validity verification device 400 includes:
[0110] The receiving module 401 is used to receive first message data through the receiving end network card, obtain the network transmission time and the third timestamp of the received first message data, and add the third timestamp and the network transmission time to the first message data to obtain second message data; wherein, the network transmission time is the time consumed for the first message data to travel from the sending end network card of the instruction sending device to the receiving end network card; wherein, the first message data is sent from the sending end network card of the instruction sending device to the instruction receiving device, wherein, the first message data includes a first timestamp, a second timestamp, the total lifespan of the sending instruction, and instruction content data, wherein the total lifespan is the effective time data of the sending instruction, the first timestamp is used to indicate the time when the sending end application layer of the instruction sending device generates the sending instruction, and the second timestamp is used to indicate the time when the sending end network card of the instruction sending device sends the first message data;
[0111] The module 402 is used to receive the second message data through the application layer of the receiving end, obtain the fourth timestamp of the received second message data, and obtain the sending instruction and the timeliness information of the sending instruction based on the second message data and the fourth timestamp.
[0112] In some implementations, module 402 can be used for:
[0113] Based on the second message data, the first timestamp, second timestamp, third timestamp, total lifecycle, and instruction content data are obtained through parsing.
[0114] Based on the instruction content data, the sending instruction can be reconstructed;
[0115] The total time consumed is obtained based on the first timestamp, the second timestamp, the network transmission time, the third timestamp, and the fourth timestamp.
[0116] Timeliness information is obtained based on the total lifecycle and total consumption time.
[0117] In some implementations, module 402 can be used for:
[0118] The first elapsed time is obtained based on the difference between the first and second timestamps;
[0119] The second time consumed is obtained based on the difference between the third and fourth timestamps;
[0120] The total time consumed is obtained by summing the first consumption time, network transmission time, and second consumption time.
[0121] In some implementations, module 402 can be used for:
[0122] If the total lifecycle is greater than the total consumption time, the timeliness information indicates that the sending instruction is valid;
[0123] If the total lifecycle is less than or equal to the total consumption time, the timeliness information indicates that the sending instruction is invalid.
[0124] In some implementations, module 402 can also be used for:
[0125] If the timeliness information indicates that the sending instruction is valid, the receiving application layer executes the corresponding instruction operation;
[0126] If the timeliness information indicates that the sending instruction is invalid, the receiving application layer performs an expiration processing operation.
[0127] Since the instruction timeliness verification device 400 adopts all the technical solutions of the instruction timeliness verification method of the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, and will not be described in detail here.
[0128] Figure 6 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application.
[0129] This electronic device may include a processor 501 and a memory 502 storing computer program instructions.
[0130] Specifically, the processor 501 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0131] Memory 502 may include mass storage for data or instructions. For example, and not limitingly, memory 502 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 502 may include removable or non-removable (or fixed) media. Where appropriate, memory 502 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 502 is non-volatile solid-state memory.
[0132] In some embodiments, memory 502 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Thus, generally, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of this disclosure.
[0133] The processor 501 reads and executes computer program instructions stored in the memory 502 to implement any of the instruction timeliness verification methods in the above embodiments.
[0134] In one example, the electronic device may also include a communication interface 503 and a bus 510. Wherein, as... Figure 6 As shown, the processor 501, memory 502, and communication interface 503 are connected through bus 510 and complete communication with each other.
[0135] The communication interface 503 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0136] Bus 510 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 510 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.
[0137] The electronic device can execute the instruction timeliness verification method in the embodiments of this application, thereby achieving the combination of Figure 1 , Figure 3 or Figure 4 , Figure 5 The described method and apparatus for verifying the validity of instructions.
[0138] Furthermore, in conjunction with the instruction timeliness verification methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the instruction timeliness verification methods in the above embodiments.
[0139] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0140] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0141] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0142] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.
[0143] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. An instruction age verification method, characterized by, The application is applied to an instruction sending device, comprising: generating a sending instruction through a sending end application layer, and obtaining a first timestamp of generating the sending instruction; sending first message data to an instruction receiving device through a sending end network card, wherein the first message data comprises the first timestamp, a second timestamp, and total life cycle and instruction content data of the sending instruction, the total life cycle is valid time data of the sending instruction, and the second timestamp is used for indicating a time of sending the first message data; wherein, in the case that the receiving end network card of the instruction receiving device receives the first message data, a network transmission time and a third timestamp of receiving the first message data are obtained, and the network transmission time and the third timestamp are added to the first message data to obtain second message data, wherein the network transmission time is a consumption time of the first message data from the sending end network card to the receiving end network card; in the case that the receiving end application layer of the instruction receiving device receives the second message data, a fourth timestamp of receiving the second message data is obtained; in the case that the receiving end application layer obtains the fourth timestamp, the sending instruction and time limit information of the sending instruction are obtained according to the second message data and the fourth timestamp; wherein, the obtaining of the sending instruction and the time limit information of the sending instruction according to the second message data and the fourth timestamp comprises: parsing the first timestamp, the second timestamp, the third timestamp, the total life cycle and the instruction content data from the second message data; restoring the sending instruction from the instruction content data; obtaining a total consumption time according to the first timestamp, the second timestamp, the network transmission time, the third timestamp and the fourth timestamp; obtaining the time limit information according to the total life cycle and the total consumption time; wherein, the obtaining of the time limit information according to the total life cycle and the total consumption time comprises: in the case that the total life cycle is greater than the total consumption time, the time limit information indicates that the sending instruction is valid; in the case that the total life cycle is less than or equal to the total consumption time, the time limit information indicates that the sending instruction is invalid.
2. An instruction aging verification apparatus, characterized by comprising: comprising: a generating module for generating a sending instruction through a sending end application layer, and obtaining a first timestamp of generating the sending instruction; a sending module for sending first message data to an instruction receiving device through a sending end network card, wherein the first message data comprises the first timestamp, a second timestamp, and total life cycle and instruction content data of the sending instruction, the total life cycle is valid time data of the sending instruction, and the second timestamp is used for indicating a time of sending the first message data; The network transmission time is the consumption time of the first message data from the sending end network card to the receiving end network card. The receiving end application layer of the instruction receiving device obtains a fourth timestamp of receiving the second message data in the case of obtaining the fourth timestamp. The sending instruction and the time limit and deadline information of the sending instruction are obtained according to the second message data and the fourth timestamp. The sending instruction and the time limit and deadline information of the sending instruction are obtained according to the second message data and the fourth timestamp. The first timestamp, the second timestamp, the third timestamp, the total life cycle and the instruction content data are parsed according to the second message data. The sending instruction is restored according to the instruction content data. The total consumption time is obtained according to the first timestamp, the second timestamp, the network transmission time, the third timestamp and the fourth timestamp. The time limit and deadline information is obtained according to the total life cycle and the total consumption time. The time limit and deadline information is obtained according to the total life cycle and the total consumption time.
3. An instruction age verification method, characterized by, In the case that the total life cycle is greater than the total consumption time, the time limit and deadline information indicates that the sending instruction is valid. In the case that the total life cycle is less than or equal to the total consumption time, the time limit and deadline information indicates that the sending instruction is invalid. The instruction receiving device comprises: The first message data is received by the receiving end network card, and the network transmission time and the third timestamp of receiving the first message data are obtained, and the third timestamp and the network transmission time are added to the first message data to obtain the second message data; wherein the network transmission time is the consumption time of the first message data from the sending end network card of the instruction sending device to the receiving end network card; wherein the first message data is sent to the instruction receiving device by the sending end network card of the instruction sending device, wherein the first message data comprises a first timestamp, a second timestamp and a total life cycle of a sending instruction, instruction content data, the total life cycle is the valid time data of the sending instruction, the first timestamp is used to indicate the time when the sending end application layer of the instruction sending device generates the sending instruction, and the second timestamp is used to indicate the time when the sending end network card of the instruction sending device sends the first message data. The second message data is received by the receiving end application layer, and the fourth timestamp of receiving the second message data is obtained, and the sending instruction and the time limit and deadline information of the sending instruction are obtained according to the second message data and the fourth timestamp. The second message data is received by the receiving end application layer, and the fourth timestamp of receiving the second message data is obtained, and the sending instruction and the time limit and deadline information of the sending instruction are obtained according to the second message data and the fourth timestamp. The method comprises the following steps: According to the second message data, the first timestamp, the second timestamp, the third timestamp, the total life cycle and the instruction content data are parsed and obtained; According to the instruction content data, the sending instruction is restored and obtained; According to the first timestamp, the second timestamp, the network transmission time, the third timestamp and the fourth timestamp, the total consumption time is obtained; According to the total life cycle and the total consumption time, the time limit information is obtained; According to the total life cycle and the total consumption time, the time limit information is obtained; In the case that the total life cycle is greater than the total consumption time, the time limit information indicates that the sending instruction is valid; In the case that the total life cycle is less than or equal to the total consumption time, the time limit information indicates that the sending instruction is invalid.
4. The instruction aging verification method of claim 3, wherein, The method comprises the following steps: According to the difference between the first timestamp and the second timestamp, the first consumption time is obtained; According to the difference between the third timestamp and the fourth timestamp, the second consumption time is obtained; According to the sum of the first consumption time, the network transmission time and the second consumption time, the total consumption time is obtained.
5. The instruction aging verification method of claim 3, wherein, After the receiving end application layer obtains the sending instruction and the time limit information of the sending instruction according to the second message data and the fourth timestamp, the receiving end application layer further comprises the following steps: In the case that the time limit information indicates that the sending instruction is valid, the receiving end application layer performs corresponding instruction operation; In the case that the time limit information indicates that the sending instruction is invalid, the receiving end application layer performs expiration processing operation.
6. An instruction age verification apparatus, characterized by comprising: The method comprises the following steps: The receiving module is used for receiving the first message data through the receiving end network card, obtaining the network transmission time and the third timestamp of receiving the first message data, and adding the third timestamp and the network transmission time to the first message data to obtain the second message data; wherein the network transmission time is the consumption time of the first message data from the sending end network card of the instruction sending device to the receiving end network card; wherein the first message data is sent by the sending end network card of the instruction sending device to the instruction receiving device, and the first message data comprises the first timestamp, the second timestamp, the total life cycle of the sending instruction, and the instruction content data; the total life cycle is the valid time data of the sending instruction; the first timestamp is used for indicating the time when the sending end application layer of the instruction sending device generates the sending instruction; and the second timestamp is used for indicating the time when the sending end network card of the instruction sending device sends the first message data. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The obtaining module is configured to receive the second message data by a receiving end application layer, obtain a fourth timestamp of receiving the second message data, and obtain the sending instruction and time limit information of the sending instruction according to the second message data and the fourth timestamp. The computer readable storage medium stores computer executable instructions for causing a computer to perform the steps of the instruction time limit verification method according to any one of claims 1 or 3-5. The computer readable storage medium stores computer executable instructions for causing a computer to perform the steps of the instruction time limit verification method according to any one of claims 1 or 3-5.
7. An electronic device, comprising: 8. A computer-readable storage medium, characterized in that,
Citation Information
Patent Citations
Aging method and device for domain name cache entry
CN107547295A
Aging guarantee method, device and system
CN117200921A