Network Topology Structure Generation Method, Electronic Device and Computer-Readable Storage Medium
By verifying the neighbor port of the network port, an accurate network topology is generated, which solves the problem of inaccurate discovery of neighbor ports and improves the accuracy and operation and maintenance efficiency of the topology structure.
Patent Information
- Application Number
- CN202510503843.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-22
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-04-22
AI Technical Summary
In the prior art, when generating network topology, there is a problem that inaccurate neighbor port discovery leads to insufficient topology accuracy.
By obtaining the neighbor ports of each target network port in the preset signal area and performing secondary neighbor port verification on ports whose number of neighbor ports is greater than the preset threshold, ensuring that only the real neighbor ports are retained and the target network topology is generated.
It improves the accuracy of network topology, reduces the complexity of topology, and improves the efficiency of network equipment operation and maintenance management.
Smart Images

Figure CN120050182B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular, to a method for generating a network topology structure, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the continuous development of communication technologies, more and more network devices are accessed by various enterprises and institutions. In order to achieve efficient and accurate operation and maintenance management of network devices, a network topology structure can be established to clearly present the complex physical connections between network devices.
[0003] Currently, the common way to obtain a network topology structure is to obtain the neighbor devices of each network device through network protocols, and access the neighbor devices step by step to obtain the connection relationships between network devices, thereby obtaining the network topology structure. However, the device capabilities of different network devices are different, resulting in different accuracies in discovering neighbor ports, which in turn affects the accuracy of the network topology structure. Summary of the Invention
[0004] The main technical problem to be solved by this application is to provide a method for generating a network topology structure, an electronic device, and a computer-readable storage medium, which can improve the accuracy of the network topology structure.
[0005] To solve the above technical problem, one technical solution adopted by this application is: to provide a method for generating a network topology structure, the method includes: obtaining neighbor ports of each target network port in a preset signal area; in response to the number of neighbor ports of a target network port being greater than a preset number threshold, verifying and processing the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port, where the secondary neighbor ports are the neighbor ports of the neighbor ports of each target network port; generating a target network topology structure according to the target neighbor ports of each target network port.
[0006] To solve the above technical problem, another technical solution adopted by this application is: to provide an electronic device, including a memory and a processor, where the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the above method for generating a network topology structure.
[0007] To solve the above technical problem, another technical solution adopted by this application is: to provide a computer-readable storage medium including stored program data, where the program data is used to implement the above method for generating a network topology structure when executed by a processor.
[0008] Advantages of the present application: The network topology structure generation method according to the embodiments of the present application obtains neighbor ports of each target network port in a preset signal area; in response to the number of neighbor ports of a target network port being greater than a preset number threshold, verification processing is performed on the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port, where the secondary neighbor ports are the neighbor ports of the neighbor ports of each target network port; a network topology structure is generated according to the target neighbor ports of each target network port. Thus, it can be ensured that only the target neighbor ports exist among the neighbor ports of each target network port, reducing the complexity of the generated network topology structure and improving the accuracy of the network topology structure. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings, where:
[0010] Figure 1 is a flowchart of an exemplary embodiment of the network topology structure generation method shown in the present application;
[0011] Figure 2 is a schematic diagram of an application scenario of an exemplary embodiment of the prior art shown in the present application;
[0012] Figure 3 is Figure 1 a flowchart of an exemplary embodiment of step S120 in the network topology structure generation method shown;
[0013] Figure 4 is a schematic diagram of an application scenario of an exemplary embodiment of the network topology structure generation method shown in the present application;
[0014] Figure 5 is a specific flowchart of an exemplary embodiment of the network topology structure generation method shown in the present application;
[0015] Figure 6 is a schematic diagram of an exemplary embodiment of the network topology structure device shown in the present application;
[0016] Figure 7 is a schematic diagram of an embodiment of an electronic device provided by the present application;
[0017] Figure 8 is a schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0018] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. It can be understood that the specific embodiments described herein are only used to explain the present application, rather than limiting the present application. In addition, it should be noted that for the convenience of description, only the parts related to the present application rather than all the structures are shown in the drawings. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.
[0019] First of all, it should be noted that the network topology structure describes the framework of the physical or logical connection methods between network ports in the network, which directly affects the performance, reliability, scalability, and security of the network. The traditional network topology generation method mainly focuses on discovering the topology structure and does not consider the accuracy of the topology structure, which may generate incorrect network topology structures. Based on this, the present application provides a network topology structure generation method, an electronic device, and a computer-readable storage medium. By verifying the neighbor ports of each network port, the correct neighbor ports are confirmed as the target neighbor ports, so that the target network topology structure generated by the target neighbor ports is more accurate.
[0020] Details can be referred to Figure 1 , Figure 1 which is a schematic flowchart of an exemplary embodiment of the network topology structure generation method shown in the present application.
[0021] The execution subject of the network topology structure generation method can be a terminal device, a server, or other processing devices. Among them, the terminal device can be a user equipment (UE), a computer, a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The execution subject of the network topology structure generation method can also be a network topology structure generation device. In some possible implementation manners, the network topology structure generation method can be implemented by a processor calling computer-readable instructions stored in a memory.
[0022] In the embodiments of the present application, the network topology structure generation device is used as the execution subject for description. Specifically, the network topology structure generation method in this embodiment includes the following steps:
[0023] S110: Obtain the neighbor ports of each target network port in the preset signal area.
[0024] The preset signal area is the area where the network port can forward signals. Exemplarily, the preset signal area can be determined by the forwarding protocol, including signal forwarding within the same local area network or subnet, forwarding between local area networks, forwarding in a wide area network environment, forwarding between an edge router and a core router, and Internet forwarding, etc.
[0025] The target network port is an interface in a network device used to communicate and connect with other devices (such as a computer, server, router, or another switch). Exemplarily, the preset signal area may include multiple network devices, and each network device may include multiple network ports. The target network device can be selected from the network devices in the preset signal area, and the network port of the target network device is used as the target network port. The network devices in this embodiment are all managed network devices: they have the Tx (Transmit) and Rx (Receive) functions of the LLDP (Link Layer Discovery Protocol) device.
[0026] The neighbor port is the port discovered by the target network port through the neighbor protocol. Usually, under a normal network device, the neighbor port discovered by the network port based on the neighbor protocol is the network port directly connected to it. At this time, the discovered neighbor port can be directly used as the target neighbor port of this network port. However, when there are abnormal network devices in the preset signal area, the neighbor ports discovered by them through the neighbor protocol may be non-directly connected network ports. The non-directly connected network ports are not the real neighbor ports of this network port. Therefore, it is necessary to verify the neighbor ports of the target network port to confirm the real neighbor ports and improve the correctness of the network topology. Among them, the abnormal network device mainly refers to the device's ability to apply the neighbor protocol. The neighbor protocol can be LLDP (Link Layer Discovery Protocol), that is, the LLDP packet will get stuck in the CPU and will also be forwarded, resulting in non-directly connected devices learning unexpected neighbor ports, such as Figure 2 As shown, when there are abnormal network devices in the preset signal area, it causes each network port to learn non-real neighbor ports as neighbor ports, and thus it is impossible to generate a correct network topology.
[0027] S120: In response to the number of neighbor ports of a target network port being greater than the preset number threshold, verify and process the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port, where the secondary neighbor port is the neighbor port of the neighbor port of each target network port, to obtain the target neighbor ports of each target network port.
[0028] The number of ports refers to the number of neighbor ports discovered by each target network port through the neighbor protocol. Exemplarily, the neighbor ports of each target network port are obtained through the neighbor protocol, and the number of neighbor ports of each target network port is counted to obtain the number of ports of the neighbor ports of each target network port.
[0029] The preset number threshold can be a value preset according to experience. Exemplarily, the preset number threshold can be set to 1, that is, as long as the number of ports of the neighbor ports of the target network port is greater than 1, it is necessary to perform verification processing on the neighbor ports of each target network port to obtain the target neighbor ports of each target network port. Of course, the preset number threshold can also be set to 2, 3, etc. In some other embodiments, as long as there is a network device in the preset signal area that belongs to an abnormal network device, it is necessary to perform verification processing on the neighbor ports of the abnormal network device to obtain the target neighbor ports of the abnormal network device.
[0030] The secondary neighbor port refers to the neighbor port of the neighbor port of the target network port. As an example, the neighbor ports of Network Port A include Network Port B, and the neighbor ports of Network Port B include Network Port C. Then Network Port C is the secondary neighbor port of Network Port A in this relationship. It should be noted that the neighbor ports of the target network port are discovered from other target network ports in the preset signal area except the target network port. The secondary neighbor ports of the target network port are discovered from other target network ports in the preset signal area except the corresponding neighbor port, and may of course also include the target network port.
[0031] The target neighbor ports can be some of the neighbor ports selected from the neighbor ports of each target network port. Exemplarily, verification processing can be performed on the neighbor ports of each target network port to obtain the neighbor ports with successful verification as the target neighbor ports. Specifically, the neighbor ports of the target network port can be verified according to the secondary neighbor ports of each target network port, so as to obtain the target neighbor ports of the target network port.
[0032] S130: Generate a target network topology based on the target neighbor ports of each target network port.
[0033] The target network topology represents the connection status between each target network port in the preset signal area. Exemplarily, after determining the target neighbor ports of each target network port, a target network topology is generated using a traversal algorithm. The traversal algorithm can be a breadth-first traversal algorithm or a depth-first traversal algorithm. Specifically, taking each target network port as a node, traversing in sequence, and connecting the nodes of each target network port with its corresponding target neighbor ports to obtain the target network topology.
[0034] It can be seen that the network topology structure generation method according to the embodiments of the present application obtains the neighbor ports of each target network port in a preset signal area; in response to the number of neighbor ports of a target network port being greater than a preset number threshold, the neighbor ports of the corresponding target network port are verified according to the secondary neighbor ports of each target network port, and the target neighbor ports of each target network port are obtained, where the secondary neighbor port is the neighbor port of the neighbor port of each target network port; a network topology structure is generated according to the target neighbor ports of each target network port. In this way, it can be ensured that only the target neighbor ports exist among the neighbor ports of each target network port, reducing the complexity of the generated network topology structure and improving the accuracy of the network topology structure.
[0035] Based on the above embodiments, the embodiments of the present application use Figure 3 a flowchart to elaborate in detail the order in which the neighbor ports of each target network port are verified. Please refer to Figure 3 , Figure 3 which Figure 1 is a schematic flowchart of an exemplary embodiment of step S120 in the network topology structure generation method shown. Specifically, the process of step S120 verifying the neighbor ports of the corresponding target network port according to the secondary neighbor ports of the neighbor ports of each target network port to obtain the target neighbor ports of each target network port further includes the following steps:
[0036] S310: Determine the verification order of each target network port in ascending order of the number of neighbor ports of each target network port.
[0037] The verification order can be the order in which the target network ports in the preset signal area determine the target neighbor ports. In some embodiments, the network topology structure generation device can sort according to the number of neighbor ports of each target network port, for example, in ascending order or descending order. In other embodiments, the network topology structure generation device can also randomly generate the verification order of each target network port and verify the neighbor ports of each target network port according to the randomly generated verification order. In other embodiments, the network topology structure generation device can also verify the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port at the same time to obtain the target neighbor ports of each target network port.
[0038] In this embodiment, the verification order of each target network port is determined in ascending order of the number of neighbor ports of each target network port. Exemplarily, the network topology structure generation device obtains the neighbor ports of all target network ports in the preset signal area; counts the number of neighbor ports of each target network port; sorts in ascending order of the number of ports to obtain the verification order of each target network port. As an example, as shown in Table 1:
[0039]
[0040] Table 1
[0041] It can be seen that the port with the least number of neighbor ports is port 5 of switch 1, and its ranking is 1, that is, it is the first to be verified, and the others are in order according to the number of ports.
[0042] S320: Screen the neighbor ports of each target network port in sequence according to the verification order of each target network port to obtain the target neighbor ports of each target network port.
[0043] After determining the verification order of each target network port, the network topology generation device performs verification processing on the neighbor ports of each target network port according to the verification order to obtain the target neighbor ports of each target network port. Specifically, it may be to remove the non-target neighbor ports from the neighbor ports of each target network port to obtain the target neighbor ports of each target network port. Thus, by verifying the neighbor ports of each target network port in ascending order of the number of neighbor ports, the determination efficiency of the target neighbor ports can be improved.
[0044] In some other embodiments, the network topology generation device randomly obtains a network port from each target network port for verification processing until all target network ports are verified. Specifically, traverse each target network port, and select the target neighbor ports of the target network port from the neighbor ports of the target network port according to the secondary neighbor ports of the target network port; screen the neighbor ports of the target neighbor ports according to the target network port to obtain the target neighbor ports of the target neighbor ports. The target neighbor ports of the target network port and the target neighbor ports of the target neighbor ports are applied to the verification processing of the next target network port. Neighbors are reciprocal. If the target neighbor port is the real neighbor of the target network port, then the target network port is also the real neighbor of the target neighbor port. Thus, in each verification processing, the neighbor ports of the target network port and the neighbor ports of its corresponding target neighbor port can be verified simultaneously. Each verification processing will correspondingly reduce the incorrect neighbor ports, and the next verification processing is carried out on the basis of removing the incorrect neighbor ports in the previous time, greatly improving the verification efficiency. Of course, in some other embodiments, when traversing each target network port, only the secondary neighbor ports of each target network port can be used to verify the neighbor ports of the target network port in sequence to obtain the target neighbor ports of the target network port.
[0045] Among them, the step of selecting the target neighbor port of the target network port from the neighbor ports of the target network port according to the secondary neighbor port of the target network port may further include: determining the currently traversed target network port as the current network port, and determining the neighbor ports of the current network port as candidate network ports; traversing each candidate network port, and in response to that the first judgment range does not include the current network port and the first judgment range does not include the network ports in the second judgment range, removing the corresponding candidate network port from the neighbor ports of the current network port; in response to that the first judgment range includes the current network port and the first judgment range does not include the network ports in the second judgment range, determining the corresponding candidate network port as the target neighbor port of the current network port; the first judgment range is the neighbor ports of each candidate network port, and the second judgment range includes the candidate network ports.
[0046] Among them, for the convenience of understanding, when verifying the target network port sequentially, the currently traversed target network port can be used as the current network port, the neighbor ports of the current network port as candidate network ports, and the neighbor ports of the candidate network ports are the secondary neighbor ports of the current network port. Among them, the neighbor ports of the current network port are the neighbor ports after verification and processing based on the previous historical network ports of the current network port. Traverse the candidate network ports of the current network port to determine whether each candidate network port is the target neighbor port of the current network port. The specific judgment method is to judge whether the neighbor ports of the candidate network port include the current network port. If it exists and there are no neighbor ports of the current network port in the neighbor ports of the candidate network port, that is, there are no other common neighbor ports, then the candidate network port can be determined as the target neighbor port of the current network port, and other candidate network ports except the target neighbor port in the candidate network ports are removed; if the neighbor ports of the candidate network port do not include the current network port and there are no neighbor ports of the current network port in the neighbor ports of the candidate network port, then the candidate network port can be removed from the neighbor ports of the current network port.
[0047] Further, the step of filtering the secondary neighbor ports of the target neighbor port according to the target network port to obtain the target neighbor port of the target neighbor port may further include: obtaining other neighbor ports except the target network port in the neighbor ports of the target neighbor port; removing the other neighbor ports from the neighbor ports of the target neighbor port to obtain the target neighbor port of the target neighbor port.
[0048] After verifying the neighbor ports of each target network port and determining the target neighbor port of the target network port, the neighbor ports of the target neighbor port can also be verified using the target network port to obtain the target neighbor port of the target neighbor port. As an example, the neighbor ports of network port 5 include network port 7, and the neighbor ports of network port 7 include network port 5, network port 3, and network port 2. After verifying the neighbor ports of network port 5, it is found that the neighbor ports of network port 7 also include network port 5 and do not include the other neighbor ports of network port 5. Then, the other neighbor ports of network port 7, that is, network port 3 and network port 2, can be removed, and the target neighbor port is obtained as network port 5. Thus, in subsequent verification processes, the neighbor port of network port 5 is network port 7, and the neighbor port of network port 7 is network port 5. Whether it is the verification party or the verified party, the number of verification ports can be reduced and the verification efficiency can be improved.
[0049] As a combined example, please refer to Figure 4 , the preset signal area includes network port 1 and network port 2 of switch 0, network port 3 and network port 5 of switch 1, network port 4 and network port 6 of switch 2, network port 7 of switch 3, and network port 8 of switch 4. The neighbor ports of network port 1 include network port 5, network port 7, and network port 3; the neighbor ports of network port 2 include network port 6, network port 8, and network port 4; the neighbor ports of network port 3 include network port 8, network port 6, network port 4, network port 2, and network port 1; the neighbor ports of network port 4 include network port 7, network port 5, network port 3, network port 1, and network port 2; the neighbor ports of network port 5 include network port 7; the neighbor ports of network port 6 include network port 8; the neighbor ports of network port 7 include network port 5, network port 3, network port 2, network port 1, network port 4, network port 6, and network port 8; the neighbor ports of network port 8 include network port 6, network port 2, network port 4, network port 3, network port 1, network port 7, and network port 5. Among them, the target network ports are network port 1, network port 2, network port 3, network port 4, network port 5, and network port 6. The verification order is determined according to the number of neighbor ports as network port 5, network port 6, network port 2, network port 1, network port 3, and network port 4 in turn.
[0050] First, traverse the neighbor ports of network port 5. Network port 7 can be found. Among the neighbor ports of network port 7, network port 5 also exists, and there are no other neighbor ports of network port 5 among the neighbor ports of network port 7. Then, determine network port 7 as the target neighbor port of network port 5, and remove the other neighbor ports of network port 7 except network port 5 from the neighbor ports of network port 7, so that the target neighbor port of network port 7 is network port 5;
[0051] Traverse the neighbor ports of network port 6. Network port 8 can be found. Among the neighbor ports of network port 8, network port 6 also exists, and there are no other neighbor ports of network port 6 among the neighbor ports of network port 8. Then, determine network port 8 as the target neighbor port of network port 6, and remove the other neighbor ports of network port 8 except network port 6 from the neighbor ports of network port 8, so that the target neighbor port of network port 8 is network port 6;
[0052] Traverse the neighbor ports of network port 2. When network port 6 is traversed, it is found that network port 6 does not exist among the neighbor ports of network port 2 and they have no common neighbor, so network port 6 is removed from the neighbor ports of network port 2; when network port 8 is traversed, it is found that the target neighbor port of network port 8 is network port 6 and they have no common neighbor, so network port 8 is removed from the neighbor ports of network port 2; when network port 4 is traversed, it is found that network port 4 exists among the neighbor ports of network port 2 and they have no other common neighbor, so network port 4 is taken as the target neighbor port of network port 2, and the other neighbor ports of network port 4 except network port 2 are removed from the neighbor ports of network port 4, so that the target neighbor port of network port 4 is network port 2;
[0053] Traverse the neighbor ports of network port 1. When network port 5 is traversed, it is found that network port 5 does not exist among the neighbor ports of network port 1 and they have no common neighbor, so network port 5 is removed from the neighbor ports of network port 1; when network port 7 is traversed, it is found that the target neighbor port of network port 7 is network port 5 and they have no common neighbor, so network port 7 is removed from the neighbor ports of network port 1; when network port 3 is traversed, it is found that network port 3 exists among the neighbor ports of network port 1 and they have no other common neighbor, so network port 3 is taken as the target neighbor port of network port 1, and the other neighbor ports of network port 3 except network port 1 are removed from the neighbor ports of network port 3, so that the target neighbor port of network port 3 is network port 1;
[0054] Traverse the neighbor ports of network port 3. It is found that the target neighbor port of network port 3 is network port 1, and network port 3 exists among the neighbor ports of network port 1, and the two are valid neighbors;
[0055] Traverse the neighbor ports of network port 4, and find that the target neighbor port of network port 4 is network port 2. Moreover, network port 4 exists among the neighbor ports of network port 2, and the two are valid neighbors.
[0056] In some other embodiments, the network topology generation device traverses each target network port. In response to the fact that the target network port is not connected to other target network ports, screen the neighbor ports of the target network port to obtain the target neighbor port of the target network port, and connect the target network port to the target neighbor port. In response to the fact that the target network port is connected to other target network ports, use the connected other target network ports as the target neighbor ports of the target network port. Compared with the method of first determining the target neighbor ports of each target network port and then using the traversal algorithm to generate the network topology, this method reduces the process of the traversal algorithm, and at the same time can also reduce the time of the target neighbor ports, improving the generation efficiency of the network topology.
[0057] Specifically, as an example, please continue to refer to Figure 4 , and still verify in ascending order of the number of ports of the neighbor ports.
[0058] First, traverse the neighbor ports of network port 5, and network port 7 can be found. Network port 5 also exists among the neighbor ports of network port 7, and there are no other neighbor ports of network port 5 among the neighbor ports of network port 7. Then, determine network port 7 as the target neighbor port of network port 5, and remove the other neighbor ports of network port 7 except network port 5 among the neighbor ports of network port 7, obtaining that the target neighbor port of network port 7 is network port 5. Use network port 5 and network port 7 as connection points respectively to draw the connection line between the two.
[0059] Traverse the neighbor ports of network port 6, and network port 8 can be found. Network port 6 also exists among the neighbor ports of network port 8, and there are no other neighbor ports of network port 6 among the neighbor ports of network port 8. Then, determine network port 8 as the target neighbor port of network port 6, and remove the other neighbor ports of network port 8 except network port 6 among the neighbor ports of network port 8, obtaining that the target neighbor port of network port 8 is network port 6. Use network port 6 and network port 8 as connection points respectively to draw the connection line between the two.
[0060] Traverse the neighbor ports of network port 2. When network port 6 is traversed, it is found that network port 2 does not exist in the neighbor ports of network port 6 and there are no common neighbors between them, so network port 6 is removed from the neighbor ports of network port 2; when network port 8 is traversed, it is found that the target neighbor port of network port 8 is network port 6 and there are no common neighbors between them, so network port 8 is removed from the neighbor ports of network port 2; when network port 4 is traversed, it is found that network port 2 exists in the neighbor ports of network port 4 and there are no other common neighbors between them, so network port 4 is used as the target neighbor port of network port 2, and other neighbor ports except network port 2 in the neighbor ports of network port 4 are removed, and the target neighbor port of network port 4 is obtained as network port 2; network port 2 and network port 4 are respectively used as connection points to draw a connecting line between them;
[0061] Traverse the neighbor ports of network port 1. When network port 5 is traversed, it is found that network port 1 does not exist in the neighbor ports of network port 5 and there are no common neighbors between them, so network port 5 is removed from the neighbor ports of network port 1; when network port 7 is traversed, it is found that the target neighbor port of network port 7 is network port 5 and there are no common neighbors between them, so network port 7 is removed from the neighbor ports of network port 1; when network port 3 is traversed, it is found that network port 1 exists in the neighbor ports of network port 3 and there are no other common neighbors between them, so network port 3 is used as the target neighbor port of network port 1, and other neighbor ports except network port 1 in the neighbor ports of network port 3 are removed, and the target neighbor port of network port 3 is obtained as network port 1; network port 1 and network port 3 are respectively used as connection points to draw a connecting line between them;
[0062] Connecting lines already exist for both network port 3 and network port 4. Therefore, there is no need for further verification. Directly use network port 1 connected to network port 3 as its target neighbor port, and use network port 2 connected to network port 4 as its target neighbor port.
[0063] When generating the target network topology structure based on the target neighbor ports of each target network port, it can be determined whether there is a connecting line between each target network port and its corresponding target neighbor port; if so, each target network port is used as a connection point of the target network topology structure, and the connecting lines of each target network port are used as the connection relationships of the target network topology structure to generate the target network topology structure; if not, each target network port is traversed and connected according to the target neighbor ports of each target network port to obtain the target network topology structure. Thus, different network topology structure generation methods are adopted for different methods to improve application flexibility.
[0064] When the network topology structure generating device first determines the target neighbor port of each target network port, each target network port can be traversed and connected according to the target neighbor port of each target network port to obtain the target network topology structure. The traversal connection can be to use each target network port as a node and sequentially traverse and connect each target network port and the corresponding target neighbor port using a breadth-first traversal algorithm.
[0065] When the network topology structure generating device determines the target neighbor port of each target network port while connecting the two as connection points, the connection relationship of each target network port can be directly used as the target network topology structure.
[0066] Furthermore, the target network port may be a portion of the network ports obtained from the initial network ports in the preset signal area. Specifically, the device capability of each initial network port applying the neighbor protocol is obtained; in response to the device capability of the initial network port applying the neighbor protocol being less than the preset device capability, the neighbor port of the initial network port is used as the neighbor port of the target network port. Since only the network ports under abnormal devices will have wrong neighbors, it is only necessary to verify the network ports with weaker device capabilities to clear the wrong neighbors under each network port and obtain the real target neighbor port.
[0067] It should be noted that during the verification process of the target network port, the non-target network ports in the initial network port will also be verified to obtain the target neighbor ports of the non-target network ports. As an example, please continue to refer to Figure 4 , Figure 4 Among them, switch 0, switch 1 and switch 2 are switches whose device capabilities of applying neighbor protocol are less than the preset device capabilities, and their corresponding network ports are target network ports. Switch 3 and switch 4 are normal devices, and their corresponding network ports are non-target network ports. When verifying the neighbor port of network port 5, it is found that its corresponding target neighbor port is network port 7. At this time, the neighbor ports of network port 7 other than network port 5 will be removed, and the target neighbor port of network port 7 is obtained as network port 5.
[0068] The target network topology is the network topology between the initial network ports in the preset signal area, that is, the target network port and the non-target network port are both used as connection points, and the connection relationship is determined according to the target neighbor port of each network port to obtain the target network topology.
[0069] In other embodiments, the target network port may also be all initial network ports in the preset signal area, that is, regardless of whether the device capability of the network port in the preset signal area applying the neighbor protocol is less than the preset device capability, it is used as the target network port for neighbor port verification.
[0070] To elaborate on the network topology generation method in the embodiments of the present application in detail, the following flowchart is used for further illustration, and the details are as follows: Figure 5 As shown in the flowchart for further illustration, the details are as follows:
[0071] S510: Obtain the neighbor ports (LLDP neighbor ports) of each initial network port in the preset signal area, and the device capabilities of each initial network port applying the neighbor protocol, which can be divided into weak neighbor devices and non-weak neighbor devices. A weak neighbor device is a device whose device capability of applying the neighbor protocol is less than the preset device capability, and a non-weak neighbor device is a device whose device capability of applying the neighbor protocol is greater than or equal to the preset device capability.
[0072] S520: Count the neighbor ports of the network ports under the weak neighbor devices, and sort them in ascending order according to the number of neighbor ports; the network ports under the weak neighbor devices can be target network ports.
[0073] S530: Optionally select one of the following methods. Method 1: According to the sorting of each target network port, establish the public neighbors of the directly connected devices from small to large, clean up the non-public neighbors of the directly connected devices, and use the breadth-first search algorithm to generate the target network topology. Method 2: According to the sorting of each target network port, establish the public neighbors of the directly connected devices from small to large, and draw connection lines for the public neighbors of the directly connected devices. The network topology generated in this way is more real and accurate, providing an accurate network topology for user network operation and maintenance, and saving manpower and time costs.
[0074] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of an exemplary embodiment of the network topology device shown in the present application. The network topology device 600 includes an acquisition module 610, a verification module 620, and a generation module 630. The acquisition module 610 is used to acquire the neighbor ports of each target network port in the preset signal area; the verification module 620 is used to, in response to the number of neighbor ports of a target network port being greater than the preset number threshold, verify the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port. The secondary neighbor port is the neighbor port of the neighbor port of each target network port; the generation module 630 is used to generate the target network topology according to the target neighbor ports of each target network port.
[0075] In the above solution, the network topology structure device obtains the neighbor ports of each target network port in a preset signal area; in response to the number of neighbor ports of a target network port being greater than a preset number threshold, the neighbor ports of the corresponding target network port are verified according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port, where the secondary neighbor port is the neighbor port of the neighbor port of each target network port; a network topology structure is generated according to the target neighbor ports of each target network port. In this way, it can be ensured that only the target neighbor ports exist among the neighbor ports of each target network port, reducing the complexity of the generated network topology structure and improving the accuracy of the network topology structure.
[0076] Among them, the functions of each module can be referred to in the embodiments of the network topology structure method and will not be elaborated here.
[0077] To implement the network topology structure method in the above embodiments, the present application proposes another electronic device. For details, please refer to Figure 7 , Figure 7 which is a schematic structural diagram of an embodiment of the electronic device provided by the present application.
[0078] The electronic device 700 includes a memory 710 and a processor 720, where the memory 710 and the processor 720 are coupled.
[0079] The memory 710 is used to store program data, and the processor 720 is used to execute the program data to implement the network topology structure method in the above embodiments.
[0080] In this embodiment, the processor 720 can also be referred to as a CPU (Central Processing Unit). The processor 720 may be an integrated circuit chip with signal processing capabilities. The processor 720 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor 720 may also be any conventional processor, etc.
[0081] The present application also provides a computer-readable storage medium, as Figure 8 shown, the computer-readable storage medium 800 is used to store program data 810, and when the program data 810 is executed by the processor, it is used to implement the network topology structure method in the method embodiments of the present application.
[0082] In the method embodiments of the network topology structure method of the present application, when the method exists in the form of a software functional unit and is sold or used as an independent product, it can be stored in a device, such as a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, 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 storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0083] The above are only the embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present application.
Claims
1. A method for generating a network topology structure, characterized in that, The network topology structure generation method includes: Obtaining the neighbor ports of each target network port in a preset signal area; In response to the number of neighbor ports of a target network port being greater than a preset number threshold, verifying the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port, where the secondary neighbor port is the neighbor port of the neighbor port of each target network port; Generating a target network topology structure according to the target neighbor ports of each target network port.
2. The method for generating a network topology structure according to claim 1, wherein The step of verifying the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port, where the secondary neighbor port is the neighbor port of the neighbor port of each target network port, includes: Determining the verification order of each target network port according to the number of neighbor ports of each target network port from small to large; Successively performing screening processing on the neighbor ports of each target network port according to the verification order of each target network port to obtain the target neighbor ports of each target network port.
3. The method for generating a network topology structure according to claim 1, wherein The step of verifying the neighbor ports of the corresponding target network port according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port, where the secondary neighbor port is the neighbor port of the neighbor port of each target network port, includes: Traversing each target network port, and selecting the target neighbor ports of the target network port from the neighbor ports of the target network port according to the secondary neighbor ports of the target network port; Performing screening processing on the neighbor ports of the target neighbor ports according to the target network port to obtain the target neighbor ports of the target neighbor ports, and the target neighbor ports of the target network port and the target neighbor ports of the target neighbor ports are applied to the verification processing of the next target network port.
4. The method for generating a network topology structure according to claim 3, wherein The step of traversing each target network port and selecting the target neighbor ports of the target network port from the neighbor ports of the target network port according to the secondary neighbor ports of the target network port includes: Determining the currently traversed target network port as the current network port, and determining the neighbor ports of the current network port as candidate network ports; Traversing each candidate network port, and in response to the first judgment range not including the current network port and the first judgment range not including the network ports in the second judgment range, removing the corresponding candidate network port from the neighbor ports of the current network port; In response to the first judgment range including the current network port and the first judgment range not including the network ports in the second judgment range, determining the corresponding candidate network port as the target neighbor port of the current network port; The first judgment range is the neighbor ports of each candidate network port, and the second judgment range includes the candidate network port.
5. The method for generating a network topology structure according to claim 3, wherein The step of performing screening processing on the neighbor ports of the target neighbor ports according to the target network port to obtain the target neighbor ports of the target neighbor ports includes: Obtain other neighbor ports among the neighbor ports of the target neighbor port except the target network port; Remove the other neighbor ports from the neighbor ports of the target neighbor port to obtain the target neighbor ports of the target neighbor port.
6. The method for generating a network topology structure according to claim 1, wherein The step of verifying the neighbor ports of each target network port according to the secondary neighbor ports of each target network port to obtain the target neighbor ports of each target network port includes: Traverse each target network port. In response to the target network port not being connected to other target network ports, perform screening processing on the neighbor ports of the target network port to obtain the target neighbor ports of the target network port, and connect the target network port to the target neighbor ports. In response to the target network port being connected to other target network ports, use the connected other target network ports as the target neighbor ports of the target network port.
7. The method for generating a network topology structure according to claim 1, wherein The step of generating a target network topology according to the target neighbor ports of each target network port includes: Determine whether there are connection lines between each target network port and its corresponding target neighbor port; If so, use each target network port as a connection point of the target network topology, and the connection lines of each target network port as the connection relationship of the target network topology to generate the target network topology; If not, perform traversal connection processing on each target network port according to the target neighbor ports of each target network port to obtain the target network topology.
8. The method for generating a network topology structure according to claim 1, wherein The step of obtaining the neighbor ports of each target network port in the preset signal area includes: Obtain the device capabilities of each initial network port applying the neighbor protocol; In response to the device capability of the initial network port applying the neighbor protocol being less than the preset device capability, use the neighbor ports of the initial network port as the neighbor ports of the target network port.
9. An electronic device, characterized in that, Includes: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the method according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, Includes: Stores program data, and when the program data is executed by the processor, it is used to implement the method according to any one of claims 1-8.
Citation Information
Patent Citations
Using neighbor discovery to create trust information for other applications
CN104335546A
Inter-domain path identification prefix conflict detection and decomposition method based on prefix tree
CN111641729A