A network topology automatic discovery method, device, equipment and medium
By obtaining the MAC address table of network management devices and constructing the network topology using iterative analysis rules, the problem of Layer 2 devices not being discoverable in existing technologies is solved, and automatic topology discovery for hybrid networks is realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CETC CYBERSPACE SECURITY TECH CO LTD
- Filing Date
- 2024-11-01
- Publication Date
- 2026-05-19
AI Technical Summary
In existing network topology management methods, topology discovery based on routing tables cannot discover Layer 2 devices, and methods based on the LLDP protocol cannot discover the complete topology structure when LLDP devices are not supported.
By obtaining the MAC address table of network management devices, the connection relationships between network management devices and between different types of devices are iteratively analyzed using preset analysis rules to construct the network topology, including the target network management devices configured with simple network management protocols, handling differences in device types, and using special processing such as multi-port forwarders or virtual hubs.
It enables automatic discovery of network topology, solves the problem of Layer 2 devices being undiscoverable, and supports the discovery of mixed network topologies for different types of devices.
Smart Images

Figure CN119299315B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer network technology, and in particular to a method, apparatus, device, and medium for automatic network topology discovery. Background Technology
[0002] Network topology management is the core of enterprise network management. It clarifies the connections between network devices, including routers, switches, gateways, firewalls, servers, and terminals. Clear and accurate network topology management helps in locating network faults and analyzing performance.
[0003] Current network topology management methods include manual maintenance, which requires timely maintenance to ensure the accuracy of the topology when connections between devices change. There are also automatic network topology discovery methods. Some of these methods use SNMP (Simple Network Management Protocol) to obtain routing tables of network devices for topology discovery; others are based on LLDP (Link Layer Discovery Protocol).
[0004] Network topology discovery is based on routing tables, where the next hop is the information of the connected device. However, the routing tables on switches or routers are typically optimized, which makes it impossible to discover the complete topology. Furthermore, if there are Layer 2 devices between the current device and the next hop device, they will not be discovered without route forwarding.
[0005] Network topology discovery based on LLDP requires that all devices support and enable LLDP. However, in real network environments, there are often a large number of different types of devices that do not support the LLDP protocol, making it impossible to discover the complete topology.
[0006] Therefore, how to solve the problem of Layer 2 devices not being discovered in topology discovery based on routing tables, and how to solve the discovery problem when devices do not support the LLDP protocol, are problems that need to be solved by those skilled in the art. Summary of the Invention
[0007] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for automatic network topology discovery, which can solve the problem of Layer 2 devices not being discoverable in routing table-based topology discovery, as well as the discovery problem when devices do not support the LLDP protocol. The specific solution is as follows:
[0008] In a first aspect, this application discloses a method for automatic network topology discovery, including:
[0009] Obtain a network management device, and identify a target network management device configured with a simple network management protocol from the network management device;
[0010] The target network management device is traversed to obtain its MAC address table; wherein, the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and devices that perform network configuration through the network management device;
[0011] The MAC address table is iteratively analyzed using a first preset analysis rule and a second preset analysis rule to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of device.
[0012] The current network topology is determined based on the first connection relationship and the second connection relationship.
[0013] Optionally, after acquiring the network management device and determining the target network management device configured with the Simple Network Management Protocol from the network management devices, the method further includes:
[0014] The target network management device is traversed to obtain the interface table of the target network management device; wherein, the interface table is used to record the interface name of each device interface in the target network management device and the MAC address of the target network management device.
[0015] Optionally, the MAC address table is iteratively analyzed using a first preset analysis rule to determine the first connection relationship between the network management devices, including:
[0016] The MAC address table is traversed to filter and obtain the first MAC address of the network management device.
[0017] Based on the first MAC address, determine the first device interface on the target network management device that has learned only the MAC address of the network management device;
[0018] Determine the first network management device corresponding to the first device interface, and determine the corresponding second network management device based on the MAC address learned from the first device interface;
[0019] Establish the connection between the first network management device and the second network management device;
[0020] Based on the first MAC address, determine the second device interface on the device interface that has learned the MAC addresses of multiple network management devices;
[0021] Determine the third network management device corresponding to the second device interface, and determine the corresponding fourth network management device based on the MAC address learned from the second device interface;
[0022] Excluding the first device interface, establish the connection between the third network management device and the fourth network management device;
[0023] When only one network management device is connected to the device interface of all the network management devices, the first connection relationship between the network management devices is determined based on the connection relationship between the first network management device and the second network management device, and the connection relationship between the third network management device and the fourth network management device.
[0024] Optionally, the MAC address table is iteratively analyzed using a second preset analysis rule to determine a second connection relationship between the network management device and the type of device, including:
[0025] The MAC address table is traversed to filter and obtain the second MAC address that is a device of the aforementioned type;
[0026] If the second MAC address corresponds to multiple network management devices, the currently occupied interface is obtained based on the first connection relationship, and the currently occupied interface is excluded to obtain the remaining devices;
[0027] If the number of remaining devices is 0, then the device of that type is determined to be in the first connection relationship, and the second connection relationship is determined based on the first connection relationship;
[0028] If the number of remaining devices is 1, then a second connection relationship is established between the device of the type and the remaining devices.
[0029] Optionally, after performing iterative analysis on the MAC address table using the first preset analysis rule and the second preset analysis rule to determine the first connection relationship between the network management devices and the second connection relationship between the network management device and the type of device, the method further includes:
[0030] The MAC address table is traversed, and when multiple MAC addresses are detected on the target device interface of the network management device, the current situation type is determined.
[0031] If the current situation type is that there is a type in the network management device that does not have the Simple Network Management Protocol configured, then obtain the fifth network management device that does not have the Simple Network Management Protocol configured, and configure the Simple Network Management Protocol for the fifth network management device;
[0032] If the current situation type is that there is a type in the network management device that cannot configure the simple network management protocol, then obtain the sixth network management device that cannot configure the simple network management protocol, and configure a multi-port forwarder for the sixth network management device.
[0033] Optionally, after performing iterative analysis on the MAC address table using the first preset analysis rule and the second preset analysis rule to determine the first connection relationship between the network management devices and the second connection relationship between the network management device and the type of device, the method further includes:
[0034] The MAC address table is traversed, and when the network management device detects that it has learned the same type of device, the device of that type is inserted into the connection between the network management devices.
[0035] Optionally, the automatic network topology discovery method further includes:
[0036] The process iterates through all MAC addresses in the MAC address table until each MAC address is connected to a device interface of the network management device.
[0037] Secondly, this application discloses an automatic network topology discovery device, comprising:
[0038] The target device determination module is used to acquire network management devices and determine, from the network management devices, a target network management device configured with the Simple Network Management Protocol;
[0039] The MAC address table acquisition module is used to traverse the target network management device to obtain the MAC address table of the target network management device; wherein, the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and type devices that perform network configuration through the network management device;
[0040] The iterative analysis module is used to perform iterative analysis on the MAC address table using a first preset analysis rule and a second preset analysis rule, respectively, to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of device;
[0041] The network topology discovery module is used to determine the current network topology based on the first connection relationship and the second connection relationship.
[0042] Thirdly, this application discloses an electronic device, which includes a processor and a memory; wherein the memory is used to store a computer program, which is loaded and executed by the processor to implement the network topology automatic discovery method as described above.
[0043] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the network topology automatic discovery method as described above.
[0044] This application provides an automatic network topology discovery method, comprising: acquiring network management devices and identifying target network management devices configured with a Simple Network Management Protocol (LLDP) from among the network management devices; traversing the target network management devices to obtain a MAC address table of the target network management devices; wherein the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management devices and type devices configured through the network management devices; iteratively analyzing the MAC address table using a first preset analysis rule and a second preset analysis rule respectively to determine a first connection relationship between the network management devices and a second connection relationship between the network management devices and the type devices; and determining the current network topology based on the first connection relationship and the second connection relationship. It is evident that by acquiring the MAC address table of network management devices in the network through the Simple Network Management Protocol, and based on iterative analysis of the MAC address table, regardless of device type, the problem of Layer 2 devices not being discovered in routing table-based topology discovery can be solved, as well as the problem of discovery when devices do not support the LLDP protocol can also be solved. In this way, automatic network topology discovery is achieved, enabling network topology discovery for networks with mixed types of devices.
[0045] In addition, the network topology automatic discovery device, equipment and storage medium provided in this application correspond to the above-mentioned network topology automatic discovery method and have the same effect. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0047] Figure 1 This is a flowchart of an automatic network topology discovery method disclosed in this application;
[0048] Figure 2 This is a schematic diagram of a network topology disclosed in this application;
[0049] Figure 3 This is a schematic diagram of a network topology automatic discovery method disclosed in this application;
[0050] Figure 4 This is a schematic diagram of the structure of an automatic network topology discovery device disclosed in this application;
[0051] Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0053] Currently, some methods for automatic network topology discovery use the SNMP protocol to obtain the routing tables of network devices, while others are based on LLDP.
[0054] Network topology discovery is based on routing tables, where the next hop is the connected device information. However, the routing tables on switches or routers typically contain optimized routing information, which makes it difficult to discover the complete topology. Furthermore, if there are Layer 2 devices between the current device and the next hop device, they will not be discovered without route forwarding.
[0055] Network topology discovery based on LLDP requires that all devices support and enable LLDP. However, in real network environments, there are often a large number of different types of devices that do not support the LLDP protocol, making it impossible to discover the complete topology.
[0056] To address this, this application provides an automatic network topology discovery scheme that can solve the problem of Layer 2 devices not being discovered in routing table-based topology discovery, as well as the discovery problem when devices do not support the LLDP protocol.
[0057] This invention discloses an automatic network topology discovery method, see [link to relevant documentation]. Figure 1 As shown, the method includes:
[0058] Step S11: Obtain the network management device and identify the target network management device configured with the Simple Network Management Protocol from the network management devices.
[0059] Network management devices are primarily used for network management in communication networks. In this embodiment, the network management devices in the network topology are first obtained. Then, the network management devices are traversed to identify the target network management device that has SNMP protocol configuration enabled. Automatic network topology discovery is then performed on the target network management device.
[0060] Step S12: Traverse the target network management device to obtain the MAC address table of the target network management device; wherein, the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and type devices that perform network configuration through the network management device.
[0061] In this embodiment, the MAC address (Media Access Control Address) table and interface table of the target network management device are obtained via the SNMP protocol. In one implementation, the MAC address table records the MAC addresses of other devices learned by each interface of the device. In another implementation, the interface table records the interface name of the device and the MAC address of the device.
[0062] It should be noted that other devices include network management devices and devices that perform network configuration through network management devices. For example, terminal devices; network management devices can provide terminal devices with wireless or wired network access functions, and may include routers, switches, etc., responsible for connecting terminal devices to the Internet.
[0063] Step S13: Iteratively analyze the MAC address table using the first preset analysis rule and the second preset analysis rule respectively to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of devices.
[0064] In one specific implementation, the MAC address table is first iteratively analyzed using a first preset analysis rule to determine the first connection relationship between the network management devices. That is, the topological connection relationship of these network management devices configured with the SNMP protocol is constructed.
[0065] Specifically, it includes the following steps:
[0066] Step 1: Traverse the MAC address table to filter and obtain the first MAC address of the network management device;
[0067] Analyzing the network topology between network management devices involves traversing the MAC address table and filtering out the MAC addresses that are the first MAC addresses of the network management devices. This means that, for the current network management device, the first MAC address can be used to determine the other network management devices it is connected to.
[0068] Step 2: Based on the first MAC address, sequentially determine the first device interface on the target network management device that has learned only the MAC address of the network management device;
[0069] Step 3: Determine the first network management device corresponding to the first device interface, and determine the corresponding second network management device based on the MAC address learned from the first device interface.
[0070] Step 4: Establish the connection between the first network management device and the second network management device.
[0071] First, save the connection where there is only one other network management device MAC address on the device interface. If the first device interface learns only the MAC address of one network management device, then establish the connection between the two devices, and save the first device interface occupied by the connection, as well as the interface name used by the device.
[0072] like Figure 2 The diagram shows an exemplary network topology, where SW1, SW2, SW3, SW4, and SW5 have SNMP enabled. SW2's G0 / 0 / 4 interface can only learn the MAC address of the network management device SW3; therefore, a connection is established between SW2 G0 / 0 / 4 and SW3 G0 / 0 / 1. Similarly, a connection is established between SW2 G0 / 0 / 5 and SW4 G0 / 0 / 1.
[0073] Step 5: Based on the first MAC address, determine the second device interface on the device interface that has learned the MAC addresses of multiple network management devices;
[0074] Step 6: Determine the third network management device corresponding to the second device interface, and determine the corresponding fourth network management device based on the MAC address learned from the second device interface;
[0075] Step 7: Exclude the first device interface and establish the connection between the third network management device and the fourth network management device.
[0076] After saving a connection where there is only one other network management device's MAC address on the device interface, connections with multiple other network management device MAC addresses on the same interface are processed based on the currently established connection relationships. At this point, if multiple network management device MAC addresses are learned on the device interface, interfaces that are already in use need to be excluded when establishing device connection relationships. Specifically, interfaces that have already been used can be excluded based on their names.
[0077] like Figure 2 As shown, for example, SW1's G0 / 0 / 1 interface can learn the MAC addresses of SW2, SW3, and SW4; SW3's G0 / 0 / 1 interface may also learn the MAC addresses of SW2 and SW1. However, since the interface addresses of SW3's G0 / 0 / 1 and SW4's G0 / 0 / 1 were already occupied when the connection relationship was established previously, only the connection relationship between SW1's G0 / 0 / 1 and SW2's G0 / 0 / 3 is saved.
[0078] Step 8: When only one network management device is connected to the device interface of all the network management devices, determine the first connection relationship between the network management devices based on the connection relationship between the first network management device and the second network management device, and the connection relationship between the third network management device and the fourth network management device.
[0079] Finally, the aforementioned steps are iterated until it is determined that only one network management device is connected to each of the interfaces of all network management devices. This process reveals the connection relationships between the network management devices.
[0080] In another specific implementation, after the network management device topology is constructed, the MAC address table is iteratively analyzed using a second preset analysis rule to determine the second connection relationship between the network management device and the type of device. That is, the connection relationship between the network management device and the type of device, such as a terminal or server, is established.
[0081] Specifically, it includes the following steps:
[0082] Step 1: Traverse the MAC address table to filter and obtain the second MAC address that is a device of the specified type;
[0083] Step 2: If the second MAC address corresponds to multiple network management devices, then obtain the currently occupied interface based on the first connection relationship, and exclude the currently occupied interface to obtain the remaining devices;
[0084] Step 3: If the number of remaining devices is 0, then determine that the device of the type is in the first connection relationship, and determine the second connection relationship based on the first connection relationship;
[0085] Step 4: If the number of remaining devices is 1, then establish a second connection relationship between the device of the type and the remaining devices.
[0086] After analyzing the topology connections between network management devices, the process begins with processing other MAC addresses learned on the network management devices, which correspond to the MAC addresses of the corresponding device types. During the connection construction between network management devices and device types, if a MAC address exists on multiple network management devices, interfaces already in use on those devices are excluded. If only one interface remains, the device type is connected to that remaining interface. If no interfaces remain, it indicates that the device type exists within the network management devices established in the previous step.
[0087] like Figure 2 As shown, SW2's G0 / 0 / 4 may learn the MAC addresses of PC1 and PC2, SW3's G0 / 0 / 2 will learn the MAC address of PC1, and G0 / 0 / 3 will learn the MAC address of PC2. However, SW2's G0 / 0 / 4 interface is already in use, so PC1 and PC2 are connected to SW3.
[0088] In one feasible implementation, if there are multiple remaining interfaces after excluding those already occupied by the network management device, it indicates that some network management devices lack SNMP configuration and need to be configured.
[0089] Step S14: Determine the current network topology based on the first connection relationship and the second connection relationship.
[0090] like Figure 3 The diagram illustrates the overall process combining the aforementioned steps. During network topology construction, the process first iterates through each device configured with SNMP to obtain its MAC address table. Next, it analyzes the connections between network management devices and the connections between analysis type devices and network management devices. Finally, based on the connections obtained from the previous analysis, it completes the overall network topology analysis and obtains the network topology structure. In this way, it is possible to obtain the MAC address tables of management devices such as switches and routers in the network via SNMP, and automatically discover the network topology structure based on iterative analysis of the MAC address tables.
[0091] This application provides an automatic network topology discovery method, comprising: acquiring network management devices and identifying target network management devices configured with a Simple Network Management Protocol (LLDP) from among the network management devices; traversing the target network management devices to obtain a MAC address table of the target network management devices; wherein the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management devices and type devices configured through the network management devices; iteratively analyzing the MAC address table using a first preset analysis rule and a second preset analysis rule respectively to determine a first connection relationship between the network management devices and a second connection relationship between the network management devices and the type devices; and determining the current network topology based on the first connection relationship and the second connection relationship. It is evident that by acquiring the MAC address table of network management devices in the network through the Simple Network Management Protocol, and based on iterative analysis of the MAC address table, regardless of device type, the problem of Layer 2 devices not being discovered in routing table-based topology discovery can be solved, as well as the problem of discovery when devices do not support the LLDP protocol can also be solved. In this way, automatic network topology discovery is achieved, enabling network topology discovery for networks with mixed types of devices.
[0092] Based on the above embodiments, in one feasible implementation, special processing of the connection relationship between devices is required. Specifically, it may also include the following steps:
[0093] The MAC address table is traversed, and when multiple MAC addresses are detected on the target device interface of the network management device, the current situation type is determined.
[0094] If the current situation type is that there is a type in the network management device that does not have the Simple Network Management Protocol configured, then obtain the fifth network management device that does not have the Simple Network Management Protocol configured, and configure the Simple Network Management Protocol for the fifth network management device;
[0095] If the current situation type is that there is a type in the network management device that cannot configure the simple network management protocol, then obtain the sixth network management device that cannot configure the simple network management protocol, and configure a multi-port forwarder for the sixth network management device.
[0096] In this embodiment, after processing all MAC addresses, there may be a situation where multiple MAC addresses exist on a single interface of the network management device. There are two possible reasons for this: one is that a hub is connected to this interface, and many devices are connected to it; the other is that a network management device connected to this interface does not have SNMP information configured and needs to be added.
[0097] like Figure 2 As shown, the SW6 device connected to the G0 / 0 / 2 interface of SW4 is not configured with SNMP; or SW6 is a HUB and cannot be configured with SNMP. In this case, there are multiple MAC addresses under the G0 / 0 / 2 interface of SW4. In this case, a virtual HUB is added and connected to the G0 / 0 / 2 interface, and then the MAC devices under the G0 / 0 / 2 interface are connected to the virtual HUB.
[0098] Based on the above embodiments, in another feasible implementation, special processing of the connection relationship between the devices is required. Specifically, it may also include the following steps:
[0099] The MAC address table is traversed, and when the network management device detects that it has learned the same type of device, the device of that type is inserted into the connection between the network management devices.
[0100] In this embodiment of the application, after processing all MAC addresses, there may be a situation where the network management device learns the same type of device, that is, other MAC addresses are inserted between the network management devices. For example... Figure 2 As shown, the connection relationship between SW1 G0 / 0 / 2 and SW5 G0 / 0 / 3 has been analyzed in the aforementioned implementation process. When processing other MAC addresses, it was found that SW1 G0 / 0 / 2 and SW5 G0 / 0 / 3 have also learned the MAC address of gateway 1 or other devices that have not been configured or cannot be configured with SNMP. Therefore, such devices are inserted into the existing connection between SW1 and SW5.
[0101] It should be noted that, based on the MAC address table, all MAC addresses in the MAC address table are processed in a loop until each of the MAC addresses is connected to a device interface of the network management device.
[0102] In summary, by obtaining the MAC address tables of management devices such as switches and routers in the network through SNMP, and based on iterative analysis of the MAC address tables, the network topology can be automatically discovered.
[0103] Accordingly, this application also discloses an automatic network topology discovery device, see [link to relevant documentation]. Figure 4 As shown, the device includes:
[0104] The target device determination module 11 is used to acquire network management devices and determine the target network management device configured with the Simple Network Management Protocol from the network management devices.
[0105] The MAC address table acquisition module 12 is used to traverse the target network management device to obtain the MAC address table of the target network management device; wherein, the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and type devices that perform network configuration through the network management device;
[0106] The iterative analysis module 13 is used to perform iterative analysis on the MAC address table using a first preset analysis rule and a second preset analysis rule, respectively, to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of devices;
[0107] The network topology discovery module 14 is used to determine the current network topology based on the first connection relationship and the second connection relationship.
[0108] For more detailed information on the working process of each of the above modules, please refer to the relevant content disclosed in the foregoing embodiments, which will not be repeated here.
[0109] Therefore, the above-described scheme in this embodiment includes: acquiring network management devices and identifying target network management devices configured with the Simple Network Management Protocol (LLDP) from among the network management devices; traversing the target network management devices to obtain a MAC address table of the target network management devices; wherein the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and type devices configured through the network management device; iteratively analyzing the MAC address table using a first preset analysis rule and a second preset analysis rule respectively to determine a first connection relationship between the network management devices and a second connection relationship between the network management device and the type device; and determining the current network topology based on the first connection relationship and the second connection relationship. It is evident that by acquiring the MAC address table of network management devices in the network through the Simple Network Management Protocol, and based on iterative analysis of the MAC address table, regardless of device type, the problem of Layer 2 devices not being discovered in topology discovery based on routing tables can be solved, as well as the problem of discovery when devices do not support the LLDP protocol can be addressed. In this way, automatic discovery of network topology is achieved, completing network topology discovery for networks with mixed types of devices.
[0110] Furthermore, embodiments of this application also disclose an electronic device, Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application.
[0111] Figure 5 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the automatic network topology discovery method disclosed in any of the foregoing embodiments.
[0112] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0113] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk, or optical disk, etc. The resources stored on it can include an operating system 221, computer programs 222, and data 223, etc. The data 223 can include various types of data. The storage method can be temporary storage or permanent storage.
[0114] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the automatic network topology discovery method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0115] Furthermore, this application also discloses a computer-readable storage medium, which includes random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, magnetic disks, optical disks, or any other form of storage medium known in the art. The computer program, when executed by a processor, implements the aforementioned automatic network topology discovery method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0116] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0117] The steps of the network topology automatic discovery method or algorithm described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0118] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0119] The present invention provides a detailed description of an automatic network topology discovery method, apparatus, device, and medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for automatic network topology discovery, characterized in that, include: Obtain a network management device, and identify a target network management device configured with a simple network management protocol from the network management device; The target network management device is traversed to obtain its MAC address table; wherein, the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and devices that perform network configuration through the network management device; The MAC address table is iteratively analyzed using a first preset analysis rule and a second preset analysis rule to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of device. The current network topology is determined based on the first connection relationship and the second connection relationship; Iterative analysis of the MAC address table using a first preset analysis rule to determine the first connection relationship between the network management devices includes: The MAC address table is traversed to filter and obtain the first MAC address of the network management device. Based on the first MAC address, determine the first device interface on the target network management device that has learned only the MAC address of the network management device; Determine the first network management device corresponding to the first device interface, and determine the corresponding second network management device based on the MAC address learned from the first device interface; Establish the connection between the first network management device and the second network management device; Based on the first MAC address, determine the second device interface on the device interface that has learned the MAC addresses of multiple network management devices; Determine the third network management device corresponding to the second device interface, and determine the corresponding fourth network management device based on the MAC address learned from the second device interface; Excluding the first device interface, establish the connection between the third network management device and the fourth network management device; When only one network management device is connected to the device interface of all the network management devices, the first connection relationship between the network management devices is determined based on the connection relationship between the first network management device and the second network management device, and the connection relationship between the third network management device and the fourth network management device; Iterative analysis of the MAC address table using a second preset analysis rule to determine the second connection relationship between the network management device and the device of the type includes: The MAC address table is traversed to filter and obtain the second MAC address that is a device of the aforementioned type; If the second MAC address corresponds to multiple network management devices, the currently occupied interface is obtained based on the first connection relationship, and the currently occupied interface is excluded to obtain the remaining devices; If the number of remaining devices is 0, then the device of that type is determined to be in the first connection relationship, and the second connection relationship is determined based on the first connection relationship; If the number of remaining devices is 1, then a second connection relationship is established between the device of the type and the remaining devices.
2. The automatic network topology discovery method according to claim 1, characterized in that, After acquiring the network management device and determining the target network management device configured with the Simple Network Management Protocol from the network management device, the method further includes: The target network management device is traversed to obtain the interface table of the target network management device; wherein, the interface table is used to record the interface name of each device interface in the target network management device and the MAC address of the target network management device.
3. The automatic network topology discovery method according to claim 1, characterized in that, After iteratively analyzing the MAC address table using the first preset analysis rule and the second preset analysis rule to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of device, the method further includes: The MAC address table is traversed, and when multiple MAC addresses are detected on the target device interface of the network management device, the current situation type is determined. If the current situation type is that there is a type in the network management device that does not have the Simple Network Management Protocol configured, then obtain the fifth network management device that does not have the Simple Network Management Protocol configured, and configure the Simple Network Management Protocol for the fifth network management device; If the current situation type is that there is a type in the network management device that cannot configure the simple network management protocol, then obtain the sixth network management device that cannot configure the simple network management protocol, and configure a multi-port forwarder for the sixth network management device.
4. The automatic network topology discovery method according to claim 1, characterized in that, After iteratively analyzing the MAC address table using the first preset analysis rule and the second preset analysis rule to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of device, the method further includes: The MAC address table is traversed, and when the network management device detects that it has learned the same type of device, the device of that type is inserted into the connection between the network management devices.
5. The automatic network topology discovery method according to claim 3 or 4, characterized in that, Also includes: The process iterates through all MAC addresses in the MAC address table until each MAC address is connected to a device interface of the network management device.
6. A network topology automatic discovery device, characterized in that, include: The target device determination module is used to acquire network management devices and determine, from the network management devices, a target network management device configured with the Simple Network Management Protocol; The MAC address table acquisition module is used to traverse the target network management device to obtain the MAC address table of the target network management device; wherein, the MAC address table is used to record the MAC addresses of other devices learned by each device interface of the target network management device; the other devices include the network management device and type devices that perform network configuration through the network management device; The iterative analysis module is used to perform iterative analysis on the MAC address table using a first preset analysis rule and a second preset analysis rule, respectively, to determine the first connection relationship between the network management devices and the second connection relationship between the network management devices and the type of device; The network topology discovery module is used to determine the current network topology based on the first connection relationship and the second connection relationship; The iterative analysis module is specifically used for: The MAC address table is traversed to filter and obtain the first MAC address of the network management device. Based on the first MAC address, determine the first device interface on the target network management device that has learned only the MAC address of the network management device; Determine the first network management device corresponding to the first device interface, and determine the corresponding second network management device based on the MAC address learned from the first device interface; Establish the connection between the first network management device and the second network management device; Based on the first MAC address, determine the second device interface on the device interface that has learned the MAC addresses of multiple network management devices; Determine the third network management device corresponding to the second device interface, and determine the corresponding fourth network management device based on the MAC address learned from the second device interface; Excluding the first device interface, establish the connection between the third network management device and the fourth network management device; When only one network management device is connected to the device interface of all the network management devices, the first connection relationship between the network management devices is determined based on the connection relationship between the first network management device and the second network management device, and the connection relationship between the third network management device and the fourth network management device; The MAC address table is traversed to filter and obtain the second MAC address that is a device of the aforementioned type; If the second MAC address corresponds to multiple network management devices, the currently occupied interface is obtained based on the first connection relationship, and the currently occupied interface is excluded to obtain the remaining devices; If the number of remaining devices is 0, then the device of that type is determined to be in the first connection relationship, and the second connection relationship is determined based on the first connection relationship; If the number of remaining devices is 1, then a second connection relationship is established between the device of the type and the remaining devices.
7. An electronic device, characterized in that, The electronic device includes a processor and a memory; wherein the memory is used to store a computer program, which is loaded and executed by the processor to implement the network topology automatic discovery method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein the computer programs, when executed by a processor, implement the network topology automatic discovery method as described in any one of claims 1 to 5.