Network topology construction method, system and device and computer storage medium
By identifying the device ports and cable positions in the target image, generating a visual connection relationship, and generating a protocol connection relationship through the network protocol, the problem of inaccurate network topology construction in the existing technology is solved, and a more accurate network topology construction is achieved.
Patent Information
- Application Number
- CN202510465082.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-06-20
AI Technical Summary
It is difficult for the prior art to accurately construct network topology, resulting in inaccurate connection between physical layout and logical paths.
By obtaining the target image containing the device and cable, identifying the device port and cable location, generating a visual connection relationship, and generating a protocol connection relationship through the network protocol, and finally data fusion of the two is carried out to build a network topology.
It realizes a more accurate construction of network topology, integrates physical connection relationships and logical connection relationships, and improves the accuracy of network management.
Smart Images

Figure CN120186028A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a network topology construction method, system, device, and computer storage medium. Background Art
[0002] With the development of the network, the number of access devices, transmission devices, hosts, etc. in the network has also increased, and the distribution has become wider and wider. In order to facilitate users to manage the devices, it is necessary to visualize the devices in the network. Network Topology refers to the physical layout (physical topology) of connecting network devices with transmission media, as well as the logical path of data transmission between devices. With the help of network topology, the connection relationship between devices can be clearly reflected, so it is necessary to generate the network topology of the devices.
[0003] For example, the network information of the device can be obtained through the SNMP (Simple Network Management Protocol) protocol, and the network topology can be generated with the help of the obtained network information. However, the SNMP protocol can only obtain the logical neighbor relationship, but the logical neighbor relationship may not match the actual connection relationship, resulting in poor accuracy in constructing the network topology.
[0004] In summary, how to accurately construct the network topology is an urgent problem to be solved by those skilled in the art at present. Summary of the Invention
[0005] The purpose of the present application is to provide a network topology construction method, which can solve the technical problem of how to accurately construct the network topology to a certain extent. The present application also provides a network topology construction system, an electronic device, and a computer-readable storage medium.
[0006] To achieve the above purpose, the present application provides the following technical solutions:
[0007] A network topology construction method includes:
[0008] Obtain a target image including devices and cables;
[0009] Identify the device ports in the target image to obtain device port position information;
[0010] Identify the cable positions in the target image to obtain cable position information;
[0011] Generate a visual connection relationship between devices according to the device port position information and the cable position information;
[0012] Generate a protocol connection relationship between devices through a network protocol;
[0013] Perform data fusion on the visual connection relationship and the protocol connection relationship to generate the network topology of the device.
[0014] In an exemplary embodiment, the identifying the device ports in the target image to obtain device port location information includes:
[0015] Input the target image into a pre-trained detection model;
[0016] Obtain the coordinates of the device port bounding box output by the detection model;
[0017] Use the coordinates of the device port bounding box as the device port location information;
[0018] The identifying the cable positions in the target image to obtain cable position information includes:
[0019] Adjust the pixel values representing the cables in the target image to a first set value to obtain a first processed image;
[0020] Adjust the pixel values representing non-cables in the first processed image to a second set value to obtain a second processed image;
[0021] Convert the second processed image into a matrix to obtain a binary matrix;
[0022] Identify the cables in the binary matrix to obtain a coordinate sequence of the cable centerlines;
[0023] Use the coordinate sequence as the cable position information.
[0024] In an exemplary embodiment, the generating the visual connection relationship between devices according to the device port location information and the cable position information includes:
[0025] Determine the first endpoint coordinates and the second endpoint coordinates of the cable according to the cable position information of the cable;
[0026] For each cable, detect whether the first endpoint coordinates and the second endpoint coordinates are located within the internal area formed by the device port bounding box coordinates;
[0027] In response to the first endpoint coordinates being located within the internal area formed by the device port bounding box coordinates of the first device port and the second endpoint coordinates being located within the internal area formed by the device port bounding box coordinates of the second device port, generate a visual connection relationship indicating the connection between the first device port and the second device port;
[0028] In response to the first endpoint coordinate being outside the internal area formed by the device port bounding box coordinates of the first device port, and / or the second endpoint coordinate being outside the internal area formed by the device port bounding box coordinates of the second device port, a visual connection relationship indicating that the first device port and the second device port are not connected is generated.
[0029] In an exemplary embodiment, generating the protocol connection relationship between devices through a network protocol includes:
[0030] Collecting the connection information between devices through each set network protocol respectively;
[0031] Detecting whether the connection information obtained by all network protocols is consistent;
[0032] If the connection information obtained by all network protocols is consistent, processing the connection information to generate the protocol connection relationship between devices.
[0033] In an exemplary embodiment, performing data fusion on the visual connection relationship and the protocol connection relationship to generate the network topology of the device includes:
[0034] Determining the visual weight corresponding to the visual connection relationship;
[0035] Determining the protocol weight corresponding to the protocol connection relationship;
[0036] Performing vector conversion on the visual connection relationship to obtain a visual feature vector;
[0037] Performing vector conversion on the protocol connection relationship to obtain a protocol feature vector;
[0038] Performing weighted processing on the visual feature vector and the protocol feature vector according to the visual weight and the protocol weight to obtain a target feature vector;
[0039] Performing conversion on the target feature vector to obtain the network topology of the device.
[0040] In an exemplary embodiment, after performing data fusion on the visual connection relationship and the protocol connection relationship to generate the network topology of the device, it further includes:
[0041] Verifying the network topology to obtain the incorrect connection relationships in the network topology;
[0042] Comparing the incorrect connection relationships with the visual connection relationship and the protocol connection relationship;
[0043] In response to the incorrect connection relationship belonging to the visual connection relationship, adjusting the visual weight;
[0044] In response to the error connection relationship belonging to the protocol connection relationship, the protocol weight is adjusted.
[0045] In an exemplary embodiment, adjusting a target weight, where the target weight is the visual weight or the protocol weight, includes:
[0046] Concatenating the visual feature vector and the protocol feature vector to obtain a concatenated feature vector;
[0047] Obtaining a trainable weight matrix;
[0048] Performing normalization processing on the concatenated feature vector based on the trainable weight matrix to obtain the adjusted target weight.
[0049] A network topology construction system includes:
[0050] A first acquisition module, configured to acquire a target image including devices and cables;
[0051] A first recognition module, configured to recognize device ports in the target image to obtain device port position information;
[0052] A second recognition module, configured to recognize cable positions in the target image to obtain cable position information;
[0053] A first generation module, configured to generate a visual connection relationship between devices according to the device port position information and the cable position information;
[0054] A second generation module, configured to generate a protocol connection relationship between devices through a network protocol;
[0055] A first fusion module, configured to perform data fusion on the visual connection relationship and the protocol connection relationship to generate a network topology of the devices.
[0056] An electronic device includes:
[0057] A memory, configured to store a computer program;
[0058] A processor, configured to implement the steps of any of the above network topology construction methods when executing the computer program.
[0059] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above network topology construction methods are implemented.
[0060] A network topology construction method provided by the present application includes: obtaining a target image containing devices and cables; identifying device ports in the target image to obtain device port location information; identifying cable locations in the target image to obtain cable location information; generating a visual connection relationship between devices according to the device port location information and the cable location information; generating a protocol connection relationship between devices through network protocols; performing data fusion on the visual connection relationship and the protocol connection relationship to generate a network topology of the devices. In the present application, since the target image contains cables and devices, the target image can be processed to obtain device port location information and cable location information. If the device ports are connected by cables, there is an association between the device port location information and the cable location information. Therefore, a visual connection relationship reflecting the physical connection relationship between devices can be generated according to the device port location information and the cable location information. And if the devices are interconnected, there is an association between the network protocols. Therefore, a protocol connection relationship reflecting the logical connection relationship between devices can be generated through network protocols. After that, only by performing data fusion on the visual connection relationship and the protocol connection relationship, the physical connection relationship and the logical connection relationship can be fused, so as to generate the network topology of the devices by integrating the physical connection and the logical connection between devices. Compared with generating the network topology only by applying network protocols, the network topology can be constructed more accurately by leveraging the complementarity between the logical connection relationship and the physical connection relationship. A network topology construction system, an electronic device, and a computer-readable storage medium provided by the present application also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained according to the provided drawings.
[0062] Figure 1 It is a flowchart of a network topology construction method provided by an embodiment of the present application;
[0063] Figure 2 It is a schematic structural diagram of a network topology construction system provided by an embodiment of the present application;
[0064] Figure 3 It is a system framework diagram for computer room deployment;
[0065] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0066] Figure 5 It is another schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0067] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0068] Please refer to Figure 1 , Figure 1 , which is a flowchart of a network topology construction method provided by an embodiment of the present application.
[0069] A network topology construction method provided by an embodiment of the present application may include the following steps:
[0070] Step S101: Obtain a target image including devices and cables.
[0071] In practical applications, a target image including devices and cables may be obtained first, so as to analyze the target image subsequently to obtain the physical connection relationship between the devices.
[0072] In a specific application scenario, an image acquisition device such as a camera may be used to collect the devices and cables for network topology construction, so as to obtain a target image including the devices and the cables connected to the devices. It should be noted that when the devices for network topology construction can be collected at one time, for example, when the devices are concentrated in a computer room, the devices and cables can be recorded by one image. When the devices for network topology construction cannot be collected at one time, for example, when the devices are distributed in multiple places, multiple images may be used to record the devices and cables.
[0073] Step S102: Identify the device ports in the target image to obtain device port location information.
[0074] Step S103: Identify the cable positions in the target image to obtain cable position information.
[0075] Step S104: Generate a visual connection relationship between the devices according to the device port location information and the cable position information.
[0076] In practical applications, since the devices in the target image are interconnected through device ports and cables, the device ports in the target image can be recognized to obtain the device port position information; the cable positions in the target image can be recognized to obtain the cable position information, and the device port position information and the cable position information need to be determined based on the same coordinate system, such as being determined based on the coordinate system corresponding to the target image, etc., so as to directly analyze the physical connection relationship between devices according to the device port position information and the cable position information in the follow-up, that is, the visual connection relationship reflecting the physical connection relationship between devices can be generated according to the device port position information and the cable position information. It should be noted that since this physical connection relationship is obtained by analyzing the target image, and the target image is obtained based on machine vision, it is called the visual connection relationship; in addition, the OCR (Optical Character Recognition) technology can also be used to recognize the label information on the device to obtain identification information such as device names and IPs for the construction of the network topology, which is not specifically limited in this application.
[0077] In a specific application scenario, in the process of recognizing the device ports in the target image to obtain the device port position information, a pre-trained neural network model can be used, that is, the target image can be input into a pre-trained detection model, and this detection model can be the YOLOV8 model, etc.; obtain the coordinates of the device port bounding box output by the detection model. Assume that the coordinates of the device port bounding box are represented by B port , then it can be expressed as B port =(x min ,y min ,x max ,y max ); regard the coordinates of the device port bounding box as the device port position information.
[0078] In a specific application scenario, in the process of recognizing the cable positions in the target image to obtain the cable position information, the cables in the target image can be segmented to obtain a binary image, and then the binary image can be recognized to obtain the cable position information.
[0079] Specifically, the cables in the target image can be extracted through a pre-trained segmentation model. For example, the cables in the target image can be extracted through a pre-trained U-Net segmentation model to obtain a cable segmentation mask image in the form of a binary matrix; then the skeletonization algorithm is applied to process the cable segmentation mask image to obtain the coordinate sequence of the cable center line, and regard the coordinate sequence of the cable center line as the cable position information, that is, Skeleton(Mcable)→Polyline={p1,p2,...,p n}, Skeleton represents the skeletonization algorithm, Mcable represents the cable segmentation mask image, Polyline represents the coordinate sequence of the cable centerline, and p n represents the nth coordinate. Of course, the pixel values representing the cable in the target image can also be adjusted to the first set value to obtain the first processed image; then, the pixel values representing non-cables in the first processed image are adjusted to the second set value to obtain the second processed image; the second processed image is converted into a matrix to obtain a binary matrix; the cables in the binary matrix are identified, for example, the binary matrix is also processed by the skeletonization algorithm to obtain the coordinate sequence of the cable centerline; the coordinate sequence is used as the cable position information.
[0080] In a specific application scenario, in the process of generating the visual connection relationship between devices according to the device port position information and the cable position information, the first endpoint coordinate and the second endpoint coordinate of the cable can be determined according to the cable position information, that is, the coordinates at both ends of the cable are determined; for each cable, it is detected whether the first endpoint coordinate and the second endpoint coordinate are located in the internal area formed by the device port bounding box coordinates; in response to the first endpoint coordinate being located in the internal area formed by the device port bounding box coordinates of the first device port, the relationship that the first endpoint of the cable is connected to the first device port is obtained, and in response to the first endpoint coordinate being located outside the internal area formed by the device port bounding box coordinates of the first device port, the relationship that the first endpoint of the cable is not connected to the first device port is obtained; in response to the second endpoint coordinate being located in the internal area formed by the device port bounding box coordinates of the second device port, the relationship that the second endpoint of the cable is connected to the second device port is obtained, and in response to the second endpoint coordinate being located outside the internal area formed by the device port bounding box coordinates of the second device port, the relationship that the second endpoint of the cable is not connected to the second device port is obtained; further, when the first endpoint of the cable is connected to the first device port and the second endpoint of the cable is connected to the second device port, that is, in response to the first endpoint coordinate being located in the internal area formed by the device port bounding box coordinates of the first device port and the second endpoint coordinate being located in the internal area formed by the device port bounding box coordinates of the second device port, a visual connection relationship representing the connection between the first device port and the second device port can be generated; when the first endpoint of the cable is not connected to the first device port and the second endpoint of the cable is not connected to the second device port, that is, in response to the first endpoint coordinate being located outside the internal area formed by the device port bounding box coordinates of the first device port and / or the second endpoint coordinate being located outside the internal area formed by the device port bounding box coordinates of the second device port, a visual connection relationship representing the disconnection between the first device port and the second device port is generated. For the sake of understanding, assume that the device ports are represented by A and B, and the connection relationship is represented by 1 when the device port A is connected to the device port B. Then:
[0081] 。
[0082] From the implementation process, it can be seen that in this application, the coordinates of the device port bounding box are used as the device port location information, and the coordinate sequence of the cable center line is used as the cable location information. In this way, when the first endpoint coordinate is within the internal area formed by the device port bounding box coordinates of the first device port, and the second endpoint coordinate is within the internal area formed by the device port bounding box coordinates of the second device port, a visual connection relationship representing the connection between the first device port and the second device port can be generated; when the first endpoint coordinate is outside the internal area formed by the device port bounding box coordinates of the first device port, and / or the second endpoint coordinate is outside the internal area formed by the device port bounding box coordinates of the second device port, a visual connection relationship representing that the first device port and the second device port are not connected can be generated. It realizes the rapid detection and generation of the visual connection relationship by detecting the positional relationship between the coordinate sequence and the device port bounding box coordinates, and improves the efficiency of converting the image into the visual connection relationship.
[0083] Step S105: Generate a protocol connection relationship between devices through a network protocol.
[0084] In practical applications, if devices are connected, there is also network interaction between the devices. Therefore, a protocol connection relationship reflecting the logical connection relationship between the devices can also be generated through a network protocol. It should be noted that since the logical connection relationship is obtained through network protocol analysis, it is called a protocol connection relationship.
[0085] In a specific application scenario, considering that the protocol connection relationship generated by means of a single network protocol may not be accurate, to avoid this situation, a protocol connection relationship can be generated through multiple network protocols. That is, in the process of generating a protocol connection relationship between devices through a network protocol, the connection information between the devices can be collected respectively through each set network protocol. The set network protocols can include the SNMP protocol, the SSH (Secure Shell) protocol, the LLDP (Link Layer Discovery Protocol) protocol, the Telnet (Remote Terminal Protocol) protocol, the SFlow protocol, the NetFlow protocol, etc.; detect whether the connection information obtained by all network protocols is consistent; if the connection information obtained by all network protocols is consistent, process the connection information to generate a protocol connection relationship between the devices. Of course, when there are differences in the connection information obtained by all network protocols, the connection information with the most information can be selected to generate a protocol connection relationship between the devices.
[0086] It should be noted that the protocol connection relationship can include port status information and device adjacency information. For example, the port status information can be represented as Sport =[s1, s2,..., s n , s k ∈ {0, 1} (0: down, 1: up), S port represents the port status information, s k represents the status of the k-th port. The device adjacency information can be expressed as:
[0087] ;
[0088] where C(i, j) represents the adjacency relationship between device i and device j, 1 indicates the existence of the adjacency relationship, and 0 indicates the non-existence of the adjacency relationship.
[0089] Step S106: Perform data fusion on the visual connection relationship and the protocol connection relationship to generate the network topology of the device.
[0090] In practical applications, after obtaining the visual connection relationship and the protocol connection relationship, the physical connection relationship and the logical connection relationship between devices are obtained. Since the physical connection and the logical connection of the device are consistent when the devices are actually connected, the physical connection relationship and the logical connection relationship can be fused to generate the network topology of the device, that is, the visual connection relationship and the protocol connection relationship can be subjected to data fusion to generate the network topology of the device. It should be noted that when the cable connection relationship between devices changes or the protocol changes, the solution of this application can be re-executed to update the network topology. Of course, the solution of this application can also be executed regularly to update the network topology to ensure the accuracy of the network topology.
[0091] In a specific application scenario, in the process of performing data fusion on the visual connection relationship and the protocol connection relationship to generate the network topology of the device, the visual weight corresponding to the visual connection relationship can be determined; the protocol weight corresponding to the protocol connection relationship can be determined. The sum of the protocol weight and the visual weight is 1, but their specific values can be flexibly determined according to the application scenario; the visual connection relationship is subjected to vector conversion to obtain a visual feature vector; the protocol connection relationship is subjected to vector conversion to obtain a protocol feature vector; according to the visual weight and the protocol weight, the visual feature vector and the protocol feature vector are weighted to obtain a target feature vector. Assuming that the visual weight is represented by α img is represented, the protocol weight is represented by α proto is represented, the visual feature vector is represented by F img is represented, the protocol feature vector is represented by F proto is represented, and the target feature vector is represented by F fusion is represented, then the generation process of the target feature vector can be expressed as F fusion = α img ⋅ F img + α proto ⋅ F proto; Transform the target feature vector to obtain the network topology of the device. That is, the visual connection relationship can be transformed into a visual feature vector and the protocol connection relationship can be transformed into a protocol feature vector by means of vector transformation. In this way, subsequent data fusion of the visual connection relationship and the protocol connection relationship can be quickly performed by means of vector operations. Moreover, during the fusion process, the visual weight corresponding to the visual connection relationship and the protocol weight corresponding to the protocol connection relationship are combined, so that the data fusion process can be more adapted to the connection relationship, ensuring the accuracy of the generation of the target feature vector. Furthermore, on the premise of ensuring the accuracy of the generation of the network topology, the generation efficiency of the network topology is improved.
[0092] In a specific application scenario, when there is an error in the generated network topology, it indicates that there is an error in the physical connection relationship or the logical connection relationship. Then, the data fusion process needs to be adjusted accordingly to ensure the accuracy of the generation of the network topology. That is, after performing data fusion on the visual connection relationship and the protocol connection relationship to generate the network topology of the device, the network topology can also be verified to obtain the incorrect connection relationship in the network topology; compare the incorrect connection relationship with the visual connection relationship and the protocol connection relationship; in response to the incorrect connection relationship belonging to the visual connection relationship, adjust the visual weight; in response to the incorrect connection relationship belonging to the protocol connection relationship, adjust the protocol weight.
[0093] In a specific application scenario, during the process of adjusting the target weight, where the target weight is the visual weight or the protocol weight, that is, during the process of adjusting the visual weight or the protocol weight, the visual feature vector and the protocol feature vector can be concatenated to obtain a concatenated feature vector; obtain a trainable weight matrix, where the trainable matrix is used to learn the importance of the visual connection relationship and the protocol connection relationship; perform normalization processing on the concatenated feature vector based on the trainable weight matrix to obtain the adjusted target weight. Suppose the trainable weight matrix is represented by Wa, the normalization is represented by Softmax, and the target weight is represented by α v , then the adjustment process of the target weight can be expressed as: α v =Softmax(Wa[F img ||F proto +ba), || represents concatenation; ba represents a bias term, which is used to enhance the flexibility of the adjustment process, and its value can be determined flexibly according to needs.
[0094] In practical applications, during the process of fusing data of visual connection relationships and protocol connection relationships to generate the network topology of a device, the device identification information parsed from the target image and information such as the device name and IP obtained through the protocol can be used to align the visual connection relationships and protocol connection relationships, so that data such as device positions and connection information are matched; then, data fusion is performed on the aligned visual connection relationships and protocol connection relationships to obtain the target connection relationships; the target connection relationships are converted to obtain the target data required for the user to draw the network topology; finally, the target data is rendered to obtain the network topology diagram. In this way, the visual connection relationships and protocol connection relationships can be aligned by means of the target image parsing results and data obtained through the protocol, so that data such as device positions and connection information of the visual connection relationships and protocol connection relationships are matched, avoiding the process of disorderly searching for connection information related to the same device from the visual connection relationships and protocol connection relationships, reducing the difficulty of data fusion of the visual connection relationships and protocol connection relationships, and improving the implementation efficiency of the solution.
[0095] A network topology construction method provided by this application includes: obtaining a target image including devices and cables; identifying the device ports in the target image to obtain device port location information; identifying the cable positions in the target image to obtain cable position information; generating visual connection relationships between devices according to the device port location information and the cable position information; generating protocol connection relationships between devices through network protocols; and performing data fusion on the visual connection relationships and the protocol connection relationships to generate the network topology of the device. In this application, since the target image includes cables and devices, the target image can be processed to obtain device port location information and cable position information. If the device ports are connected by cables, there is an association between the device port location information and the cable position information. Therefore, visual connection relationships reflecting the physical connection relationships between devices can be generated according to the device port location information and the cable position information; and if the devices are interconnected, there is an association between the network protocols. Therefore, protocol connection relationships reflecting the logical connection relationships between devices can be generated through network protocols; then, only by performing data fusion on the visual connection relationships and the protocol connection relationships, the physical connection relationships and the logical connection relationships can be fused, so as to generate the network topology of the device by integrating the physical connection and the logical connection between devices. Compared with generating the network topology only by applying network protocols, the network topology can be constructed more accurately by means of the complementarity between the logical connection relationships and the physical connection relationships.
[0096] Please refer to Figure 2 , Figure 2 which is a schematic structural diagram of a network topology construction system provided by an embodiment of this application.
[0097] A network topology construction system provided by an embodiment of this application may include:
[0098] The first acquisition module 101 is configured to acquire a target image including devices and cables;
[0099] The first recognition module 102 is configured to recognize the device ports in the target image to obtain device port position information;
[0100] The second recognition module 103 is configured to recognize the cable positions in the target image to obtain cable position information;
[0101] The first generation module 104 is configured to generate a visual connection relationship between devices according to the device port position information and the cable position information;
[0102] The second generation module 105 is configured to generate a protocol connection relationship between devices through a network protocol;
[0103] The first fusion module 106 is configured to perform data fusion on the visual connection relationship and the protocol connection relationship to generate a network topology of the devices.
[0104] For a network topology construction system provided by an embodiment of the present application, the first recognition module may include:
[0105] The first input unit is configured to input the target image into a pre-trained detection model;
[0106] The first acquisition unit is configured to acquire the coordinates of the device port bounding box output by the detection model;
[0107] The first setting unit is configured to use the coordinates of the device port bounding box as the device port position information;
[0108] The second recognition module may include:
[0109] The first adjustment unit is configured to adjust the pixel values representing the cables in the target image to a first set value to obtain a first processed image;
[0110] The second adjustment unit is configured to adjust the pixel values representing non-cables in the first processed image to a second set value to obtain a second processed image;
[0111] The first conversion unit is configured to convert the second processed image into a matrix to obtain a binary matrix;
[0112] The first recognition unit is configured to recognize the cables in the binary matrix to obtain a coordinate sequence of the cable center line;
[0113] The second setting unit is configured to use the coordinate sequence as the cable position information.
[0114] For a network topology construction system provided by an embodiment of the present application, the first generation module may include:
[0115] A first determination unit, configured to determine a first endpoint coordinate and a second endpoint coordinate of a cable according to the cable position information of the cable;
[0116] A first detection unit, configured to detect, for each cable, whether the first endpoint coordinate and the second endpoint coordinate are located within the internal area formed by the device port bounding box coordinates;
[0117] A first generation unit, configured to generate a visual connection relationship representing the connection between the first device port and the second device port in response to the first endpoint coordinate being located within the internal area formed by the device port bounding box coordinates of the first device port and the second endpoint coordinate being located within the internal area formed by the device port bounding box coordinates of the second device port;
[0118] A second generation unit, configured to generate a visual connection relationship representing that the first device port and the second device port are not connected in response to the first endpoint coordinate being located outside the internal area formed by the device port bounding box coordinates of the first device port, and / or the second endpoint coordinate being located outside the internal area formed by the device port bounding box coordinates of the second device port.
[0119] For a network topology construction system provided by an embodiment of the present application, the second generation module may include:
[0120] A first acquisition unit, configured to respectively acquire the connection information between devices through each set network protocol;
[0121] A second detection unit, configured to detect whether the connection information obtained by all network protocols is consistent; if the connection information obtained by all network protocols is consistent, process the connection information to generate a protocol connection relationship between devices.
[0122] For a network topology construction system provided by an embodiment of the present application, the first fusion module may include:
[0123] A second determination unit, configured to determine the visual weight corresponding to the visual connection relationship;
[0124] A third determination unit, configured to determine the protocol weight corresponding to the protocol connection relationship;
[0125] A second conversion unit, configured to perform vector conversion on the visual connection relationship to obtain a visual feature vector;
[0126] A third conversion unit, configured to perform vector conversion on the protocol connection relationship to obtain a protocol feature vector;
[0127] A first processing unit, configured to perform weighted processing on the visual feature vector and the protocol feature vector according to the visual weight and the protocol weight to obtain a target feature vector;
[0128] A third setting unit, configured to convert the target feature vector to obtain the network topology of the device.
[0129] A network topology construction system provided by an embodiment of the present application further includes:
[0130] A first verification module, configured to, after a first fusion module fuses visual connection relationships and protocol connection relationships to generate the network topology of the device, verify the network topology to obtain incorrect connection relationships in the network topology;
[0131] A first comparison module, configured to compare the incorrect connection relationships with the visual connection relationships and protocol connection relationships; in response to the incorrect connection relationship belonging to the visual connection relationship, adjust the visual weight; in response to the incorrect connection relationship belonging to the protocol connection relationship, adjust the protocol weight.
[0132] In a network topology construction system provided by an embodiment of the present application, the first comparison module may include:
[0133] A weight adjustment unit, configured to adjust a target weight, where the target weight is a visual weight or a protocol weight; and specifically, the weight adjustment unit is configured to splice a visual feature vector and a protocol feature vector to obtain a spliced feature vector, obtain a trainable weight matrix, and perform normalization processing on the spliced feature vector based on the trainable weight matrix to obtain the adjusted target weight.
[0134] To facilitate understanding of the network topology construction solution provided by the present application, the solution of the present application is described below by taking a computer room as an example. The system framework deployed in the computer room may be as Figure 3 shown, and the generation process may be as follows;
[0135] A visual feature module collects computer room visual images through computer room cameras, identifies device ports in the computer room visual images to obtain device port location information, and identifies cable locations in the computer room visual images to obtain cable location information; according to the device port location information and the cable location information, generate visual connection relationships between devices.
[0136] A multi-protocol adaptation module generates protocol connection relationships between devices through network protocols.
[0137] A multi-modal fusion module performs data fusion on the visual connection relationships and protocol connection relationships to obtain target connection relationships.
[0138] A network topology drawing module converts the machine location information and port interconnection information between machines in the target connection relationships into a data format required for drawing; uses front-end technologies such as the D3.js library to render the converted data into a network topology diagram.
[0139] Among them, the machine information in the data format may include:
[0140] {"nodeId": 84, / / Machine ID;
[0141] "name": "test router", / / Machine name;
[0142] "category": "31", / / Machine type (server / switch / router);
[0143] "vendor": null, / / Manufacturer;
[0144] "model": null, / / Model;
[0145] "serial": null, / / Serial number;
[0146] "ip": null, / / IP address;
[0147] "mac": null, / / MAC address;
[0148] "x": -785.1041870117188, / / X-axis coordinate converted from the machine room location;
[0149] "y": -228.26390075683594 / / Y-axis coordinate converted from the machine room location.}
[0150] The link relationship can include:
[0151] {"status": "up", / / Link status;
[0152] "srcNodeId": 74, / / Source machine ID;
[0153] "srcCategory": null, / / Source machine type (server / switch / router);
[0154] "srcName": null, / / Source machine name;
[0155] "srcPort": null, / / Source machine port;
[0156] "targetNodeId": 84, / / Destination machine ID;
[0157] "targetCategory": null, / / Destination machine type (server / switch / router);
[0158] "targetName": null, / / Destination machine name;
[0159] "targetPort": null, / / Destination machine port;
[0160] "receiveSpeed": null, / / Receive rate;
[0161] "sendspeed": null, / / Transmission rate;
[0162] "bandUsage": null, / / Bandwidth utilization rate;
[0163] "maxBand": null / / Maximum bandwidth}
[0164] The link connection or machine position in the computer room is monitored in real time through a camera. If any change is detected, the topology is refreshed in real time, that is, the visual connection relationship and protocol connection relationship are re-obtained to generate the latest network topology diagram. At the same time, the protocol data is updated regularly. If any change is detected or a conflict between visual data and network data is found, the network topology is also updated to avoid the problem of inaccurate topology diagrams caused by the change of network protocol status while the physical facilities remain unchanged for a long time.
[0165] This application also provides an electronic device and a computer-readable storage medium, both of which have the corresponding effects of a network topology construction method provided by an embodiment of this application. Please refer to Figure 4 , Figure 4 which is a schematic structural diagram of an electronic device provided by an embodiment of this application.
[0166] An electronic device provided by an embodiment of this application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the steps of the network topology construction method described in any of the above embodiments are implemented.
[0167] Please refer to Figure 5, another electronic device provided by an embodiment of the present application may further include: an input port 203 connected to the processor 202, configured to transmit an externally input command to the processor 202; a display unit 204 connected to the processor 202, configured to display the processing result of the processor 202 to the outside; a communication module 205 connected to the processor 202, configured to implement communication between the electronic device and the outside. The display unit 204 may be a display panel, a laser scanning display, etc.; the communication methods adopted by the communication module 205 include but are not limited to Mobile High-Definition Link (MHL), Universal Serial Bus (USB), High-Definition Multimedia Interface (HDMI), wireless connection: Wireless Fidelity (WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, communication technology based on IEEE802.11s.
[0168] A computer-readable storage medium provided by an embodiment of the present application stores a computer program, and when the computer program is executed by a processor, it implements the steps of the network topology construction method described in any one of the above embodiments.
[0169] The computer-readable storage medium involved in the present application includes Random Access Memory (RAM), memory, Read-Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium well-known in the technical field.
[0170] A computer program product provided by an embodiment of the present application includes a computer program / instructions, and when the computer program / instructions are executed by a processor, it implements the steps of the network topology construction method described in any one of the above embodiments.
[0171] For the descriptions of relevant parts in a network topology construction system, an electronic device, a computer program product, and a computer-readable storage medium provided by an embodiment of the present application, please refer to the detailed descriptions of the corresponding parts in a network topology construction method provided by an embodiment of the present application, which will not be elaborated here. In addition, for the parts of the above technical solutions provided by the embodiments of the present application that are consistent with the corresponding technical solutions in the prior art in terms of implementation principles, no detailed description is given to avoid excessive elaboration.
[0172] It should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0173] The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A network topology construction method, characterized in that: include: Get the target image including the equipment and cables; Identifying the device port in the target image to obtain device port location information; Identifying the cable position in the target image to obtain cable position information; Generating a visual connection relationship between devices according to the device port location information and the cable location information; Generate protocol connection relationship between devices through network protocol; Data fusion is performed on the visual connection relationship and the protocol connection relationship to generate a network topology of the device.
2. The network topology construction method according to claim 1, characterized in that: The step of identifying the device port in the target image to obtain the device port location information includes: Inputting the target image into a pre-trained detection model; Obtaining the device port bounding box coordinates output by the detection model; Using the device port boundary box coordinates as device port location information; The identifying the cable position in the target image to obtain the cable position information includes: Adjusting the pixel value representing the cable in the target image to a first set value to obtain a first processed image; Adjusting the pixel values representing non-cables in the first processed image to a second set value to obtain a second processed image; Converting the second processed image into a matrix to obtain a binary matrix; Identifying the cables in the binary matrix to obtain a coordinate sequence of the cable center lines; The coordinate sequence is used as the cable position information.
3. The network topology construction method according to claim 2, characterized in that: The generating a visual connection relationship between devices according to the device port location information and the cable location information includes: Determining the first endpoint coordinates and the second endpoint coordinates of the cable according to the cable position information of the cable; For each cable, detecting whether the first endpoint coordinates and the second endpoint coordinates are located within an internal area formed by the device port boundary box coordinates; In response to the first endpoint coordinates being located within the inner region formed by the device port bounding box coordinates of the first device port, and the second endpoint coordinates being located within the inner region formed by the device port bounding box coordinates of the second device port, generating a visual connection relationship representing the connection between the first device port and the second device port; In response to the first endpoint coordinates being outside the internal area formed by the device port bounding box coordinates of the first device port, and / or the second endpoint coordinates being outside the internal area formed by the device port bounding box coordinates of the second device port, a visual connection relationship is generated indicating that the first device port and the second device port are not connected.
4. The network topology construction method according to claim 1, characterized in that: The generating of a protocol connection relationship between devices through a network protocol includes: Through each set network protocol, the connection information between devices is collected separately; Detecting whether the connection information obtained by all network protocols is consistent; If the connection information obtained by all network protocols is consistent, the connection information is processed to generate a protocol connection relationship between devices.
5. The network topology construction method according to claim 1, characterized in that: The step of fusing the visual connection relationship and the protocol connection relationship to generate a network topology of the device includes: Determining a visual weight corresponding to the visual connection relationship; Determining a protocol weight corresponding to the protocol connection relationship; Performing vector conversion on the visual connection relationship to obtain a visual feature vector; Performing vector conversion on the protocol connection relationship to obtain a protocol feature vector; According to the visual weight and the protocol weight, weighted processing is performed on the visual feature vector and the protocol feature vector to obtain a target feature vector; The target feature vector is transformed to obtain a network topology of the device.
6. The network topology construction method according to claim 5, characterized in that: After fusing the visual connection relationship and the protocol connection relationship to generate a network topology of the device, the method further includes: Verifying the network topology to obtain an erroneous connection relationship in the network topology; comparing the erroneous connection relationship with the visual connection relationship and the protocol connection relationship; In response to the erroneous connection relationship belonging to the visual connection relationship, adjusting the visual weight; In response to the erroneous connection relationship belonging to the protocol connection relationship, the protocol weight is adjusted.
7. The network topology construction method according to claim 6, characterized in that: Adjusting a target weight, where the target weight is the visual weight or the protocol weight, includes: splicing the visual feature vector and the protocol feature vector to obtain a spliced feature vector; Get the trainable weight matrix; The concatenated feature vector is normalized based on the trainable weight matrix to obtain an adjusted target weight.
8. A network topology construction system, characterized in that: include: A first acquisition module, used to acquire a target image including equipment and cables; A first recognition module, used to recognize the device port in the target image and obtain the device port position information; A second recognition module is used to recognize the cable position in the target image to obtain the cable position information; A first generating module, used for generating a visual connection relationship between devices according to the device port location information and the cable location information; A second generating module is used to generate a protocol connection relationship between devices through a network protocol; The first fusion module is used to perform data fusion on the visual connection relationship and the protocol connection relationship to generate a network topology of the device.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the network topology construction method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the network topology construction method according to any one of claims 1 to 7 are implemented.