A Virtual Data Link Collaborative Switching Method and System for IoT Terminals
By recording and verifying the instruction boundaries and execution status during the virtual data link transition process of IoT terminals, the continuity of the link transition is ensured, the problem of inconsistency between the virtual data link boundary and the terminal execution boundary is solved, and the stability and consistency of the terminal status are achieved.
Patent Information
- Application Number
- CN202611146140.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-11-17
AI Technical Summary
During link switching, the boundary of the virtual data link of existing IoT terminals is inconsistent with the actual execution boundary of the terminal, which may cause control messages to become outdated, resulting in repeated actions or state rollback, especially when the interaction between the periodically dormant terminal and the gateway is not timely.
By establishing a virtual data link status record, including the current link epoch, source gateway identifier, instruction delivery boundary sequence number, instruction execution boundary sequence number, and terminal execution status verification value, the target gateway is determined and a transfer status packet is sent. The target gateway verifies the execution status of the control instruction, ensuring the continuity of the link transfer and isolating the source gateway when necessary.
This effectively avoids the repeated execution of control commands and state forks, ensures the consistency between the virtual data link state and the actual execution state of the terminal, and prevents repeated actions and state rollback.
Smart Images

Figure CN123124017A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) technology, specifically to a virtual data link collaborative switching method and system for IoT terminals. Background Technology
[0002] In data transfer for execution-oriented IoT terminals, link continuity is not the same as control continuity. Existing systems typically use whether a message is delivered as the boundary of virtual data link continuity, and when the physical link changes, they transfer the terminal communication relationship from the source gateway to the target gateway through buffer retention, sequence number continuation, or retransmission of unacknowledged messages.
[0003] However, there is an execution interval between the terminal receiving the control message and the terminal completing the corresponding physical action. If a link transfer occurs during this interval, the target gateway may send subsequent control messages first, while the earlier control messages retained by the source gateway arrive later due to retransmission or transmission delays. In this case, the caching and retransmission mechanisms originally intended to avoid data loss may instead cause outdated control messages to be executed after the new control messages, resulting in repeated actions or state rollbacks for terminals such as valves, motors, or switches.
[0004] For IoT terminals that are in periodic dormancy, gateways still struggle to promptly identify control messages that the terminal has received but not yet executed through continuous interaction. Therefore, the message boundaries upon which existing virtual data link switching is based are not consistent with the actual execution boundaries of the terminal. How to prevent this boundary misalignment from transforming into a reverse change in physical control state during link switching is a technical problem that needs to be solved in this field. Summary of the Invention
[0005] The purpose of this invention is to provide a virtual data link collaborative switching method and system for Internet of Things (IoT) terminals to solve the problems mentioned in the background art.
[0006] To address the aforementioned technical problems, this invention provides the following technical solution: a virtual data link collaborative switching method for IoT terminals, comprising the following steps: Step S1: Establish a virtual data link status record for the IoT terminal. The record includes the current link epoch, source gateway identifier, instruction delivery boundary sequence number, instruction execution boundary sequence number, and terminal execution status verification value. Step S2: In response to the physical link of the source gateway meeting the transfer conditions, obtain the control command to be confirmed and the most recently returned execution receipt from the terminal, determine the target gateway from the candidate gateways that receive the same uplink data frame, and send a transfer status packet to the target gateway. Step S3: Control the target gateway to send a link switching frame within the downlink receiving window associated with the uplink data frame. The frame carries the link epoch to be activated, the first control command, and its predecessor status check value. Step S4: Compare the predecessor status verification value with the local execution status verification value. If they match, execute the first control instruction and generate an execution receipt based on the physical status feedback. If they do not match, prevent execution and generate a boundary difference receipt carrying the local instruction execution boundary sequence number and the local execution status verification value. Step S5: In response to the execution receipt forwarded by the target gateway satisfying the transfer submission condition, switch the physical gateway mapping to the target gateway and put the source gateway into the old link epoch isolation state; in response to the receipt of boundary difference or execution receipt timeout, maintain the physical gateway mapping of the source gateway and start instruction gap recovery.
[0007] According to the above technical solution, the instruction delivery boundary number is the largest instruction number among the control instructions that the IoT terminal has continuously confirmed to receive, and the instruction execution boundary number is the largest instruction number among the continuous control instructions that have been confirmed to have been executed based on physical state feedback. The terminal execution status verification value is generated based on the instruction execution boundary number and at least two of the following: the position feedback value of the execution component of the IoT terminal, the switch status, the output register value, and the fault status. After each confirmation control instruction is completed, the updated instruction execution boundary number is associated with the terminal execution status verification value and written into the virtual data link status record.
[0008] According to the above technical solution, determining the target gateway from the candidate gateways includes: Obtain the reception timestamp of each candidate gateway receiving the same uplink data frame, and determine the downlink reception window corresponding to the IoT terminal based on the reception timestamp; Calculate the preparation margin for each candidate gateway after completing the reception of the transfer status packet, encapsulation of the link transfer frame, and preparation for radio frequency transmission before the downlink reception window opens. Candidate gateways with a preparation margin greater than the transmission protection duration and which have been fully loaded with the transfer status packet are identified as relayable gateways, and the target gateway is determined from the relayable gateways. If no relay gateway is available, the current handover is delayed, and the target gateway is re-determined in the next uplink data frame of the IoT terminal. No additional wake-up request is sent to the IoT terminal.
[0009] According to the above technical solution, a transfer status packet is sent to the target gateway, including: An execution state transition barrier is constructed using the instruction execution boundary sequence number and its corresponding terminal execution state verification value; Control instructions whose sequence number is not greater than the instruction execution boundary sequence number are marked as closed instructions; control instructions whose sequence number is greater than the instruction execution boundary sequence number but not greater than the instruction delivery boundary sequence number are marked as instructions to be verified; and control instructions whose sequence number is greater than the instruction delivery boundary sequence number are marked as undelivered instructions. The pending verification instruction and undelivered instruction are extracted from the instruction cache of the source gateway, and an instruction sequence number, predecessor status verification value and expected successor status verification value are associated with each control instruction to form the transfer status packet; before the transfer is submitted, the target gateway does not resend the pending verification instruction except in response to the boundary difference acknowledgment execution instruction gap recovery.
[0010] According to the above technical solution, the IoT terminal processes the control commands in the link transfer frame, including: Read the locally stored link epoch, local instruction execution boundary sequence number, and local execution status verification value; When the instruction sequence number of the control instruction is not greater than the local instruction execution boundary sequence number, the control instruction is prevented from being executed repeatedly, and the historical execution result corresponding to the control instruction is returned; When the instruction sequence number of the control instruction is the next consecutive sequence number after the local instruction execution boundary sequence number, and the predecessor state verification value is consistent with the local execution state verification value, the control instruction is delivered to the terminal execution unit. When the instruction sequence number of the control instruction is not continuous with the local instruction execution boundary sequence number, or when the predecessor state verification value is inconsistent with the local execution state verification value, the current state of the terminal execution unit is maintained, and the missing start sequence number, received instruction sequence number and local execution state verification value are written into the boundary difference receipt.
[0011] According to the above technical solution, the instruction gap recovery includes: Based on the local instruction execution boundary number and local execution status verification value in the boundary difference receipt, search for the first control instruction in the transition status packet whose predecessor status verification value matches the local execution status verification value. Starting with the found control instruction, and based on the condition that the expected successor state check value of the previous control instruction is the same as the predecessor state check value of the next control instruction, the shortest continuous instruction chain extending to the control instruction that is prevented from being executed is constructed. The shortest continuous instruction chain is sent sequentially through the target gateway, and the next control instruction is released after receiving the execution receipt of the previous control instruction. If the shortest continuous instruction chain is not found, the proposed link activation epoch is revoked, the target gateway stops sending control commands, and the source gateway continues to maintain the current virtual data link.
[0012] According to the above technical solution, the step of generating an execution receipt based on the physical state feedback after execution includes: In response to a control command being delivered to the terminal execution unit, at least one of the following is collected: the actual position value of the terminal execution unit, the state of the switch contact, the current feedback value, and the operating status word; The collected results are compared with the expected execution state range carried by the control command. When the collected results remain within the expected execution state range for the verification time, the execution of the control command is confirmed to be complete, and the local command execution boundary sequence number and local execution state verification value are updated. If the collected results do not enter the expected execution state range or leave the expected execution state range within the verification time, the local instruction execution boundary number is not updated, and an execution failure receipt containing the actual physical state and execution exception identifier is generated.
[0013] According to the above technical solution, enabling the source gateway to enter the old link epoch isolation state includes: The source gateway is prohibited from continuing to send control commands carrying the old link epoch, while retaining the source gateway's ability to receive acknowledgments of the old link epoch. For the execution receipt received by the source gateway during the isolation period, if the corresponding instruction sequence number is not greater than the instruction execution boundary sequence number at the time of transfer submission, the execution receipt is merged into the historical execution record; if the corresponding instruction sequence number is greater than the instruction execution boundary sequence number at the time of transfer submission, the execution receipt is forwarded to the link coordination node for boundary conflict verification. The isolation duration of the old link epoch is not less than the sum of the maximum message retention duration of the source physical link and the control command retransmission retention duration of the source gateway. When the isolation duration expires and there are no unprocessed boundary conflicts, the old link epoch state saved by the source gateway is released.
[0014] A virtual data link collaborative switching system for IoT terminals includes a link collaboration node, at least two IoT gateways, and IoT terminals. The at least two IoT gateways act as a source gateway and a target gateway, respectively, before and after the virtual data link switching. The link coordination node includes a status recording unit, a transfer control unit, and a mapping submission unit. The status recording unit records the current link epoch of the virtual data link, the physical gateway mapping, the instruction delivery boundary number, the instruction execution boundary number, and the terminal execution status verification value. The transfer control unit generates a transfer status packet in response to physical link transfer conditions and sends the transfer status packet to the target gateway. The mapping submission unit submits or cancels the virtual data link transfer based on the execution receipt forwarded by the target gateway. The source gateway includes an instruction cache and a status packaging unit. The status packaging unit is used to extract the control instruction to be confirmed after the instruction execution boundary number from the instruction cache, and write the control instruction to be confirmed into the transfer status packet. The target gateway includes a receiving window control unit and a receipt forwarding unit. The receiving window control unit is used to send a link transition frame carrying the link epoch to be enabled and the predecessor state verification value within the downlink receiving window associated with the uplink data frame of the IoT terminal. The receipt forwarding unit is used to send the execution receipt or boundary difference receipt returned by the IoT terminal to the link coordination node. The IoT terminal includes an execution status register, an instruction fence unit, and an execution feedback interface. The execution status register is used to store the local link epoch, the local instruction execution boundary number, and the local execution status verification value. The instruction fence unit is used to determine whether to allow execution, block execution, or return the historical execution result based on the instruction number of the control instruction and the predecessor status verification value. The execution feedback interface is used to collect the physical status of the terminal's execution components and generate an execution receipt containing the link epoch, the instruction execution boundary number, and the execution status verification value.
[0015] According to the above technical solution, the execution status register includes a first status storage area and a second status storage area that are written alternately. Each status storage area is used to store the link epoch, instruction execution boundary sequence number, terminal execution status verification value, write version number and integrity verification code. After confirming that the physical action corresponding to the control command has been completed, the IoT terminal writes the updated link epoch, command execution boundary sequence number and terminal execution status verification value into the currently inactive state storage area. After completing the integrity verification, it switches the valid area identifier. In response to the IoT terminal being powered on again, it selects the state storage area with the larger version number from the state storage areas that have passed the integrity verification to restore the execution state.
[0016] Compared with existing technologies, the beneficial effects achieved by this invention are as follows: This invention distinguishes between the delivered state and the actual execution state of control instructions by simultaneously recording the instruction delivery boundary, instruction execution boundary, and terminal execution status verification value. During link switching, the terminal verifies the continuity between the first control instruction and the local execution state, and uses the execution receipt as the basis for switching the physical gateway mapping. When the verification passes, the system switches to the target gateway and isolates the source gateway. When boundary differences occur or the receipt times out, the original mapping is maintained and the instruction gap is restored, thereby avoiding instruction replay, out-of-order execution, and duplicate execution and state forking caused by concurrent control of dual gateways, ensuring that the virtual data link state is consistent with the actual execution state of the terminal. Attached Figure Description
[0017] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a flowchart of the virtual data link collaborative switching method for IoT terminals according to the present invention; Figure 2 This is a structural diagram of the virtual data link collaborative switching system for IoT terminals according to the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] In this embodiment of the invention, an IoT terminal refers to a terminal device capable of receiving control commands via a wireless communication link and driving valves, relays, switches, actuators, or other terminal execution components to change their physical operating state according to the control commands. The IoT terminal can establish a communication connection with the business platform through at least two IoT gateways.
[0020] Furthermore, a virtual data link refers to the logical communication relationship formed between a business platform and an IoT terminal. The physical gateway corresponding to the virtual data link can change, but the terminal identifier and logical addressing relationship used by the business platform remain unchanged. Therefore, the coordinated switching of the virtual data link not only requires changing the physical gateway mapping, but also requires ensuring the continuous connection of control commands before and after the switching along the existing physical execution state of the IoT terminal.
[0021] Example 1 Please see Figure 1 This invention provides a virtual data link collaborative switching method for Internet of Things (IoT) terminals, the method comprising the following steps: Step S1: Establish a virtual data link status record for the IoT terminal. The record includes the current link epoch, source gateway identifier, instruction delivery boundary sequence number, instruction execution boundary sequence number, and terminal execution status verification value. Specifically, in step S1, the link coordination node can be set up in a business platform, an edge server, or a collaborative control device that can be accessed by multiple IoT gateways. The link coordination node establishes a virtual data link status record using the terminal identifier of the IoT terminal as an index, and updates the virtual data link status record according to the instruction delivery information sent by the source gateway and the execution receipt returned by the IoT terminal.
[0022] The current link epoch identifies the currently valid physical gateway mapping for the IoT terminal. Each time a virtual data link handover is completed and confirmed by the terminal's execution status, the link coordinating node updates the link epoch. Control commands carrying a link epoch value lower than the current link epoch are considered old link epoch control commands.
[0023] Specifically, the instruction delivery boundary number is the highest instruction number among the control instructions continuously acknowledged and received by the IoT terminal, while the instruction execution boundary number is the highest instruction number among the continuous control instructions whose execution has been confirmed based on physical state feedback. After a control instruction is received by the IoT terminal, the instruction delivery boundary number can advance; only after the IoT terminal completes the corresponding physical action and generates a valid execution receipt based on the actual state of the terminal's execution components will the instruction execution boundary number advance. Therefore, when the instruction delivery boundary number is greater than the instruction execution boundary number, although the control instruction between them has been delivered, it cannot be directly considered that physical execution has been completed.
[0024] The terminal execution status verification value is generated based on at least two of the following: instruction execution boundary sequence number and the position feedback value of the execution component of the IoT terminal, switch status, output register value, and fault status. In one embodiment, the terminal execution status verification value is expressed as: In the formula, This indicates the terminal execution status verification value. This indicates a preset verification operation. Indicates the instruction execution boundary number. This indicates the position feedback value of the terminal execution unit. Indicates the switch status or output register value. Indicates a fault state, symbol " "" indicates a combination of fields.
[0025] Furthermore, after each confirmed control command execution, the IoT terminal associates and saves the updated command execution boundary sequence number with the terminal execution status verification value, and sends it to the link coordination node via an execution receipt. The link coordination node then associates the two and writes them into the virtual data link status record. The terminal execution status verification value is generated with the participation of physical status feedback. Since the command delivery boundary sequence number is updated after the IoT terminal confirms receipt of the control command, while the command execution boundary sequence number and the terminal execution status verification value are only updated after the physical state of the terminal execution component reaches the expected execution state range, the link coordination node can distinguish whether the control command is in a state of being received but not yet confirmed for execution, or in a state where the expected physical execution result has been achieved, based on the difference between the command delivery boundary sequence number and the command execution boundary sequence number, and the correspondence between the terminal execution status verification value and the expected subsequent state verification value.
[0026] Step S2: In response to the physical link of the source gateway meeting the transfer conditions, obtain the control command to be confirmed and the most recently returned execution receipt from the terminal, determine the target gateway from the candidate gateways that receive the same uplink data frame, and send a transfer status packet to the target gateway. Specifically, in step S2, the physical link meeting the switching conditions may include a source gateway malfunction, the source gateway load exceeding a set threshold, a decrease in communication quality between the source gateway and the IoT terminal, or other IoT gateways having more suitable downlink communication conditions. Meeting the switching conditions only initiates the switching process and does not directly change the physical gateway mapping of the virtual data link.
[0027] In one specific implementation, when an IoT terminal sends an uplink data frame, multiple IoT gateways within its wireless coverage area may simultaneously receive the uplink data frame. Each IoT gateway sends the terminal identifier, frame identifier, reception timestamp, and reception status of the uplink data frame to the link coordination node. The link coordination node then forms a candidate gateway set by identifying IoT gateways that have received uplink data frames from the same terminal and with the same frame identifier.
[0028] Furthermore, the link coordination node obtains the reception timestamp of each candidate gateway receiving the same uplink data frame, and determines the downlink reception window corresponding to the IoT terminal based on the reception timestamp; calculates the preparation margin of each candidate gateway after completing the reception of the transfer status packet, encapsulation of the link transfer frame, and radio frequency transmission preparation before the downlink reception window opens; determines the candidate gateway with a preparation margin greater than the transmission protection duration and fully loaded with the transfer status packet as a relay gateway, and determines the target gateway from the relay gateways.
[0029] Specifically, when no suitable gateway exists, the link coordination node delays the handover and waits for the next uplink data frame from the IoT terminal to re-determine the target gateway, without sending an additional wake-up request to the IoT terminal. Therefore, the handover can be implemented using the downlink receiving window formed after the low-power IoT terminal's normal uplink, avoiding the need for separate status queries and wake-up interactions.
[0030] The link coordination nodes process the control commands to be confirmed based on the instruction execution boundary number, instruction delivery boundary number, and existing execution receipts. Specifically, an execution state transition barrier is constructed using the instruction execution boundary number and its corresponding terminal execution status verification value; control commands with a sequence number not greater than the instruction execution boundary number are marked as closed commands, control commands with a sequence number greater than the instruction execution boundary number but not greater than the instruction delivery boundary number are marked as commands to be verified, and control commands with a sequence number greater than the instruction delivery boundary number are marked as undelivered commands.
[0031] Closed commands have already received execution receipts based on physical state feedback and do not need to be resent during the handover process. Commands awaiting verification have been acknowledged by the IoT terminal but have not yet received execution receipts proving the completion of the physical action. Commands not yet delivered have not been acknowledged by the IoT terminal and need to be delivered by the physical gateway after the handover.
[0032] Furthermore, the link coordination node extracts the instructions to be verified and the undelivered instructions from the source gateway's instruction cache, and associates each control instruction with an instruction sequence number, a predecessor state verification value, and an expected successor state verification value to form a transition state packet. The predecessor state verification value indicates the execution state that the IoT terminal should have before executing the corresponding control instruction, and the expected successor state verification value indicates the execution state that the IoT terminal should form after the corresponding control instruction is executed.
[0033] In this embodiment of the invention, the target gateway establishes an execution-state transfer barrier after receiving the transfer status packet. Before submitting the transfer, the target gateway does not resend the pending verification instruction, except in response to the recovery of the gap in the execution instruction of the boundary difference receipt. This prevents the target gateway from resending the same control instruction when the pending verification instruction has already been delivered by the source gateway and actually executed by the IoT terminal, but its execution receipt has not yet been received by the link coordination node.
[0034] Step S3: Control the target gateway to send a link switching frame within the downlink receiving window associated with the uplink data frame. The frame carries the link epoch to be activated, the first control command, and its predecessor status check value. Specifically, in step S3, the target gateway generates a link transfer frame based on the transfer status packet and sends the link transfer frame within the downlink receive window associated with the same uplink data frame used to select the target gateway in step S2. A link epoch is activated to identify the virtual data link transfer to be confirmed, but the target gateway's completion of link transfer frame transmission does not indicate that the physical gateway mapping has been switched.
[0035] Specifically, the first control instruction in the pending transfer control instructions can be the undelivered instruction with the smallest sequence number. The preceding state verification value of the first control instruction corresponds to the terminal state that should be formed after executing its preceding control instructions in a predetermined instruction sequence.
[0036] For example, suppose the instruction execution boundary sequence number of the IoT terminal is 20 and the instruction delivery boundary sequence number is 21. The control instruction with sequence number 21 has been acknowledged and received by the IoT terminal, but the link coordination node has not yet obtained the corresponding execution acknowledgment. The control instruction with sequence number 22 is an undelivered instruction. The target gateway can use the control instruction with sequence number 22 as the first control instruction and make the control instruction with sequence number 22 carry the expected subsequent state verification value corresponding to sequence number 21.
[0037] If the IoT terminal has already executed control command number 21, its local command execution boundary number has been updated to 21, and a local execution status verification value consistent with the predecessor status verification value carried by command number 22 has been formed. Therefore, it can continue to execute control command number 22. If the IoT terminal has not yet executed control command number 21, its local execution status verification value is inconsistent with the predecessor status verification value carried by command number 22, and control command number 22 is prevented from being executed. Thus, the predecessor status requirement of subsequent control commands can be used to determine whether the command to be verified has formed the expected physical execution result, without having to directly resend the command to be verified.
[0038] As an optional implementation, when there is no undelivered instruction that can serve as the first control instruction in the transition status packet, the link coordination node can also generate a status confirmation instruction that does not change the current physical state of the terminal execution component, and write this status confirmation instruction into the transition status packet as the control instruction to be transferred. The IoT terminal responds to the status confirmation instruction by returning the local link epoch, the local instruction execution boundary sequence number, and the local execution status verification value, so that the link coordination node can verify the actual execution status at the time of transition.
[0039] Step S4: Compare the predecessor status verification value with the local execution status verification value. If they match, execute the first control instruction and generate an execution receipt based on the physical status feedback. If they do not match, prevent execution and generate a boundary difference receipt carrying the local instruction execution boundary sequence number and the local execution status verification value. Specifically, in step S4, after receiving the link transfer frame, the IoT terminal reads the locally stored link epoch, local instruction execution boundary sequence number, and local execution status verification value, and determines whether to allow execution, block execution, or return the historical execution result based on the instruction sequence number of the control instruction and the predecessor status verification value.
[0040] Specifically, when the instruction sequence number of a control command is not greater than the local instruction execution boundary sequence number, it indicates that the control command has been executed or belongs to a closed historical control command. The IoT terminal prevents the control command from being executed repeatedly and returns the historical execution result corresponding to the control command, avoiding repeated opening and closing of valves, repeated switching of relays, or unexpected displacement of the actuator motor.
[0041] When the instruction sequence number of the control instruction is the next consecutive sequence number after the local instruction execution boundary number, and the predecessor state check value is consistent with the local execution state check value, it indicates that the control instruction is continuously connected to the current state of the IoT terminal in terms of both instruction sequence and physical execution state. The IoT terminal delivers the control instruction to the terminal execution component.
[0042] When the instruction sequence number of the control instruction is not continuous with the local instruction execution boundary sequence number, or when the predecessor state verification value is inconsistent with the local execution state verification value, the IoT terminal maintains the current state of the terminal execution component and writes the missing start sequence number, received instruction sequence number and local execution state verification value into the boundary difference receipt.
[0043] After the control command is delivered to the terminal execution component, the IoT terminal collects at least one of the following: the actual position value of the terminal execution component, the state of the switch contact, the current feedback value, and the operating status word, and compares the collected results with the expected execution state range carried by the control command.
[0044] For example, taking an electric valve as an example, the control command requires the valve to open to the target opening degree. The IoT terminal collects the actual valve opening degree, the opening limit contact, the closing limit contact, the drive current, and the actuator operating status word. Only when the actual opening degree enters the expected execution state range, the limit contact status is correct, the drive current does not exceed the allowable range, and the collected results are continuously maintained within the expected execution state range for the verification time, does the IoT terminal confirm that the control command has been executed, update the local command execution boundary sequence number and the local execution status verification value, and generate an execution receipt.
[0045] Furthermore, when the collected results do not fall within the expected execution state range, or leave the expected execution state range within the verification period, the IoT terminal does not update the local instruction execution boundary sequence number, but generates an execution failure receipt containing the actual physical state and execution anomaly identifiers. Thus, the execution receipt confirms that the control instruction has acted on the terminal's execution components and formed a verifiable physical result, rather than merely confirming that wireless data has been received.
[0046] Step S5: In response to the execution receipt forwarded by the target gateway satisfying the transfer submission condition, switch the physical gateway mapping to the target gateway and put the source gateway into the old link epoch isolation state; in response to the receipt of boundary difference or execution receipt timeout, maintain the physical gateway mapping of the source gateway and start instruction gap recovery.
[0047] Specifically, in step S5, the transfer submission conditions include at least the following: the link epoch carried by the execution receipt is consistent with the link epoch to be enabled; the execution receipt is forwarded by the target gateway; the local instruction execution boundary sequence number carried by the execution receipt matches the execution order of the first control instruction; and the local execution status verification value carried by the execution receipt matches the expected subsequent status verification value corresponding to the first control instruction.
[0048] Upon receiving an execution confirmation that the transfer submission conditions are met, the link coordinating node switches the physical gateway mapping of the virtual data link from the source gateway to the target gateway. The target gateway then becomes the valid physical gateway for the virtual data link, and subsequent control commands are delivered via the target gateway according to the updated link epoch.
[0049] Furthermore, while switching the physical gateway mapping, the link coordinating node puts the source gateway into an old link epoch isolation state. After entering the old link epoch isolation state, the source gateway is prohibited from sending control commands carrying the old link epoch, but retains the ability to receive acknowledgments of old link epoch execution.
[0050] Specifically, for the execution receipt received by the source gateway during the isolation period, if the corresponding instruction sequence number is not greater than the instruction execution boundary sequence number at the time of transfer submission, the link coordination node will merge the execution receipt into the historical execution record; if the corresponding instruction sequence number is greater than the instruction execution boundary sequence number at the time of transfer submission, the source gateway will forward the execution receipt to the link coordination node for boundary conflict verification.
[0051] The isolation period for the old link epoch is no less than the sum of the maximum packet retention period of the source physical link and the control command retransmission retention period of the source gateway. When the isolation period expires and there are no unresolved boundary conflicts, the source gateway releases the stored old link epoch state.
[0052] In response to the link coordination node receiving a boundary difference acknowledgment, or failing to receive an execution acknowledgment that meets the transfer submission conditions within a set period, the completion of the virtual data link transfer is not based on the fact that the target gateway has completed the transmission of the link transfer frame. Instead, the physical gateway mapping of the source gateway is maintained and command gap recovery is initiated.
[0053] As an optional implementation, if the execution receipt is lost due to uplink transmission anomalies, the link coordination node can perform a status review during the instruction gap recovery process using the local link epoch, local instruction execution boundary sequence number, and local execution status check value carried by the IoT terminal during the next normal uplink. If the review result indicates that the IoT terminal has formed a continuous execution state corresponding to the control instruction to be transferred, the corresponding control instruction is closed, and the transfer submission conditions are re-evaluated. If the review result indicates that the IoT terminal has not yet executed the corresponding control instruction or that there is a gap in the execution state, recovery is performed according to Embodiment Two, without directly resending all pending confirmation control instructions.
[0054] Example 2 This embodiment describes the recovery of instruction gaps based on Embodiment 1.
[0055] Specifically, the link coordination node searches for the first control instruction in the transition status packet whose predecessor status verification value matches the local execution status verification value, based on the local instruction execution boundary sequence number and local execution status verification value in the boundary difference receipt.
[0056] Starting from the found control instruction, the link coordination node constructs the shortest continuous instruction chain extending to the blocked control instruction, based on the condition that the expected successor state verification value of the previous control instruction is the same as the predecessor state verification value of the next control instruction.
[0057] For example, assume that the transition state packet includes control commands numbered 21, 22, and 23. The predecessor state check value of command number 21 is... The expected subsequent state verification value is The predecessor status verification value for serial number 22 is... The expected subsequent state verification value is The predecessor status verification value for serial number 23 is... The expected subsequent state verification value is .
[0058] When the boundary difference receipt indicates that the local instruction execution boundary number of the IoT terminal is 21 and the local execution status verification value is... If this occurs, it indicates that the control command of sequence number 21 has been actually executed, but its original execution receipt was not received by the link coordinating node. At this point, the control command of sequence number 21 is not resent; instead, the shortest continuous command chain is constructed starting from sequence number 22.
[0059] When the boundary difference receipt indicates that the local instruction execution boundary sequence number of the IoT terminal is 20 and the local execution status verification value is... At that time, the link coordinating nodes construct the shortest continuous instruction chain starting from sequence number 21.
[0060] The target gateway sequentially sends control commands in the shortest consecutive command chain and releases the next control command after receiving the execution receipt of the previous control command. Each execution receipt needs to be generated based on the physical state feedback of the terminal execution component; therefore, the next control command is only released after the previous control command has generated a verifiable physical execution result.
[0061] Furthermore, when the link coordination node fails to find the shortest continuous instruction chain, it indicates that the actual physical state of the IoT terminal cannot be continuously interpreted from the control instructions in the transition state packet. In this case, the link coordination node cancels the proposed link epoch, stops the target gateway from sending control instructions, and allows the source gateway to continue maintaining the current virtual data link, thus avoiding the expansion of the terminal's physical state deviation by blindly resending control instructions.
[0062] Example 3 This embodiment, based on Embodiment 1 or Embodiment 2, explains how to save the execution state of an IoT terminal.
[0063] In this embodiment of the invention, the execution status register of the IoT terminal includes a first status storage area and a second status storage area that are alternately written. Each status storage area is used to store the link epoch, instruction execution boundary sequence number, terminal execution status verification value, write version number, and integrity verification code, and one of the status storage areas is marked as the currently valid status storage area.
[0064] After the IoT terminal confirms that the physical action corresponding to the control command has been completed, it writes the updated link epoch, command execution boundary sequence number, and terminal execution status verification value into the currently inactive state storage area, and also writes the incremented write version number and integrity verification code. After completing the integrity verification, the IoT terminal switches the valid area identifier, making the state storage area the new valid state storage area.
[0065] In an abnormal scenario, if the IoT terminal loses power during the state writing process, the original valid state storage area still retains the complete execution state, and will not generate inexplicable link epochs or instruction execution boundary numbers due to the fact that some fields have been updated.
[0066] In response to the IoT terminal being powered on again, the integrity check codes of the first state storage area and the second state storage area are verified respectively, and the state storage area with the larger write version number is selected from the state storage areas that have passed the integrity verification to restore the execution state.
[0067] Furthermore, after resuming execution, the IoT terminal can re-collect the actual location value, switch contact status, output register value, and fault status of the terminal execution components, and compare the re-collected physical status with the recovered terminal execution status verification value. When they match, the recovered link epoch and instruction execution boundary sequence number continue to be used; when they do not match, the current state of the terminal execution components is maintained and a boundary difference receipt is returned, and the link coordination node initiates instruction gap recovery.
[0068] By alternating state storage and physical state verification after power-on, it is possible to avoid power outages that occur when physical actions have already taken place but the corresponding execution states have not been fully written, thus preventing IoT terminals from repeatedly executing completed control commands after power-on.
[0069] Example 4 Please see Figure 2 This embodiment provides a virtual data link collaborative switching system for IoT terminals, including a link collaboration node, at least two IoT gateways, and IoT terminals. The at least two IoT gateways act as the source gateway and the target gateway, respectively, before and after the virtual data link switching.
[0070] Specifically, the link coordination node includes a status recording unit, a transfer control unit, and a mapping submission unit. The status recording unit records the current link epoch, physical gateway mapping, instruction delivery boundary number, instruction execution boundary number, and terminal execution status verification value of the virtual data link. The transfer control unit generates a transfer status packet in response to physical link transfer conditions and sends the transfer status packet to the target gateway. The mapping submission unit submits or cancels the virtual data link transfer based on the execution receipt forwarded by the target gateway.
[0071] Furthermore, the source gateway includes an instruction cache and a state packaging unit. The state packaging unit is used to extract the control instructions to be confirmed after the instruction execution boundary sequence number from the instruction cache and write the control instructions to be confirmed into the transition state packet. The source gateway is also used to enter the old link epoch isolation state after the physical gateway mapping switch, prevent the old link epoch control instructions from continuing to be sent, and receive the execution receipt corresponding to the old link epoch.
[0072] Accordingly, the target gateway includes a receive window control unit and a receipt forwarding unit. The receive window control unit is used to send a link transition frame carrying the proposed link epoch and the predecessor state check value within the downlink receive window associated with the uplink data frame of the IoT terminal. The receipt forwarding unit is used to send the execution receipt or boundary difference receipt returned by the IoT terminal to the link coordination node.
[0073] In this embodiment of the invention, the IoT terminal includes an execution status register, an instruction fence unit, and an execution feedback interface. The execution status register stores the local link epoch, the local instruction execution boundary number, and the local execution status verification value. The instruction fence unit determines whether to allow execution, block execution, or return historical execution results based on the instruction number of the control instruction and the predecessor status verification value. The execution feedback interface collects the physical state of the terminal's execution components and generates an execution receipt containing the link epoch, instruction execution boundary number, and execution status verification value.
[0074] The execution status register can include a first status storage area and a second status storage area that are written alternately. After confirming that the physical action corresponding to the control command has been completed, the IoT terminal writes the updated link epoch, command execution boundary sequence number, and terminal execution status verification value into the currently inactive status storage area. After completing the integrity verification, it switches the valid area identifier. In response to the IoT terminal being powered on again, it selects the status storage area with the larger written version number from the status storage areas that have passed the integrity verification to restore the execution status.
[0075] This invention records the instruction delivery boundary number and the instruction execution boundary number separately to avoid equating the receipt of a control instruction with the completion of a physical action by the terminal execution component; it uses the predecessor state verification value to constrain the execution of control instructions after the handover, ensuring that control instructions are continuously connected along the actual physical execution state of the IoT terminal; and it uses the execution receipt forwarded by the target gateway as the basis for judging the physical gateway mapping switch, thereby avoiding repeated execution, out-of-order execution, or causing the terminal physical state to regress during the virtual data link handover.
[0076] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of 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, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0077] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0078] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0079] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A virtual data link collaborative switching method for Internet of Things (IoT) terminals, characterized in that, Includes the following steps: Step S1: Establish a virtual data link status record for the IoT terminal. The record includes the current link epoch, source gateway identifier, instruction delivery boundary sequence number, instruction execution boundary sequence number, and terminal execution status verification value. Step S2: In response to the physical link of the source gateway meeting the transfer conditions, obtain the control command to be confirmed and the most recently returned execution receipt from the terminal, determine the target gateway from the candidate gateways that receive the same uplink data frame, and send a transfer status packet to the target gateway. Step S3: Control the target gateway to send a link switching frame within the downlink receiving window associated with the uplink data frame. The frame carries the link epoch to be activated, the first control command, and its predecessor status check value. Step S4: Compare the predecessor status verification value with the local execution status verification value. If they match, execute the first control instruction and generate an execution receipt based on the physical status feedback. If they do not match, prevent execution and generate a boundary difference receipt carrying the local instruction execution boundary sequence number and the local execution status verification value. Step S5: In response to the execution receipt forwarded by the target gateway satisfying the transfer submission condition, switch the physical gateway mapping to the target gateway and put the source gateway into the old link epoch isolation state; in response to the receipt of boundary difference or execution receipt timeout, maintain the physical gateway mapping of the source gateway and start instruction gap recovery.
2. The virtual data link collaborative switching method for IoT terminals according to claim 1, characterized in that, The instruction delivery boundary number is the largest instruction number among the control instructions that the IoT terminal has continuously confirmed to have received, and the instruction execution boundary number is the largest instruction number among the continuous control instructions that have been confirmed to have been executed based on physical state feedback. The terminal execution status verification value is generated based on the instruction execution boundary number and at least two of the following: the position feedback value of the execution component of the IoT terminal, the switch status, the output register value, and the fault status. After each confirmation control instruction is completed, the updated instruction execution boundary number is associated with the terminal execution status verification value and written into the virtual data link status record.
3. The virtual data link collaborative switching method for IoT terminals according to claim 2, characterized in that, Determining the target gateway from the candidate gateways includes: Obtain the reception timestamp of each candidate gateway receiving the same uplink data frame, and determine the downlink reception window corresponding to the IoT terminal based on the reception timestamp; Calculate the preparation margin for each candidate gateway after completing the reception of the transfer status packet, encapsulation of the link transfer frame, and preparation for radio frequency transmission before the downlink reception window opens. Candidate gateways with a preparation margin greater than the transmission protection duration and which have been fully loaded with the transfer status packet are identified as relayable gateways, and the target gateway is determined from the relayable gateways. If no relay gateway is available, the current handover is delayed, and the target gateway is re-determined in the next uplink data frame of the IoT terminal. No additional wake-up request is sent to the IoT terminal.
4. The virtual data link collaborative switching method for IoT terminals according to claim 2, characterized in that, Sending a transfer status packet to the target gateway includes: An execution state transition barrier is constructed using the instruction execution boundary sequence number and its corresponding terminal execution state verification value; Control instructions whose sequence number is not greater than the instruction execution boundary sequence number are marked as closed instructions; control instructions whose sequence number is greater than the instruction execution boundary sequence number but not greater than the instruction delivery boundary sequence number are marked as instructions to be verified; and control instructions whose sequence number is greater than the instruction delivery boundary sequence number are marked as undelivered instructions. The pending verification instruction and undelivered instruction are extracted from the instruction cache of the source gateway, and an instruction sequence number, predecessor status verification value and expected successor status verification value are associated with each control instruction to form the transfer status packet; before the transfer is submitted, the target gateway does not resend the pending verification instruction except in response to the boundary difference acknowledgment execution instruction gap recovery.
5. The virtual data link collaborative switching method for IoT terminals according to claim 4, characterized in that, The IoT terminal processes the control commands in the link transfer frame, including: Read the locally stored link epoch, local instruction execution boundary sequence number, and local execution status verification value; When the instruction sequence number of the control instruction is not greater than the local instruction execution boundary sequence number, the control instruction is prevented from being executed repeatedly, and the historical execution result corresponding to the control instruction is returned; When the instruction sequence number of the control instruction is the next consecutive sequence number after the local instruction execution boundary sequence number, and the predecessor state verification value is consistent with the local execution state verification value, the control instruction is delivered to the terminal execution unit. When the instruction sequence number of the control instruction is not continuous with the local instruction execution boundary sequence number, or when the predecessor state verification value is inconsistent with the local execution state verification value, the current state of the terminal execution unit is maintained, and the missing start sequence number, received instruction sequence number and local execution state verification value are written into the boundary difference receipt.
6. The virtual data link collaborative switching method for IoT terminals according to claim 5, characterized in that, The instruction gap recovery includes: Based on the local instruction execution boundary number and local execution status verification value in the boundary difference receipt, search for the first control instruction in the transition status packet whose predecessor status verification value matches the local execution status verification value. Starting with the found control instruction, and based on the condition that the expected successor state check value of the previous control instruction is the same as the predecessor state check value of the next control instruction, the shortest continuous instruction chain extending to the control instruction that is prevented from being executed is constructed. The shortest continuous instruction chain is sent sequentially through the target gateway, and the next control instruction is released after receiving the execution receipt of the previous control instruction. If the shortest continuous instruction chain is not found, the proposed link activation epoch is revoked, the target gateway stops sending control commands, and the source gateway continues to maintain the current virtual data link.
7. The virtual data link collaborative switching method for IoT terminals according to claim 5, characterized in that, An execution receipt is generated based on the physical state feedback after execution, including: In response to a control command being delivered to the terminal execution unit, at least one of the following is collected: the actual position value of the terminal execution unit, the state of the switch contact, the current feedback value, and the operating status word; The collected results are compared with the expected execution state range carried by the control command. When the collected results remain within the expected execution state range for the verification time, the execution of the control command is confirmed to be complete, and the local command execution boundary sequence number and local execution state verification value are updated. If the collected results do not enter the expected execution state range or leave the expected execution state range within the verification time, the local instruction execution boundary number is not updated, and an execution failure receipt containing the actual physical state and execution exception identifier is generated.
8. The virtual data link collaborative switching method for IoT terminals according to claim 7, characterized in that, To put the source gateway into an old link epoch isolation state, the following steps are included: The source gateway is prohibited from continuing to send control commands carrying the old link epoch, while retaining the source gateway's ability to receive acknowledgments of the old link epoch. For the execution receipt received by the source gateway during the isolation period, if the corresponding instruction sequence number is not greater than the instruction execution boundary sequence number at the time of transfer submission, the execution receipt is merged into the historical execution record; if the corresponding instruction sequence number is greater than the instruction execution boundary sequence number at the time of transfer submission, the execution receipt is forwarded to the link coordination node for boundary conflict verification. The isolation duration of the old link epoch is not less than the sum of the maximum message retention duration of the source physical link and the control command retransmission retention duration of the source gateway. When the isolation duration expires and there are no unprocessed boundary conflicts, the old link epoch state saved by the source gateway is released.
9. A virtual data link collaborative switching system for Internet of Things (IoT) terminals, characterized in that, It includes a link coordination node, at least two IoT gateways, and IoT terminals, wherein the at least two IoT gateways serve as the source gateway and the target gateway, respectively, before and after the virtual data link switching; wherein, The link coordination node includes a status recording unit, a transfer control unit, and a mapping submission unit. The status recording unit records the current link epoch of the virtual data link, the physical gateway mapping, the instruction delivery boundary number, the instruction execution boundary number, and the terminal execution status verification value. The transfer control unit generates a transfer status packet in response to physical link transfer conditions and sends the transfer status packet to the target gateway. The mapping submission unit submits or cancels the virtual data link transfer based on the execution receipt forwarded by the target gateway. The source gateway includes an instruction cache and a status packaging unit. The status packaging unit is used to extract the control instruction to be confirmed after the instruction execution boundary number from the instruction cache, and write the control instruction to be confirmed into the transfer status packet. The target gateway includes a receiving window control unit and a receipt forwarding unit. The receiving window control unit is used to send a link transition frame carrying the link epoch to be enabled and the predecessor state verification value within the downlink receiving window associated with the uplink data frame of the IoT terminal. The receipt forwarding unit is used to send the execution receipt or boundary difference receipt returned by the IoT terminal to the link coordination node. The IoT terminal includes an execution status register, an instruction fence unit, and an execution feedback interface. The execution status register is used to store the local link epoch, the local instruction execution boundary number, and the local execution status verification value. The instruction fence unit is used to determine whether to allow execution, block execution, or return the historical execution result based on the instruction number of the control instruction and the predecessor status verification value. The execution feedback interface is used to collect the physical status of the terminal's execution components and generate an execution receipt containing the link epoch, the instruction execution boundary number, and the execution status verification value.
10. The virtual data link collaborative switching system for IoT terminals according to claim 9, characterized in that, The execution status register includes a first status storage area and a second status storage area that are written alternately. Each status storage area is used to store the link epoch, instruction execution boundary sequence number, terminal execution status verification value, write version number and integrity verification code. After confirming that the physical action corresponding to the control command has been completed, the IoT terminal writes the updated link epoch, command execution boundary sequence number and terminal execution status verification value into the currently inactive state storage area, and switches the valid area identifier after completing the integrity verification. In response to the IoT terminal being powered on again, the execution state is restored by selecting the state storage area with the larger write version number from the state storage area that has passed the integrity verification.
