Routing forwarding method, gateway, program product and system

CN122698516APending Publication Date: 2026-09-04XIAMEN LEELEN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611185888.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-09-04

AI Technical Summary

Technical Problem

这种方式存在延迟不确定、性能低、实现复杂、资源浪费等问题

Benefits of technology

[0007] According to one technical solution, by directly accessing the next-hop index table instance using the gateway's unique identifier as an array index, ultra-fast route lookup can be achieved. This avoids complex calculations and traversals using traditional hash and tree structures, significantly improving the forwarding efficiency and real-time performance of device control commands in multi-level gateway scenarios. Simultaneously, storing network connection handles using a fixed array structure simplifies data structure design, reduces memory access overhead, and improves system stability and maintainability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122698516A_ABST
    Figure CN122698516A_ABST
Patent Text Reader

Abstract

The present disclosure provides a routing forwarding method, a gateway, a program product and a system, and relates to the field of routing forwarding. The routing forwarding method comprises the following steps: in response to receiving an n-level device control instruction, an n-level gateway analyzes the n-level device control instruction to obtain an n-level logical address and a basic control instruction; the n-level logical address is segmented to obtain a first target gateway unique identifier; the first target gateway unique identifier is used as an array subscript to access a next hop index table instance to obtain a target network connection handle corresponding to the first target gateway; a first segment address is removed from the n-level logical address to obtain an n-1-level logical address; and based on the n-1-level logical address and the basic control instruction, an n-1-level device control instruction is generated and is forwarded to the first target gateway through the target network connection handle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of Internet of Things (IoT) technology, specifically to a routing and forwarding method, gateway, program product, and system. Background Technology

[0002] With the widespread application of IoT technology in smart communities, intelligent buildings, and large parks, the IoT network topology has evolved from the traditional single-gateway star topology to a hierarchical distributed architecture composed of multiple gateways. The number of devices and network scale are growing exponentially, making device addressing and routing crucial for ensuring efficient and stable system operation.

[0003] In a multi-level gateway IoT addressing system based on hierarchical logical addresses, the parent gateway is responsible for registering and managing directly connected sub-gateways and completing routing forwarding based on the hierarchical logical addresses in the downlink commands. The core routing forwarding process is as follows: the parent gateway parses the first segment of the target hierarchical logical address to obtain the corresponding gateway's unique identifier; then, based on the gateway's unique identifier, it finds the network connection handle (TCP connection, Unix domain socket, IPC channel, etc.) of the next-hop gateway; finally, it forwards the remaining logical address after removing the first segment address and the control commands to the target sub-gateway.

[0004] The operation of "finding the network connection handle of the next-hop gateway based on the gateway's unique identifier" in the routing process is a critical step affecting routing latency. Currently, the technical solutions for parent gateways to implement "finding the network connection handle of the next-hop gateway based on the gateway's unique identifier" generally adopt a "general routing table + general query data structure" approach. This approach suffers from problems such as uncertain latency, low performance, complex implementation, and wasteful resources. It cannot adapt to the needs of large-scale, high real-time, and high-stability multi-level IoT gateway networking. Summary of the Invention

[0005] This disclosure provides a routing and forwarding method, gateway, program product, and system.

[0006] According to one aspect of this disclosure, a routing and forwarding method is provided, comprising: an nth-level gateway responding to receiving an nth-level device control instruction, parsing the nth-level device control instruction to obtain an nth-level logical address and a basic control instruction; wherein n represents the level of the gateways other than leaf gateways, n>1, the nth-level logical address includes multiple address segments, the first segment address being the first unique identifier of a first target gateway among the lower-level gateways connected to the nth-level gateway; the nth-level gateway performing segmentation processing on the nth-level logical address to obtain a unique identifier of the first target gateway; the nth-level gateway using the unique identifier of the first target gateway as an array index to access a next-hop index table instance to obtain a target network connection handle corresponding to the first target gateway; the nth-level gateway removing the first segment address from the nth-level logical address to obtain an (n-1)th-level logical address; and the nth-level gateway generating an (n-1)th-level device control instruction based on the (n-1)th-level logical address and the basic control instruction, and forwarding it to the first target gateway through the target network connection handle.

[0007] According to one technical solution, by directly accessing the next-hop index table instance using the gateway's unique identifier as an array index, ultra-fast route lookup can be achieved. This avoids complex calculations and traversals using traditional hash and tree structures, significantly improving the forwarding efficiency and real-time performance of device control commands in multi-level gateway scenarios. Simultaneously, storing network connection handles using a fixed array structure simplifies data structure design, reduces memory access overhead, and improves system stability and maintainability.

[0008] According to at least one embodiment of the routing and forwarding method of this disclosure, before the nth-level gateway responds to receiving the control command of the nth-level device, the method further includes: the nth-level gateway responding to startup by constructing a next-hop index table instance containing an array of array elements corresponding to the number of values ​​in the range of the gateway's unique identifier, and each array element containing a valid flag bit; and setting the valid flag bit of each array element in the next-hop index table instance to an invalid flag.

[0009] According to the technical solution of this embodiment, the static and standardized configuration of the next-hop index table instance can be realized, laying the foundation for subsequent fast routing queries, while ensuring that the system enters a stable and usable state upon startup.

[0010] According to at least one embodiment of the routing and forwarding method of this disclosure, the data structure of the next-hop index table instance is a structure, the structure contains an array whose length is consistent with the number of values ​​included in the value range, each array element in the array corresponds to a next-hop table entry, and the next-hop table entry contains a valid flag bit and a network connection handle field.

[0011] According to the technical solution of this embodiment, direct mapping addressing from the gateway's unique identifier to the network connection handle can be realized, eliminating hash calculation and traversal search, thereby improving search efficiency and system reliability.

[0012] According to at least one embodiment of the routing and forwarding method of this disclosure, the value range is determined based on the maximum number of lower-level gateways that the nth-level gateway can connect to.

[0013] According to the technical solution of this embodiment, the array length can be accurately matched with the actual access scale, avoiding resource waste or index out-of-bounds errors, and improving system resource utilization and operational stability.

[0014] According to at least one embodiment of the routing and forwarding method of this disclosure, before the nth-level gateway responds to receiving the control command of the nth-level device, the method further includes: the nth-level gateway, in response to the access of the first target gateway, selecting a gateway unique identifier from the set of unallocated gateway unique identifiers as the first target gateway unique identifier; writing the network connection handle corresponding to the first target gateway into the next-hop index table instance at the position of the array index with the first target gateway unique identifier as the subscript; setting the valid flag bit of the array element in the next-hop index table instance with the first target gateway unique identifier as the array subscript to indicate a valid identifier; and returning the first target gateway unique identifier to the first target gateway.

[0015] According to the technical solution of this embodiment, the gateway can be detected as soon as it goes online, without the need for subsequent dynamic updates and traversal registration, thereby improving the real-time performance and availability of command forwarding.

[0016] According to at least one embodiment of the routing and forwarding method of this disclosure, before the nth-level gateway responds to the access of the first target gateway, the method further includes: the nth-level gateway, in response to startup, initializing the unallocated gateway unique identifier set to include each gateway unique identifier corresponding to the value range; the nth-level gateway detects the accessed lower-level gateways to obtain the second target gateway; and the nth-level gateway deletes the second target gateway unique identifier of the second target gateway from the unallocated gateway unique identifier set.

[0017] According to the technical solution of this embodiment, the gateway unique identifier can be allocated in an orderly and conflict-free manner, avoiding duplicate allocation or index failure.

[0018] The routing and forwarding method according to at least one embodiment of the present disclosure further includes: in response to the disconnection of the third target gateway, the nth-level gateway re-adds the third target gateway's unique identifier to the unallocated gateway unique identifier set; and sets the valid flag bit of the array element in the next-hop index table instance with the third target gateway's unique identifier as the array subscript to indicate invalidity.

[0019] According to the technical solution of this embodiment, the unique identifier resource of the gateway can be reused cyclically, while ensuring that the next-hop index table instance is always consistent with the actual connection state.

[0020] According to at least one embodiment of the routing and forwarding method of this disclosure, before the nth-level gateway accesses the next-hop index table instance using the unique identifier of the first target gateway as the array index, the method further includes: determining whether the valid flag bit of the array element in the next-hop index table instance using the unique identifier of the first target gateway as the array index is a valid identifier; and if the valid flag bit is a valid identifier, accessing the next-hop index table instance using the unique identifier of the first target gateway as the array index.

[0021] According to the technical solution of this embodiment, by pre-verifying the valid flag bit of the corresponding table entry before accessing the next-hop index table instance, invalid or abnormal routing access can be effectively avoided, thereby improving the security, accuracy and stability of the instruction forwarding process.

[0022] According to another aspect of this disclosure, a gateway is provided, comprising: a memory storing execution instructions; and a processor executing the execution instructions stored in the memory, causing the processor to perform a routing and forwarding method according to any embodiment of this disclosure.

[0023] According to another aspect of this disclosure, a readable storage medium is provided, wherein executable instructions are stored therein, which, when executed by a processor, are used to implement the routing and forwarding method of any embodiment of this disclosure.

[0024] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a routing and forwarding method according to any embodiment of this disclosure.

[0025] According to another aspect of this disclosure, a smart home system is provided, including a multi-level gateway, wherein the other gateways in the multi-level gateway, other than the leaf gateways, implement the routing and forwarding method of any embodiment of this disclosure.

[0026] This disclosure enables ultra-fast route lookup, avoiding complex calculations and traversals of traditional hash and tree structures, and significantly improves the forwarding efficiency and real-time performance of device control commands in multi-level gateway scenarios. Attached Figure Description

[0027] The accompanying drawings illustrate exemplary embodiments of the present disclosure and, together with the description thereof, serve to explain the principles of the present disclosure. These drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification.

[0028] Figure 1 This is a flowchart illustrating a routing and forwarding method according to one embodiment of the present disclosure.

[0029] Figure 2 This is a flowchart illustrating a gateway access processing method according to one embodiment of the present disclosure.

[0030] Figure 3 This is a flowchart illustrating a method for constructing a set of unassigned gateway unique identifiers according to one embodiment of this disclosure.

[0031] Figure 4 This is a flowchart illustrating a gateway disconnection processing method according to one embodiment of the present disclosure.

[0032] Figure 5 This is a schematic block diagram of a routing and forwarding device according to one embodiment of the present disclosure.

[0033] Figure 6 This is a schematic structural block diagram of a gateway using a processor-based hardware implementation according to one embodiment of the present disclosure. Detailed Implementation

[0034] The present disclosure will now be described in further detail with reference to the accompanying drawings and examples. It should be understood that the specific examples described herein are for illustrative purposes only and are not intended to limit the scope of the disclosure. Furthermore, it should be noted that, for ease of description, only the parts relevant to the present disclosure are shown in the accompanying drawings.

[0035] It should be noted that, where there is no conflict, the embodiments and features described in this disclosure can be combined with each other. The technical solutions of this disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0036] Existing solutions for a parent gateway to "find the network connection handle of the next-hop gateway based on the child gateway identifier" mainly employ hash tables (using the child gateway's local unique identifier as the key and the next-hop network connection handle as the value), balanced binary trees or red-black trees (maintaining an ordered mapping between the child gateway's local unique identifier and the next-hop network connection handle), and linear list traversal (associating the child gateway's local unique identifier with the next-hop network connection handle in a contiguous list, and sequentially traversing to match the child gateway's local unique identifier during a query). These solutions have the following significant technical drawbacks: (1) The routing lookup delay is uncertain and cannot meet the real-time requirements.

[0037] Hash tables suffer from hash collisions, leading to a sharp drop in query efficiency under high-collision scenarios. The query time complexity of tree structures such as balanced binary trees and red-black trees is O(logN) (where N is the number of sub-gateways), and query latency increases significantly with the number of sub-gateways. Sequential query methods such as linear list traversal have a time complexity of O(N), and query latency is linearly positively correlated with the number of sub-gateways. None of these methods can provide constant query latency, making it difficult to meet the core requirement of deterministic low forwarding latency for real-time control of IoT devices.

[0038] (2) Low memory access efficiency, which can easily affect system performance.

[0039] Hash tables may involve multiple random memory accesses, and tree structures involve pointer jumps. Both of these methods can lead to cache misses, further increasing the actual forwarding latency and limiting system efficiency.

[0040] (3) It has high implementation complexity and high failure risk.

[0041] Maintaining complex logic such as hash functions, collision resolution logic, balancing algorithms, and memory allocation increases code complexity and the risk of failure.

[0042] (4) The inherent characteristics of the hierarchical logical address system were not fully utilized.

[0043] In a hierarchical logical address architecture, the unique gateway identifier assigned by the parent gateway to the child gateway has the inherent properties of being continuous, locally unique, and having a fixed value range. However, existing general routing schemes treat it as a regular routing key value and do not utilize this characteristic.

[0044] To address these issues, this disclosure proposes the following technical solution. In this solution, by directly accessing the next-hop index table instance using the gateway's unique identifier as the array index, extremely fast route lookup can be achieved. This avoids complex calculations and traversals using traditional hash and tree structures, significantly improving the forwarding efficiency and real-time performance of device control commands in multi-level gateway scenarios. Simultaneously, storing network connection handles using a fixed array structure simplifies data structure design, reduces memory access overhead, and enhances system stability and maintainability.

[0045] To facilitate description and make the technical solutions of this disclosure easier to understand, the terminology of this disclosure will be explained before describing the technical solutions of this disclosure.

[0046] Basic control instructions refer to the raw instruction data used to implement equipment control functions, which may include the control parameters and operation instructions required for equipment execution.

[0047] A network connection handle is a unique identifier for an established network communication link between a parent gateway and a child gateway.

[0048] This disclosure applies to scenarios involving the routing and forwarding of device control commands in a multi-level IoT gateway architecture.

[0049] Figure 1 A schematic diagram illustrating the overall flow of a routing and forwarding method according to one embodiment of this disclosure is shown. Figure 1 The method shown includes steps S110 to S150. This method can be executed by an electronic device such as a gateway.

[0050] In step S110, the nth-level gateway responds to receiving the nth-level device control command by parsing the nth-level device control command to obtain the nth-level logical address and basic control command.

[0051] In a multi-level gateway, the first level is the leaf gateway. n>1 indicates the level of the gateways other than the leaf gateways, which can be the root gateway or an intermediate gateway between the root network and the leaf gateways.

[0052] The nth-level logical address comprises multiple address segments. The first address segment, located at the beginning, corresponds to the unique identifier of the first target gateway among the lower-level gateways (n-1th-level gateways) connected to the nth-level gateway. For example, when three levels of gateways are included, the root gateway (3rd-level gateway) receives the 3rd-level device control command. The 3rd-level device control command contains the 3rd-level logical address. The 3rd-level logical address can be represented as "CBA", comprising three address segments: "C", "B", and "A". The first (leftmost) address segment, "C", represents the unique identifier of the intermediate gateway (2nd-level gateway). The intermediate gateway (2nd-level gateway) receives the 2nd-level device control command. The 2nd-level device control command contains the 2nd-level logical address. The 2nd-level logical address can be represented as "BA", comprising two address segments: "B" and "A". The first (leftmost) address segment, "B", represents the unique identifier of the leaf gateway (1st-level gateway).

[0053] In step S120, the nth-level gateway segments the nth-level logical address to obtain the unique identifier of the first target gateway.

[0054] In one possible implementation, the nth-level logical address, composed of multiple address segments, is separated by a delimiter (such as "."). The nth-level logical address can be segmented by identifying the delimiter, resulting in multiple address segments. These multiple address segments are arranged from left to right, with the leftmost segment identified as the first address segment, serving as the unique identifier of the first target gateway.

[0055] In step S130, the nth-level gateway uses the unique identifier of the first target gateway as the array index to access the next-hop index table instance and obtain the target network connection handle corresponding to the first target gateway.

[0056] The next-hop index table instance can be used to store the network connection handles corresponding to each child gateway of the parent gateway (gateways other than leaf gateways) in array form. In one possible implementation, a corresponding next-hop index table instance can be pre-created in each parent gateway, and the network connection handles of each child gateway corresponding to the parent gateway can be stored in the next-hop index table instance in an array structure.

[0057] In step S140, the nth-level gateway removes the first segment address from the nth-level logical address to obtain the (n-1)th-level logical address.

[0058] In the example of the three-level gateway above, the third-level logical address obtained by the root gateway (third-level gateway) can be represented as "CBA", where the first segment address is "C". The second-level logical address obtained after removing the first segment address "C" is "BA".

[0059] In step S150, the nth-level gateway generates the (n-1)th-level device control command based on the (n-1)th-level logical address and basic control command, and forwards it to the first target gateway through the target network connection handle.

[0060] This disclosure enables ultra-fast route lookup by directly accessing the next-hop index table instance using the gateway's unique identifier as the array index. This avoids complex calculations and traversals associated with traditional hash and tree structures, significantly improving the forwarding efficiency and real-time performance of device control commands in multi-level gateway scenarios. Furthermore, storing network connection handles in a fixed array structure simplifies data structure design, reduces memory access overhead, and enhances system stability and maintainability.

[0061] As one possible implementation, before the nth-level gateway receives the control command from the nth-level device, the method further includes: Upon startup, the nth-level gateway constructs a next-hop index table instance containing an array of array elements corresponding to the number of values ​​within the unique identifier range, with each array element containing a valid flag. The valid flag of each array element in the next-hop index table instance is set to an invalid flag. For example, an invalid flag can be "0". This implementation enables static and standardized configuration of the next-hop index table instance, laying the foundation for subsequent fast route queries, while ensuring the system enters a stable and usable state upon startup.

[0062] As one possible implementation, the value range is determined based on the maximum number of lower-level gateways that the nth-level gateway can connect to. For example, the value range can be set to 0-63. This implementation ensures that the array length precisely matches the actual access scale, avoiding resource waste or index out-of-bounds errors, and improving system resource utilization and operational stability.

[0063] As one possible implementation, the data structure of the next-hop index table instance is a structure containing an array of length equal to the number of values ​​within the value range. Each array element corresponds to a next-hop entry, which includes a valid flag and a network connection handle field. In the example above, the value range is 0-63, containing 64 values, so the array length of the structure is 64. The network connection handle field can be used to store the network connection identifier, and can carry the socket, handle, or pointer of the inter-gateway communication link, allowing the upper-level gateway to directly execute command forwarding operations based on the network connection handle field. This implementation enables direct mapping addressing from the gateway's unique identifier to the network connection handle, eliminating hash calculations and traversal searches, thus improving search efficiency and system reliability.

[0064] As one possible implementation, the method further includes a gateway access processing method before the nth-level gateway responds to receiving the control command from the nth-level device. Figure 2 A schematic flowchart illustrating a gateway access processing method according to one embodiment of this disclosure is shown. Figure 2 The method shown includes steps S210 to S240.

[0065] In step S210, in response to the access of the first target gateway, the nth level gateway selects (can be randomly selected) a gateway unique identifier from the set of unassigned gateway unique identifiers as the first target gateway unique identifier.

[0066] In step S220, the network connection handle corresponding to the first target gateway is written into the next-hop index table instance at the position of the array index with the unique identifier of the first target gateway.

[0067] In step S230, the valid flag bit of the array element in the next-hop index table instance, whose array index is the unique identifier of the first target gateway, is set to a valid flag. For example, the valid flag can be "1".

[0068] In step S240, the unique identifier of the first target gateway is returned to the first target gateway.

[0069] This implementation method assigns a unique identifier and synchronously writes the corresponding network connection handle and valid flag bit when the lower-level gateway accesses the network. This enables the gateway to be detected as soon as it goes online, without the need for subsequent dynamic updates and traversal registration, thus improving the real-time performance and availability of command forwarding.

[0070] As one possible implementation, the method for constructing a set of unassigned gateway unique identifiers is also included before the nth-level gateway responds to the access of the first target gateway. Figure 3 A flowchart illustrating a method for constructing a set of unassigned gateway unique identifiers according to one embodiment of this disclosure is shown. Figure 3 The method shown includes steps S310 to S330.

[0071] In step S310, in response to startup, the nth-level gateway initializes the set of unassigned gateway unique identifiers to include the unique identifiers of each gateway corresponding to the value range. In the example above, the value range is 0-63, so the initialized set of unassigned gateway unique identifiers contains 64 elements from 0 to 63.

[0072] In step S320, the nth-level gateway detects the connected lower-level gateways to obtain the second target gateway.

[0073] In step S330, the nth-level gateway deletes the second target gateway unique identifier of the second target gateway from the set of unassigned gateway unique identifiers.

[0074] This implementation method ensures that the gateway's unique identifier is allocated in an orderly and conflict-free manner, avoiding duplicate allocation or index failure.

[0075] As one possible implementation, a gateway disconnection handling method is also included. Figure 4 A schematic flowchart illustrating a gateway disconnection handling method according to one embodiment of this disclosure is shown. Figure 4 The method shown includes steps S410 to S420.

[0076] In step S410, in response to the disconnection of the third target gateway, the nth level gateway adds the third target gateway's unique identifier back to the set of unassigned gateway unique identifiers.

[0077] In step S420, the valid flag bit of the array element in the next-hop index table instance that uses the unique identifier of the third target gateway as the array subscript is set to an invalid flag.

[0078] This implementation method enables the cyclic reuse of gateway unique identifier resources by immediately reclaiming the unique identifier and resetting the corresponding valid flag bit when the gateway disconnects, while ensuring that the next-hop index table instance is always consistent with the actual connection state.

[0079] As one possible implementation, before the nth-level gateway accesses the next-hop index table instance using the unique identifier of the first target gateway as the array index, it further includes: determining whether the valid flag bit of the array element in the next-hop index table instance using the unique identifier of the first target gateway as the array index is a valid identifier. If the valid flag bit is a valid identifier, the next-hop index table instance is accessed using the unique identifier of the first target gateway as the array index. This implementation, by pre-verifying the valid flag bit of the corresponding table entry before accessing the next-hop index table instance, can effectively avoid invalid or abnormal route access, improving the security, accuracy, and stability of the command forwarding process.

[0080] According to any of the above embodiments, this disclosure also provides a routing and forwarding device 500. Figure 5 This is a schematic block diagram of a routing and forwarding device 500 according to one embodiment of this disclosure. Figure 5 As shown, the routing forwarding device 500 includes: a device control command receiving and parsing module 510, a logical address segmentation module 520, a target network connection handle determination module 530, a first segment address removal module 540, and a device control command forwarding module 550.

[0081] The device control command receiving and parsing module 510 is used by the nth-level gateway to parse the nth-level device control command in response to receiving the nth-level device control command, and obtain the nth-level logical address and basic control command; where n represents the gateway other than the leaf gateway, n>1, the nth-level logical address includes multiple address segments, and the first segment address at the beginning corresponds to the unique identifier of the first target gateway among the lower-level gateways connected to the nth-level gateway.

[0082] The logical address segmentation module 520 is used by the nth-level gateway to segment the nth-level logical address to obtain the unique identifier of the first target gateway.

[0083] The target network connection handle determination module 530 is used by the nth-level gateway to access the next-hop index table instance using the unique identifier of the first target gateway as the array index, and obtain the target network connection handle corresponding to the first target gateway.

[0084] The first segment address removal module 540 is used by the nth level gateway to remove the first segment address from the nth level logical address to obtain the (n-1)th level logical address.

[0085] The device control command forwarding module 550 is used by the nth-level gateway to generate the n-1th-level device control command based on the n-1th-level logical address and basic control command, and forward it to the first target gateway through the target network connection handle.

[0086] The routing and forwarding device 500 disclosed herein can be implemented through a computer software architecture.

[0087] According to a further embodiment of this disclosure, a gateway is also provided. Figure 6A schematic block diagram of a gateway using a processor-based hardware implementation according to an embodiment of this disclosure is shown. The hardware structure of the gateway of this disclosure can be implemented using a bus architecture. The bus architecture can include any number of interconnect buses and bridges, depending on the specific application and overall design constraints of the hardware. Bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules. Bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc. Bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. Buses can be classified as address buses, data buses, control buses, etc. For ease of illustration, only one connecting line is used in this figure, but this does not mean that there is only one bus or one type of bus.

[0088] This disclosure also provides a readable storage medium storing a computer program that, when executed by a processor, is used to implement the methods described above. A "readable storage medium" can be any means capable of containing, storing, communicating, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples of a readable storage medium include: an electrical connection with one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable read-only memory (CDROM), etc.

[0089] This disclosure also provides a computer program product, the methods of which can be implemented wholly or partially through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented wholly or partially as a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed, all or part of the processes or functions of this disclosure are performed.

[0090] Computer programs or instructions can be stored in a readable storage medium or transferred from one readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The readable storage medium can be any available medium capable of access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; an optical medium, such as a digital video optical disc; or a semiconductor medium, such as a solid-state drive. The computer-readable storage medium can be a volatile or non-volatile storage medium, or it can include both volatile and non-volatile types of storage media.

[0091] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0092] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to this disclosure. 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. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0093] 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.

[0094] 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.

[0095] This disclosure also provides a readable storage medium and a smart home system, including a multi-level gateway. Other gateways in the multi-level gateway, besides the leaf gateways, implement the routing and forwarding method described in any embodiment of this disclosure.

[0096] In the description of this specification, the references to terms such as "one embodiment / mode," "some embodiments / modes," "example," "specific example," or "some examples," etc., refer to specific features, structures, or characteristics described in connection with that embodiment / mode or example, which are included in at least one embodiment / mode or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment / mode or example. Moreover, the specific features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments / modes or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments / modes or examples described in this specification, as well as the features of different embodiments / modes or examples.

[0097] Those skilled in the art should understand that the above embodiments are merely for illustrating the present disclosure and are not intended to limit the scope of the disclosure. Those skilled in the art can make other changes or modifications based on the above disclosure, and these changes or modifications still fall within the scope of the present disclosure.

Claims

1. A routing and forwarding method, characterized in that, include: The nth-level gateway responds to the nth-level device control command by parsing the nth-level device control command to obtain the nth-level logical address and basic control command; where n represents the level of the gateway other than the leaf gateway, n>1, and the nth-level logical address includes multiple address segments, with the first segment address at the beginning corresponding to the unique identifier of the first target gateway among the lower-level gateways connected to the nth-level gateway. The nth-level gateway performs segmentation processing on the nth-level logical address to obtain a unique identifier for the first target gateway. The nth-level gateway uses the unique identifier of the first target gateway as the array index to access the next-hop index table instance and obtain the target network connection handle corresponding to the first target gateway. The nth-level gateway removes the first segment address from the nth-level logical address to obtain the (n-1)th-level logical address; and The nth-level gateway generates a (n-1)th-level device control command based on the (n-1)th-level logical address and the basic control command, and forwards it to the first target gateway through the target network connection handle.

2. The routing and forwarding method as described in claim 1, characterized in that, Before the nth-level gateway responds to receiving the control command from the nth-level device, it also includes: In response to startup, the nth-level gateway constructs a next-hop index table instance containing an array of array elements corresponding to the number of values ​​within the unique identifier range of the gateway, with each array element containing a valid flag bit; and Set the valid flag bit of each array element in the next-hop index table instance to indicate invalidity.

3. The routing and forwarding method as described in claim 2, characterized in that, The data structure of the next-hop index table instance is a structure, which contains an array whose length is the same as the number of values ​​included in the value range. Each array element in the array corresponds to a next-hop table entry, and the next-hop table entry contains a valid flag bit and a network connection handle field.

4. The routing and forwarding method as described in claim 2, characterized in that, Before the nth-level gateway responds to receiving the control command from the nth-level device, it also includes: In response to the access of the first target gateway, the nth level gateway selects a gateway unique identifier from the set of unassigned gateway unique identifiers as the first target gateway unique identifier of the first target gateway. Write the network connection handle corresponding to the first target gateway into the array index position of the next hop index table instance, using the unique identifier of the first target gateway as the subscript; Set the valid flag bit of the array element in the next-hop index table instance, whose array index is the unique identifier of the first target gateway, to indicate that it is valid; and Return the unique identifier of the first target gateway to the first target gateway.

5. The routing and forwarding method as described in claim 4, characterized in that, Before the nth-level gateway responds to the access of the first target gateway, the following is also included: In response to startup, the nth-level gateway initializes the set of unassigned gateway unique identifiers to include the unique identifiers of each gateway corresponding to the value range. The nth-level gateway detects the already connected lower-level gateways to obtain the second target gateway; and The nth-level gateway removes the unique identifier of the second target gateway from the set of unassigned gateway unique identifiers.

6. The routing and forwarding method as described in claim 5, characterized in that, Also includes: In response to the disconnection of the third target gateway, the nth level gateway adds the unique identifier of the third target gateway to the set of unassigned gateway unique identifiers. as well as Set the valid flag bit of the array element in the next-hop index table instance whose array index is the unique identifier of the third target gateway to an invalid flag.

7. The routing and forwarding method as described in claim 1, characterized in that, Before the nth-level gateway accesses the next-hop index table instance using the unique identifier of the first target gateway as the array index, the following steps are also included: Determine whether the valid flag bit of the array element in the next-hop index table instance, whose array index is the unique identifier of the first target gateway, is a valid identifier; and If the valid flag bit indicates a valid identifier, the next-hop index table instance is accessed using the unique identifier of the first target gateway as the array index.

8. A gateway, characterized in that, include: The memory stores execution instructions; as well as A processor that executes the execution instructions stored in the memory, causing the processor to perform the routing and forwarding method according to any one of claims 1 to 7.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the routing and forwarding method according to any one of claims 1 to 7.

10. A smart home system, comprising a multi-level gateway, characterized in that, The other gateways in the multi-level gateway, besides the leaf gateways, implement the routing and forwarding method as described in any one of claims 1 to 7.