Methods, apparatus, storage media, and electronic devices for creating tree-structured tables
By managing the nested relationships of protocols using a tree table structure, the problem of memory waste caused by duplicate records in the protocol record stack is solved, enabling quick location and deletion of erroneous protocols and simplifying system management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QINGDAO HAIER TECH
- Filing Date
- 2023-03-27
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, duplicate recording of protocol record stacks leads to wasted memory space, and searching for erroneous protocol record stacks is time-consuming.
A tree-like table structure is used to manage the nesting relationship of protocols. The nesting relationship of protocols is recorded through parent nodes and child nodes to avoid duplicate records and to unify the management of ports and protocols.
It saves system memory space and quickly locates and deletes erroneous protocol records, simplifying protocol management logic.
Smart Images

Figure CN116455992B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart home technology, and more specifically, to a method, apparatus, storage medium, and electronic device for creating a tree structure. Background Technology
[0002] Many IoT smart terminals support multiple connection methods, such as Wi-Fi, Bluetooth, and Zigbee, with different protocols running on different connections. For example, Wi-Fi connections typically run IP, TCP, UDP, SSL, MQTT, CoAP, HTTP / HTTPS, and some user-defined protocols, such as... Figure 2 As shown. Bluetooth protocols include L2CAP, GATT, GAP, RFCOMM, and SerialPort, etc. Figure 3 As shown.
[0003] Protocols are layered and nested. For example, when transmitting HTTPS data on a Wi-Fi communication protocol stack, the application layer focuses on the HTTPS protocol data, but the connection management component (in this article, "component" refers to a software module with certain functions) needs to manage data whose outermost layer is encapsulated by the IP protocol (not related to the Media Access Control layer and physical layer protocols), followed by the TCP or UDP layer protocols, and then the SSL and HTTP protocols in that order.
[0004] During system operation, data transmission occurs in two directions: receiving data and sending data. The connection management component receives data packets from the remote location and performs layer-by-layer protocol parsing (i.e., unpacking, removing the lower-level protocol headers) by analyzing the data content. Simultaneously, it records the nesting relationships of the protocols to construct the data for the sending direction (adding protocol headers layer by layer). If the data packets for the sending direction are encapsulated with incorrect protocols, insufficient protocols, excessive protocols, or in the wrong protocol encapsulation order, communication will fail.
[0005] Nested relationships are typically recorded using a stack, with the data structure usually being a First-In-First-Out (FIFO) queue or a linear array. After recording, a tag is generated to locate the record; this tag is typically a pointer or reference to the stack object.
[0006] During system operation, an application layer program may use multiple protocols at different layers. Therefore, the connection management component must send a tag corresponding to each data packet to the application layer program. When the application layer program needs to reply to a data packet (i.e., send data), it needs to send the tag to the connection management component. The connection management component can use this tag to find the protocol nesting relationship (stack) used to encapsulate the data packet when replying, thereby completing the encapsulation of the sent data.
[0007] The encapsulation and decapsulation of data in related technologies have at least the following problems:
[0008] 1. During system operation, data packets are constantly being received, and new protocol record stacks are constantly being created. Due to the lack of a unified management method, some protocol record stacks are recorded repeatedly.
[0009] 2. Since the underlying protocols are basically the same, if each protocol record stack saves the complete protocol nesting relationship, the underlying protocol will be repeatedly saved by multiple protocol record stacks, which will waste a lot of memory space.
[0010] 3. When an error occurs in a port or a protocol layer connection, if the application layer program is to be notified of the disconnection event or re-establish the connection, it is necessary to find all protocol record stacks related to the error, which takes a considerable amount of time to traverse or query these protocol record stacks.
[0011] There is still no effective solution to the problem that some protocol record stacks are repeatedly recorded in related technologies, thus wasting system memory space. Summary of the Invention
[0012] This application provides a method, apparatus, storage medium, and electronic device for creating a tree table, in order to at least solve the problem in related technologies where some protocol record stacks are repeatedly recorded, thus wasting system memory space.
[0013] According to one embodiment of the present application, a method for creating a tree table is provided, comprising:
[0014] The first data to be sent to the application is parsed to determine multiple first protocols used to encapsulate the first data and the nesting relationship of the multiple first protocols; the connection relationship between the first child nodes corresponding to the multiple first protocols is determined according to the nesting relationship of the first protocols, and it is determined whether there is a second child node in the tree table, wherein the connection relationship between the multiple second child nodes is the same as the connection relationship between the multiple first child nodes; if there is no second child node in the tree table, a new branch is established in the tree table according to the multiple first child nodes and the connection relationship of the multiple first child nodes.
[0015] In an exemplary embodiment, before determining the connection relationship between the first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, the method further includes: determining a first port for transmitting the first data; abstracting the first port and the first protocol corresponding to the first port into channel objects, and abstracting other first protocols besides the first protocol corresponding to the first port into channel objects; and determining a plurality of first child nodes in a new branch of the tree table according to the plurality of channel objects.
[0016] In an exemplary embodiment, after establishing a new branch in the tree table according to the plurality of first child nodes and the connection relationship of the plurality of first child nodes, the method further includes: determining the level corresponding to each first child node in the tree table; determining the segment data corresponding to each level, wherein an integer of a preset length is segmented to obtain a plurality of segment data, each segment data being used to identify a level of the tree table; and determining the first index value of each first child node according to the segment data corresponding to each level.
[0017] In an exemplary embodiment, after establishing a new branch in the tree table according to the plurality of first child nodes and the connection relationship of the plurality of first child nodes, the method further includes: determining the innermost protocol for encapsulating the first data, wherein the plurality of first protocols include: the innermost protocol; determining a third child node corresponding to the innermost protocol from the plurality of first child nodes; and sending the parsed first data and the second index value corresponding to the third child node to the application.
[0018] In an exemplary embodiment, after establishing a new branch in the tree table based on the plurality of first child nodes and their connection relationships, the method further includes: obtaining second data to be sent by the application, and obtaining a third index value for indicating a fourth child node in the tree table; determining a plurality of second protocols for encapsulating the second data, and a second protocol nesting relationship of the plurality of second protocols, based on the fourth child node corresponding to the third index value and the tree table; and encapsulating the second data based on the plurality of second protocols and their second protocol nesting relationship.
[0019] In an exemplary embodiment, determining a plurality of second protocols for encapsulating the second data, and the nesting relationship of the plurality of second protocols, based on the fourth child node corresponding to the third index value and the tree table, includes: determining a path from the fourth child node to the root node of the tree table; determining a plurality of fifth child nodes corresponding to the path, wherein the plurality of fifth child nodes include the fourth child node; determining a plurality of second protocols for encapsulating the second data based on the plurality of fifth child nodes; and determining the nesting relationship of the plurality of second protocols based on the connection relationship of the fifth child nodes.
[0020] In an exemplary embodiment, after establishing a new branch in the tree table based on the plurality of first child nodes and the connection relationship of the plurality of first child nodes, the method further includes: if it is determined that there is an error event in the second port or an error event in the connection relationship corresponding to the third protocol, determining a sixth child node corresponding to the second port or the third protocol in the tree table; deleting the sixth child node in the tree table, as well as the child node corresponding to the sixth child node.
[0021] According to another embodiment of the present application, a tree table creation apparatus is also provided, comprising: a parsing module, configured to parse first data to be sent to an application to determine a plurality of first protocols used to encapsulate the first data and a first protocol nesting relationship of the plurality of first protocols; a determining module, configured to determine the connection relationship between first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, and to determine whether a second child node exists in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes; and a creation module, configured to create a new branch in the tree table according to the plurality of first child nodes and the connection relationship of the plurality of first child nodes when the second child node does not exist in the tree table.
[0022] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the above-described tree table creation method at runtime.
[0023] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described tree table creation method through the computer program.
[0024] In this embodiment, the first data to be sent to the application is parsed to determine multiple first protocols used to encapsulate the first data and the nesting relationship of the multiple first protocols; the connection relationship between the first child nodes corresponding to the multiple first protocols is determined according to the nesting relationship of the first protocols, and it is determined whether there is a second child node in the tree table, wherein the connection relationship between the multiple second child nodes is the same as the connection relationship between the multiple first child nodes; if there is no second child node in the tree table, a new branch is established in the tree table according to the multiple first child nodes and the connection relationship of the multiple first child nodes; in this embodiment of the invention, a tree structure table is used to manage the nesting relationship between different ports and protocols, and the protocol nesting relationship is recorded through the relationship between parent nodes and child nodes. By adopting the above technical solution, the problem that some protocol record stacks are repeatedly recorded, thus wasting system memory space, is solved, thereby saving system memory space. Attached Figure Description
[0025] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0026] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a schematic diagram of the hardware environment for a method of creating a tree table according to an embodiment of this application;
[0028] Figure 2 This is a schematic diagram of the existing Wi-Fi protocol;
[0029] Figure 3 This is a schematic diagram of the Bluetooth protocol in existing technology;
[0030] Figure 4 This is a flowchart of a method for creating a tree table according to an embodiment of this application;
[0031] Figure 5 This is a schematic diagram of a method for creating a tree table according to an embodiment of this application;
[0032] Figure 6 This is a schematic diagram of a tree table according to an embodiment of this application;
[0033] Figure 7 This is a structural block diagram of a tree table creation device according to an embodiment of this application. Detailed Implementation
[0034] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0035] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0036] According to one aspect of the embodiments of this application, a method for constructing a tree table is provided. This method for constructing a tree table is widely applicable to whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned method for constructing a tree table can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0037] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0038] This embodiment provides a method for creating a tree table, applied to a terminal device. Figure 4 This is a flowchart of a method for creating a tree table according to an embodiment of this application. The process includes the following steps:
[0039] Step S402: Parse the first data to be sent to the application to determine the multiple first protocols used to encapsulate the first data and the nesting relationship of the multiple first protocols;
[0040] Step S404: Determine the connection relationship between the first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, and determine whether there are second child nodes in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes;
[0041] Step S406: If the second child node does not exist in the tree table, a new branch is established in the tree table according to the plurality of first child nodes and the connection relationship between the plurality of first child nodes.
[0042] It should be noted that any branch in the above tree table has a preset lifespan. If the lifespan of any branch in the tree table reaches the preset lifespan, that branch will be deleted.
[0043] Through the above steps, the first data to be sent to the application is parsed to determine multiple first protocols used to encapsulate the first data and the nesting relationship of the multiple first protocols; the connection relationship between the first child nodes corresponding to the multiple first protocols is determined according to the nesting relationship of the first protocols, and it is determined whether there is a second child node in the tree table, wherein the connection relationship between the multiple second child nodes is the same as the connection relationship between the multiple first child nodes; if there is no second child node in the tree table, a new branch is established in the tree table according to the multiple first child nodes and the connection relationship of the multiple first child nodes. In this embodiment of the invention, a tree structure table is used to manage the nesting relationship between different ports and protocols, and the protocol nesting relationship is recorded through the relationship between parent nodes and child nodes, which solves the problem in related technologies that some protocol record stacks are repeatedly recorded, thus wasting system memory space, thereby saving system memory space.
[0044] In an exemplary embodiment, before determining the connection relationship between the first child nodes corresponding to the plurality of first protocols based on the first protocol nesting relationship, the following steps are also required: determining a first port for transmitting the first data; abstracting the first port and the first protocol corresponding to the first port into channel objects, and abstracting other first protocols besides the first protocol corresponding to the first port into channel objects; and determining a plurality of first child nodes in a new branch of the tree table based on the plurality of channel objects.
[0045] It should be noted that in this embodiment of the invention, physical ports, logical ports, and the corresponding protocols are all uniformly abstracted into channel objects. Each channel object has the function of receiving and sending data. Channels can be nested, meaning that data from an inner channel can be transmitted through an outer channel; that is, inner protocol data will be encapsulated within an outer protocol for transmission. Through the above embodiments, channel abstraction unifies the management of ports and different communication protocols, simplifies management logic, and facilitates the maintenance of attribute tables.
[0046] In an exemplary embodiment, after establishing a new branch in the tree table based on the plurality of first child nodes and their connection relationships, the following steps are further performed: determining the level corresponding to each first child node in the tree table; determining the segment data corresponding to each level, wherein an integer of a preset length is segmented to obtain multiple segment data, each segment data being used to identify a level of the tree table; and determining the first index value of each first child node based on the segment data corresponding to each level.
[0047] In this embodiment of the invention, each node in the tree table is encoded, and this encoding can accurately describe the node's position in the tree. Taking a 16-bit length as an example, it is divided into 4 segments, each segment being 4 bits. Each segment corresponds to a level in the graph, and the value of each segment is the left-to-right order of the node within that level. The 4 segments correspond to levels 1 to 4 from top to bottom. The root node address is fixed at 0. Specifically, "0x1000", "0x2000", "0x3000", ..., "0xF000" are used to identify the encoding of nodes in level 1; "0x1100", "0x1200", "0x1300", ..., "0x1F00" are used to identify the encoding of child nodes under the node corresponding to "0x1000" in level 2; "0x2200", "0x2200", "0x2300", ..., "0x2F00" are used to identify the encoding of child nodes under the node corresponding to "0x2000" in level 2; "0x3300", "0x3200", "0x3300", ..., "0x3F00" are used to identify the encoding of child nodes under the node corresponding to "0x3000" in level 2; "0xFF00", "0xF200", "0xF300", ..., "0xFF00" are used to identify... The encoding of child nodes under the node corresponding to "0xF000" in level 2; "0x1110", "0x1120", "0x1130", ..., "0x11F0" are used to identify the encoding of child nodes under the node corresponding to "0x1100" in level 3; "0x1210", "0x1220", "0x1230", ..., "0x12F0" are used to identify the encoding of child nodes under the node corresponding to "0x1200" in level 3; "0x1310", "0x1320", "0x1330", ..., "0x13F0" are used to identify the encoding of child nodes under the node corresponding to "0x1300" in level 3; "0xFF10", "0xFF20", "0xFF30", ..., "0xFFF0" are used to identify the encoding of child nodes under the node corresponding to "0xFF00" in level 3, and so on.
[0048] It should be noted that in actual use, different bit counts can be used for encoding depending on the actual situation, and the number of bits in each segment can be different. This embodiment of the invention does not limit this.
[0049] In an exemplary embodiment, after establishing a new branch in the tree table according to the plurality of first child nodes and the connection relationship of the plurality of first child nodes, the following operations are also required: determining the innermost protocol for encapsulating the first data, wherein the plurality of first protocols include: the innermost protocol; determining the third child node corresponding to the innermost protocol from the plurality of first child nodes; and sending the parsed first data and the second index value corresponding to the third child node to the application.
[0050] It should be noted that after receiving the first data packet, the connection management component parses the first data sequentially according to the protocol encapsulating the first data. This is equivalent to moving down a certain path from the root node layer by layer. When all protocols are parsed, it reaches a certain node (not necessarily a leaf node) at a certain layer. This node is the endpoint of the first data. The parsed first data and the second index value corresponding to the third child node are sent to the application so that the application can process and generate response data. Then, the application sends the business data and the second index value corresponding to the third child node to the connection management component. The connection management component finds the corresponding third child node according to the second index value, and then sequentially performs protocol encapsulation along the direction from the third child node to the root node. Encapsulation is completed when the root node is reached.
[0051] In an exemplary embodiment, after establishing a new branch in the tree table according to the plurality of first child nodes and their connection relationships, the second data to be sent by the application is obtained, and a third index value for indicating the fourth child node in the tree table is obtained; a plurality of second protocols for encapsulating the second data and the second protocol nesting relationship of the plurality of second protocols are determined according to the fourth child node corresponding to the third index value and the tree table; the second data is encapsulated based on the plurality of second protocols and their second protocol nesting relationship.
[0052] It should be noted that when the application sends second data to other business modules, the receiving application first connects to the management component to send the second data and a third index value indicating the fourth child node in the tree table. The connection management component finds the corresponding fourth child node based on the third index value, and then sequentially performs protocol encapsulation along the direction from the fourth child node to the root node. Encapsulation is complete when the root node is reached. Through the above embodiment, it is not necessary to establish a protocol record stack for the data packets in the receiving direction. A tree structure table is used to manage the embedding relationship between different ports and protocols. The protocol nesting relationship is recorded through the relationship between parent nodes and child nodes, which solves the problem in related technologies where some protocol record stacks are repeatedly recorded, thus wasting system memory space, thereby saving system memory space.
[0053] Specifically, multiple second protocols and their nesting relationships are determined as follows: the path from the fourth child node to the root node of the tree table is determined; multiple fifth child nodes corresponding to the path are determined, wherein the multiple fifth child nodes include the fourth child node; multiple second protocols for encapsulating the second data are determined based on the multiple fifth child nodes; and the nesting relationship of the multiple second protocols is determined based on the connection relationship of the fifth child nodes.
[0054] In an exemplary embodiment, after establishing a new branch in the tree table based on the plurality of first child nodes and the connection relationship of the plurality of first child nodes, the method further includes: if it is determined that there is an error event in the second port or an error event in the connection relationship corresponding to the third protocol, determining a sixth child node corresponding to the second port or the third protocol in the tree table; deleting the sixth child node in the tree table, as well as the child node corresponding to the sixth child node.
[0055] In this embodiment of the invention, when a connection or a protocol session at a certain layer fails, the sixth child node corresponding to the failure point, as well as the child nodes below it, are determined. Since the communication of the sixth child node and its corresponding child nodes is affected when a physical connection or protocol session at a certain layer fails, the sixth child node and its corresponding child nodes are deleted from the tree table. Through the above embodiment, the scope of impact can be accurately and quickly located. This solves the problem in related technologies where, when an error occurs in a port or a protocol link at a certain layer, if the application layer program is to be notified of the disconnection event or re-establish the connection, it is necessary to find all protocol record stacks related to the error, which takes a considerable amount of time to traverse or query the protocol record stack.
[0056] To better understand the process of creating the tree table described above, the implementation flow of creating the tree table will be further explained below with reference to optional embodiments, but this is not intended to limit the technical solution of the embodiments of this application.
[0057] This embodiment provides a method for creating a tree table. Figure 5 This is a schematic diagram of a method for creating a tree table according to an embodiment of this application, and the specific steps are as follows:
[0058] Step S501: Unify and abstract the physical port, logical port, and protocol into a channel object;
[0059] It should be noted that each channel object has the function of receiving and sending data. Channels can be nested, meaning that data from an inner channel will be transmitted through an outer channel; that is, data from an inner protocol will be encapsulated within an outer protocol for transmission.
[0060] Step S502: Use a tree structure to record the nesting relationships between protocols;
[0061] Specifically: adopting, for example Figure 6 The tree structure shown is used to record the nesting relationships between protocols. Figure 6 This is a schematic diagram of a tree table according to an embodiment of this application. The nodes closest to the root node represent the underlying protocols, and the root node extends downwards according to the protocol nesting relationship. The relationship between parent and child nodes in the tree structure reflects the protocol nesting relationship; specifically, the parent node represents the outer protocol, and the child node represents the inner protocol. In this embodiment of the invention, the same protocol bound to different channels is considered as different nodes. Figure 6 As shown, TCP ports (port1 and port2) connected to the same IP address but different ports are considered different nodes.
[0062] Step S503: Encode each node of the tree structure;
[0063] It should be noted that the above encoding can accurately describe the position of a node in the tree. For convenience, this illustration uses a 16-bit length, divided into 4 segments, each segment being 4 bits. Each segment corresponds to a level in the graph, and the value of each segment represents the node's left-to-right order within that level. In this example, the 4 segments correspond to levels 1 through 4 from top to bottom, with the root node address fixed at 0. It should be noted that in actual use, different bit counts can be used depending on the specific circumstances, and the number of bits in each segment can also be different.
[0064] Step S504: After receiving the data packet, the connection management component parses the data packet sequentially according to the protocol used to encapsulate the data packet;
[0065] Specifically: After the connection management component receives the data packet, it proceeds down the tree structure table layer by layer from the root node. When all protocols have been parsed, it reaches a certain node (not necessarily a leaf node) at a certain level. This node is the endpoint of the data packet (equivalent to the third child node in the above embodiment), and the encoding of this node is TA (equivalent to the second index value in the above embodiment).
[0066] Step S505: Send the TA and the data with the underlying protocol header removed to the application side;
[0067] Step S506: The application side completes the processing and generates response data. The application side then sends the response data and TA to the connection management component.
[0068] Step S507: The connection management component finds the corresponding node based on the TA, and then sequentially performs protocol encapsulation along the root direction of the tree structure from that node until the root node is reached, at which point the encapsulation of the response data is complete.
[0069] Through the above embodiments, it is not necessary to establish a protocol encapsulation record stack for data packets in the receiving direction; when a physical connection or a protocol session at a certain layer fails, communication below the node corresponding to the failure point is affected, making it easy to locate the scope of the impact. Optimization of tree structure storage and node lookup and location: To access each node more quickly, it is recommended to store the tree structure in memory in the following way. Taking the 16-bit 4-segment encoding used above as an example, four arrays that can be addressed by index are used to store four segments respectively. Each array has a length of 15, corresponding to a maximum of 15 nodes at each level (in this example, the encoding starts from 1, corresponding to 1 to 15). Thus, the encoding value of each segment is the index value of the node in the array. The node data can be accessed directly through the index value without traversal or search.
[0070] Furthermore, this solution eliminates the need to establish a protocol encapsulation record stack for data packets in the receiving direction, saving storage space and avoiding the issue of maintaining the record stack's lifecycle. When a physical connection or a protocol session at a certain layer fails, communication of all child nodes below the node corresponding to the failure point is affected, making it easy to pinpoint the scope of the impact. Through channel abstraction, port and different communication protocol management are unified, simplifying management logic and facilitating maintenance.
[0071] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0072] Figure 7 This is a structural block diagram of a tree table creation device according to an embodiment of this application; as shown... Figure 7 As shown, it includes:
[0073] Parsing module 72 is used to parse the first data to be sent to the application to determine a plurality of first protocols used to encapsulate the first data and the nesting relationship of the first protocols of the plurality of first protocols;
[0074] The determining module 74 is used to determine the connection relationship between the first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, and to determine whether there are second child nodes in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes;
[0075] The module 76 is used to create a new branch in the tree table according to the plurality of first child nodes and the connection relationship between the plurality of first child nodes when the second child node does not exist in the tree table.
[0076] The aforementioned device parses the first data to be sent to the application to determine multiple first protocols used to encapsulate the first data and the nesting relationship of the multiple first protocols; it determines the connection relationship between the first child nodes corresponding to the multiple first protocols based on the nesting relationship of the first protocols, and determines whether there are second child nodes in the tree table, wherein the connection relationship between the multiple second child nodes is the same as the connection relationship between the multiple first child nodes; if there are no second child nodes in the tree table, a new branch is established in the tree table based on the multiple first child nodes and the connection relationship of the multiple first child nodes. This solves the problem in related technologies where some protocol record stacks are repeatedly recorded, thus wasting system memory space, thereby saving system memory space.
[0077] In an exemplary embodiment, the determining module 74 is configured to determine a first port for transmitting the first data; abstract the first port and the first protocol corresponding to the first port into channel objects, and abstract other first protocols besides the first protocol corresponding to the first port into channel objects; and determine multiple first child nodes in a new branch of the tree table based on the multiple channel objects.
[0078] In an exemplary embodiment, the determining module 74 is configured to determine the level corresponding to each first child node in the tree table; determine the segment data corresponding to each level, wherein an integer of a preset length is segmented to obtain multiple segment data, each segment data being used to identify a level of the tree table; and determine the first index value of each first child node based on the segment data corresponding to each level.
[0079] In an exemplary embodiment, a determining module 74 is configured to determine the innermost protocol for encapsulating the first data, wherein the plurality of first protocols include: the innermost protocol; determining a third child node corresponding to the innermost protocol from the plurality of first child nodes; and a sending module is configured to send the parsed first data and the second index value corresponding to the third child node to the application.
[0080] In one exemplary embodiment, the apparatus further includes: an encapsulation module, configured to acquire second data to be sent by the application and acquire a third index value for indicating a fourth child node in a tree table; determine a plurality of second protocols for encapsulating the second data and a second protocol nesting relationship of the plurality of second protocols based on the fourth child node corresponding to the third index value and the tree table; and encapsulate the second data based on the plurality of second protocols and the second protocol nesting relationship of the plurality of second protocols.
[0081] In an exemplary embodiment, the encapsulation module is configured to determine the path from the fourth child node to the root node of the tree table; determine a plurality of fifth child nodes corresponding to the path, wherein the plurality of fifth child nodes include the fourth child node; determine a plurality of second protocols for encapsulating the second data based on the plurality of fifth child nodes; and determine the second protocol nesting relationship of the plurality of second protocols based on the connection relationship of the fifth child nodes.
[0082] In an exemplary embodiment, the establishment module 76 is configured to, in the event that an error event occurs at the second port or the connection relationship corresponding to the third protocol, determine the sixth child node corresponding to the second port or the third protocol in the tree table; delete the sixth child node in the tree table, as well as the child node corresponding to the sixth child node.
[0083] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the methods described above when it is run.
[0084] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0085] S1, parse the first data to be sent to the application to determine a plurality of first protocols used to encapsulate the first data and the nesting relationship of the first protocols of the plurality of first protocols;
[0086] S2, determine the connection relationship between the first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, and determine whether there are second child nodes in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes;
[0087] S3, if the second child node does not exist in the tree table, a new branch is established in the tree table according to the multiple first child nodes and the connection relationship between the multiple first child nodes.
[0088] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0089] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0090] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0091] S1, parse the first data to be sent to the application to determine a plurality of first protocols used to encapsulate the first data and the nesting relationship of the first protocols of the plurality of first protocols;
[0092] S2, determine the connection relationship between the first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, and determine whether there are second child nodes in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes;
[0093] S3, if the second child node does not exist in the tree table, a new branch is established in the tree table according to the multiple first child nodes and the connection relationship between the multiple first child nodes.
[0094] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0095] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0096] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0097] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for creating a tree-structured table, characterized in that, include: The first data to be sent to the application is parsed to determine a plurality of first protocols used to encapsulate the first data and the nesting relationship of the plurality of first protocols; The connection relationship between the first child nodes corresponding to the plurality of first protocols is determined according to the first protocol nesting relationship, and it is determined whether there are second child nodes in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes; If the second child node does not exist in the tree table, a new branch is established in the tree table according to the plurality of first child nodes and the connection relationship between the plurality of first child nodes; The method further includes, after establishing a new branch in the tree table based on the plurality of first child nodes and their connection relationships: Determine the innermost protocol used to encapsulate the first data, wherein the plurality of first protocols include: the innermost protocol; Determine the third child node corresponding to the innermost protocol from the plurality of first child nodes; The parsed first data and the second index value corresponding to the third child node are sent to the application.
2. The method for establishing a tree table according to claim 1, characterized in that, Before determining the connection relationship between the first child nodes corresponding to the plurality of first protocols based on the first protocol nesting relationship, the method further includes: Determine the first port for transmitting the first data; The first port and the first protocol corresponding to the first port are abstracted into channel objects, and other first protocols besides the first protocol corresponding to the first port are abstracted into channel objects; Multiple first child nodes in a new branch of the tree table are determined based on multiple channel objects.
3. The method for establishing a tree table according to claim 1, characterized in that, After establishing a new branch in the tree table based on the plurality of first child nodes and their connection relationships, the method further includes: Determine the level corresponding to each first child node in the tree table; Determine the segment data corresponding to each level, wherein an integer of a preset length is divided into segments to obtain multiple segments, and each segment is used to identify a level of the tree table; The first index value of each first child node is determined based on the segment data corresponding to each level.
4. The method for establishing a tree table according to claim 1, characterized in that, After establishing a new branch in the tree table based on the plurality of first child nodes and their connection relationships, the method further includes: Obtain the second data to be sent by the application, and obtain the third index value used to indicate the fourth child node in the tree table; Based on the fourth child node corresponding to the third index value and the tree table, a plurality of second protocols for encapsulating the second data are determined, as well as the nesting relationship of the plurality of second protocols; The second data is encapsulated based on the plurality of second protocols and the nesting relationship of the second protocols.
5. The method for establishing a tree table according to claim 4, characterized in that, Based on the fourth child node corresponding to the third index value and the tree table, multiple second protocols for encapsulating the second data are determined, along with the nesting relationship of the multiple second protocols, including: Determine the path from the fourth child node to the root node of the tree table; Determine multiple fifth child nodes corresponding to the path, wherein the multiple fifth child nodes include: the fourth child node; Based on the plurality of fifth child nodes, a plurality of second protocols for encapsulating the second data are determined, and based on the connection relationship of the fifth child nodes, a second protocol nesting relationship of the plurality of second protocols is determined.
6. The method for establishing a tree table according to claim 1, characterized in that, After establishing a new branch in the tree table based on the plurality of first child nodes and their connection relationships, the method further includes: If it is determined that there is an error event on the second port or an error event in the connection relationship corresponding to the third protocol, determine the sixth child node corresponding to the second port or the third protocol in the tree table; Delete the sixth child node in the tree table, as well as the child nodes corresponding to the sixth child node.
7. A device for creating a tree-like table, characterized in that, include: The parsing module is used to parse the first data to be sent to the application to determine the multiple first protocols used to encapsulate the first data and the nesting relationship of the multiple first protocols; The determining module is used to determine the connection relationship between the first child nodes corresponding to the plurality of first protocols according to the first protocol nesting relationship, and to determine whether there are second child nodes in the tree table, wherein the connection relationship between the plurality of second child nodes is the same as the connection relationship between the plurality of first child nodes; A module is established to create a new branch in the tree table based on the plurality of first child nodes and their connection relationships when the second child node does not exist in the tree table. The determining module is further configured to determine the innermost protocol used to encapsulate the first data, wherein the plurality of first protocols include: the innermost protocol; and to determine a third child node corresponding to the innermost protocol from the plurality of first child nodes; the device further includes: a sending module configured to send the parsed first data and the second index value corresponding to the third child node to the application.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method according to any one of claims 1 to 6.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 6 through the computer program.