Network topology drawing method, system, device and medium based on active detection
Through the combination of active detection and SNMP protocol, the problem of insufficient support for multi-VLAN and layer-3 switches in the prior art is solved, the accurate construction and dynamic update of network topology are achieved, and the efficiency of network management is improved.
Patent Information
- Application Number
- CN202411187229.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-08-28
AI Technical Summary
The existing network topology discovery technology lacks support for multi-VLAN environments and layer three switches, and cannot accurately capture routing tables and ARP table information, resulting in inaccurate network topology construction, and the accuracy of multi-IP addresses of network devices and dynamic networks cannot be realized. Automatic update.
Using an active detection method, the network layer and link layer information is obtained through the SNMP protocol, combined with the breadth priority traversal strategy and dummy node simulation technology, the connection relationship between the router and the switch is determined, the network topology structure is generated, and the network layer and link are realized. Equipment connection status collection in two dimensions of the road layer.
It improves the accuracy and timeliness of network topology drawing, solves the problems of multi-VLAN, multi-IP addresses and dynamic network updates, and ensures that the accuracy and management complexity of network topology are reduced.
Smart Images

Figure CN118694701B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer network technology, and more specifically to a network topology drawing method, system, device and medium based on active detection. Background Art
[0002] As the scale of networks continues to expand, network management and maintenance become increasingly difficult. A good network management system must first grasp the topology of the entire management network. The main purpose of topology discovery in network management is to obtain and maintain the existence information of network elements and the connection relationship between them, and ultimately achieve effective management of them.
[0003] SNMP is the most widely used network management protocol in TCP / IP networks. Its basic idea is that all network devices maintain a management information base (MIB), which defines the control and status information of the managed devices and responds to queries from the management workstation.
[0004] Most commercial network management software is based on SNMP, which uses the network management agent in the network management device to access or configure the variables in the MIB to achieve network management functions (including five functional domains: performance, fault, billing, configuration and security management). MIB contains descriptions of routing tables, forwarding tables and interfaces, making it possible to build network topology structures. It can not only construct the connection management of network layer devices (routers, gateways), but also construct the connection relationship of link layer devices (bridges, switches).
[0005] Currently, existing network topology technologies generally only solve the network topology information of the network layer or link layer, and lack the network topology maintained jointly from both the network layer and the link layer. In addition, they lack the processing of the following key points:
[0006] 1. Existing network topology discovery technologies fail to fully support multi-VLAN environments, or can only provide limited VLAN information based on static configuration, which is called "pseudo multi-VLAN" support.
[0007] 2. Existing network topology discovery tools often focus on the information of Layer 2 switches, and their support for Layer 3 switches is not comprehensive enough. They cannot accurately capture key information such as their routing tables and ARP tables, thus affecting the accurate construction of the entire network topology.
[0008] 3. Since network devices may be configured with multiple IP addresses, existing network topology discovery tools usually cannot accurately display this in the topology map, which increases the complexity of management.
[0009] 4. Due to the lack of support for dynamic networks, when new unknown devices are added, the network topology cannot be automatically updated, resulting in an outdated topology map. Summary of the invention
[0010] In response to the above problems, the purpose of the present invention is to provide a network topology drawing method, system, device and medium based on active detection, which realizes the collection of device connection status in the network from two dimensions: network layer and link layer, and ensures the accuracy and timeliness of the network topology.
[0011] In order to achieve the above object, the present invention is implemented through the following technical solutions:
[0012] In a first aspect, the present invention discloses a network topology drawing method based on active detection, comprising:
[0013] The SNMP protocol is used to obtain the information of each router and the corresponding subnet information of the network layer, and the breadth-first traversal strategy is used to determine the connection relationship between routers to determine the network topology relationship of the network layer;
[0014] Collect the forwarding sets ForwardSet of all switches in each subnet of the link layer, sort the forwarding sets ForwardSet of switches from small to large, and put the corresponding switch names into the queue Queue according to the sorting results;
[0015] Iterate the forwarding set ForwardSet of the switch in the queue Queue, determine and correct the switch connection relationship according to the switch port connection logic, and simulate the switch connection structure by introducing the dummy node Hub to determine the network topology relationship of the link layer;
[0016] The final network topology structure is generated according to the network topology relationship of the network layer and the network topology relationship of the link layer.
[0017] Further, the method of using the SNMP protocol to obtain information of each router and corresponding subnet information of the network layer, and using a breadth-first traversal strategy to determine the connection relationship between the routers to determine the network topology relationship of the network layer includes the following steps:
[0018] S101: Initialize the queue of routers to be visited, the queue of subnets, the queue of visited routers, and the queue of connections between routers and subnets;
[0019] S102: Obtain the default gateway IP address and add it to the queue of routers to be accessed;
[0020] S103: Determine whether the queue of routers to be visited is empty; if so, go to step S108; if not, go to the next step;
[0021] S104: taking an IP address from the queue of routers to be accessed as the IP address of the current router;
[0022] S105: Access the SNMP service of the current router to obtain its IP address table ipAddrTable; select the largest IP address from the ipAddrTable as the unique identifier of the current router, and record the IP addresses of all its interfaces; add the unique identifier of the current router to the queue of visited routers, and delete the IP address of the current router from the queue of routers to be visited;
[0023] S106: Access the routing table ipRouteTable of the current router, traverse the routing table ipRouteTable using the SNMP protocol, obtain the destination address ipRouteDest, the next hop address ipRouteNextHop, the routing type ipRouteType and the destination network mask ipRouteMask of each routing entry; by analyzing the routing type ipRouteType of each routing entry, determine the subnet information and connection relationship of the current router according to the analysis result, and store them in the subnet queue or the router and subnet connection queue;
[0024] S107: Update the queue of routers to be visited by traversing the queue of routers and subnet connections, and go to step S103;
[0025] S108: The network topology discovery process of the network layer is completed, and the network topology relationship of the network layer is obtained according to the visited router queue.
[0026] Furthermore, the router queue is used to store the IP addresses of routers to be discovered; the subnet queue is used to store the discovered subnet information; the visited router queue is used to record the visited routers and their information; the router and subnet connection queue is used to record the connection relationship between the router and the subnet.
[0027] Further, the method analyzes the route type ipRouteType of each route entry, determines the subnet information and connection relationship of the current router according to the analysis result, and stores them in the subnet queue or the router and subnet connection queue, including:
[0028] For the route entry, determine whether the value of the route type ipRouteType is 3;
[0029] If yes, the destination network address of the current router is calculated by the destination address ipRouteDest and the destination network mask ipRouteMask, and the network address is added to the subnet queue;
[0030] If not, a record of the destination address ipRouteDest, the next hop address ipRouteNextHop, and the route type ipRouteType is generated and added to the router and subnet connection queue.
[0031] Further, the updating of the queue of routers to be visited by traversing the queue of routers and subnet connections includes:
[0032] Traverse the newly added next hop address ipRouteNextHop in the router and subnet connection queue to determine whether the address is stored in the visited router queue. If not, add the address to the queue of routers to be visited.
[0033] Furthermore, the iterative processing of the forwarding set ForwardSet of the switch in the queue Queue determines and corrects the switch connection relationship according to the switch port connection logic, and simulates the connection structure of the switch by introducing a dummy node Hub to determine the network topology relationship of the link layer, including:
[0034] S301: Determine whether the queue Queue is empty; if so, execute step S307; if not, execute the next step;
[0035] S302: Take the first element S from the queue Queue k , and delete it from the queue Queue, and S k As the switch currently being processed;
[0036] S303: traverse each element in the queue Queue and find the first port S that meets the preset identification condition ij ; Among them, S ij For switch S i The jth port of
[0037] S304: Determine port S ij Whether other devices are connected; if not, execute step S305; if yes, execute step S306;
[0038] S305: Set port S ij With switch S k The first port S k1 Connect, and go to step S301;
[0039] S306: Identify port S ij The type of device S connected;
[0040] If device S is a switch, add a dumb node Hub and set port S ij , device S, port S k1All are connected to the dumb node Hub;
[0041] If device S is a dumb node Hub, then set port S k1 Connect to device S;
[0042] After the setting is completed, go to step S301;
[0043] S307: Determine the network topology relationship of the link layer according to the connection information of all switches in the current subnet.
[0044] Furthermore, the preset identification condition is specifically:
[0045] ;
[0046] Among them, A ij Indicates port S ij Address forwarding table; ForwardSet(S k ) indicates switch S k The set of switch MAC addresses recorded in the address forwarding table of all downstream ports.
[0047] In a second aspect, the present invention further discloses a network topology drawing system based on active detection, comprising:
[0048] The first network topology relationship identification module is used to obtain the information of each router and the corresponding subnet information of the network layer by using the SNMP protocol, and determine the connection relationship between the routers by using the breadth-first traversal strategy to determine the network topology relationship of the network layer;
[0049] The forwarding set collection and sorting module is used to collect the forwarding sets ForwardSet of all switches in each subnet of the link layer, sort the forwarding sets ForwardSet of the switches from small to large, and put the corresponding switch names into the queue according to the sorting results;
[0050] The second network topology relationship identification module is used to iteratively process the forwarding set ForwardSet of the switch in the queue Queue, judge and correct the switch connection relationship according to the switch port connection logic, and simulate the connection structure of the switch by introducing a dummy node Hub to determine the network topology relationship of the link layer;
[0051] The network topology structure generation module is used to generate the final network topology structure according to the network topology relationship of the network layer and the network topology relationship of the link layer.
[0052] In a third aspect, the present invention further discloses a network topology drawing device based on active detection, comprising:
[0053] A memory, used for storing a network topology drawing program based on active detection;
[0054] A processor is used to implement the steps of the network topology drawing method based on active detection as described in any one of the above items when executing the network topology drawing program based on active detection.
[0055] In a fourth aspect, the present invention further discloses a readable storage medium, on which is stored a network topology drawing program based on active detection. When the network topology drawing program based on active detection is executed by a processor, the steps of the network topology drawing method based on active detection as described in any of the above items are implemented.
[0056] Compared with the prior art, the beneficial effects of the present invention are as follows: The present invention discloses a network topology drawing method, system, device and medium based on active detection, which realizes the collection of device connection status in the network from the two dimensions of network layer and link layer, and improves the accuracy of network topology drawing. The present invention effectively solves the problems of multi-VLAN network equipment status, three-layer switch support, multi-IP of network equipment, automatic update of network topology, and processing of dumb node equipment in the process of network topology drawing, and solves the abnormal points that may be encountered in the process of network topology drawing, thereby ultimately ensuring the accuracy and timeliness of network topology.
[0057] It can be seen that compared with the prior art, the present invention has outstanding substantive features and significant progress, and the beneficial effects of its implementation are also obvious. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0059] Figure 1 It is a method flow chart of a specific implementation mode of the present invention.
[0060] Figure 2 It is a flow chart of step S1 of a specific implementation mode of the present invention.
[0061] Figure 3 It is a flow chart of step S3 of a specific implementation mode of the present invention.
[0062] Figure 4 It is a system structure diagram of a specific implementation mode of the present invention.
[0063] In the figure, 1. a first network topology relationship identification module; 2. a forwarding set collection and sorting module; 3. a second network topology relationship identification module; 4. a network topology structure generation module. DETAILED DESCRIPTION
[0064] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0065] This embodiment provides a method for drawing a network topology based on active detection. Since an IP network can be divided into a backbone network and a subnet two-level structure, they are responsible for the third layer (network layer) and the second layer (link layer) of the network structure respectively. The backbone network connects each subnet through a router, and the subnet usually includes switches, bridges, hubs, and a large number of hosts. This method uses a multi-layer network topology discovery algorithm to determine the topology of the network, see Figure 1 As shown, this method specifically includes the following steps:
[0066] S1: Use SNMP protocol to obtain the information of each router and the corresponding subnet information of the network layer, and use breadth-first traversal strategy to determine the connection relationship between routers to determine the network topology relationship of the network layer.
[0067] In a specific implementation, the purpose of network layer topology discovery is to obtain the information of each router and the corresponding subnet information by using the SNMP protocol. This step adopts a breadth-first traversal scheme: assuming that a router P0 in the community is the starting point, all the nodes adjacent to it are P1, P2, P3...P i , starting from P0, visit P1, P2, P3...P i , and then visit all nodes adjacent to P1, and so on. Starting from the default router, the topology is discovered in a breadth-first traversal manner, and the connection relationship between routers is obtained according to the ipRouteTable in SNMP.
[0068] S2: Collect the forwarding sets ForwardSet of all switches in each subnet of the link layer, sort the forwarding sets ForwardSet of the switches from small to large, and put the corresponding switch names into the queue Queue according to the sorting results.
[0069] S3: Iterate the forwarding set ForwardSet of the switch in the queue Queue, judge and correct the switch connection relationship according to the switch port connection logic, and simulate the connection structure of the switch by introducing the dummy node Hub to determine the network topology relationship of the link layer.
[0070] In a specific implementation, first take the head switch S k , delete S from the queue Queue k , check the other switches in the queue in turn, and find the port S that meets the conditions ij , determine S ij With S k1 Directly connect, then take the head of the queue, and continue to execute the judgment until the queue is empty. Since dumb nodes lack SNMP management information, there is no relevant information in the address forwarding table of the switch, which will cause multiple switches to be directly connected to one port, which is inconsistent with the facts. Therefore, during the topology discovery process, if this situation is found, it will be directly added as a dumb node Hub.
[0071] S4: Generate a final network topology structure according to the network topology relationship of the network layer and the network topology relationship of the link layer.
[0072] In a specific implementation, first, a backbone network framework consisting of routers and logical connections between them is constructed based on the topological relationship of the network layer. Subsequently, the switches in the link layer and their connection details are embedded into this backbone network framework according to the actual physical or logical connection relationship. By identifying the interface connection between the switch and the router (such as the switch port connected to a certain interface of the router), the topological structure of the link layer is seamlessly integrated into the topology of the network layer. Finally, a complete network topology diagram is generated that includes both high-level connection relationships between routers and detailed display of switch port connection details, providing a detailed visual reference for network management and optimization.
[0073] In a specific embodiment, Figure 2 As shown, step S1 of the above-mentioned network topology drawing method based on active detection specifically includes the following steps:
[0074] S101: Initialize a queue of routers to be visited, a queue of subnets, a queue of visited routers, and a queue of connections between routers and subnets.
[0075] Among them, the router queue is used to store the IP addresses of routers to be discovered; the subnet queue is used to store the discovered subnet information; the visited router queue is used to record the visited routers and their information; the router and subnet connection queue is used to record the connection relationship between the router and the subnet.
[0076] S102: Obtain the default gateway IP address and add it to the queue of routers to be accessed.
[0077] As an example, the default gateway IP address is obtained by reading a system file or identifying information manually input by an administrator, and is stored in a queue of routers to be accessed.
[0078] S103: Determine whether the queue of routers to be visited is empty; if so, go to step S108; if not, execute the next step.
[0079] S104: Take an IP address from the queue of routers to be accessed as the IP address of the current router.
[0080] The initial setting is the default gateway or the gateway entered by the administrator.
[0081] S105: Access the SNMP service of the current router to obtain its IP address table ipAddrTable; select the largest IP address from the ipAddrTable as the unique identifier of the current router, and record the IP addresses of all its interfaces; add the unique identifier of the current router to the queue of visited routers, and delete the IP address of the current router from the queue of routers to be visited.
[0082] As an example, access the ipAdEntAddr in the ipAddrTable of the current router, obtain the IP of all interfaces of the current router, and select the largest IP address as the ID of the current router. Write this information into the queue of the visited routers, and delete the addresses of all interfaces of the current router in the router to be visited.
[0083] S106: Access the routing table ipRouteTable of the current router, use the SNMP protocol to traverse the routing table ipRouteTable, obtain the destination address ipRouteDest, next hop address ipRouteNextHop, routing type ipRouteType and destination network mask ipRouteMask of each routing entry; by analyzing the routing type pRouteType of each routing entry, determine the subnet information and connection relationship of the current router according to the analysis results, and store them in the subnet queue or the router and subnet connection queue.
[0084] As an example, access the ipRouteTable of the current router, and obtain the following values through the GetNextRequest operation in SNMP: ipRouteDest (destination address), ipRouteNextHop (next hop address), ipRouteType (route type, 3 is direct connection, 4 is indirect connection) and ipRouteMask (destination network mask) in the table to obtain all interfaces of the current router and select the largest address as the ID of the current router. Write this information into the queue of the visited routers and delete the same addresses as all interfaces of the current router in the routers to be visited.
[0085] At this time, for each routing entry, determine whether the value of the routing type ipRouteType is 3.
[0086] If yes, the destination network address of the current router is calculated by performing a bitwise AND operation on the destination address ipRouteDest and the destination network mask ipRouteMask, and the network address is added to the subnet queue;
[0087] If not, a record of the destination address ipRouteDest, the next hop address ipRouteNextHop, and the route type ipRouteType is generated and added to the router and subnet connection queue.
[0088] S107: Update the queue of routers to be visited by traversing the queues of routers and subnet connections, and go to step S103.
[0089] As an example, the newly added next hop address ipRouteNextHop in the router and subnet connection queue is traversed to determine whether the address is stored in the visited router queue. If not, the address is added to the to-be-visited router queue.
[0090] S108: The network topology discovery process of the network layer is completed, and the network topology relationship of the network layer is obtained according to the visited router queue.
[0091] In a specific embodiment, Figure 3 As shown, step S3 of the above-mentioned network topology drawing method based on active detection specifically includes the following steps:
[0092] S301: Determine whether the queue Queue is empty; if so, execute step S307; if not, execute the next step.
[0093] S302: Take the first element S from the queue Queue k , and delete it from the queue Queue, and S k as the switch currently being processed.
[0094] S303: traverse each element in the queue Queue and find the first port S that meets the preset identification condition ij ; Among them, S ij For switch S i The j-th port of .
[0095] The preset identification conditions are as follows:
[0096] ;
[0097] Among them, A ij Indicates port S ij Address forwarding table; ForwardSet(S k ) indicates switch S k The set of switch MAC addresses recorded in the address forwarding table of all downstream ports.
[0098] It should be noted that the theoretical basis of the above preset identification conditions is as follows:
[0099] First, define the following:
[0100] S i Identifies the i-th switch in the switching domain, S ij Indicates S i The jth interface, A ij Indicates port S ij Each switch has a unique uplink port, and the address forwarding table of this port contains the MAC address of the machine running the algorithm or the MAC address of the router forwarding the data packets of the machine. The other ports are called downlink ports. Define ForwardSet(S), the set of switch MAC addresses recorded in the address forwarding table of all downlink ports of switch S, that is, all switches that can be reached by switching S triggered from the machine.
[0101] The core theoretical basis is as follows: Under the condition that all downstream ports of switches in the spanning tree are complete, for downstream port S ij , if the relationship If established, then S ij With S k1 connected.
[0102] S304: Determine port S ij Whether other devices are connected; if not, execute step S305; if yes, execute step S306.
[0103] S305: Set port S ij With switch S k The first port S k1Connect, and go to step S301.
[0104] S306: Identify port S ij The type of the connected device S; if the device S is a switch, add a dumb node Hub and set port S ij , device S, port S k1 If device S is a dumb node Hub, then set port S k1 Connect to device S; after setting is completed, go to step S301.
[0105] S307: Determine the network topology relationship of the link layer according to the connection information of all switches in the current subnet.
[0106] See also Figure 4 As shown, the present invention also discloses a network topology drawing system based on active detection, including: a first network topology relationship identification module 1, a forwarding set collection and sorting module 2, a second network topology relationship identification module 3 and a network topology structure generation module 4.
[0107] The first network topology relationship identification module 1 is used to obtain the information of each router and the corresponding subnet information of the network layer by using the SNMP protocol, and to determine the connection relationship between the routers by using the breadth-first traversal strategy to determine the network topology relationship of the network layer.
[0108] The forwarding set collection and sorting module 2 is used to collect the forwarding sets ForwardSet of all switches in each subnet of the link layer, sort the forwarding sets ForwardSet of the switches from small to large, and put the corresponding switch names into the queue Queue according to the sorting results.
[0109] The second network topology relationship identification module 3 is used to iteratively process the forwarding set ForwardSet of the switch in the queue Queue, judge and correct the switch connection relationship according to the switch port connection logic, and simulate the connection structure of the switch by introducing a dummy node Hub to determine the network topology relationship of the link layer.
[0110] The network topology structure generating module 4 is used to generate a final network topology structure according to the network topology relationship of the network layer and the network topology relationship of the link layer.
[0111] The specific implementation of the network topology drawing system based on active detection in this embodiment is basically the same as the specific implementation of the network topology drawing method based on active detection described above, and will not be repeated here.
[0112] The present invention also discloses a network topology drawing device based on active detection, comprising a processor and a memory; wherein, when the processor executes the network topology drawing program based on active detection stored in the memory, the steps of the network topology drawing method based on active detection as described in any one of the above items are implemented.
[0113] Furthermore, the network topology drawing device based on active detection in this embodiment may also include:
[0114] The input interface is used to obtain the network topology drawing program based on active detection imported from the outside, and save the obtained network topology drawing program based on active detection to the memory, and can also be used to obtain various instructions and parameters transmitted by external terminal devices, and transmit them to the processor, so that the processor can use the above various instructions and parameters to carry out corresponding processing. In this embodiment, the input interface can specifically include but is not limited to a USB interface, a serial interface, a voice input interface, a fingerprint input interface, a hard disk reading interface, etc.
[0115] The output interface is used to output various data generated by the processor to the terminal device connected thereto, so that other terminal devices connected to the output interface can obtain various data generated by the processor. In this embodiment, the output interface may specifically include but is not limited to a USB interface, a serial interface, etc.
[0116] The communication unit is used to establish a remote communication connection between the network topology drawing device based on active detection and an external server, so that the network topology drawing device based on active detection can mount the image file to the external server. In this embodiment, the communication unit may specifically include but is not limited to a remote communication unit based on wireless communication technology or wired communication technology.
[0117] The keyboard is used to obtain various parameter data or instructions input by the user by tapping the keycaps in real time.
[0118] A display is used to display in real time the relevant information of the network topology drawing process based on active detection.
[0119] The mouse can be used to assist users in inputting data and simplify user operations.
[0120] The present invention also discloses a readable storage medium, wherein the readable storage medium includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable hard disk, a CD-ROM, or any other form of storage medium known in the technical field. The readable storage medium stores a network topology drawing program based on active detection, and when the network topology drawing program based on active detection is executed by a processor, the steps of the network topology drawing method based on active detection as described in any one of the above items are implemented.
[0121] In summary, the present invention realizes the collection of device connection status in the network from two dimensions of network layer and link layer, ensuring the accuracy and timeliness of network topology.
[0122] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. As for the method disclosed in the embodiment, since it corresponds to the system disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0123] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0124] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0126] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit.
[0127] Similarly, each processing unit in each embodiment of the present invention may be integrated into one functional module, or each processing unit may exist physically, or two or more processing units may be integrated into one functional module.
[0128] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0129] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0130] The above is a detailed introduction to the network topology drawing method, system, device and readable storage medium based on active detection provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A network topology drawing method based on active detection, characterized in that: include: The SNMP protocol is used to obtain the information of each router and the corresponding subnet information of the network layer, and the breadth-first traversal strategy is used to determine the connection relationship between routers to determine the network topology relationship of the network layer; Collect the forwarding sets ForwardSet of all switches in each subnet of the link layer, sort the forwarding sets ForwardSet of switches from small to large, and put the corresponding switch names into the queue Queue according to the sorting results; Iterate the forwarding set ForwardSet of the switch in the queue Queue, determine and correct the switch connection relationship according to the switch port connection logic, and simulate the switch connection structure by introducing the dummy node Hub to determine the network topology relationship of the link layer; Generate the final network topology structure according to the network topology relationship of the network layer and the network topology relationship of the link layer; The method of using the SNMP protocol to obtain information about each router of the network layer and corresponding subnet information, and using a breadth-first traversal strategy to determine the connection relationship between the routers to determine the network topology relationship of the network layer includes the following steps: S101: Initialize the queue of routers to be visited, the queue of subnets, the queue of visited routers, and the queue of connections between routers and subnets; S102: Obtain the default gateway IP address and add it to the queue of routers to be accessed; S103: Determine whether the queue of the router to be visited is empty; if so, go to step S108; If not, proceed to the next step; S104: taking an IP address from the queue of routers to be accessed as the IP address of the current router; S105: Access the SNMP service of the current router to obtain its IP address table ipAddrTable; Select the largest IP address from ipAddrTable as the unique identifier of the current router, and record the IP addresses of all its interfaces; Add the unique identifier of the current router to the queue of visited routers, and delete the IP address of the current router from the queue of routers to be visited; S106: Access the routing table ipRouteTable of the current router, traverse the routing table ipRouteTable using the SNMP protocol, obtain the destination address ipRouteDest, the next hop address ipRouteNextHop, the routing type ipRouteType and the destination network mask ipRouteMask of each routing entry; by analyzing the routing type pRouteType of each routing entry, determine the subnet information and connection relationship of the current router according to the analysis result, and store them in the subnet queue or the router and subnet connection queue; S107: Update the queue of routers to be visited by traversing the queue of routers and subnet connections, and go to step S103; S108: The network topology discovery process of the network layer is completed, and the network topology relationship of the network layer is obtained according to the visited router queue; The iterative processing of the forwarding set ForwardSet of the switch in the queue Queue determines and corrects the switch connection relationship according to the switch port connection logic, and simulates the connection structure of the switch by introducing a dummy node Hub to determine the network topology relationship of the link layer, including: S301: Determine whether the queue Queue is empty; if so, execute step S307; if not, execute the next step; S302: Take the first element S from the queue Queue k , and delete it from the queue Queue, and S k As the switch currently being processed; S303: traverse each element in the queue Queue and find the first port S that meets the preset identification condition ij ; Among them, S ij For switch S i The jth port of S304: Determine port S ij Whether other devices are connected; if not, execute step S305; if yes, execute step S306; S305: Set port S ij With switch S k The first port S k1 Connect, and go to step S301; S306: Identify port S ij The type of device S connected; If device S is a switch, add a dumb node Hub and set port S ij , device S, port S k1 All are connected to the dumb node Hub; If device S is a dumb node Hub, then set port S k1 Connect to device S; After the setting is completed, go to step S301; S307: Determine the network topology relationship of the link layer according to the connection information of all switches in the current subnet.
2. The network topology drawing method based on active detection according to claim 1 is characterized in that ; The router queue is used to store the IP addresses of routers to be discovered; The subnet queue is used to store discovered subnet information; The visited router queue is used to record the visited routers and their information; The router and subnet connection queue is used to record the connection relationship between the router and the subnet.
3. The network topology drawing method based on active detection according to claim 2 is characterized in that: The method analyzes the route type ipRouteType of each route entry, determines the subnet information and connection relationship of the current router according to the analysis result, and stores them in the subnet queue or the router and subnet connection queue, including: For the route entry, determine whether the value of the route type ipRouteType is 3; If yes, the destination network address of the current router is calculated by the destination address ipRouteDest and the destination network mask ipRouteMask, and the network address is added to the subnet queue; If not, a record of the destination address ipRouteDest, the next hop address ipRouteNextHop, and the route type ipRouteType is generated and added to the router and subnet connection queue.
4. The network topology drawing method based on active detection according to claim 3 is characterized in that: The updating of the queue of routers to be visited by traversing the queue of routers and subnet connections includes: Traverse the newly added next hop address ipRouteNextHop in the router and subnet connection queue to determine whether the address is stored in the visited router queue. If not, add the address to the queue of routers to be visited.
5. The network topology drawing method based on active detection according to claim 1 is characterized in that: The preset identification conditions are specifically: ; Among them, A ij Indicates port S ij Address forwarding table; ForwardSet(S k ) indicates switch S k The set of switch MAC addresses recorded in the address forwarding table of all downstream ports.
6. A network topology drawing system based on active detection, characterized in that: include: The first network topology relationship identification module is used to obtain the information of each router and the corresponding subnet information of the network layer by using the SNMP protocol, and determine the connection relationship between the routers by using the breadth-first traversal strategy to determine the network topology relationship of the network layer; The forwarding set collection and sorting module is used to collect the forwarding sets ForwardSet of all switches in each subnet of the link layer, sort the forwarding sets ForwardSet of the switches from small to large, and put the corresponding switch names into the queue according to the sorting results; The second network topology relationship identification module is used to iteratively process the forwarding set ForwardSet of the switch in the queue Queue, judge and correct the switch connection relationship according to the switch port connection logic, and simulate the connection structure of the switch by introducing a dummy node Hub to determine the network topology relationship of the link layer; A network topology structure generation module is used to generate a final network topology structure according to the network topology relationship of the network layer and the network topology relationship of the link layer; The method of using the SNMP protocol to obtain information about each router of the network layer and corresponding subnet information, and using a breadth-first traversal strategy to determine the connection relationship between the routers to determine the network topology relationship of the network layer includes the following steps: S101: Initialize the queue of routers to be visited, the queue of subnets, the queue of visited routers, and the queue of connections between routers and subnets; S102: Obtain the default gateway IP address and add it to the queue of routers to be accessed; S103: Determine whether the queue of the router to be visited is empty; if so, go to step S108; If not, proceed to the next step; S104: taking an IP address from the queue of routers to be accessed as the IP address of the current router; S105: Access the SNMP service of the current router to obtain its IP address table ipAddrTable; Select the largest IP address from ipAddrTable as the unique identifier of the current router, and record the IP addresses of all its interfaces; Add the unique identifier of the current router to the queue of visited routers, and delete the IP address of the current router from the queue of routers to be visited; S106: Access the routing table ipRouteTable of the current router, traverse the routing table ipRouteTable using the SNMP protocol, obtain the destination address ipRouteDest, the next hop address ipRouteNextHop, the routing type ipRouteType and the destination network mask ipRouteMask of each routing entry; by analyzing the routing type pRouteType of each routing entry, determine the subnet information and connection relationship of the current router according to the analysis result, and store them in the subnet queue or the router and subnet connection queue; S107: Update the queue of routers to be visited by traversing the queue of routers and subnet connections, and go to step S103; S108: The network topology discovery process of the network layer is completed, and the network topology relationship of the network layer is obtained according to the visited router queue; The iterative processing of the forwarding set ForwardSet of the switch in the queue Queue determines and corrects the switch connection relationship according to the switch port connection logic, and simulates the connection structure of the switch by introducing a dummy node Hub to determine the network topology relationship of the link layer, including: S301: Determine whether the queue Queue is empty; if so, execute step S307; if not, execute the next step; S302: Take the first element S from the queue Queue k , and delete it from the queue Queue, and S k As the switch currently being processed; S303: traverse each element in the queue Queue and find the first port S that meets the preset identification condition ij ; Among them, S ij For switch S i The jth port of S304: Determine port S ij Whether other devices are connected; if not, execute step S305; if yes, execute step S306; S305: Set port S ij With switch S k The first port S k1 Connect, and go to step S301; S306: Identify port S ij The type of device S connected; If device S is a switch, add a dumb node Hub and set port S ij , device S, port S k1 All are connected to the dumb node Hub; If device S is a dumb node Hub, then set port S k1 Connect to device S; After the setting is completed, go to step S301; S307: Determine the network topology relationship of the link layer according to the connection information of all switches in the current subnet.
7. A network topology drawing device based on active detection, characterized in that: include: A memory, used for storing a network topology drawing program based on active detection; A processor is used to implement the steps of the network topology drawing method based on active detection as described in any one of claims 1 to 5 when executing the network topology drawing program based on active detection.
8. A readable storage medium, characterized in that: The readable storage medium stores a network topology drawing program based on active detection, and when the network topology drawing program based on active detection is executed by a processor, the steps of the network topology drawing method based on active detection as claimed in any one of claims 1 to 5 are implemented.
