Network topology structure generation method, electronic equipment and computer readable storage medium

By verifying the neighbor port of the network port when acquiring the network topology, and establishing the target neighbor port, the problem that the accuracy of the network topology in the prior art is affected by the equipment capabilities, achieving higher accuracy and lower complexity.

CN120050182AActive Publication Date: 2025-05-27ZHEJIANG DAHUA TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510503843.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-22
Publication Date
2025-05-27
Estimated Expiration
2045-04-22

AI Technical Summary

Technical Problem

When obtaining network topology, the prior art is affected by the different capabilities of different network equipment, resulting in the discovery of the accuracy of neighbor ports, which in turn affects the accuracy of network topology.

Method used

By obtaining the neighbor ports of each target network port in the preset signal area, and when the number of ports is greater than the preset threshold, the neighbor port is used to verify the neighbor port to establish the target neighbor port, thereby generating a more accurate network topology.

Benefits of technology

Ensure that only the target neighbor ports are included in the network topology, reducing structural complexity and improving accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120050182A_ABST
    Figure CN120050182A_ABST
Patent Text Reader

Abstract

The invention discloses a network topological structure generation method, electronic equipment and a computer readable storage medium. The method comprises the following steps: acquiring neighbor ports of target network ports in a preset signal area; in response to the fact that the number of the neighbor ports of one target network port is larger than a preset number threshold value, verification processing is conducted on the neighbor ports corresponding to the target network port according to the secondary neighbor ports of each target network port, and target neighbor ports of all the target network ports are obtained, the secondary neighbor port is a neighbor port of a neighbor port of each target network port; and generating a network topology structure according to the target neighbor port of each target network port. Therefore, the accuracy of the network topology structure is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a network topology generation method, an electronic device and a computer-readable storage medium. Background Art

[0002] With the continuous development of communication technology, more and more network devices are connected to each enterprise unit. In order to achieve efficient and accurate network equipment operation and maintenance management, the complex physical connections between network devices can be clearly presented by establishing a network topology structure.

[0003] At present, the way to obtain the network topology is usually to obtain the neighbor devices of each network device through the network protocol, and to access the neighbor devices step by step to obtain the connection relationship between the network devices, so as to obtain the network topology. However, the device capabilities of different network devices are different, resulting in different accuracy in discovering neighbor ports, which affects the accuracy of the network topology. Summary of the invention

[0004] The main technical problem solved by the present application is to provide a network topology generation method, an electronic device and a computer-readable storage medium, which can improve the accuracy of the network topology.

[0005] In order to solve the above technical problems, a technical solution adopted in the present application is: a method for generating a network topology structure is provided, the method comprising: obtaining the neighbor ports of each target network port in a preset signal area; in response to the existence of a target network port whose number of neighbor ports is 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, wherein the secondary neighbor ports are the neighbor ports of the neighbor ports of each target network port; and generating a target network topology structure according to the target neighbor ports of each target network port.

[0006] To solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, including a memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the above network topology generation method.

[0007] In order to solve the above technical problems, another technical solution adopted by the present application is: providing a computer-readable storage medium including program data stored therein, wherein the program data is used to implement the above network topology structure generation method when executed by a processor.

[0008] Beneficial effects of the present application: The network topology structure generation method of the embodiment of the present application obtains the neighbor ports of each target network port in a preset signal area; in response to the port number of the neighbor ports of a target network port being greater than the 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, and the secondary neighbor ports are the neighbor ports of the neighbor ports of each target network port; the 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 network topology structure generated thereby, and improving the accuracy of the network topology structure. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which: Figure 1 It is a flowchart of an exemplary embodiment of a method for generating a network topology structure shown in the present application; Figure 2 It is a schematic diagram of an application scenario of an exemplary embodiment of the prior art shown in this application; Figure 3 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S120 in the network topology structure generating method; Figure 4 It is a schematic diagram of an application scenario of an exemplary embodiment of the network topology generation method shown in the present application; Figure 5 It is a specific flow chart of an exemplary embodiment of a method for generating a network topology structure shown in the present application; Figure 6 It is a structural diagram of an exemplary embodiment of a network topology structure device shown in the present application; Figure 7 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application; Figure 8 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION

[0010] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It will be appreciated that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only some but not all structures related to the present application are shown in the drawings. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the art without making creative work are within the scope of protection of the present application.

[0011] First of all, it should be noted that the network topology structure describes the framework of the physical or logical connection method between each network port 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 an erroneous network topology structure. Based on this, the present application provides a network topology structure generation method, an electronic device and a computer-readable storage medium, which verifies the neighbor port of each network port and confirms the correct neighbor port as the target neighbor port, so that the target network topology structure generated by the target neighbor port is more accurate.

[0012] For details, please refer to Figure 1 , Figure 1 It is a flowchart of an exemplary embodiment of a method for generating a network topology structure shown in the present application.

[0013] The execution subject of the network topology structure generation method may be a terminal device or a server or other processing device, wherein the terminal device may 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 may also be a network topology structure generation device. In some possible implementations, the network topology structure generation method may be implemented by a processor calling a computer-readable instruction stored in a memory.

[0014] In the embodiment 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 of this embodiment includes the following steps: S110: Obtain neighbor ports of each target network port in a preset signal area.

[0015] The preset signal area is an area where the network port can achieve signal forwarding. Exemplarily, the preset signal area can be determined by a forwarding protocol, including signal forwarding within the same LAN or subnet, forwarding between LANs, forwarding in a WAN environment, forwarding between edge routers and core routers, and Internet forwarding.

[0016] The target network port is an interface in a network device for communicating with other devices (such as a computer, a server, a 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 can be used as the target network port. The network devices in this embodiment are all managed network devices: they have Tx (Transmit) and Rx (Receive) functions of LLDP (Link Layer Discovery Protocol) devices.

[0017] The neighbor port is the port discovered by the target network port through the neighbor protocol. Normally, the neighbor port discovered by the network port under a normal network device based on the neighbor protocol is the network port directly connected to it. In this case, the discovered neighbor port can be directly used as the target neighbor port of the network port. However, when there are abnormal network devices in the preset signal area, the neighbor ports discovered by the neighbor protocol may have non-directly connected network ports. Non-directly connected network ports are not the real neighbor ports of the 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 capability of the network device to apply the neighbor protocol. The neighbor protocol can be LLDP (Link Layer Discovery Protocol), that is, the LLDP message will be trapped in the CPU and forwarded at the same time, causing the non-directly connected device to learn unexpected neighbor ports, such as Figure 2 As shown, when an abnormal network device exists in the preset signal area, each network port will learn a non-real neighbor port as a neighbor port, and thus a correct network topology structure cannot be generated.

[0018] S120: In response to the existence of a target network port whose number of neighbor ports is greater than a 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, where the secondary neighbor ports are the neighbor ports of the neighbor ports of each target network port.

[0019] The port quantity 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 port number of the neighbor ports of each target network port.

[0020] The preset quantity threshold may be a value preset based on experience. Exemplarily, the preset quantity threshold may be set to 1, that is, as long as the number of 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 quantity threshold may also be set to 2, 3, etc. In other embodiments, as long as there is a network device that is an abnormal network device in the preset signal area, 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.

[0021] The secondary neighbor port refers to the neighbor port of the neighbor port of the target network port. As an example, the neighbor port of network port A includes network port B, and the neighbor port of network port B includes 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 port of the target network port is found from other target network ports in the preset signal area except the target network port, and the secondary neighbor port of the target network port is found from other target network ports in the preset signal area except the corresponding neighbor port, and of course it may also include the target network port.

[0022] The target neighbor ports may be some ports selected from the neighbor ports of each target network port. Exemplarily, the neighbor ports of each target network port may be verified, and the neighbor ports that have been successfully verified may be used as the target neighbor ports. Specifically, the neighbor ports of the target network port may 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.

[0023] S130: Generate a target network topology structure according to the target neighbor ports of each target network port.

[0024] The target network topology structure represents the connection status between each target network port in the preset signal area. Exemplarily, after determining the target neighbor port of each target network port, a traversal algorithm is used to generate the target network topology structure. The traversal algorithm can be a breadth-first traversal algorithm or a depth-first traversal algorithm. Specifically, each target network port is used as a node, and traversed in sequence, and each target network port is connected to its corresponding target neighbor port to obtain a target network topology structure.

[0025] It can be seen that the network topology structure generation method of the embodiment of the present application obtains the neighbor ports of each target network port in the preset signal area; in response to the port number of the neighbor ports of a target network port being greater than the 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, and the secondary neighbor ports are the neighbor ports of the neighbor ports of each target network port; the network topology structure is generated according to the target neighbor ports of each target network port. In this way, it can be ensured that there are only target neighbor ports among the neighbor ports of each target network port, reducing the complexity of the network topology structure generated thereby, and improving the accuracy of the network topology structure.

[0026] Based on the above embodiments, the embodiments of the present application adopt Figure 3 The flowchart details the order in which the neighbor ports of each target network port are verified. Figure 3 , Figure 3 yes Figure 1 The flowchart of an exemplary embodiment of step S120 in the network topology structure generation method is shown. Specifically, step S120 verifies the neighbor port of the corresponding target network port according to the secondary neighbor port of the neighbor port of each target network port, and the process of obtaining the target neighbor port of each target network port specifically includes the following steps: S310: Determine the verification order of each target network port according to the port number of the neighboring port of each target network port from small to large.

[0027] The verification order may be the order in which the target network port in the preset signal area determines the target neighbor port. In some embodiments, the network topology structure generating device may sort the neighbor ports of each target network port according to the port number, for example, from small to large or from large to small. In other embodiments, the network topology structure generating device may also randomly generate a verification order for each target network port, and perform verification processing on the neighbor port of each target network port according to the randomly generated verification order. In other embodiments, the network topology structure generating device may also simultaneously perform verification processing on the neighbor port of the corresponding target network port according to the secondary neighbor port of each target network port to obtain the target neighbor port of each target network port.

[0028] In this embodiment, the verification order of each target network port is determined according to the number of neighbor ports of each target network port from small to large. 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 the number of ports from small to large, and obtains the verification order of each target network port. As an example, as shown in Table 1:

[0029] Table 1 It can be seen that the neighbor port with the least number of ports is port 5 of switch 1, which is ranked 1, that is, it is the first to be verified, and the others are ranked in order of port number.

[0030] S320: screening neighbor ports of each target network port in sequence according to the verification order of each target network port to obtain a target neighbor port of each target network port.

[0031] After determining the verification order of each target network port, the network topology structure generating device verifies 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, the non-target neighbor ports among the neighbor ports of each target network port can be removed to obtain the target neighbor ports of each target network port. Thus, the neighbor ports of each target network port are verified in order from the smallest to the largest according to the number of neighbor ports, which can improve the efficiency of determining the target neighbor ports.

[0032] In other embodiments, the network topology structure generating 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, select 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; screen the neighbor ports of the target neighbor port according to the target network port to obtain the target neighbor port of the target neighbor port, and the target neighbor port of the target network port and the target neighbor port of the target neighbor port are applied to the verification processing of the next target network port. The neighbors are mutual, and the target neighbor port is the real neighbor of the target network port, and the target network port is also the real neighbor of the target neighbor port. Therefore, in each verification process, the neighbor port of the target network port and the neighbor port of the corresponding target neighbor port can be verified at the same time, and each verification process will reduce the wrong neighbor port accordingly. The next verification process is performed on the basis of removing the wrong neighbor port last time, which greatly improves the verification efficiency. Of course, in other embodiments, when traversing each target network port, only the secondary neighbor port of each target network port can be used to verify the neighbor port of the target network port in turn to obtain the target neighbor port of the target network port.

[0033] 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 can also include: determining the currently traversed target network port as the current network port, and determining the neighbor port of the current network port as the candidate network port; traversing each candidate network port, in response to the current network port not being included in the first judgment range, and the network ports in the second judgment range not being included in the first judgment range, the corresponding candidate network port is removed from the neighbor ports of the current network port; in response to the current network port being included in the first judgment range, and the network ports in the second judgment range not being included in the first judgment range, the corresponding candidate network port is determined as the target neighbor port of the current network port; the first judgment range is the neighbor port of each candidate network port, and the second judgment range includes the candidate network port.

[0034] Among them, for the convenience of understanding, when verifying the target network port in sequence, the currently traversed target network port can be used as the current network port, and the neighbor port of the current network port can be used as the candidate network port, and the neighbor port of the candidate network port is the secondary neighbor port of the current network port. Among them, the neighbor port of the current network port is a neighbor port after verification and processing based on the historical network port before 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 determine whether the neighbor port of the candidate network port includes the current network port. If it exists and there is no neighbor port of the current network port in the neighbor port of the candidate network port, that is, there is no other public neighbor port, 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 port are removed; if there is no current network port in the neighbor port of the candidate network port and there is no neighbor port of the current network port in the neighbor port of the candidate network port, then the candidate network port can be removed from the neighbor port of the current network port.

[0035] Furthermore, the step of screening 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 also include: obtaining other neighbor ports except the target network port from 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.

[0036] After verifying the neighbor ports of each target network port and determining the target neighbor port of the target network port, the target network port can also be used to verify the neighbor ports of the target neighbor 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 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 to obtain the target neighbor port as network port 5. Therefore, in the subsequent verification process, 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 verifying party or the verified party, the number of verification ports can be reduced and the verification efficiency can be improved.

[0037] As a combined example, see 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. 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 port number of the neighbor ports, which is network port 5, network port 6, network port 2, network port 1, network port 3 and network port 4.

[0038] First, traverse the neighbor ports of network port 5, and you can find network port 7. 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, network port 7 is determined as the target neighbor port of network port 5, and other neighbor ports except network port 5 are removed from the neighbor ports of network port 7, and the target neighbor port of network port 7 is obtained as network port 5; By traversing the neighbor ports of network port 6, 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, network port 8 is determined as the target neighbor port of network port 6, and other neighbor ports except network port 6 are removed from the neighbor ports of network port 8, so that the target neighbor port of network port 8 is network port 6. Traverse the neighbor ports of network port 2. When traversing to network port 6, it is found that network port 2 does not exist among the neighbor ports of network port 6, and the two have no public neighbors, then network port 6 is removed from the neighbor ports of network port 2; when traversing to network port 8, it is found that the target neighbor port of network port 8 is network port 6, and the two have no public neighbors, then network port 8 is removed from the neighbor ports of network port 2; when traversing to network port 4, it is found that network port 2 exists among the neighbor ports of network port 4, and the two have no other public neighbors, then network port 4 is used as the target neighbor port of network port 2, and the other neighbor ports of network port 4 except network port 2 are removed, so that the target neighbor port of network port 4 is network port 2; Traverse the neighbor ports of network port 1. When traversing to network port 5, it is found that network port 1 does not exist among the neighbor ports of network port 5, and the two have no public neighbors, then network port 5 is removed from the neighbor ports of network port 1; when traversing to network port 7, it is found that the target neighbor port of network port 7 is network port 5, and the two have no public neighbors, then network port 7 is removed from the neighbor ports of network port 1; when traversing to network port 3, it is found that network port 1 exists among the neighbor ports of network port 3, and the two have no other public neighbors, then network port 3 is used as the target neighbor port of network port 1, and the other neighbor ports of network port 3 except network port 1 are removed, so that the target neighbor port of network port 3 is network port 1; Traverse the neighbor ports of network port 3 and find that the target neighbor port of network port 3 is network port 1, and network port 1 has network port 3 among its neighbor ports. The two are valid neighbors. By traversing the neighbor ports of network port 4, it is found that the target neighbor port of network port 4 is network port 2, and network port 2 has network port 4 among its neighbor ports, so the two are valid neighbors.

[0039] In other embodiments, the network topology structure generating device traverses each target network port, and in response to the target network port not being connected to other target network ports, the neighbor ports of the target network port are screened to obtain the target neighbor port of the target network port, and the target network port is connected to the target neighbor port; in response to the target network port being connected to other target network ports, the other connected target network ports are used as the target neighbor ports of the target network port. Compared with first establishing the target neighbor ports of each target network port and then using the traversal algorithm to generate the network topology structure, this method reduces the process of the traversal algorithm, and can also reduce the time of the target neighbor port, thereby improving the generation efficiency of the network topology structure.

[0040] For a specific example, please refer to Figure 4 , or verify according to the port number of neighbor ports from small to large.

[0041] First, traverse the neighbor ports of network port 5, and find network port 7. 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, network port 7 is determined as the target neighbor port of network port 5, and other neighbor ports except network port 5 are removed from the neighbor ports of network port 7, so that the target neighbor port of network port 7 is network port 5; use network port 5 and network port 7 as connection points and draw a connection line between them; By traversing the neighbor ports of network port 6, 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, network port 8 is determined as the target neighbor port of network port 6, and other neighbor ports except network port 6 are removed from the neighbor ports of network port 8, so that the target neighbor port of network port 8 is network port 6; network port 6 and network port 8 are respectively used as connection points to draw a connection line between the two; Traverse the neighbor ports of network port 2. When traversing to network port 6, it is found that network port 2 does not exist among the neighbor ports of network port 6, and the two have no public neighbors, then network port 6 is removed from the neighbor ports of network port 2; when traversing to network port 8, it is found that the target neighbor port of network port 8 is network port 6, and the two have no public neighbors, then network port 8 is removed from the neighbor ports of network port 2; when traversing to network port 4, it is found that network port 2 exists among the neighbor ports of network port 4, and the two have no other public neighbors, then network port 4 is used as the target neighbor port of network port 2, and other neighbor ports 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; use network port 2 and network port 4 as connection points respectively to draw a connection line between the two; Traverse the neighbor ports of network port 1. When traversing to network port 5, it is found that network port 1 does not exist among the neighbor ports of network port 5, and the two have no public neighbors, then network port 5 is removed from the neighbor ports of network port 1; when traversing to network port 7, it is found that the target neighbor port of network port 7 is network port 5, and the two have no public neighbors, then network port 7 is removed from the neighbor ports of network port 1; when traversing to network port 3, it is found that network port 1 exists among the neighbor ports of network port 3, and the two have no other public neighbors, then network port 3 is used as the target neighbor port of network port 1, and the other neighbor ports of network port 3 except network port 1 are removed, so that the target neighbor port of network port 3 is network port 1; use network port 1 and network port 3 as connection points respectively to draw a connection line between the two; Network port 3 and network port 4 already have connection lines, so no further verification is required. Network port 1 connected to network port 3 can be directly used as its target neighbor port, and network port 2 connected to network port 4 can be directly used as its target neighbor port.

[0042] Therefore, when generating the target network topology structure according to the target neighbor port of each target network port, it can be determined whether each target network port has a connection line with the corresponding target neighbor port; if so, each target network port is used as a connection point of the target network topology structure, and the connection line of each target network port is used as the connection relationship 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 port of each target network port to obtain the target network topology structure. Therefore, different network topology generation methods are used for different modes to improve application flexibility.

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

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

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

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

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

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

[0049] In order to elaborate on the network topology generation method in the embodiment of the present application, Figure 5 The flowchart shown further illustrates it, and the details are as follows: S510: Obtain neighbor ports (LLDP neighbor ports) of each initial network port in a preset signal area, and 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 capability of applying the neighbor protocol is less than the preset device capability, and a non-weak neighbor device is a device whose capability of applying the neighbor protocol is greater than or equal to the preset device capability.

[0050] S520: Count neighbor ports of the network port of the weak neighbor device, and sort the neighbor ports in ascending order according to the number of ports; the network port of the weak neighbor device may be the target network port.

[0051] S530: Select any one of the following methods: Method 1: According to the order of each target network port, the public neighbors of the directly connected device are determined from small to large, and the non-public neighbors of the directly connected device are cleaned up, and the target network topology structure is generated using the breadth-first traversal algorithm. Method 2: According to the order of each target network port, the public neighbors of the directly connected device are determined from small to large, and the connection lines are drawn for the public neighbors of the directly connected device. The network topology structure thus generated is more realistic and accurate, providing accurate network topology structure for user network operation and maintenance, saving manpower and time costs.

[0052] See also Figure 6 , Figure 6 It is a structural diagram of an exemplary embodiment of a network topology structure device shown in the present application. The network topology structure 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 a preset signal area; the verification module 620 is used to respond to the existence of a target network port The number of neighbor ports is greater than the preset number threshold, and the neighbor port of the corresponding target network port is verified according to the secondary neighbor port of each target network port to obtain the target neighbor port of each target network port, and 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 a target network topology structure according to the target neighbor port of each target network port.

[0053] In the above scheme, the network topology structure device obtains the neighbor ports of each target network port in the preset signal area; in response to the port number of the neighbor ports of a target network port being greater than the 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 ports are the neighbor ports of the neighbor ports of each target network port; and 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 network topology structure generated thereby and improving the accuracy of the network topology structure.

[0054] The functions of each module can be found in the network topology structure method implementation example, and will not be repeated here.

[0055] In order to implement the network topology structure method of the above embodiment, the present application proposes another electronic device, which can be specifically referred to as Figure 7 , Figure 7 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application.

[0056] The electronic device 700 includes a memory 710 and a processor 720 , wherein the memory 710 and the processor 720 are coupled.

[0057] 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 of the above embodiment.

[0058] In this embodiment, the processor 720 may also be referred to as a CPU (Central Processing Unit). The processor 720 may be an integrated circuit chip having 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. A general-purpose processor may be a microprocessor or the processor 720 may also be any conventional processor, etc.

[0059] The present application also provides a computer-readable storage medium, such as Figure 8 As shown, the computer-readable storage medium 800 is used to store program data 810. When the program data 810 is executed by the processor, it is used to implement the network topology structure method in the method embodiment of the present application.

[0060] The method involved in the network topology structure method embodiment of the present application, when implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0061] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also 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 comprises: Obtain neighbor ports of each target network port in a preset signal area; In response to the existence of a target network port whose number of neighbor ports is 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 target neighbor ports of each target network port, wherein the secondary neighbor ports are neighbor ports of the neighbor ports of each target network port; A target network topology structure is generated according to the target neighbor ports of each target network port.

2. The network topology generation method according to claim 1, characterized in that: The step of verifying the neighbor port of the corresponding target network port according to the secondary neighbor port of each target network port to obtain the target neighbor port of each target network port, wherein the secondary neighbor port is the neighbor port of the neighbor port of each target network port, comprises: Determine the verification order of each target network port according to the port number of the neighbor port of each target network port from small to large; The neighbor ports of each target network port are screened in turn according to the verification order of each target network port to obtain the target neighbor port of each target network port.

3. The network topology generation method according to claim 1, characterized in that: The step of verifying the neighbor port of the corresponding target network port according to the secondary neighbor port of each target network port to obtain the target neighbor port of each target network port, wherein the secondary neighbor port is the neighbor port of the neighbor port of each target network port, comprises: Traversing each target network port, and selecting a target neighbor port of the target network port from neighbor ports of the target network port according to a secondary neighbor port of the target network port; The neighbor ports of the target neighbor port are screened according to the target network port to obtain the target neighbor port of the target neighbor port, and the target neighbor port of the target network port and the target neighbor port of the target neighbor port are applied to the verification process of the next target network port.

4. The network topology generation method according to claim 3, characterized in that: The step of traversing each target network port and selecting a target neighbor port of the target network port from neighbor ports of the target network port according to the secondary neighbor port of the target network port comprises: Determine the currently traversed target network port as the current network port, and determine the neighbor port of the current network port as the candidate network port; Traversing each candidate network port, in response to the current network port not being included in the first judgment range and the network port in the second judgment range not being included in the first judgment range, removing the corresponding candidate network port from the neighboring port of the current network port; In response to the current network port being included in the first judgment range and the network ports in the second judgment range not being included in the first judgment range, determining the corresponding candidate network port as a target neighbor port of the current network port; The first determination range is the neighboring ports of each candidate network port, and the second determination range includes the candidate network ports.

5. The network topology generation method according to claim 3, characterized in that: The step of screening the neighbor ports of the target neighbor port according to the target network port to obtain the target neighbor port of the target neighbor port includes: Acquire other neighbor ports of the target neighbor port except the target network port; The other neighbor ports are removed from the neighbor ports of the target neighbor port to obtain the target neighbor port of the target neighbor port.

6. The network topology generation method according to claim 1, characterized in that: The step of verifying the neighbor port of the corresponding target network port according to the secondary neighbor port of each target network port to obtain the target neighbor port of each target network port includes: Traversing each target network port, in response to the target network port not being connected to other target network ports, screening neighbor ports of the target network port to obtain a target neighbor port of the target network port, and connecting the target network port to the target neighbor port; In response to the target network port being connected to another target network port, the other connected target network port is used as a target neighbor port of the target network port.

7. The network topology generation method according to claim 1, characterized in that: The step of generating a target network topology structure according to the target neighbor ports of each target network port comprises: Determine whether each target network port has a connection line with the corresponding target neighbor port; If yes, each target network port is used as a connection point of the target network topology structure, and the connection line of each target network port is used as a connection relationship of the target network topology structure to generate the target network topology structure; If not, then traversal connection processing is performed on each target network port according to the target neighbor port of each target network port to obtain the target network topology structure.

8. The network topology generation method according to claim 1, characterized in that: The step of obtaining neighbor ports of each target network port in the preset signal area includes: Obtain the device capability of applying neighbor protocol on each initial network port; In response to the device capability of the initial network port for 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.

9. An electronic device, characterized in that: include: 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 to 8.

10. A computer-readable storage medium, characterized in that: include: Program data is stored, and when the program data is executed by a processor, it is used to implement the method according to any one of claims 1 to 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

  • Deploying secure neighbor discovery in evpn

    CN112688873A

  • Network topology information generation method and device, storage medium and processor

    CN116566832A

  • Neighbor discovery method, device and equipment and readable storage medium

    CN119729442A