CN113452561B - Topology generation method, device, equipment and readable storage medium - Google Patents

Topology generation method, device, equipment and readable storage medium Download PDF

Info

Publication number
CN113452561B
CN113452561B CN202110712154.3A CN202110712154A CN113452561B CN 113452561 B CN113452561 B CN 113452561B CN 202110712154 A CN202110712154 A CN 202110712154A CN 113452561 B CN113452561 B CN 113452561B
Authority
CN
China
Prior art keywords
information
network
router
switch
scanned
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110712154.3A
Other languages
Chinese (zh)
Other versions
CN113452561A (en
Inventor
周奇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202110712154.3A priority Critical patent/CN113452561B/en
Publication of CN113452561A publication Critical patent/CN113452561A/en
Application granted granted Critical
Publication of CN113452561B publication Critical patent/CN113452561B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/12Discovery or management of network topologies
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/02Standardisation; Integration
    • H04L41/0213Standardised network management protocols, e.g. simple network management protocol [SNMP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/02Topology update or discovery
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles

Abstract

The application discloses a topology generation method, device, equipment and readable storage medium. The method comprises the steps of determining a network corresponding to a mark to be scanned as the network to be scanned, obtaining a network configuration file of the network to be scanned, classifying equipment information in the network configuration file into router information and switch information according to a preset type label, determining connection relations among all equipment in a target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned to indicate that the network topology graph is generated for the current network. According to the scheme, network topology discovery can be performed on the network needing to generate the topology map in time on the premise that normal operation of the network is not affected. The topology generation device, the topology generation equipment and the readable storage medium have the technical effects.

Description

Topology generation method, device, equipment and readable storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a topology generating method, apparatus, device, and readable storage medium.
Background
At present, network topology discovery can be generally performed by sending test packets, and the method can increase the flow in the network and influence the originally born service of the network. Meanwhile, the change of the equipment in the network is not easy to be perceived, so that the topology diagrams of which networks need to be updated and which networks do not have the corresponding topology diagrams can not be known in time. Therefore, how to discover the network topology of the network which needs to generate the topology map in time on the premise of not affecting the normal operation of the network is a problem which needs to be solved by the person skilled in the art.
Disclosure of Invention
In view of this, an object of the present application is to provide a topology generating method, apparatus, device and readable storage medium, so as to discover network topology of a network that needs to generate a topology map in time without affecting normal operation of the network. The specific scheme is as follows:
in a first aspect, the present application provides a topology generation method, including:
if the target network corresponds to the mark to be scanned, determining the target network as the network to be scanned;
acquiring a network configuration file of the network to be scanned;
classifying the equipment information in the network configuration file into router information and switch information according to a preset class label;
and determining the connection relation among all devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned.
Preferably, after the obtaining the network configuration file of the network to be scanned, the method further includes:
acquiring a scanning mode of the network to be scanned:
if the scanning mode is timing scanning, executing the step of classifying the equipment information in the network configuration file into router information and switch information according to a preset category label under the condition that the timing scanning time is reached; and determining the connection relation among all devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned.
Preferably, the method further comprises:
if the scanning mode is real-time scanning, executing the step of classifying the equipment information in the network configuration file into router information and switch information according to a preset category label under the condition that a real-time scanning function is started and a topology file does not exist currently; and determining the connection relation among all devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned.
Preferably, the determining, based on the router information and the switch information, a connection relationship between each device in the target network to generate a network topology map includes:
determining a subnet of each router, a connection relationship between different routers, a connection relationship between different switches, and a connection relationship between each switch and a host device based on the router information and the switch information to generate the network topology map.
Preferably, the determining the subnet of each router, the connection relationship between different routers, the connection relationship between different switches, and the connection relationship between each switch and the host device based on the router information and the switch information to generate the network topology map includes:
determining the connection relation between the subnet of each router and different routers based on the router information;
determining a connection relationship between different switches and a connection relationship between each switch and host equipment based on the switch information and the subnet of each router;
writing all the determined connection relations into a topology file, and generating the network topology graph according to the topology file.
Preferably, the determining connection relationship between the subnet of each router and different routers based on the router information includes:
determining a plurality of routers based on the router information;
for any router, if the type of the next hop recorded in the routing table of the router is a routing type and the IP address of the next hop is in the address range covered by the router, determining that the router is directly connected with another router; otherwise, determining that the router is directly connected with the subnet.
Preferably, the determining, based on the switch information and the subnet of each router, a connection relationship between different switches and a connection relationship between each switch and a host device includes:
determining a plurality of switches based on the switch information, and dividing each switch into corresponding subnets;
for any switch in any subnet, if address information of host equipment is recorded in a port mapping table of the switch, recording a connection relationship between the switch and the host equipment; if the forwarding table of the switch records the address information of other switches in the current subnet, the connection relationship between the switch and the other switches is recorded.
Preferably, the method further comprises:
and monitoring the states of all the devices in the network topology diagram in real time by utilizing the snmptrap.
Preferably, the method further comprises:
acquiring update information of a user on the target network based on a man-machine interaction interface;
and updating the network configuration file according to the updating information, and generating the mark to be scanned.
In a second aspect, the present application provides a topology generating apparatus, including:
the detection module is used for determining the target network as the network to be scanned if the target network corresponds to the mark to be scanned;
the acquisition module is used for acquiring the network configuration file of the network to be scanned;
the classification module is used for classifying the equipment information in the network configuration file into router information and switch information according to a preset class label;
and the topology generation module is used for determining the connection relation among all the devices in the target network based on the router information and the switch information so as to generate a network topology graph and deleting the mark to be scanned.
In a third aspect, the present application provides an electronic device, including:
a memory for storing a computer program;
a processor for executing the computer program to implement the topology generation method disclosed previously.
In a fourth aspect, the present application provides a readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the topology generation method disclosed above.
According to the scheme, the application provides a topology generation method, which comprises the following steps: if the target network corresponds to the mark to be scanned, determining the target network as the network to be scanned; acquiring a network configuration file of the network to be scanned; classifying the equipment information in the network configuration file into router information and switch information according to a preset class label; determining a subnet of each router, a connection relationship between different routers, a connection relationship between different switches, and a connection relationship between each switch and a host device based on the router information and the switch information, to generate a network topology map, and deleting the to-be-scanned flag.
As can be seen, the method and the device for marking the network to be scanned with the mark to be scanned mark, wherein the updated network to be scanned or the network to be scanned is not scanned, when a certain network is determined to correspond to the mark to be scanned, the mark to be scanned is determined to be the network to be scanned, then a network configuration file of the network to be scanned is obtained, and equipment information in the network configuration file is classified into router information and switch information according to a preset type label; and finally, determining the connection relation among all the devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting a mark to be scanned to indicate that the corresponding network topology graph is generated for the current network. According to the method, which networks need to generate the topological graph can be automatically found, and automatic generation of the network topological graph is realized. The method and the device can directly determine the connection relation between the devices based on the router information and the switch information, and each device is not required to send test packets mutually, so that the flow in the network can not be increased, network topology discovery can be performed on the network needing to generate the topology map in time on the premise of not affecting the normal operation of the network, and the efficiency is improved.
Accordingly, the topology generation device, the topology generation equipment and the readable storage medium have the technical effects.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings may be obtained according to the provided drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flow chart of a topology generation method disclosed in the present application;
FIG. 2 is a flow chart of another topology generation method disclosed herein;
FIG. 3 is a flow chart of discovering a subnet of a router, a direct connection of different routers, as disclosed herein;
FIG. 4 is a flow chart of discovering a direct connection relationship between a switch and a host device as disclosed herein;
FIG. 5 is a flow chart of discovering a switch to switch direct connection relationship as disclosed herein;
fig. 6 is a schematic diagram of a scheme for determining a network topology disclosed in the present application;
fig. 7 is a schematic diagram of a topology generating apparatus disclosed in the present application;
FIG. 8 is a schematic diagram of an electronic device disclosed herein;
fig. 9 is a schematic diagram of another electronic device disclosed herein.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
At present, network topology discovery can be generally performed by sending test packets, and the method can increase the flow in the network and influence the originally born service of the network. Meanwhile, the change of the equipment in the network is not easy to be perceived, so that the topology diagrams of which networks need to be updated and which networks do not have the corresponding topology diagrams can not be known in time. Therefore, the topology generation scheme provided by the application can be used for discovering the network topology of the network needing to generate the topology map in time on the premise of not influencing the normal operation of the network.
Referring to fig. 1, an embodiment of the present application discloses a topology generating method, including:
s101, if the target network corresponds to the mark to be scanned, determining the target network as the network to be scanned.
The present embodiment marks the network to be scanned with a mark to be scanned. The mark to be scanned can be recorded by a file or a variable, and can be specifically '1', 'T', and the like.
S102, acquiring a network configuration file of a network to be scanned.
Wherein, the network configuration file records the relevant information of all routers and switches in the current network, such as: IP addresses, names, etc. of routers and switches. The information is defined by the user based on the man-machine interaction interface, so the user can change the information based on the man-machine interaction interface and also can delete or add certain information. Such as: when deleting or adding equipment to the network, deleting or adding corresponding information based on the human-computer interaction interface.
S103, classifying the equipment information in the network configuration file into router information and switch information according to the preset category label.
When deleting or adding the device information based on the man-machine interaction interface, different category labels (for example, the category labels of the router information are collectively marked as A, and the category labels of the switch information are collectively marked as B) can be preset for the router information and the switch information, so that all the device information can be classified into the router information and the switch information according to the category labels. After classification, the connection relationship between each device in the target network can be found conveniently. Each device in the target network comprises: routers, switches, host devices, etc., and thus the connection relationship between the respective devices includes: a subnet to which the router is connected, a connection relationship between different routers, a connection relationship between different switches, a connection relationship between each switch and the host device, and the like.
S104, determining the connection relation among all the devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned. .
It should be noted that step S104 may be implemented by using SNMP (Simple Network Management Protocol). SNMP is a standard protocol for managing network nodes (servers, workstations, routers, switches, and hub, etc.), which is an application layer protocol. SNMP enables network administrators to manage network performance, discover and solve network problems, and plan network growth. Random messages (and event reports) can also be received through SNMP, and network problems are known in time.
The network topology map can clarify the physical or logical arrangement of the members constituting the network. If the connection structures of two networks are identical, we say that their network topologies are identical, although their respective internal physical connections, inter-node distances may be different.
Marking a network to be scanned with updated or not scanned equipment by using a mark to be scanned, determining a certain network as the network to be scanned when the mark to be scanned is determined to correspond to the mark to be scanned, then acquiring a network configuration file of the network to be scanned, and classifying equipment information in the network configuration file into router information and switch information according to a preset type label; and finally, determining the subnet of each router, the connection relation between different routers, the connection relation between different switches and the connection relation between each switch and host equipment based on the router information and the switch information, thereby generating a network topology graph, and deleting a mark to be scanned to indicate that a corresponding network topology graph is generated for the current network.
It can be seen that according to the to-be-scanned mark in the embodiment, which networks need to generate the topology map can be automatically found, so that automatic generation of the network topology map is realized. The connection relation between the devices can be directly determined based on the router information and the switch information, and the devices are not required to send test packets mutually, so that the flow in the network is not increased, network topology discovery can be performed on the network needing to generate the topology map in time on the premise of not affecting the normal operation of the network, and the efficiency is improved.
Based on the above embodiments, it should be noted that the scanning manner (timing scanning or real-time scanning) may be set for each network in advance, and thus further includes:
acquiring a scanning mode of a network to be scanned:
if the scanning mode is the timing scanning, under the condition that the timing scanning time is reached, classifying the equipment information in the network configuration file into router information and switch information according to a preset category label; and determining the connection relation among all the devices in the target network based on the router information and the switch information to generate a network topological graph, and deleting the mark to be scanned.
In one specific embodiment, the method further comprises:
if the scanning mode is real-time scanning, under the condition that a real-time scanning function is started and no topology file exists currently, classifying equipment information in the network configuration file into router information and switch information according to a preset category label; and determining the connection relation among all the devices in the target network based on the router information and the switch information to generate a network topological graph, and deleting the mark to be scanned.
It should be noted that, the acquiring and judging of the scanning manner may be performed after "acquiring the network configuration file of the network to be scanned", or may be performed before "acquiring the network configuration file of the network to be scanned", where the modification of the execution sequence does not affect the implementation of the present invention.
Please refer to fig. 2 in detail. In fig. 2, snmp_device.json is the network configuration file, scan_time is the timing scan time (e.g., in half an hour as a scan unit), if it is empty, it indicates that the timing scan is not currently set; otherwise, a timing scan is currently set. If the timing scanning is currently set, judging whether the set scanning time is reached currently, if so, classifying the switch and the router, and executing the subsequent steps; otherwise, the flow is ended. If the timing scanning is not set currently, further judging whether scan_enable is True and change_enable.flag exists (namely judging whether real-time scanning is set or not); if yes, under the condition that real-time scanning is started and no topology file exists (so as to avoid repeated scanning), classifying the switch and the router, and executing the subsequent steps; otherwise, the flow is ended. The mark file is the mark to be scanned.
Wherein, special scanning equipment can also be used for scanning various areas in the network, such as: one for each subnet. It should be noted at this point that the IP address of the scanning device and the IP address of the router interconnected in the subnet it scans may not be the same, otherwise it may cause a network topology drawing error.
As can be seen from the above embodiments, generating the network topology map requires to clarify the subnet of each router, the connection relationship between different routers, the connection relationship between different switches, and the connection relationship between each switch and the host device, so that the connection relationship related to the router and the connection relationship related to the switch can be determined separately. Thus in one embodiment, determining a connection relationship between devices in a target network based on router information and switch information to generate a network topology comprises: a network topology map is generated by determining a subnet of each router, a connection relationship between different routers, a connection relationship between different switches, and a connection relationship between each switch and a host device based on the router information and the switch information.
Wherein determining the subnet of each router, the connection relationship between different routers, the connection relationship between different switches, and the connection relationship between each switch and the host device based on the router information and the switch information to generate the network topology graph includes: determining a subnet of each router and a connection relation between different routers based on the router information; determining a connection relationship between different switches and a connection relationship between each switch and a host device based on the switch information and the subnet of each router; and writing all the determined connection relations into a topology file, and generating a network topology graph according to the topology file.
Wherein the connection relation related to the router can be determined according to the following steps, so in a specific embodiment, the connection relation between the different routers and the subnet of each router is determined based on the router information, which comprises the following steps: determining a plurality of routers based on the router information; for any router, if the type of the next hop recorded in the routing table of the router is a routing type (namely 4) and the IP address of the next hop is in the address range covered by the router, determining that the router is directly connected with another router; otherwise, determining that the router is directly connected with the subnet.
Note that, the routing table of each router is recorded with: ipRouteDest, ipRouteIfIndex, ipRouteNextHop, ipRouteType. The ip routedest records the destination address range which can be reached by taking the router as a starting point; the iprouteifIndx records the interface index number corresponding to the iprouteDest; the ipRouteNextHop records the router address of the next hop corresponding to the router or the gateway address of the direct-connected subnet; the ipRouteType records the connection relation between the address represented by the ipRouteNextHop and the router, and when the ipRouteType is 4, the address is represented by the router and the router are directly connected; when it is 3, it means that the corresponding interface is connected to a subnet; ports can be discovered through the ipRouteIfIndex of the routing table. Therefore, the direct connection relation between the subnet of each router and the current router and other routers can be known by traversing the routing table of each router. The routing table can be designed as shown in fig. 3 to find the connection relationship between the subnet of each router and different routers.
Wherein the connection relation related to the switches may be determined according to the following steps, so in a specific embodiment, determining the connection relation between different switches and the connection relation between each switch and the host device based on the switch information and the subnet of each router includes: determining a plurality of switches based on the switch information, and dividing each switch into corresponding sub-networks; if address information (MAC address or IP address) of the host device is recorded in a port mapping table of any switch in any subnet, a connection relationship between the switch and the host device is recorded; if the forwarding table of the switch records the address information of other switches in the current subnet, the connection relationship between the switch and other switches is recorded.
The connection relationship between the switch and the host device can be found with reference to fig. 4. In fig. 4, the port of connect_msg [ ip ] is used to connect the switch. As in fig. 4, the node where the host device is located may be named by its MAC address or IP address. The connection relationship between switches can be found with reference to fig. 5. SWA in fig. 5 represents a certain switch in a certain subnet, and SWB is another switch in the subnet.
Based on the above embodiment, it should be noted that the state of each device in the network topology map may be monitored in real time by using the snmptrap. Such as: whether the device address changes, whether a device is newly added, and whether a device is deleted.
Of course, the above state change may be implemented by the user based on a man-machine interaction interface, for example, the user modifies an address of a device in the target network, adds a device, deletes a device, and the like based on the man-machine interaction interface. Thus in one embodiment, further comprising: acquiring update information of a user on a target network based on a man-machine interaction interface; updating the network configuration file according to the updating information, and generating a mark to be scanned so as to discover the network to be scanned in time. Wherein, the updating information is: the user is based on the device address modified by the man-machine interface, the related information of the newly added device, the related information of the deleted device, and the like.
The following describes a specific scheme for determining a network topology, and the scheme provided in this embodiment includes: the system comprises a network topology identification module and a device monitoring module.
The network topology identification module mainly uses SNMP to acquire a forwarding table, a routing table and a port mapping table, and then assembles the forwarding table, the routing table and the port mapping table through an algorithm to obtain a process of actual network topology in a network. The method comprises the following steps: router relationship identification, switch and host relationship identification, switch and switch relationship identification.
Specifically, the router relationship identification is: the relationship between routers is identified by retrieving a routing table. The filtering out of the data is of the direct route and the indirect route type.
Switch and host relationship identification is: the relation between the switch and the host is identified by acquiring a port mapping table of the switch through SNMP, the port of the switch is filtered, and the rest is the connection port of the switch and the host.
Switch-to-switch relationship identification is: grouping the switches through the sub-networks separated by the route identification, and determining according to a forwarding table of each switch after grouping: the data information of the other party exists in the forwarding tables of the different switches with the communication relationship. The communication relationship between the switches can be derived by this principle.
The connection relation of the routers of each subnet is obtained through the routing tables among the routers, the network equipment under each subnet is divided through the identification of the routers, the connection relation of the switch and the switch is obtained through the forwarding tables, and finally the position of the host on the switch or the router is obtained by adding the port mapping tables on the switch, so that a network topology structure diagram is compiled.
The device monitoring module monitors the dynamics of the connected devices on the network device through the snmptap. If the equipment is offline, newly accessed or imitated, and the like, the detailed dynamic change of the equipment can be monitored through the snmptrap, and then the system updates a network topology structure diagram and carries out alarm prompt through assembling and comparing the original network topology data.
Therefore, in this embodiment, the network topology of the area where the network device is located is calculated by scanning the network topology of the area where the network device is located, automatically analyzing the connection condition of the device according to the scanning result, and summarizing the scanned area topology to the foreground page for display. And meanwhile, the network equipment is dynamically monitored, and alarm information is generated if the network equipment is changed.
The scheme can display a network topology structure diagram in time, can help a user to clear the deployment condition of equipment in a network, and avoids blindness of equipment deployment. The state and the safety of the equipment in the network can be known in real time, and each equipment can be effectively managed and controlled.
A topology generating apparatus provided in an embodiment of the present application is described below, and a topology generating apparatus described below and a topology generating method described above may be referred to each other.
Referring to fig. 7, an embodiment of the present application discloses a topology generating apparatus, which is characterized by including:
the detection module 701 is configured to determine the target network as the network to be scanned if the target network corresponds to the mark to be scanned;
an obtaining module 702, configured to obtain a network configuration file of a network to be scanned;
a classification module 703, configured to classify the device information in the network configuration file into router information and switch information according to a preset class label;
the topology generation module 704 is configured to determine a connection relationship between each device in the target network based on the router information and the switch information, so as to generate a network topology map, and delete the to-be-scanned flag.
In one specific embodiment, the method further comprises:
the scanning mode acquisition module is used for acquiring the scanning mode of the network to be scanned:
and the timing scanning module is used for executing the steps in the classification module and the topology generation module under the condition that the timing scanning time is reached if the scanning mode is the timing scanning.
In one specific embodiment, the method further comprises:
and the real-time scanning module is used for executing the steps in the classification module and the topology generation module under the condition that the real-time scanning function is started and the topology file does not exist currently if the scanning mode is real-time scanning.
In one embodiment, the topology generation module is specifically configured to:
a network topology map is generated by determining a subnet of each router, a connection relationship between different routers, a connection relationship between different switches, and a connection relationship between each switch and a host device based on the router information and the switch information.
In one embodiment, the topology generation module includes:
a router relation determining unit for determining a connection relation between the subnet of each router and different routers based on the router information;
a switch relationship determining unit configured to determine a connection relationship between different switches and a connection relationship between each switch and the host device based on the switch information and the subnet of each router;
and the generating unit is used for writing all the determined connection relations into the topology file and generating a network topology graph according to the topology file.
In one embodiment, the router relation determination unit is specifically configured to:
determining a plurality of routers based on the router information;
for any router, if the type of the next hop recorded in the routing table of the router is a routing type and the IP address of the next hop is in the address range covered by the router, determining that the router is directly connected with another router; otherwise, determining that the router is directly connected with the subnet.
In one embodiment, the switch relation determining unit is specifically configured to:
determining a plurality of switches based on the switch information, and dividing each switch into corresponding sub-networks;
for any switch in any subnet, if address information of host equipment is recorded in a port mapping table of the switch, recording a connection relationship between the switch and the host equipment; if the forwarding table of the switch records the address information of other switches in the current subnet, the connection relationship between the switch and other switches is recorded.
In one specific embodiment, the method further comprises:
and the monitoring module is used for monitoring the states of all the devices in the network topology graph in real time by utilizing the snmptrap.
In one specific embodiment, the method further comprises:
the updating module is used for acquiring updating information of a user on the target network based on the human-computer interaction interface; and updating the network configuration file according to the updating information, and generating a mark to be scanned.
The more specific working process of each module and unit in this embodiment may refer to the corresponding content disclosed in the foregoing embodiment, and will not be described herein.
It can be seen that the present embodiment provides a topology generating apparatus, which can discover a network topology of a network that needs to generate a topology map in time on the premise that normal operation of the network is not affected.
An electronic device provided in an embodiment of the present application is introduced below, and an electronic device described below and a topology generating method and apparatus described above may be referred to each other.
Referring to fig. 8, an embodiment of the present application discloses an electronic device, including:
a memory 801 for storing a computer program;
a processor 802 for executing the computer program to implement the method disclosed in any of the embodiments above.
Referring to fig. 9, fig. 9 is a schematic diagram of another electronic device provided in this embodiment, where the electronic device may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPU) 322 (e.g., one or more processors) and a memory 332, and one or more storage media 330 (e.g., one or more mass storage devices) storing application programs 342 or data 344. Wherein the memory 332 and the storage medium 330 may be transitory or persistent. The program stored on the storage medium 330 may include one or more modules (not shown), each of which may include a series of instruction operations in the data processing apparatus. Still further, the central processor 322 may be configured to communicate with the storage medium 330 and execute a series of instruction operations in the storage medium 330 on the electronic device 301.
The electronic device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input/output interfaces 358, and/or one or more operating systems 341. For example WindowsServerTM, macOSXTM, unixTM, linuxTM, freeBSDTM, etc.
In fig. 9, the application 342 may be a program that performs a topology generation method, and the data 344 may be data required or generated to perform the topology generation method.
The steps in the topology generation method described above may be implemented by the structure of the electronic device.
The following describes a readable storage medium provided in the embodiments of the present application, and the readable storage medium described below and the topology generating method, apparatus and device described above may refer to each other.
A readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the topology generation method disclosed in the foregoing embodiments. For specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no further description is given here.
Reference to "first," "second," "third," "fourth," etc. (if present) herein is used to distinguish similar objects from each other and does not necessarily describe a particular order or sequence. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be implemented in other sequences than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, or apparatus.
It should be noted that the description herein of "first," "second," etc. is for descriptive purposes only and is not to be construed as indicating or implying a relative importance or implying an indication of the number of technical features being indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be regarded as not exist and not within the protection scope of the present application.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of readable storage medium known in the art.
The principles and embodiments of the present application are described herein with specific examples, the above examples being provided only to assist in understanding the methods of the present application and their core ideas; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (9)

1. A topology generation method, comprising:
if the target network corresponds to the mark to be scanned, determining the target network as the network to be scanned;
acquiring a network configuration file of the network to be scanned; the network configuration file records the related information of all routers and switches in the current network;
classifying the equipment information in the network configuration file into router information and switch information according to a preset class label;
determining connection relations among all devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned;
acquiring update information of a user on the target network based on a man-machine interaction interface; the update information includes: the user is based on the device address modified by the man-machine interaction interface, the information of the newly added device and the information of the deleted device;
and updating the network configuration file according to the updating information, and generating the mark to be scanned.
2. The method as recited in claim 1, further comprising:
acquiring a scanning mode of the network to be scanned:
if the scanning mode is timing scanning, executing the step of classifying the equipment information in the network configuration file into router information and switch information according to a preset category label under the condition that the timing scanning time is reached; determining a connection relation between each device in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned;
if the scanning mode is real-time scanning, executing the step of classifying the equipment information in the network configuration file into router information and switch information according to a preset category label under the condition that a real-time scanning function is started and a topology file does not exist currently; and determining the connection relation among all devices in the target network based on the router information and the switch information to generate a network topology graph, and deleting the mark to be scanned.
3. The method of claim 1, wherein determining connection relationships between devices in the target network based on the router information and the switch information to generate a network topology comprises:
determining a subnet of each router, a connection relationship between different routers, a connection relationship between different switches, and a connection relationship between each switch and a host device based on the router information and the switch information to generate the network topology map.
4. The method of claim 3, wherein the determining the subnet of each router, the connection relationship between different routers, the connection relationship between different switches, and the connection relationship between each switch and a host device based on the router information and the switch information to generate the network topology graph comprises:
determining the connection relation between the subnet of each router and different routers based on the router information;
determining a connection relationship between different switches and a connection relationship between each switch and host equipment based on the switch information and the subnet of each router;
writing all the determined connection relations into a topology file, and generating the network topology graph according to the topology file.
5. The method of claim 4, wherein determining a connection relationship between the different routers and the subnet of each router based on the router information comprises:
determining a plurality of routers based on the router information;
for any router, if the type of the next hop recorded in the routing table of the router is a routing type and the IP address of the next hop is in the address range covered by the router, determining that the router is directly connected with another router; otherwise, determining that the router is directly connected with the subnet.
6. The method of claim 4, wherein determining connection relationships between different switches and connection relationships between each switch and a host device based on the switch information and the subnet of each router comprises:
determining a plurality of switches based on the switch information, and dividing each switch into corresponding subnets;
for any switch in any subnet, if address information of host equipment is recorded in a port mapping table of the switch, recording a connection relationship between the switch and the host equipment; if the forwarding table of the switch records the address information of other switches in the current subnet, the connection relationship between the switch and the other switches is recorded.
7. A topology generation apparatus, comprising:
the detection module is used for determining the target network as the network to be scanned if the target network corresponds to the mark to be scanned;
the acquisition module is used for acquiring the network configuration file of the network to be scanned; the network configuration file records the related information of all routers and switches in the current network;
the classification module is used for classifying the equipment information in the network configuration file into router information and switch information according to a preset class label;
the topology generation module is used for determining the connection relation between all the devices in the target network based on the router information and the switch information so as to generate a network topology graph and deleting the mark to be scanned;
the updating module is used for acquiring updating information of a user on the target network based on a man-machine interaction interface; the update information includes: the user is based on the device address modified by the man-machine interaction interface, the information of the newly added device and the information of the deleted device; and updating the network configuration file according to the updating information, and generating the mark to be scanned.
8. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the method of any one of claims 1 to 6.
9. A readable storage medium for storing a computer program, wherein the computer program when executed by a processor implements the method of any one of claims 1 to 6.
CN202110712154.3A 2021-06-25 2021-06-25 Topology generation method, device, equipment and readable storage medium Active CN113452561B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110712154.3A CN113452561B (en) 2021-06-25 2021-06-25 Topology generation method, device, equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110712154.3A CN113452561B (en) 2021-06-25 2021-06-25 Topology generation method, device, equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN113452561A CN113452561A (en) 2021-09-28
CN113452561B true CN113452561B (en) 2023-05-16

Family

ID=77812868

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110712154.3A Active CN113452561B (en) 2021-06-25 2021-06-25 Topology generation method, device, equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN113452561B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114338410A (en) * 2021-12-09 2022-04-12 海光信息技术股份有限公司 Method, device and system for generating routing path file and related equipment
CN114285718B (en) * 2021-12-28 2024-02-09 北京航天数据股份有限公司 Topology generation method and device, electronic equipment and storage medium
CN114430364A (en) * 2022-01-21 2022-05-03 京东科技信息技术有限公司 Information display method and device, electronic equipment and computer readable medium
CN114520770A (en) * 2022-02-16 2022-05-20 浪潮思科网络科技有限公司 Topological graph generation method, device, equipment and medium for network equipment
CN114615066A (en) * 2022-03-17 2022-06-10 浙江网商银行股份有限公司 Target path determination method and device
CN114915561B (en) * 2022-04-19 2024-02-20 北京宝兰德软件股份有限公司 Network topology graph generation method and device

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4681472B2 (en) * 2006-02-24 2011-05-11 富士通株式会社 Topology information collection program, topology information collection device, and topology information collection method
CN105227383B (en) * 2015-11-06 2018-07-03 广东电网有限责任公司电力科学研究院 A kind of device of network topology investigation
CN105450442B (en) * 2015-11-06 2019-02-15 广东电网有限责任公司电力科学研究院 A kind of network topology investigation method and its system
US10320619B2 (en) * 2016-11-12 2019-06-11 Solana Networks Inc. Method and system for discovery and mapping of a network topology
CN108055207A (en) * 2017-10-26 2018-05-18 北京天元创新科技有限公司 A kind of network topology cognitive method and device
CN111934921B (en) * 2020-07-29 2023-11-07 深信服科技股份有限公司 Network topology discovery method and device, equipment and storage medium

Also Published As

Publication number Publication date
CN113452561A (en) 2021-09-28

Similar Documents

Publication Publication Date Title
CN113452561B (en) Topology generation method, device, equipment and readable storage medium
US6377987B1 (en) Mechanism for determining actual physical topology of network based on gathered configuration information representing true neighboring devices
JP4112492B2 (en) Use of link state information for IP network topology discovery
EP1238515B1 (en) Automatically identifying subnetworks in a network
US8045486B2 (en) Discovery and visualization of active directory domain controllers in topological network maps
US9118587B2 (en) Network multi-path discovery
JP4018638B2 (en) Method for providing topology awareness information in an IP network
EP2316192B1 (en) Incremental and targeted auto-discovery of network devices
US7869349B2 (en) Method and system for deducing network routes by querying routers
US20220200844A1 (en) Data processing method and apparatus, and computer storage medium
CN107733713B (en) Method, system, device and storage medium for acquiring network topology in hybrid network
US8914503B2 (en) Detected IP link and connectivity inference
CN111786857B (en) Network asset active detection method and system based on distribution
CN112953774B (en) Network topology generation method, system, equipment and computer storage medium
CN107465621B (en) Router discovery method, SDN controller, router and network system
CN116545861A (en) Network topology graph generation method, device and equipment
CN107040423B (en) Method and system for discovering network topology
CN116827801B (en) Network topology construction method, device, computer equipment and readable storage medium
CN112866116B (en) Network access detection method, device, equipment and storage medium
CN110730093B (en) Metropolitan area network topology mapping method and device
CN113300880B (en) Ethernet switch topology generation and drawing method based on Tarjan algorithm
CN102075364B (en) Method and equipment for determining direct link
CN114666227A (en) Network topology detection method under non-cooperative condition
CN117176639B (en) Multi-protocol-based network topology automatic discovery method and device
Peng et al. Analysis and research of network topology discovery method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant