A Method and System for Changing the Network Relationship of Computing Nodes in a Network Range

By incrementally modifying the node network relationship of topological instances in the network shooting range, the problems of poor performance and resource waste in the existing technology are solved, and efficient topological instance adjustment and resource management are achieved.

CN119583365BActive Publication Date: 2025-06-27SAINING WANGAN
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510112108.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-06-27
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

The method of computing changes in network relationships in existing network shooting ranges has poor performance, requiring the recycling and recreation of all virtual machines and network resources, resulting in waste of resources and time-consuming.

Method used

By sorting and traversing the nodes in the topological instance, node network relationships are generated, including derivative networks and access networks, node changes are compared before and after modification, invalid relationships are cleaned up, network identification data with incremental modifications, node network relationships are regenerated, new and deleted networks are determined, and incremental modifications are made.

Benefits of technology

Incremental modification of the built topology is realized, performance is improved, unnecessary resource recycling and reconstruction is avoided, and resource usage and operation time during the modification process is optimized.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119583365B_ABST
    Figure CN119583365B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for changing the network relationship of computing nodes in a network range. The method includes: generating node network relationships for the topology instance before modification, including the derived network information and access network information of the nodes; comparing the changes in nodes and ports before and after modification, and cleaning up invalid node network relationships; based on the network identification data of the node ports in the topology instance after modification, and all the derived network sets generated from the topology instance before modification, generating the derived network information and access network information of the nodes in the topology instance after modification; for the topology instance after modification, re-executing the node network relationship generation process to supplement the newly added node network relationships; determining the networks to be deleted and added by comparing all the node-derived network sets before and after the modification of the topology instance; and making incremental modifications to the network resources and virtual machine resources according to the new node network relationships. The present invention greatly improves the performance of modifying the running topology instance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and system for changing the network relationship of computing nodes in a network range, belonging to the technical fields of computer software and network security. Background Art

[0002] A network range is a simulation of a real network environment based on virtualization technology, and serves as a platform to support network space security technology verification, attack and defense confrontation drills, and network risk assessment.

[0003] After a certain topology instance in the range is constructed, sometimes it is necessary to adjust the node and connection relationships of this topology. Usually, this topology instance needs to be shut down, which will cause all resources such as virtual machines, networks, routers, etc. created by this topology instance to be recycled. Then, the topology template is edited to adjust the node and connection relationships. Then, a topology instance is rebuilt according to the topology template.

[0004] The existing network relationship change processing solutions have the following problems: 1. Poor performance. If an already constructed topology instance is adjusted, all resources such as virtual machines, networks, routers, etc. created are recycled, and then a global reconstruction is completed again. This process consumes a large amount of CPU, memory, and disk, involves a large number of disk I / O operations, consumes a large amount of system resources, and is also very time-consuming. 2. For topology instance modification, if it involves reconstructing (recycling and then recreating) virtual machines, since the reconstruction will recycle disk resources, all the virtual machine data generated before the reconstruction will be lost. Summary of the Invention

[0005] Object of the Invention: Aiming at the problems existing in the above-mentioned prior art, the object of the present invention is to provide a method and system for changing the network relationship of computing nodes in a network range, which can calculate the changes in the node network relationship after modifying a constructed topology. According to the calculated results of the node network relationship changes, the constructed topology can be incrementally modified to improve the reconstruction performance.

[0006] Technical Solution: To achieve the above object of the invention, the present invention adopts the following technical solutions:

[0007] In the first aspect, the present invention provides a method for changing the network relationship of computing nodes in a network range, including the following steps:

[0008] Sort the nodes in the topology instance before modification, and traverse the node set to generate the node network relationship, including the derived network information and access network information of the nodes; wherein the derived network is the network generated when traversing the node and its ports, and neither the port of the node nor the peer port is added to the network; the access network is the network added by the peer port when traversing the node and its ports.

[0009] Compare the changes in nodes and the connection ports of node connections before and after modifying the topology instance, and clean up invalid node network relationships;

[0010] Based on the network identification data of the node ports in the modified topology instance and all the derived network sets generated from the topology instance before modification, generate the derived network information and access network information of the nodes in the modified topology instance;

[0011] For the modified topology instance, re-execute the node network relationship generation process to supplement the newly added node network relationships;

[0012] By comparing all the node-derived network sets before and after modifying the topology instance, determine the networks that need to be deleted and added;

[0013] According to the new node network relationships, perform incremental modifications to the network resources and virtual machine resources.

[0014] Further, the sorting of the nodes in the topology instance before modification and traversing the node set to generate node network relationships includes:

[0015] Sort the nodes according to the node type, and sort the nodes of the same type according to the node identifier to obtain a node set; the sorting of node types is in the order of switch, router, and terminal;

[0016] Maintain a global port and network mapping relationship to record the network information corresponding to each port, traverse the node set, and for each node, execute:

[0017] Initialize a default network to serve as the derived network of the current non-router type node; traverse all the connection ports of the current node, and for each port, execute: Determine whether the port exists in the mapping relationship: If it exists, obtain the target network corresponding to the current port. If neither the access network nor the derived network of the current node contains the obtained target network, add the obtained target network to the access network of the current node, otherwise end the processing of the current port; If it does not exist, different processing is performed according to the node type: For a terminal or switch node, set the node identifier of the default network to the identifier of the current node, update the port and network mapping relationship, add the mapping of the current port and the peer port of the connection where the current port is located to the default network, and add the two ports to the connection port pair of the default network; If neither the access network nor the derived network of the current node contains the default network, add the default network to the derived network of the current node; For a router node, initialize a new network to serve as the derived network of each port of the current router node; set the node identifier of the new network to the identifier of the current node, update the port and network mapping relationship, add the mapping of the current port and the peer port of the connection where the current port is located to the new network, and add the two ports to the connection port pair of the new network; If neither the access network nor the derived network of the current node contains the new network, add the new network to the derived network of the current node.

[0018] Further, compare the changes in nodes and node connection ports before and after modifying the topology instance, and clean up invalid node network relationships, including:

[0019] Traverse all the nodes in the modified topology instance, and for each node, check whether there is a node with the same node identifier in the topology instance before modification;

[0020] If not, clear the network identifier information of all its ports;

[0021] If it exists, traverse all its ports; for each port, check whether there is a port with the same port identifier in the topology instance before modification. If not, clear the network identifier information of the current port; If it exists, respectively obtain the peer ports before and after modification, and perform the following processing according to different connection states:

[0022] If both connection ports are empty or have the same identifier, the network identifier information of the current port remains unchanged;

[0023] If one of the connection ports is empty, clear the network identifier information of the current port;

[0024] If the two connection port identifiers are different, clear the network identifier information of the current port. If the current node type is a switch, traverse all ports under this node, and for each port and its peer port, clear their network identifier information.

[0025] Further, generating the derived network information and access network information of the nodes in the modified topology instance includes:

[0026] Obtain all the derived network sets corresponding to the topology instance before modification, and maintain a global port and network mapping relationship to record the network information corresponding to each port;

[0027] For each derived network in the derived network set, perform the following: traverse each port of each node in the modified topology instance, process the network identifier information of the port. When the network identifier information is not empty and is the same as the identifier of the current derived network, obtain the peer port, update the connection port pair of the derived network and the port and network mapping relationship according to the peer port situation. When there is a peer port, also add the current derived network to the access network of the node to which the peer port belongs;

[0028] For each derived network in the derived network set, perform the following: according to the node identifier recorded in the current derived network, obtain the corresponding node information. If the connection port pair of the derived network is not empty, add the current derived network to the derived network sequence of the obtained node.

[0029] Further, determining the networks to be deleted and added by comparing all the node-derived network sets before and after modifying the topology instance includes:

[0030] Load all the derived network sets corresponding to the topology instance before modification into the first set;

[0031] Traverse each node in the modified topology instance, and add all the derived networks of each node to the second set;

[0032] Traverse the first set, and determine whether each derived network exists in the second set. If not, mark the current derived network as the network to be deleted;

[0033] Traverse the second set, and determine whether each derived network exists in the first set. If not, mark the current derived network as the network to be added.

[0034] Further, performing incremental modification on network resources and virtual machine resources includes:

[0035] For the deleted network, directly delete it;

[0036] For the newly added node, directly create it based on the new node network relationship;

[0037] For the deleted nodes, directly delete them;

[0038] For the nodes with network changes, based on the derived network information and access network information before modification, as well as the derived network information and access network information after modification, change the network card access information of the virtual machines of the nodes.

[0039] Furthermore, the data structure for storing node information includes node identification, node type, access network information of the node, derived network information, and port list; each port in the port list includes port identification and network identification; the data structures of the access network and derived network of the node are the same, including network identification, node identification, and connection port pair list.

[0040] In a second aspect, the present invention provides a system for changing the network relationship of computing nodes in a network range, including:

[0041] An old topology node network relationship generation module, configured to sort the nodes in the topology instance before modification, and traverse the node set to generate node network relationships, including the derived network information and access network information of the nodes; the derived network information is the network generated when neither the port of the node nor the peer port joins the network when traversing the node and its ports; the access network information is the network joined by the peer port when traversing the node and its ports;

[0042] A node network relationship change calculation module, configured to compare the changes in nodes and node connection ports before and after the modification of the topology instance, and clean up invalid node network relationships; based on the network identification data of the node ports in the topology instance after modification, and all the derived network sets generated from the topology instance before modification, generate the derived network information and access network information of the nodes in the topology instance after modification; for the topology instance after modification, re-execute the node network relationship generation process to supplement the newly added node network relationships; and determine the networks to be deleted and added by comparing all the node-derived network sets before and after the modification of the topology instance;

[0043] And an incremental modification module, configured to perform incremental modification on network resources and virtual machine resources according to the new node network relationships.

[0044] In a third aspect, the present invention provides a computer system, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the computer program is executed by the processor, the steps of the method for changing the network relationship of computing nodes in a network range are implemented.

[0045] Fourthly, the present invention provides a computer program product, including a computer program which, when executed by a processor, implements the steps of the method for changing the network relationship of computing nodes in a network range.

[0046] Beneficial effects: Compared with the prior art, the method proposed by the present invention can calculate the change of the node network relationship after the constructed topology is modified. According to the calculated result of the node network relationship change, the constructed topology can be incrementally modified without first reclaiming all resources and then re - executing the full construction process. The advantages of incremental modification compared with first globally reclaiming and then reconstructing are as follows: 1. The performance is greatly improved. The construction of the topology involves a large number of operations on the network, CPU, memory, and disk. Supporting incremental modification of the constructed topology can greatly optimize the unnecessary network, CPU, memory, and disk resource occupation and operations during the modification process. 2. For the nodes that still exist before and after the topology modification, the incremental modification will not reclaim their disk resources, and the disk data generated before the topology modification can be retained after the modification. Description of the Drawings

[0047] Figure 1 It is a schematic flowchart of an embodiment of the present invention.

[0048] Figure 2 It is a schematic diagram of the topology change of an example in an embodiment of the present invention. Detailed Embodiments

[0049] Next, the technical solutions of the present invention will be clearly and completely described in conjunction with the drawings and specific embodiments.

[0050] As Figure 1As shown in the figure, for the problems existing in the running instance of the modified topology, a method for changing the network relationship of computing nodes in a network range disclosed in an embodiment of the present invention mainly includes: First, sort the nodes in the topology instance before modification, and traverse the node set to generate the network relationship of the nodes, including the derived network information and access network information of the nodes; where the derived network and the access network are two types of networks defined by the present invention for recording and comparing the network relationship of nodes. The derived network is the network generated when neither the port of the node nor the peer port is added to the network when traversing the node and its ports, and the access network is the network to which the peer port is added when traversing the node and its ports; then compare the changes in the nodes and the node connection ports before and after the modification of the topology instance, clean up the invalid node network relationships, and generate the derived network information and access network information of the nodes in the modified topology instance based on the network identification data of the node ports in the modified topology instance and all the derived network sets generated by the topology instance before modification; then, for the modified topology instance, re-execute the node network relationship generation process to supplement the newly added node network relationships; finally, determine the networks that need to be deleted and added by comparing all the node-derived network sets before and after the modification of the topology instance, and make incremental modifications to the network resources and virtual machine resources according to the new node network relationship.

[0051] Through the method for changing the network relationship of computing nodes described in the embodiment of the present invention, it can be known the change situation of the network relationship between nodes before and after the dynamic change of the topology instance. Thus, for 1. nodes with unchanged network relationships, no processing is required; 2. nodes with changed network relationships only need to modify their access network information, and no additional processing is required for their CPU, memory, and disk resources; 3. deleted nodes need to release their network, CPU, memory, and disk resources; 4. newly added nodes need to apply for network, CPU, memory, and disk resources.

[0052] To better describe the implementation process, taking the Figure 2 topology structure described in the Figure 2 as an example, the method of this embodiment is exemplarily described. The left side in the

[0053] After being modified by the user, port s2-p2 of switch s2 is connected to port r2-p2 of the new router r2, terminal t3 is deleted, and port s2-p3 of switch s2 is not connected to any node. Port r2-p1 of the new router r2 is connected to port r1-p3 of router r1. Port r1-p2 of router r1 is not connected to any node.

[0054] Before introducing in detail how to incrementally calculate network relationship changes, the data structures involved in this embodiment are given first.

[0055] Storage structure of Network network information:

[0056] {

[0057] "network_id": "2343252345", / / Network ID

[0058] "node_id": "s1", / / Node ID of the derived network

[0059] "connect_ports": [ / / Network connection relationship

[0060] {

[0061] "from": "s1-p1", / / Departure port

[0062] "to": "t1-p1" / / Destination port

[0063] },

[0064] {

[0065] "from": "s1-p2", / / Departure port

[0066] "to": "r1-p1" / / Destination port

[0067] }

[0069] }

[0070] Among them, network_id is the unique identification ID of the network, generated using a standard uuid generator. node_id is the node ID that derives the network. In this embodiment, the relationship between the network and the node is divided into a node-derived network and a node-access network. connect_ports are the ports accessed in the current network, and there are multiple groups. One group is a connection line, one end of the connection line is the from departure port, and the other end is the to destination port. The from departure ports are all the ports of the node corresponding to node_id.

[0071] ​Data structure of Node node information:

[0072] {

[0073] "node_id": "s1",

[0074] "node_type": "1", / / The node type is divided into 0 - terminal, 1 - switch, 2 - router

[0075] "access_networks":

[0076] ,

[0077] "derive_networks":

[0078] {

[0079] "network_id": "2343252345",

[0080] "node_id": "s1",

[0081] "connect_ports":

[0082] {

[0083] "from": "s1-p1",

[0084] "to": "t1-p1"

[0085] },{

[0086] "from": "s1-p2",

[0087] "to": "r1-p1"

[0088] }

[0090] }

[0091] ,

[0092] "ports":

[0093] {

[0094] "port_id": "s1_p1",

[0095] "network_id": "2343252345",

[0096] "src_element": "Reference pointing to the current node"

[0097] },​

[0098] {

[0099] "port_id": "s1-p2",

[0100] "network_id": "2343252345",

[0101] "src_element": "Reference to the current node"

[0102] }

[0104] }

[0105] Each node holds the derived network information of the derive_networks node and the access network information of the access_networks node. The types of these two fields are both List <network>。Meanwhile, the node Node also holds information about the ports it owns, and the relevant information is stored in the List it holds <port>In the ports. The port data ports of each node are determined according to the topology. The calculation process of its derived network and access network data is shown in Step 1 below.

[0106] Step 1: When the topology is constructed for the first time, generate the node network relationships. The generation process of the node network relationships is actually the calculation process of the derive_networks node-derived network information and access_networks node-access network information of each node. The specific steps include:

[0107] Step 1.1 Sort the nodes to obtain the sorted set of nodes List <node>Before calculating the network relationship of nodes, the nodes need to be sorted according to the type of nodes first. The node types are divided into terminals, routers, and switches. If the types are the same, they are sorted according to the node ID. Among the node types, switches are ranked at the front, followed by router types, and finally terminal types.

[0108] Step 1.2 Traverse the node set List <node>, generate the node network relationship. The specific process includes:

[0109] Step 1.2.1 Maintain a global mapping relationship Map<Port, Network> portToNetworkMap between ports and networks.

[0110] Step 1.2.2 Traverse the node set List <node>, for each of the nodes therein, perform the following steps.

[0111] Step 1.2.3 Initialize a default network (initializing a network specifically means setting the network ID using a standard uuid generator and setting everything else to empty, the same below) Network defaultNetwork, process the current node, and traverse all the connection ports List of this node <port>ports. For each of these ports, perform the following steps.

[0112] Step 1.2.4 For the current port Port port, perform:

[0113] Step 1.2.4.1 Determine whether portToNetworkMap contains the current port port. If it does, perform the steps below Step 1.2.4.1.

[0114] Step 1.2.4.1.1 Use portToNetworkMap.get(port) to obtain the network Network target_network corresponding to the current port port. If neither the access_networks nor the derive_networks of the current node node contains the current target_network, add target_network to the access_networks of the current node node. Otherwise, the processing of the current port port ends.

[0115] Step 1.2.4.2 Determine whether portToNetworkMap contains the current port port. If it does not, perform the steps below Step 1.2.4.2.

[0116] Step 1.2.4.2.1 If the current node type node_type is 0 or 1, that is, the terminal type or the switch type, the node_id of defaultNetwork is the node_id of the currently traversed node.

[0117] Step 1.2.4.2.1.1 The other port on the connection where the current port 'port' is located is 'Port connect_port'. Set portToNetworkMap.put(port, defaultNetwork) and portToNetworkMap.put(connect_port, defaultNetwork). At the same time, defaultNetwork.getConnectPorts.add(port, connect_port). That is, add a mapping in portToNetworkMap with key 'port' and value 'defaultNetwork'; add a mapping with key 'connect_port' and value 'defaultNetwork'. And add a port pair with 'from' as 'port' and 'to' as 'connect_port' to the connect_ports of defaultNetwork. At the same time, set the network_id values of both 'port' and 'connect_port' to the network_id of defaultNetwork.

[0118] Step 1.2.4.2.1.2 If neither the access_networks nor the derive_networks of the current node 'node' contains defaultNetwork, then add defaultNetwork to the derive_networks of the current node.

[0119] Step 1.2.4.2.2 If the current node type 'node_type' is 2, a router.

[0120] Step 1.2.4.2.2.1 Initialize a network 'Network currentNetwork'. The node_id of currentNetwork is the node_id of the currently traversed node 'node'.

[0121] Step 1.2.4.2.2.2 The other port on the connection where the current port "port" is located is "Port connect_port". Set portToNetworkMap.put(port, currentNetwork) and portToNetworkMap.put(connect_port, currentNetwork). At the same time, currentNetwork.getConnectPorts.add(port, connect_port). That is, add a mapping in portToNetworkMap with key "port" and value "currentNetwork"; add a mapping with key "connect_port" and value "currentNetwork". And add a port pair with "from" as "port" and "to" as "connect_port" to the connect_ports of currentNetwork. At the same time, set the network_id values of both port and connect_port to the network_id of currentNetwork.

[0122] Step 1.2.4.2.2.3 If neither the access_networks nor the derive_networks of the current node "node" contains currentNetwork, then add currentNetwork to the derive_networks of the current node.

[0123] In the example topology diagram, according to the description in Steps 1.1~1.2, we can obtain such a node network relationship:

[0124] There is only one element "network1" in the derive_networks of switch s1, and the access_networks is empty. The node_id of network1 is the node_id of s1. The included port connection pairs connect_ports are (s1-p2, r1-p1) and (s1-p1, t1-p1), where the first element of the connection pair is "from" and the second element is "to".

[0125] There is also only one element, network2, in the derived network derive_networks of switch s2, and the access network access_networks is empty. The node_id of network2 is the node_id of s2. The included port connection pairs connect_ports are (s2-p2, r1-p2), (s2-p1, t2-p1), and (s2-p3, t3-p1).

[0126] The derived network derive_networks of terminal t1 is empty, and access_networks has one element, which is network1.

[0127] The derived network derive_networks of terminal t2 is empty, and access_networks has one element, which is network2.

[0128] The derived network derive_networks of terminal t3 is empty, and access_networks has one element, which is network2.

[0129] The derived network derive_networks of router r1 is empty, and access_networks has two elements, which are network1 and network2.

[0130] After obtaining the above relationships in step 1.3, we traverse the derive_networks of all nodes to obtain all derived network sets List <network>all_networks and persist it. At the same time, persist the node information and port information.

[0131] Step 2: After modifying the topology instance, clean up the invalid node network relationships.

[0132] In this step, compare the changes in nodes and the connection ports of nodes before and after the topology modification. Clear the invalid network information recorded in the network_id field of the node ports due to the change in the node network relationship. This facilitates step 4 to correctly calculate the valid node network relationships before and after the topology change. The following details how to clean up the invalid node network relationships.

[0133] Step 2.1 Compare the topologies before and after the topology instance modification. The topology before modification is denoted as old_topo, and the topology after modification is denoted as new_topo.

[0134] Step 2.2 Traverse all the nodes in new_topo and perform the following operations for each node new_topo_node.

[0135] Step 2.2.1 The current node ID is new_topo_node.node_id. Check whether there is a node with the same node ID in old_topo.

[0136] Step 2.2.2 If there is no node with the same node ID in old_topo, this new_topo_node is a newly added node, and the network_id information of all ports of this node is set to empty.

[0137] Step 2.2.3 If there is a node with the same node ID in old_topo, denoted as old_topo_node. Traverse all the ports of new_topo_node and perform the following operations for each port new_topo_node_port

[0138] Step 2.2.3.1 The current port ID is new_topo_node_port.port_id. Check whether there is a port in old_topo_node with the same port ID as new_topo_node_port.port_id.

[0139] Step 2.2.3.2 If there is no port with the same ID, it means that new_topo_node_port is a new port, and the network_id information of the port should be empty.

[0140] Step 2.2.3.3 If there is a port old_topo_node_port with the same ID, obtain the port new_topo_node_connect_port at the other end of the connection where new_topo_node_port is located in new_topo. In old_topo, obtain the port old_topo_node_connect_port at the other end of the connection where old_topo_node_port is located.

[0141] Step 2.2.3.4 If new_topo_node_connect_port is empty and old_topo_node_connect_port is empty, it means that the ports corresponding to new_topo_node_port before and after the topology modification are not connected to any connections, and the network_id information of new_topo_node_port remains unchanged.

[0142] Step 2.2.3.5 If new_topo_node_connect_port is not empty and old_topo_node_connect_port is empty, it means that the port new_topo_node_port had no connection before the topology modification, and a connection for this port was added after the modification. Set new_topo_node_port.network_id to null.

[0143] Step 2.2.3.6 If new_topo_node_connect_port is empty and old_topo_node_connect_port is not empty, it means that the port new_topo_node_port had a connection before the topology modification, and the connection was deleted after the modification. Set new_topo_node_port.network_id to null.

[0144] Step 2.2.3.7 If new_topo_node_connect_port is not empty and old_topo_node_connect_port is also not empty.

[0145] Step 2.2.3.7.1 If the port_id of new_topo_node_connect_port is the same as the port_id of old_topo_node_connect_port, it means that the connection has not changed before and after the topology modification, and no processing is required.

[0146] Step 2.2.3.7.2 If new_topo_node_connect_port.port_id and old_topo_node_connect_port.port_id are different, it indicates that the ports connected by new_topo_node_port before and after the topology modification have changed. Set new_topo_node_port.network_id to null.

[0147] Step 2.2.3.7.2.1 If the current node type new_topo_node.node_type is a switch, traverse all ports under new_topo_node.

[0148] Step 2.2.3.7.2.1 Denote the current port as sw-p, and denote the opposite end port of the current port connection as sw-connect-p. Set sw-p.network_id to null. At the same time, if sw-connect-p is not null, set sw-connect-p.network_id to null.

[0149] Thus, the cleaning of invalid node network relationships is completed. According to the description rules in Step 2, the situation of cleaning invalid node network relationships in the example topology diagram is as follows:

[0150] All port connections of terminal t1 have not changed, and no processing is required.

[0151] All port connections of switch s1 have not changed, and no processing is required.

[0152] The connection of port r1-p1 of router r1 has not changed and does not need to be processed; the connection of port r1-p2 is deleted, and r1-p2.network_id is set to null; the connection of port r1-p3 is newly added, and r1-p3.network_id should be null.

[0153] For router r2 which is a newly added node, all port network_ids should be null.

[0154] The connection of port s2-p2 of switch s2 has changed, and the network_ids of its ports s2-p2, s2-p1, and the opposite end ports t2-p1, r2-p2 of the port connection need to be set to null.

[0155] The network_id of port t2-p1 of terminal t2 is set to null.

[0156] Terminal t3 is deleted before and after the topology modification and is not involved in the processing in Step 2.

[0157] Step 4: Calculate the unchanged node network relationships.

[0158] Step 1 completes the initialization of the network relationships of the topology before modification. After the user modifies the topology, we need to incrementally calculate the node network relationships based on the node network relationships recorded in the old topology and the changes in the connection relationships between the nodes and nodes in the new topology. Step 2 clears the invalid node network relationships due to topology changes. Step 4 starts to calculate the valid node network relationships. That is, according to the network_id data of the node ports in the new topology and all_networks generated in Step 1, the derived networks derive_networks and access networks of the nodes are loaded. Because of the processing in Step 3, the node network relationships obtained in Step 4 are the node network relationships that have not changed before and after the topology modification. This relationship needs to go through the subsequent steps to process the newly added node network relationships in the new topology to finally obtain the complete node network relationships of the new topology.

[0159] The following details how to calculate the unchanged valid node network relationships.

[0160] Step 3.1 Obtain the set of all derived networks all_networks. All derived network sets were persisted at the end of Step 2. Here we reload them into memory to obtain all the derived network sets all_networks built in the previous topology construction.

[0161] Step 3.2 Load the derived networks derive_networks of the nodes, and use Map<Port, Network> portToNetworkMap to record the mapping relationship between the node ports and the networks. Perform the following steps:

[0162] Step 3.2.1 Traverse all nodes in the edited topology, obtain the mapping management from node_id to node information node, and store it in Map<String, Node> nodeIdToNodeMap.

[0163] Step 3.2.2 Traverse all_networks, and for each network network in it, perform the following operations.

[0164] Step 3.2.2.1 Traverse all nodes in the topology, and for each node node, perform the following operations.

[0165] Step 3.2.2.1.1 Traverse the ports ports of the current node, and for each port port, perform the following processing.

[0166] Step 3.2.2.1.1.1 If port.network_id is empty, skip the processing of the current port.

[0167] Step 3.2.2.1.1.2 If port.network_id is not null and port.network_id is different from network.network_id, skip the processing of the current port.

[0168] Step 3.2.2.1.1.3 If port.network_id is not null and port.network_id is the same as network.network_id, obtain the peer port connect_port of the connection where the current port is located.

[0169] Step 3.2.2.1.1.3.1 If connect_port is null, add (port, null) to network.connect_ports, and at the same time add a mapping relationship with key port and value network to portToNetworkMap.

[0170] Step 3.2.2.1.1.3.2 If connect_port is not null.

[0171] Step 3.2.2.1.1.3.2.1 If connect_port.network_id is the same as network.network_id.

[0172] Step 3.2.2.1.1.3.2.1.1 Add (port, connect_port) to network.connect_ports.

[0173] Step 3.2.2.1.1.3.2.1.2 At the same time, add a mapping relationship with key port and value network to portToNetworkMap; add a mapping with key connect_port and value network.

[0174] Step 3.2.2.1.1.3.2.1.3 connect_port.node_id is the node to which the peer port of the connection belongs. Obtain the peer node Node connect_node through nodeIdToNodeMap.get(connect_port.node_id), and add the current network network to the access network of the peer node, connect_node.add(network).

[0175] Step 3.2.2.1.1.3.2.2 If connect_port.network_id and network.network_id are different, there is an anomaly in the topology data, and all current processes are aborted.

[0176] Step 3.2.2.2 Derive the node node_id of the current network network as network.node_id. Obtain the corresponding node information node through nodeIdToNodeMap.get(node_id).

[0177] Step 3.2.2.2.1 If the current network network.connect_ports is not empty, add the current network to the derived network sequence of the node node, i.e., node.derive_networks.add(network).

[0178] Step 3.2.2.2.2 If the current network network.connect_ports is empty, do nothing.

[0179] So far, the calculation of the invariant node network relationship is completed. According to the rules described in Step 3, the results of calculating the invariant node network relationship in the example topology diagram are as follows:

[0180] There is only one element network1 in the derived network derive_networks of switch s1, and the access network access_networks is empty. The node_id of network1 is the node_id of s1. The included port connection pairs connect_ports are (s1-p2,r1-p1) and (s1-p1,t1-p1), where the first element of the connection pair is from and the second element is to.

[0181] The derived network derive_networks of switch s2 is empty, and the access network access_networks is also empty.

[0182] The derived network derive_networks of terminal t1 is empty, and access_networks has one element which is network1.

[0183] The derived network derive_networks of terminal t2 is empty, and the access network access_networks is also empty.

[0184] Terminal t3 is a node deleted after topology modification and does not need to be processed in Step 3.

[0185] The derived network of router r1, derive_networks, is empty, and there is one element in access_networks, which is network1.

[0186] Router r2 is a new node, and both its derived network, derive_networks, and access network, access_networks, are empty.

[0187] Step 4: Calculate the network relationships of the newly added nodes.

[0188] Calculating the network relationships of the newly added nodes means re-executing Step 1 for each node. The network relationships of the nodes that have not changed after the topology modification have been calculated in Steps 2 and 3. Each calculated port has its corresponding network, and this relationship is recorded in portToNetworkMap in Step 3.2. If a certain port of the current node does not obtain the mapped network in this Map, it means that the network relationship of this port needs to be recalculated. Therefore, for the ports that do not obtain the mapped network in portToNetworkMap, Step 1.2 needs to be re-executed to supplement the network relationships of the newly added nodes.

[0189] Step 4.1: Execute Step 1.1 on the edited topology new_topo to sort its nodes. Traverse the sorted nodes, and denote the current node as new_topo_node.

[0190] Step 4.2: Execute all the steps below Step 1.2 for each current node new_topo_node, where the value of portToNetworkMap declared in Step 1.2.1 is the value of portToNetworkMap in Step 3.2.

[0191] According to the rules described in Steps 4.1 to 4.2, the final network relationships of the nodes in the new topology in the example topology diagram are as follows:

[0192] In the derived network derive_networks of switch s1, there is only one element, network1, and the access network access_networks is empty. The node_id of network1 is the node_id of s1. The included port connection pairs connect_ports are (s1 - p2, r1 - p1) and (s1 - p1, t1 - p1). The first element of the connection pair is from, and the second element is to.

[0193] There is an element network3 in the derived network derive_networks of switch s2, and the access network access_networks is empty. The node_id of network3 is the node_id of s2. The included port connection pairs connect_ports are (s2-p1, t2-p1), (s2-p2, r2-p2).

[0194] The derived network derive_networks of terminal t1 is empty, and access_networks has an element which is network1.

[0195] The derived network derive_networks of terminal t2 is empty, and access_networks has an element which is network3.

[0196] Terminal t3 is a node deleted after topology modification and is not in the edited topology new_topo, so no processing is required in step 4.

[0197] The derived network derive_networks of router r1 has an element which is network4. Access_networks has an element which is network1. The node_id of network4 is the node_id of r1. The included port connection pair connect_ports is (r1-p3, r2-p1).

[0198] Router r2 is a new node. The derived network derive_networks is empty, and access_networks has two elements which are network3 and network4.

[0199] Step 5: Calculate the networks to be deleted and added.

[0200] Denote the set of the derived networks of all nodes when the topology was built before modification as A, and denote the set of the derived networks of all nodes in the new topology after being processed in steps 2 to 4 after the topology is modified as B. The networks to be deleted are A - B, and the networks to be added are B - A. The specific implementation steps are as follows:

[0201] Step 5.1 Obtain the set List of the derived networks of all nodes when the topology persisted in step 1.4 was built before modification <network>allNetworks。

[0202] Step 5.2 Obtain the edited topology new_topo after step 4 is executed. Use List <network>allNetworksForNewTopo records all the derived networks of the new topology.

[0203] Step 5.3 Traverse all the nodes in new_topo. For each node current_node.

[0204] Step 5.3.1 Add the derived networks of current_node into allNetworksForNewTopo. allNetwoksForNewTopo.addAll(current_node.derive_networks).

[0205] Step 5.4 Traverse allNetworks. For the element network under allNetworks, perform the following operations.

[0206] Step 5.4.1 If network does not exist in allNetworksForNewTopo, then network is the network to be deleted.

[0207] Step 5.5 Traverse allNetworkForNewTopo. For the element new_topo_network under allNetworkForNewTopo, perform the following operations

[0208] Step 5.5.1 If new_topo_network does not exist in allNetworks, then new_topo_network is the network to be added.

[0209] According to the rules described in Step 5, in the example topology diagram, the network to be deleted is network2, and the networks to be added are network3 and network4.

[0210] Step 6: According to the calculated new node-network relationships, operate on the added, deleted, and changed networks and virtual machine resources.

[0211] After the above Steps 1 to 5, we can obtain the node-network relationships of the edited topology. For the added networks, they can be directly created. For the deleted networks, they can be directly deleted. For the added nodes, their new node-network relationships have been generated and can be directly created. For the deleted nodes, they can be directly deleted. For the nodes with network changes, they have their derived networks and access network relationships before modification and their derived networks and access network relationships after modification. Directly change the network accessed by the network card of the virtual machine of this node according to the changes between the two.

[0212] Specifically, according to the topology modification situation shown in the example topology diagram, the following operations need to be performed:

[0213] Step 6.1 Delete network network2.

[0214] Step 6.2 Add new networks network3 and network4.

[0215] After the topology of terminal t3 is modified, the nodes are deleted and the virtual machine resources are recycled.

[0216] After the topology of terminal t1 is modified, the nodes exist. Before the modification, the derived network derive_networks is empty and the access_networks has one element which is network1. After the modification, the derived network derive_networks is empty and the access_networks has one element which is network1. There is no change in its derived network and access network before and after the topology modification, so no processing is required.

[0217] After the topology of switch s1 is modified, the nodes exist. Before the modification, there is only one element network1 in the derived network derive_networks and the access network access_networks is empty. After the modification, there is only one element network1 in the derived network derive_networks and the access network access_networks is empty. There is no change in its derived network and access network before and after the topology modification, and no operation is required for the corresponding network resource network1.

[0218] Before the topology of router r1 is modified, the derived network derive_networks is empty and the access_networks has two elements which are network1 and network2. According to network1.connect_ports, the port r1-p1 of r1 corresponds to the network card accessing network1. According to network2.connect_ports, the port r1-p2 of r1 corresponds to the network card accessing network2. After the topology modification, the derived network derive_networks of router r1 has one element which is network4. The access_networks has one element which is network1. The network card corresponding to port r1-p2 no longer accesses network2; the network card corresponding to port r1-p3 accesses network4; the network card corresponding to port r1-p1 does not need to be changed.

[0219] Step 6.7 Router r2 is a newly added node. Its derived networks derive_networks are empty, and its access networks access_networks have two elements, namely network3 and network4. Port r2-p1 corresponds to the network card accessing network4; port r2-p2 corresponds to the network card accessing network3.

[0220] Step 6.8 Before the topology modification of switch s2, there was only one element network2 in its derived networks derive_networks, and its access networks access_networks were empty. After the topology modification, there is only one element network3 in its derived networks derive_networks, and its access networks access_networks are empty. The derived networks before and after its topology modification change from network2 to network3.

[0221] Step 6.9 Before the topology modification of terminal t2, its derived networks derive_networks were empty, and its access networks access_networks had one element, namely network2. After the topology modification, its derived networks derive_networks are empty, and its access networks access_networks have one element, namely network3. The network accessed by the network card corresponding to port t2-p1 changes from network2 to network3.

[0222] Based on the method of the embodiment of the present invention, it is possible to incrementally calculate the changes in the network relationship before and after the topology change. For virtual nodes whose network access relationship has not changed, no resources are consumed during the dynamic adjustment of the topology instance; for virtual nodes whose network access relationship has changed, during the dynamic adjustment of the topology instance, only the network access relationship is adjusted, and resources such as CPU, memory, and disk allocated to the virtual nodes do not need to be recycled, and only the accessed network needs to be adjusted. Thus, the performance of modifying the topology instance can be greatly optimized. By incrementally calculating the network relationship changes, only when the virtual machine is deleted before and after the topology instance change will disk resource recycling be involved, and the disk data of other virtual machines will not be affected.

[0223] Based on the same inventive concept, a system for changing the network relationship of computing nodes in a network range according to an embodiment of the present invention includes: an old topology node network relationship generation module, configured to sort nodes in a topology instance before modification, and traverse the node set to generate node network relationships, including the derived network information and access network information of the nodes; a node network relationship change calculation module, configured to compare the changes in nodes and node connection ports before and after the modification of the topology instance, and clean up invalid node network relationships; based on the network identification data of the node ports in the topology instance after modification, and all the derived network sets generated from the topology instance before modification, generate the derived network information and access network information of the nodes in the topology instance after modification; for the topology instance after modification, re-execute the node network relationship generation process to supplement the newly added node network relationships; and determine the networks to be deleted and added by comparing all the node-derived network sets before and after the modification of the topology instance; and an incremental modification module, configured to perform incremental modification on network resources and virtual machine resources according to the new node network relationships. For the specific implementation details of each module, refer to the foregoing method embodiment and will not be elaborated herein.

[0224] An embodiment of the present invention also discloses a computer system, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the computer program is executed by the processor, the steps of the method for changing the network relationship of computing nodes in a network range are implemented.

[0225] An embodiment of the present invention also discloses a computer program product, including a computer program. When the computer program is executed by the processor, the steps of the method for changing the network relationship of computing nodes in a network range are implemented.< / network> < / network> < / network> < / port> < / node> < / node> < / node> < / port> < / network> ​

Claims

1. A method for changing the network relationship of computing nodes in a network range, characterized in that: The steps include: Sorting the nodes in the topology instance before modification, and traversing the node set to generate the node network relationship, including the derived network information and access network information of the node; The derived network is the network generated when the node and its port are traversed and the port of the node and the port of the opposite end are not added to the network; the access network is the network added by the opposite end port when the node and its port are traversed; for each terminal or switch node, a default network is initialized, and for the current port of the current node traversed, if the target network corresponding to the current port is obtained from the port and network mapping relationship, and the access network and derived network of the current node do not contain the target network, then the target network is added to the access network of the current node; If not obtained, for terminal or switch nodes, set the node ID of the default network as the ID of the current node; for router nodes, initialize a new network and set the node ID of the new network as the ID of the current node; Update the port and network mapping relationship, add the mapping of the current port and the peer port to the default network / new network, and add the two ports to the connection port pair of the default network / new network. If the access network and derived network of the current node do not contain the default network / new network, then add the default network / new network to the derived network of the current node; Compare the changes in nodes and node connection ports before and after the topology instance is modified, and clean up invalid node network relationships; Generate derived network information and access network information of nodes in the modified topology instance based on network identification data of node ports in the modified topology instance and a set of all derived networks generated by the topology instance before modification; For the modified topology instance, re-execute the node network relationship generation process and add the newly added node network relationship; By comparing all node derived network sets before and after the topology instance is modified, determine the networks that need to be deleted and added; Based on the new node network relationship, incremental modifications are made to network resources and virtual machine resources.

2. According to claim 1, a method for changing the network relationship of computing nodes in a network range is characterized in that: The step of sorting the nodes in the topology instance before modification and traversing the node set to generate a node network relationship includes: Sort the nodes according to their types, and sort the nodes of the same type according to their node identifiers to obtain a node set; the node types are sorted in the order of switches, routers, and terminals; Maintain a global port and network mapping relationship to record the network information corresponding to each port, traverse the node set, and execute for each node: Initialize a default network to serve as a derived network of the current non-router type node; traverse all the connection ports of the current node, and for each port, perform the following: Determine whether the port exists in the mapping relationship: If it does, obtain the target network corresponding to the current port. If neither the access network nor the derived network of the current node contains the obtained target network, add the obtained target network to the access network of the current node, otherwise end the processing of the current port; If it does not exist, perform different processing according to the node type: For terminal or switch nodes, set the node identifier of the default network to the identifier of the current node, update the port and network mapping relationship, and add the current port and the opposite port of the line where the current port is connected Mapping to the default network, and add the two ports to the connection port pair of the default network; if neither the access network nor the derived network of the current node contains the default network, add the default network to the derived network of the current node; for the router node, initialize a new network to serve as the derived network of each port of the current router node; set the node identifier of the new network to the identifier of the current node, update the port and network mapping relationship, add the mapping of the current port and the opposite port of the line where the current port is located to the new network, and add the two ports to the connection port pair of the new network; if neither the access network nor the derived network of the current node contains the new network, add the new network to the derived network of the current node.

3. According to claim 1, a method for changing the network relationship of computing nodes in a network range is characterized in that: The comparing the changes of nodes and node connection ports before and after the topology instance is modified, and clearing invalid node network relationships, includes: Traverse all nodes in the modified topology instance, and for each node, check whether there is a node with the same node ID in the topology instance before modification; If it does not exist, clear the network identification information of all its ports; If it exists, then traverse all its ports; for each port, check whether there is a port with the same port ID in the topology instance before the modification. If not, clear the network ID information of the current port; if it exists, respectively obtain the opposite end ports before and after the modification, and perform the following processing according to different connection states: If both connection ports are empty or have the same identifier, the network identification information of the current port remains unchanged; If one of the connection ports is empty, clear the network identification information of the current port; If the two connection port identifiers are different, the network identification information of the current port is cleared. If the current node type is a switch, all ports under the node are traversed, and the network identification information of each port and its opposite port is cleared.

4. According to claim 1, a method for changing the network relationship of computing nodes in a network range is characterized in that: The generating of the derived network information and the access network information of the nodes in the modified topology instance includes: Obtain all derived network sets corresponding to the topology instance before modification, maintain a global port and network mapping relationship, and record the network information corresponding to each port; For each derived network in the derived network set, execute: traverse each port of each node in the modified topology instance, process the network identification information of the port, and when the network identification information is not empty and is the same as the identification of the current derived network, obtain the opposite port, update the connection port pair of the derived network and the port and network mapping relationship according to the opposite port situation, and when the opposite port exists, add the current derived network to the access network of the node to which the opposite port belongs; For each derived network in the derived network set, execute: according to the node identifier recorded in the current derived network, obtain the corresponding node information; if the connection port pair of the derived network is not empty, add the current derived network to the derived network sequence of the obtained node.

5. The method for changing the network relationship of computing nodes in a network range according to claim 1, characterized in that: The determining of the networks to be deleted and added by comparing all node derived network sets before and after the topology instance is modified includes: Load all derived network sets corresponding to the topology instance before modification into the first set; Traversing each node in the modified topology instance, and adding all derived networks of each node to the second set; Traverse the first set and determine whether each derived network exists in the second set. If not, mark the current derived network as a network to be deleted. The second set is traversed to determine whether each derived network exists in the first set. If not, the current derived network is marked as a network that needs to be added.

6. A method for changing the network relationship of computing nodes in a network range according to claim 1, characterized in that: The incremental modification of network resources and virtual machine resources includes: For the deleted network, delete it directly; For newly added nodes, they are created directly based on the new node network relationship; For the deleted nodes, delete them directly; For a node whose network has been changed, the network card access information of the node virtual machine is changed based on the derived network information and access network information before the modification and the derived network information and access network information after the modification.

7. A method for changing the network relationship of computing nodes in a network range according to claim 1, characterized in that: The data structure for storing node information includes node identification, node type, node access network information, derived network information and port list; each port in the port list includes a port identification and a network identification; the data structure of the node's access network and derived network is the same, including a network identification, a node identification and a list of connection port pairs.

8. A system for computing node network relationship changes in a network range, characterized in that: include: The old topology node network relationship generation module is used to sort the nodes in the topology instance before modification, and traverse the node set to generate the node network relationship, including the derived network information and access network information of the node; the derived network information is the network generated when the node port and the opposite port are not added to the network when traversing the node and its port; the access network information is the network added to the opposite port when traversing the node and its port; for each terminal or switch node, a default network is initialized, and for the current port of the current node being traversed, if the target network corresponding to the current port is obtained from the port and network mapping relationship, and the access network and derived network of the current node do not contain the target network, then the target network is added to the access network of the current node; If not obtained, for terminal or switch nodes, set the node ID of the default network as the ID of the current node; for router nodes, initialize a new network and set the node ID of the new network as the ID of the current node; Update the port and network mapping relationship, add the mapping of the current port and the peer port to the default network / new network, and add the two ports to the connection port pair of the default network / new network. If the access network and derived network of the current node do not contain the default network / new network, then add the default network / new network to the derived network of the current node; The node network relationship change calculation module is used to compare the changes of nodes and node connection ports before and after the topology instance is modified, and to clean up invalid node network relationships; based on the network identification data of the node ports in the modified topology instance and all the derived network sets generated by the topology instance before the modification, the derived network information and access network information of the nodes in the modified topology instance are generated; for the modified topology instance, the node network relationship generation process is re-executed to supplement the newly added node network relationship; And by comparing all node derived network sets before and after the topology instance is modified, determine the networks that need to be deleted and added; And an incremental modification module is used to incrementally modify network resources and virtual machine resources according to new node network relationships.

9. A computer system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the computer program is executed by a processor, the steps of a method for changing the network relationship of computing nodes in a network range according to any one of claims 1 to 7 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of a method for changing the network relationship of computing nodes in a network range according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Virtual network topology construction and dynamic change method

    CN112804081A

  • Method and system for network resource allocation and topological distribution of distributed network target range

    CN119011362A