A dynamic IP distribution method and system suitable for network tester
By using a dictionary tree in the network tester to find the thread identifier corresponding to the IP address, the problem of low dynamic IP distribution performance in the existing technology is solved, efficient IP distribution and storage is achieved, and the performance requirements of the network tester for dynamic IP distribution is met.
Patent Information
- Application Number
- CN202310072638.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-13
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2043-01-13
AI Technical Summary
The existing IP array distribution methods and IP hash table distribution methods have performance problems when dealing with dynamic IP, especially the high algorithm complexity and waste of storage space, which is difficult to meet the performance requirements of network testers for dynamic IP distribution.
By using a dictionary tree in the network tester to find the thread identifier corresponding to the IP address, the user's message is distributed to the corresponding thread for processing. The method includes obtaining the packet sent by the TCP/IP protocol stack, determining the user's IP address, and looking for the thread identifier corresponding to the IP address in the preset dictionary tree.
This method not only improves the storage and search efficiency of network testers in the IP distribution process, but also meets the performance requirements of network testers for dynamic IP distribution, reducing algorithm complexity and storage space waste.
Smart Images

Figure CN116192805B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of IP distribution, and in particular to a dynamic IP distribution method and system suitable for a network tester. Background Art
[0002] With the rapid development of the Internet, network stability and security have become extremely important in enterprises and institutions. The responsibilities of network administrators have also increased, and heavy network failures will follow.
[0003] At present, network administrators use network testers to detect and maintain network faults. Network testers are high-performance testers involving a multi-threaded TCP / IP protocol stack architecture. In protocol simulation, the same source IP belongs to the same simulated user. In order to efficiently process user services, the network tester needs to distribute the messages of the same user IP to the same thread for processing, thereby avoiding the performance loss caused by mutex locks. Among them, static IP segments can be distributed by binding fixed threads through a fixed algorithm, while dynamic IP (DHCP / PPPoE) has no rules to follow and can only determine the distribution thread through a dynamic algorithm. Therefore, the design of IP distribution scheme is crucial. However, the existing IP array distribution method cannot guarantee the continuity of dynamic IP values, so array search needs to use a traversal search method, and the algorithm complexity is O(n), which is not suitable for a large number of IPs and has performance problems; the IP hash table distribution method increases the distribution complexity because the number of different IPs will affect the allocation of the number of hash table elements, and when the number of allocated hash table elements is too large, it will also cause a waste of storage space.
[0004] Therefore, both of the above two methods cannot well meet the performance requirements of the network tester for dynamic IP distribution. Summary of the invention
[0005] The present application provides a dynamic IP distribution method and system suitable for a network tester. The network tester of the present application determines the user's IP address based on the acquired message, searches for the thread identifier corresponding to the IP address in a preset dictionary tree, and distributes the user's message to the corresponding thread for processing based on the thread identifier. Compared with traditional technologies, it is easier to meet the performance requirements of the network tester for dynamic IP distribution.
[0006] In a first aspect of the present application, a dynamic IP distribution method applicable to a network tester is provided, which is applied to the network tester, and the method comprises:
[0007] Get the message sent by the TCP / IP protocol stack;
[0008] Determining the IP address of the user based on the message;
[0009] According to the IP address, the thread identifier corresponding to the IP address is searched in a preset dictionary tree, and the user's message is distributed to the thread corresponding to the thread identifier for processing.
[0010] By adopting the above technical solution, first, the network tester obtains the message sent by the TCP / IP protocol stack, and then determines the user's IP address based on the message. Next, the network tester searches for the thread identifier corresponding to the IP address in the preset dictionary tree, and finally distributes the user's message to the thread corresponding to the thread identifier for processing. Compared with traditional technologies, it not only ensures the efficiency of storage and search of the network tester in the process of distributing IP, but also further meets the performance requirements of the network tester for dynamic IP distribution.
[0011] Optionally, before obtaining the message sent by the TCP / IP protocol stack, the method further includes:
[0012] Abstracting the IP address into a fixed-length byte array;
[0013] The fixed-length byte array is stored in a dictionary tree.
[0014] By adopting the above technical solution, before the network tester obtains the message sent by the TCP / IP protocol stack, the network tester will abstract the IP address, thereby abstracting the IP address into a fixed-length byte array, and then storing the fixed-length byte array in the dictionary tree. In this way, the characteristic of the network tester that the IP address prefix byte is the unit is met, and this characteristic is applied to the dictionary tree for storage, so as to improve the storage efficiency of the network tester for dynamic IP.
[0015] Optionally, determining the address type of the IP address, the address type including an IPV4 address and an IPV6 address;
[0016] When the address type is an IPV4 address, determining that the fixed-length byte array is a 4-byte array;
[0017] When the address type is an IPV6 address, the fixed-length byte array is determined to be a 16-byte array.
[0018] By adopting the above technical solution, the network tester will determine the address type of the IP address and can be compatible with both IPV4 addresses and IPV6 addresses, that is, the IPV4 address is abstracted as a 4-byte array, and the IPV6 address is abstracted as a 16-byte array. Therefore, the IPV4 dictionary tree search only requires 4 addressings, and the IPV6 dictionary tree search only requires 16 addressings, which further saves the network tester's search time for the thread corresponding to the IP address and improves the network tester's distribution efficiency of the IP address.
[0019] Optionally, storing the fixed-length byte array in a dictionary tree includes:
[0020] The bytes in the fixed-length byte array are sequentially stored in the branch nodes, lower-layer branch nodes, and leaf nodes corresponding to the lower-layer branch nodes of the dictionary tree;
[0021] Determine whether the root node in the dictionary tree is initialized;
[0022] If the root node is not initialized, initialize the root node;
[0023] If the root node has been initialized, determine whether the branch node indexed by the root node is initialized;
[0024] If the branch nodes of the index corresponding to the root node are not initialized, then initialize the branch nodes of the index corresponding to the root node;
[0025] If the branch node of the index corresponding to the root node has been initialized, then determine whether the lower layer branch node of the index corresponding to the branch node is initialized;
[0026] If the lower layer branch nodes of the index corresponding to the branch node are not initialized, then initialize the lower layer branch nodes of the index corresponding to the branch node;
[0027] If the lower layer branch node of the index corresponding to the branch node has been initialized, then determine whether the leaf node of the index corresponding to the lower layer branch node is initialized;
[0028] If the leaf nodes of the index corresponding to the lower layer branch nodes are not initialized, then initialize the leaf nodes of the index corresponding to the lower layer branch nodes;
[0029] If the leaf node of the index corresponding to the lower layer branch node has been initialized, the thread identifier is stored in the leaf node of the index corresponding to the lower layer branch node.
[0030] By adopting the above technical solution, the network tester determines whether the root node, branch node, lower branch node, and leaf node of the dictionary tree are initialized. Initialization saves memory for the network tester, thereby allocating more memory to the fixed-length byte array, which is convenient for storing the fixed-length byte array.
[0031] Optionally, searching, according to the IP address, a thread identifier corresponding to the IP address in a preset dictionary tree includes:
[0032] Determine whether the root node in the dictionary tree is initialized;
[0033] If the root node has been initialized, determine whether the branch node indexed by the root node is initialized;
[0034] If the branch node of the index corresponding to the root node has been initialized, then determine whether the lower layer branch node of the index corresponding to the branch node is initialized;
[0035] If the lower layer branch node of the index corresponding to the branch node has been initialized, then determine whether the leaf node of the index corresponding to the lower layer branch node is initialized;
[0036] If the leaf node of the index corresponding to the lower layer branch node has been initialized, then determine whether the thread identifier of the index corresponding to the leaf node is stored;
[0037] If the thread identifier of the index corresponding to the leaf node has been stored, the thread identifier stored in the leaf node is returned.
[0038] By adopting the above technical solution, the network tester determines whether the root node, branch node, lower branch node and leaf node in the dictionary tree are initialized. Initialization saves memory for the network tester, thereby providing memory for the network tester to find the thread identifier corresponding to the user IP, thereby improving the efficiency of the network tester in searching for the thread identifier.
[0039] Optionally, if the root node and / or the branch node and / or the lower branch node and / or the leaf node are not initialized, it is determined that the thread identifier search of the corresponding index fails, and an invalid thread identifier is returned.
[0040] By adopting the above technical solution, the network tester determines whether the root node, branch node and leaf node in the dictionary tree are initialized. When the root node and / or branch node and / or lower branch node and / or leaf node are not initialized, the network tester determines that the thread identifier corresponding to the user IP fails to be found, and returns an invalid thread identifier. Therefore, it is convenient for the network tester to find a valid thread identifier in the dictionary tree, thereby meeting the performance requirements of the network tester for dynamic IP distribution.
[0041] Optionally, distributing the user's message to the thread corresponding to the thread identifier for processing includes:
[0042] Determine a target thread corresponding to the thread identifier among multiple threads;
[0043] Determining whether the user's message is a message stored in a thread other than the target thread;
[0044] If the user's message is a message stored in a thread other than the target thread, the user's message is discarded.
[0045] By adopting the above technical solution, the network tester first determines the target thread corresponding to the thread identifier in multiple threads, and then determines whether the user's message is a message of a thread other than the target thread. If the user's message is a message stored in a thread other than the target thread, the message is discarded. This makes it easier for the network tester to identify the source of the message, thereby filtering out the interfering messages, and improving the accuracy of determining the correspondence between the user's message and the target thread.
[0046] Optionally, if the user's message is not a message stored in a thread other than the target thread, the user's message is stored in a cache queue corresponding to the user's message processing thread, so that the user's message processing thread processes the user's message.
[0047] By adopting the above technical solution, when the user's message is not a message stored in a thread other than the target thread, the message is stored in a cache queue corresponding to the message processing thread, so that the user's message processing thread processes the user's message, thereby facilitating improving the accuracy of the network tester matching the user's message to the corresponding thread.
[0048] In a second aspect of the present application, a dynamic IP distribution system applicable to a network tester is provided, which is applied to the above-mentioned dynamic IP distribution method. The dynamic IP distribution system includes an acquisition module, a processing module and a distribution module, wherein:
[0049] The acquisition module is used to acquire the message sent by the TCP / IP protocol stack;
[0050] The processing module is used to determine the IP address of the user based on the message;
[0051] The distribution module searches for a thread identifier corresponding to the IP address in a preset dictionary tree according to the IP address, and distributes the user's message to the thread corresponding to the thread identifier for processing.
[0052] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are both used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the methods described above.
[0053] In summary, the present application includes at least one of the following beneficial technical effects:
[0054] 1. In this application, the network tester first obtains the message sent by the TCP / IP protocol stack, and then determines the user's IP address based on the message. Next, the network tester searches for the thread identifier corresponding to the IP address in the preset dictionary tree, and finally distributes the user's message to the thread corresponding to the thread identifier for processing. Compared with traditional technologies, it not only ensures the efficiency of storage and search in the process of distributing IPs by the network tester, but also further meets the performance requirements of the network tester for dynamic IP distribution;
[0055] 2. The network tester determines whether the root node, branch node, lower branch node and leaf node of the dictionary tree are initialized. Initialization saves memory for the network tester, thereby allocating more memory for fixed-length byte arrays, facilitating storage and search of fixed-length byte arrays, and further improving the network tester's distribution efficiency for dynamic IPs. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 It is a flow chart of a dynamic IP distribution method applicable to a network tester according to an embodiment of the present application.
[0057] Figure 2 This is a schematic diagram of an example of a message in an embodiment of the present application.
[0058] Figure 3 It is a schematic diagram of a dictionary tree structure suitable for a network tester according to an embodiment of the present application.
[0059] Figure 4 This is another flow chart of a dynamic IP distribution method applicable to a network tester according to an embodiment of the present application.
[0060] Figure 5 It is a module diagram of a dynamic IP distribution system suitable for a network tester according to an embodiment of the present application.
[0061] Figure 6 It is a structural schematic diagram of an electronic device according to an embodiment of the present application.
[0062] Explanation of the reference numerals: 51, acquisition module; 52, processing module; 53, distribution module; 61, processor; 62, communication bus; 63, user interface; 64, network interface; 65, memory. DETAILED DESCRIPTION
[0063] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0064] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.
[0065] In the description of the embodiments of the present application, "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. Unless otherwise specified, the term "multiple" means two or more. For example, multiple companies refer to two or more companies, and multiple information refers to two or more information. In addition, the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "include", "comprise", "have" and their variations all mean "including but not limited to" unless otherwise specifically emphasized.
[0066] Before introducing the embodiments of the present application, some terms involved in the embodiments of the present application are first defined and explained.
[0067] Network tester: a portable, visual intelligent detection device that can detect the operating status of the physical layer, data link layer, and network layer defined by the OSI model (Open System Interconnection Reference Model). It is mainly suitable for LAN fault detection, maintenance, and integrated wiring construction. The functions of the network tester cover the physical layer, data link layer, and network layer.
[0068] Dynamic IP: Dynamic IP (Dynamic IP, dynamic IP address) refers to the way of assigning IP addresses. Dynamic IP addresses correspond to static IP addresses. The so-called dynamic IP means that when users surf the Internet on a daily basis, they will be randomly assigned an IP address; static IP means that an IP address is fixedly assigned and the user uses this address every time he surfs the Internet.
[0069] With the popularization and complexity of the network, the reasonable construction and normal operation of the network have become extremely important, and the normal operation of the network must be guaranteed from two aspects. First, the quality of network construction directly affects the subsequent use of the network, so the construction quality cannot be ignored, and must be strictly required to prevent problems before they happen. Second, the troubleshooting of network faults is crucial and directly affects the operating efficiency of the network. It is necessary to pursue high efficiency and short time. Therefore, network detection auxiliary equipment has become increasingly important in network construction and network maintenance. For example, the network tester can detect the performance of the network such as network traffic testing, data interception, IP query, and traffic analysis. The existing network tester involves a multi-threaded TCP / IP protocol stack architecture. In the protocol simulation, the same source IP belongs to the same simulated user. In order to efficiently process user services, the messages of the same user IP need to be distributed to the same thread for processing. In order to avoid the performance loss caused by the mutex lock, the static IP segment can be distributed by binding a fixed thread through a fixed algorithm, while the dynamic IP (DHCP / PPPoE, etc.) has no rules to follow and can only determine the distribution thread through a dynamic algorithm. Therefore, the design of the distribution plan for dynamic IP is particularly important. However, when faced with a huge number of IP addresses, the existing dynamic IP distribution algorithm is prone to algorithm failure due to complex calculations; the existing IP array distribution method cannot guarantee the continuity of dynamic IP values, so array search requires a traversal search method, which results in performance problems.
[0070] In order to solve this problem, the present application provides a dynamic IP distribution method suitable for a network tester, referring to Figure 1 , Figure 1 The following is a flow chart of a dynamic IP distribution method applicable to a network tester according to an embodiment of the present application. The dynamic IP distribution method is applied to a network tester, and the dynamic IP distribution method includes steps S110 to S130, which are as follows:
[0071] S110: Acquire a message sent by the TCP / IP protocol stack.
[0072] S120: Determine the IP address of the user based on the message.
[0073] S130. According to the IP address, search for the thread identifier corresponding to the IP address in a preset dictionary tree, and distribute the user's message to the thread corresponding to the thread identifier for processing.
[0074] Specifically, the network tester obtains the message sent by the TCP / IP protocol stack. The TCP / IP protocol stack includes the application layer, transport layer, network layer, data link layer and physical layer. The message is transmitted to the network tester by the transport layer of the TCP / IP protocol stack. After the network tester obtains the message, it uses the message to find the IP address corresponding to the message, and searches for the thread identifier corresponding to the IP address in the preset dictionary tree according to the IP address, and finally achieves the purpose of distributing the messages of the same user to the same thread for processing.
[0075] Reference Figure 2 , Figure 2 This is an example diagram of a message in an embodiment of the present application. The content of the message may include, but is not limited to: version, header length, ToS, message length, identification, flag, segment offset, protocol, TTL, header checksum, source IP address, destination IP address, optional items, and data, etc. Thus, the network tester can obtain the IP address of the message, thereby determining the user IP.
[0076] In a possible implementation manner, before obtaining the message sent by the TCP / IP protocol stack, it also includes: the network tester abstracts the IP address into a fixed-length byte array; and stores the fixed-length byte array in a dictionary tree.
[0077] In a possible implementation, the network tester will determine the type of the IP address. If the IP address type is an IPV4 address, the fixed-length byte array is determined to be a 4-byte array; if the IP address type is an IPV6 address, the fixed-length byte array is determined to be a 16-byte array. The dictionary tree is applied to IP address storage because the prefix of the same IP address reuses the same tree node, and the number of IPs that the network tester needs to simulate in the same network segment is in the millions or tens of millions. Therefore, the IPV4 prefix length is usually set to 8, and the IPV6 prefix length is usually set to 48, that is, they are usually multiples of 8, and the unit of the dictionary tree hierarchical node design is byte.
[0078] For example, the IPV4 address 192.168.1.10 can be represented by 4 hexadecimal bytes as C0 A8 01 0A, and the IPV4 address 192.168.1.100 can be represented by 4 hexadecimal bytes as C0 A8 01 64. It can be seen that the first three bytes stored in the two IPV4 addresses are both C0 A8 01; the IPV6 address 2001::1001:1:1:A is represented by 16 hexadecimal bytes as 20 01 00 0000 00 00 00 10 01 00 01 00 01 00 0A, and the IPV6 address 2001::2002:2:2:64 is represented by 16 hexadecimal bytes as 20 01 00 00 00 00 00 00 20 02 00, you can see that the first eight bytes of the two IPV6 addresses are both 2001 00 00 00 00 00 00.
[0079] In a possible implementation, the network tester stores a fixed-length byte array in a dictionary tree, including: storing each byte in the fixed-length byte array in the branch node, the lower-level branch node, and the leaf node corresponding to the lower-level branch node of the dictionary tree in sequence; determining whether the root node in the dictionary tree is initialized; if the root node is not initialized, initializing the root node; if the root node is initialized, determining whether the branch node of the index corresponding to the root node is initialized; if the branch node of the index corresponding to the root node is not initialized, initializing the branch node of the index corresponding to the root node; if the branch node of the index corresponding to the root node is initialized , then determine whether the lower-level branch nodes of the index corresponding to the branch node are initialized; if the lower-level branch nodes of the index corresponding to the branch node are not initialized, then initialize the lower-level branch nodes of the index corresponding to the branch node; if the lower-level branch nodes of the index corresponding to the branch node are initialized, then determine whether the leaf nodes of the index corresponding to the lower-level branch node are initialized; if the leaf nodes of the index corresponding to the lower-level branch node are not initialized, then initialize the leaf nodes of the index corresponding to the lower-level branch node; if the leaf nodes of the index corresponding to the lower-level branch node are initialized, then store the thread identifier in the leaf node of the index corresponding to the lower-level branch node.
[0080] Specifically, the above is the process of the network tester storing the fixed-length byte array into the dictionary tree. The purpose of initializing the node is to save memory for the storage of the node, so as to improve the storage efficiency. The node types of the dictionary tree include root nodes, branch nodes, lower branch nodes and leaf nodes. Each array element of the 256 fixed-length byte array of the branch node is stored in the 256 fixed-length byte array information of the lower branch node or the leaf node, and each array element of the 256 fixed-length byte array of the leaf node stores the distribution thread identifier corresponding to the IP address.
[0081] For example, an IPV4 address is displayed in the dictionary tree as 1 root node, 1 branch node, 1 lower branch node, and 1 leaf node. At this time, there is 1 lower branch node; an IPV6 address is displayed in the dictionary tree as 1 root node, 1 branch node, 13 lower branch nodes, and 1 leaf node. At this time, there are multiple lower branch nodes. Therefore, the number of lower branch nodes is 1 or more. Among them, the storage process of IPV6 addresses is similar to that of IPV4 addresses, which will not be repeated here.
[0082] In a possible implementation, based on the IP address, the network tester searches for the thread identifier corresponding to the IP address in a preset dictionary tree, including: determining whether the root node in the dictionary tree is initialized; if the root node is initialized, determining whether the branch node of the index corresponding to the root node is initialized; if the branch node of the index corresponding to the root node is initialized, determining whether the lower-level branch node of the index corresponding to the branch node is initialized; if the lower-level branch node of the index corresponding to the branch node is initialized, determining whether the leaf node of the index corresponding to the lower-level branch node is initialized; if the leaf node of the index corresponding to the lower-level branch node is initialized, determining whether the thread identifier of the index corresponding to the leaf node is stored; if the thread identifier of the index corresponding to the leaf node is stored, returning the thread identifier stored in the leaf node.
[0083] Specifically, refer to Figure 3 , Figure 3 This is a schematic diagram of a dictionary tree structure suitable for a network tester according to an embodiment of the present application. The above figure shows the process of the network tester searching for the thread identifier corresponding to the IPV4 address 192.168.1.10 in the dictionary tree. It can be seen that the IPV4 dictionary tree search only requires 4 addressings, and the IPV6 dictionary tree search only requires 16 addressings. Among them, the thread identifier search process corresponding to the IPV6 address is similar to the thread identifier search process corresponding to the IPV4 address, which will not be repeated here.
[0084] In a possible implementation, if the root node and / or the branch node and / or the lower branch node and / or the leaf node are not initialized, it is determined that the thread identifier search of the corresponding index fails, and an invalid thread identifier is returned.
[0085] Specifically, when the network tester searches for the thread identifier corresponding to the user IP address in the dictionary tree, if the root node and / or branch node and / or lower branch node and / or leaf node in the dictionary tree are not initialized, the search fails and returns an invalid thread identifier.
[0086] In one possible implementation, refer to Figure 4 , Figure 4This is another flow chart of a dynamic IP distribution method applicable to a network tester according to an embodiment of the present application. The user's message is distributed to the thread corresponding to the thread identifier for processing, including steps S1301 to S1303, and the above steps are as follows:
[0087] S1301. Determine a target thread corresponding to a thread identifier among multiple threads.
[0088] S1302: Determine whether the user's message is a message stored in a thread other than the target thread.
[0089] S1303: If the user's message is a message stored in a thread other than the target thread, the user's message is discarded.
[0090] Specifically, after the network tester finds the thread identifier corresponding to the user IP in the dictionary tree, it will determine the target thread corresponding to the thread identifier in multiple threads. The network tester determines whether the user's message is a message stored in a thread other than the target thread. When the user's message is a message stored in a thread other than the target thread, the network tester cannot find the thread identifier of the corresponding IP or an invalid thread identifier in the dictionary tree. Therefore, the message does not belong to the TCP / IP protocol stack of the network tester and will be determined as an interference message and discarded, and will not be further processed by the distribution thread.
[0091] In a possible implementation, if the user's message is not a message stored in a thread other than the target thread, the user's message is stored in a cache queue corresponding to the user's message processing thread, so that the user's message processing thread processes the user's message.
[0092] Specifically, when the user's message is not a message stored in a thread other than the target thread, the network tester analyzes that the message may be a message corresponding to the target thread or a message corresponding to other processing threads, and automatically stores the user's message in a cache queue corresponding to the processing thread of the message, thereby facilitating the user's message processing thread to further process the user's message.
[0093] The present application also provides a dynamic IP distribution system suitable for a network tester, which is applied to the above-mentioned dynamic IP distribution method. Figure 5 , Figure 5The present invention is a module diagram of a dynamic IP distribution system applicable to a network tester in an embodiment of the present application. The dynamic IP distribution system includes an acquisition module 51, a processing module 52 and a distribution module 53, wherein the acquisition module 51 is used to acquire a message sent by a TCP / IP protocol stack; the processing module 52 is used to determine a user's IP address based on the message; and the distribution module 53 searches for a thread identifier corresponding to the IP address in a preset dictionary tree according to the IP address, and distributes the user's message to the thread corresponding to the thread identifier for processing.
[0094] In a possible implementation, before the acquisition module 51 acquires the message sent by the TCP / IP protocol stack, it also includes: the processing module 52 abstracts the IP address into a fixed-length byte array; and stores the fixed-length byte array in a dictionary tree.
[0095] In one possible implementation, the processing module 52 determines the address type of the IP address, where the address types include IPV4 addresses and IPV6 addresses; when the address type is an IPV4 address, the fixed-length byte array is determined to be a 4-byte array; when the address type is an IPV6 address, the fixed-length byte array is determined to be a 16-byte array.
[0096] In a possible implementation, the processing module 52 stores the fixed-length byte array in the dictionary tree, including: the processing module 52 stores each byte in the fixed-length byte array in the branch node, the lower-level branch node and the leaf node corresponding to the lower-level branch node of the dictionary tree in sequence; the processing module 52 determines whether the root node in the dictionary tree is initialized; if the root node is not initialized, the processing module 52 initializes the root node; if the root node is initialized, the processing module 52 determines whether the branch node of the index corresponding to the root node is initialized; if the branch node of the index corresponding to the root node is not initialized, the processing module 52 initializes the branch node of the index corresponding to the root node; if the branch node of the index corresponding to the root node has been initialized If the lower layer branch nodes of the branch node corresponding to the index are initialized, the processing module 52 determines whether the lower layer branch nodes of the branch node corresponding to the index are initialized; if the lower layer branch nodes of the branch node corresponding to the index are not initialized, the processing module 52 initializes the lower layer branch nodes of the branch node corresponding to the index; if the lower layer branch nodes of the branch node corresponding to the index are initialized, the processing module 52 determines whether the leaf nodes of the lower layer branch node corresponding to the index are initialized; if the leaf nodes of the lower layer branch node corresponding to the index are not initialized, the processing module 52 initializes the leaf nodes of the lower layer branch node corresponding to the index; if the leaf nodes of the lower layer branch node corresponding to the index are initialized, the processing module 52 stores the thread identifier in the leaf node of the index corresponding to the lower layer branch node.
[0097] In one possible implementation, based on the IP address, the processing module 52 searches for the thread identifier corresponding to the IP address in a preset dictionary tree, including: determining whether the root node in the dictionary tree is initialized; if the root node has been initialized, the processing module 52 determines whether the branch node of the index corresponding to the root node is initialized; if the branch node of the index corresponding to the root node has been initialized, the processing module 52 determines whether the lower-level branch node of the index corresponding to the branch node is initialized; if the lower-level branch node of the index corresponding to the branch node has been initialized, the processing module 52 determines whether the leaf node of the index corresponding to the lower-level branch node is initialized; if the leaf node of the index corresponding to the lower-level branch node has been initialized, the processing module 52 determines whether the thread identifier of the index corresponding to the leaf node is stored; if the thread identifier of the index corresponding to the leaf node has been stored, the processing module 52 returns the thread identifier stored in the leaf node.
[0098] In a possible implementation, if the root node and / or the branch node and / or the lower branch node and / or the leaf node are not initialized, the processing module 52 determines that the thread identifier search of the corresponding index fails and returns an invalid thread identifier.
[0099] In a possible implementation, the processing module 52 distributes the user's message to the thread corresponding to the thread identifier for processing, including: the processing module 52 determines the target thread corresponding to the thread identifier among multiple threads; the processing module 52 determines whether the user's message is a message stored in a thread other than the target thread; if the user's message is a message stored in a thread other than the target thread, the processing module 52 discards the user's message.
[0100] In a possible implementation, if the user's message is not a message stored in a thread other than the target thread, the processing module 52 stores the user's message in a cache queue corresponding to the user's message processing thread so that the user's message processing thread processes the user's message.
[0101] The present application also provides an electronic device, referring to Figure 6 The electronic device may include: at least one processor 61 , at least one network interface 64 , a user interface 63 , a memory 65 , and at least one communication bus 62 .
[0102] The communication bus 62 is used to realize the connection and communication between these components.
[0103] The user interface 63 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 63 may also include a standard wired interface and a wireless interface.
[0104] The network interface 64 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0105] Among them, the processor 61 may include one or more processing cores. The processor 61 uses various interfaces and lines to connect various parts in the entire network tester, and executes various functions of the network tester and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 65, and calling data stored in the memory 65. Optionally, the processor 61 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 61 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 61, and can be implemented separately through a chip.
[0106] The memory 65 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 65 includes a non-transitory computer-readable storage medium. The memory 65 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 65 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory 65 may optionally be at least one storage device located away from the aforementioned processor 61. As Figure 6 As shown, the memory 65 as a computer storage medium may include an operating system, a network communication module, a user interface module, and an application program suitable for a dynamic IP distribution method of a network tester.
[0107] exist Figure 6In the electronic device shown, the user interface 63 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 61 can be used to call an application program stored in the memory 65 for a dynamic IP distribution method suitable for a network tester. When executed by one or more processors, the electronic device executes one or more methods in the above-mentioned embodiments.
[0108] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.
[0109] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0111] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0112] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0113] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a memory, including a number of instructions for a computer device (which can be a personal computer, a network tester or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: various media that can store program codes, such as USB flash drives, mobile hard drives, magnetic disks or optical disks.
[0114] The above is only an exemplary embodiment of the present disclosure, and the scope of the present disclosure cannot be limited thereto. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, it will be easy for those skilled in the art to think of other embodiments of the present disclosure. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the technical field that are not recorded in the present disclosure. The description and examples are regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A dynamic IP distribution method suitable for a network tester, characterized in that: Applied to a network tester, the method comprises: Get the message sent by the TCP / IP protocol stack; Determining the IP address of the user based on the message; According to the IP address, searching for the thread identifier corresponding to the IP address in a preset dictionary tree, and distributing the user's message to the thread corresponding to the thread identifier for processing; The searching, according to the IP address, in a preset dictionary tree for a thread identifier corresponding to the IP address includes: Determine whether the root node in the dictionary tree is initialized; If the root node has been initialized, determine whether the branch node indexed by the root node is initialized; If the branch node of the index corresponding to the root node has been initialized, then determine whether the lower layer branch node of the index corresponding to the branch node is initialized; If the lower layer branch node of the index corresponding to the branch node has been initialized, then determine whether the leaf node of the index corresponding to the lower layer branch node is initialized; If the leaf node of the index corresponding to the lower layer branch node has been initialized, then determine whether the thread identifier of the index corresponding to the leaf node is stored; If the thread identifier of the leaf node corresponding to the index has been stored, then returning the thread identifier stored in the leaf node; The distributing the user's message to the thread corresponding to the thread identifier for processing includes: Determine a target thread corresponding to the thread identifier among multiple threads; Determining whether the user's message is a message stored in a thread other than the target thread; If the user's message is a message stored in a thread other than the target thread, discarding the user's message; Before obtaining the message sent by the TCP / IP protocol stack, the method further includes: Abstracting the IP address into a fixed-length byte array; Storing the fixed-length byte array in a dictionary tree; The storing of the fixed-length byte array into the dictionary tree comprises: The bytes in the fixed-length byte array are sequentially stored in the branch nodes, lower-layer branch nodes, and leaf nodes corresponding to the lower-layer branch nodes of the dictionary tree; Determine whether the root node in the dictionary tree is initialized; If the root node is not initialized, initialize the root node; If the root node has been initialized, determine whether the branch node indexed by the root node is initialized; If the branch nodes of the index corresponding to the root node are not initialized, then initialize the branch nodes of the index corresponding to the root node; If the branch node of the index corresponding to the root node has been initialized, then determine whether the lower layer branch node of the index corresponding to the branch node is initialized; If the lower layer branch nodes of the index corresponding to the branch node are not initialized, then initialize the lower layer branch nodes of the index corresponding to the branch node; If the lower layer branch node of the index corresponding to the branch node has been initialized, then determine whether the leaf node of the index corresponding to the lower layer branch node is initialized; If the leaf nodes of the index corresponding to the lower layer branch nodes are not initialized, then initialize the leaf nodes of the index corresponding to the lower layer branch nodes; If the leaf node of the index corresponding to the lower layer branch node has been initialized, the thread identifier is stored in the leaf node of the index corresponding to the lower layer branch node; If the root node and / or the branch node and / or the lower branch node and / or the leaf node are not initialized, it is determined that the thread identifier search of the corresponding index fails, and an invalid thread identifier is returned.
2. The dynamic IP distribution method according to claim 1, characterized in that: The method further comprises: Determine the address type of the IP address, the address type includes an IPV4 address and an IPV6 address; When the address type is an IPV4 address, determining that the fixed-length byte array is a 4-byte array; When the address type is an IPV6 address, the fixed-length byte array is determined to be a 16-byte array.
3. The dynamic IP distribution method according to claim 1, characterized in that: The method further comprises: If the user's message is not a message stored in a thread other than the target thread, the user's message is stored in a cache queue corresponding to the user's message processing thread, so that the user's message processing thread processes the user's message.
4. A dynamic IP distribution system suitable for a network tester, applied to the dynamic IP distribution method according to any one of claims 1 to 3, the dynamic IP distribution system comprising an acquisition module (51), a processing module (52) and a distribution module (53), wherein: The acquisition module (51) is used to acquire the message sent by the TCP / IP protocol stack; The processing module (52) is used to determine the IP address of the user based on the message; The distribution module (53) searches for a thread identifier corresponding to the IP address in a preset dictionary tree according to the IP address, and distributes the user's message to the thread corresponding to the thread identifier for processing; The distribution module (53) is also used to search for the thread identifier corresponding to the IP address in a preset dictionary tree according to the IP address, including: judging whether the root node in the dictionary tree is initialized; if the root node is initialized, judging whether the branch node of the index corresponding to the root node is initialized; if the branch node of the index corresponding to the root node is initialized, judging whether the lower branch node of the index corresponding to the branch node is initialized; if the lower branch node of the index corresponding to the branch node is initialized, judging whether the leaf node of the index corresponding to the lower branch node is initialized; if the leaf node of the index corresponding to the lower branch node is initialized, judging whether the thread identifier of the index corresponding to the leaf node is stored; if the thread identifier of the index corresponding to the leaf node is stored, returning the thread identifier stored in the leaf node; The distribution module (53) is further used to distribute the user's message to the thread corresponding to the thread identifier for processing, including: determining a target thread corresponding to the thread identifier among multiple threads; judging whether the user's message is a message stored in a thread other than the target thread; if the user's message is a message stored in a thread other than the target thread, discarding the user's message; The acquisition module (51) is also used for, before acquiring the message sent by the TCP / IP protocol stack, the method further comprising: abstracting the IP address into a fixed-length byte array; storing the fixed-length byte array in a dictionary tree; The processing module (52) is also used for storing the fixed-length byte array in the dictionary tree, including: storing each byte in the fixed-length byte array in the branch node, the lower branch node and the leaf node corresponding to the lower branch node of the dictionary tree in sequence; judging whether the root node in the dictionary tree is initialized; if the root node is not initialized, initializing the root node; if the root node is initialized, judging whether the branch node of the index corresponding to the root node is initialized; if the branch node of the index corresponding to the root node is not initialized, initializing the branch node of the index corresponding to the root node; if the branch node of the index corresponding to the root node is initialized , then determine whether the lower-level branch nodes of the index corresponding to the branch node are initialized; if the lower-level branch nodes of the index corresponding to the branch node are not initialized, then initialize the lower-level branch nodes of the index corresponding to the branch node; if the lower-level branch nodes of the index corresponding to the branch node are initialized, then determine whether the leaf nodes of the index corresponding to the lower-level branch node are initialized; if the leaf nodes of the index corresponding to the lower-level branch node are not initialized, then initialize the leaf nodes of the index corresponding to the lower-level branch node; if the leaf nodes of the index corresponding to the lower-level branch node are initialized, then store the thread identifier in the leaf node of the index corresponding to the lower-level branch node; The processing module (52) is also used to determine that the thread identifier search of the corresponding index fails and return an invalid thread identifier if the root node and / or the branch node and / or the lower branch node and / or the leaf node are not initialized.
5. An electronic device, characterized in that: The electronic device comprises a processor (61), a memory (65), a user interface (63) and a network interface (64), wherein the memory (65) is used to store instructions, the user interface (63) and the network interface (64) are both used to communicate with other devices, and the processor (61) is used to execute the instructions stored in the memory (65) so that the electronic device executes the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Message flow statistical method and device
CN113783825A