A network device configuration translation method based on semantic similarity

By employing a semantic similarity-based network device configuration translation method, utilizing the auxiliary frameworks Nassim and SBERT models for parameter and statement mapping, constructing a configuration tree, and designing a recursive algorithm, the problem of low efficiency and poor scalability in configuration file conversion between devices from different manufacturers is solved, achieving efficient configuration translation.

CN117236345BActive Publication Date: 2026-11-06NORTHEASTERN UNIV CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311261019.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2026-11-06
Estimated Expiration
2043-09-27

AI Technical Summary

Technical Problem

Existing network device configuration translation methods cannot achieve command 'one-to-many' or 'many-to-many' conversion, and the conversion efficiency of configuration files between different vendors is low, resulting in high labor costs and poor scalability.

Method used

A semantic similarity-based network device configuration translation method is adopted. Using the auxiliary frameworks Nassim, SBERT model and unified device model, the correspondence between parameters and statements is realized through parameter mapping and configuration tree construction. A recursive algorithm is designed to sort the statements and generate configuration files that meet the grammatical requirements.

Benefits of technology

It improves the efficiency and scalability of network device configuration translation, enabling rapid adaptation to new models or manufacturers' equipment, reducing configuration translation costs, and solving the problems of 'one-to-many,' 'many-to-one,' and 'many-to-many', thus greatly improving work efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117236345B_ABST
    Figure CN117236345B_ABST
Patent Text Reader

Abstract

This invention proposes a network device configuration translation method based on semantic similarity. The method includes inputting the device manuals of a first device and a second device; directly mapping the parameters of the first device and the second device based on the auxiliary frameworks Nassim, SBERT model, and unified device model, obtaining parameter correspondence results for the first and second devices; combining the device statements of the first device with the parameter correspondence results into a command-based configuration file; constructing the configuration file as a configuration tree for statement correspondence, obtaining statement correspondence results; combining the parameter correspondence results with the statement correspondence results to obtain multiple command blocks; sorting the multiple command blocks to obtain a statement order that corresponds to the device statements of the second device and satisfies the view relationship; and outputting the configuration file of the second device. This invention can improve configuration translation efficiency, achieve scalability, and solve the problem that existing methods cannot achieve "one-to-one," "one-to-many," and "many-to-many" relationships in configuration commands.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of network configuration, and specifically discloses a method for translating network device configurations based on semantic similarity.

[0002] Background Introduction

[0003] With the widespread use of the internet and technological advancements, the network has become an indispensable part of people's lives, and network infrastructure has been significantly upgraded. A network protocol is a set of rules that all devices on a computer network, such as switches and routers, must follow when exchanging information. Different network protocols implement different network functions, such as routing, security, or access control. Currently, there are many different network protocols, and implementing a single function often requires configuring multiple different network protocols. This includes not only configuring various parameters within the network protocols themselves but also configuring parameters between different protocols to achieve interaction. Moreover, with the increase in application scenarios, the configuration of network protocols for devices in different scenarios has become increasingly complex.

[0004] During network operation, equipment failures and damages are inevitable, or network equipment may need to be replaced due to new requirements. Often, the new equipment will differ from the existing equipment in model or manufacturer. Different manufacturers also use different syntax for configuration commands, making their configuration manuals incompatible and requiring conversion. When equipment failures or damages occur, network administrators need to replace the existing equipment with a new one to enable it to perform the functions of the old equipment. This requires administrators to study the new equipment's product manual, compare it with the existing equipment's configuration file to find the new configuration commands, and create a new configuration file to import into the new equipment. This process of translating the existing equipment's configuration file into the new equipment's configuration file is called configuration translation.

[0005] Existing configuration translations are mostly done manually by configuration experts, which typically consumes significant time and manpower. This is not only inefficient but also wastes valuable human resources, failing to fully utilize the expertise of configuration experts. This is especially true when dealing with equipment from new vendors, requiring additional investment in learning new syntax and exhibiting poor scalability. Chinese patent "CN1615480A Translation of Configuration Files Between Network Devices" provides a system and method for simplifying the translation of command-line interface configuration scripts, translating a device-related command-line interface configuration script into a peer CLI configuration script corresponding to another device. The system includes a translator and one or more data dictionaries. The translator includes a user interface module, a translator logic module for implementing the translation, and a current data dictionary module storing selected data dictionaries. Each data dictionary includes common syntax generated based on multiple CLI script types. A specific data dictionary is based on initial input from a network administrator. The translator then automatically translates the corresponding script from the original device and translates it to a device with different script requirements. However, this patent does not fully align with current mainstream network configurations and cannot address "one-to-many" or "many-to-many" command communication. The paper "Software-Defined Network Assimilation: Bridging the Last Mile Towards Centralized Network Configuration Management with NAssim" proposes an auxiliary framework called Nassim. Its solution includes a deep learning-based mapping algorithm that uses state-of-the-art neural language processing techniques to generate human-understandable recommended mappings between validated configuration models and configuration models in SDN controllers. However, it cannot translate configuration files between different vendors and lacks scalability. To address these issues, it is essential to research and design a novel semantic similarity-based network device configuration translation method to overcome the problems existing in current network device configuration translation methods. Summary of the Invention

[0006] This invention proposes a semantic similarity-based network device configuration translation method to address the problems of existing network device configuration translation methods, such as the inability to achieve "one-to-many" or "many-to-many" command translation, the inability to convert configuration files between different vendors, and low efficiency.

[0007] This invention provides a method for translating network device configurations based on semantic similarity, comprising the following steps:

[0008] S1. Input the equipment manuals of the first and second devices, and complete the direct correspondence between the parameters of the first and second devices based on the auxiliary frameworks Nassim, SBERT model and unified device model, to obtain the parameter correspondence results of the first and second devices;

[0009] S2. Combine the device statement of the first device with the parameter correspondence result obtained in step S1 into a command-based configuration file, construct the configuration file into a configuration tree to perform statement correspondence, and obtain the statement correspondence result;

[0010] S3. Combine the parameter correspondence results obtained in step S1 with the statement correspondence results obtained in step S2 to obtain multiple command blocks;

[0011] S4. Sort the multiple command blocks obtained in step S3 to obtain the sorted statement that corresponds to the device statement of the second device and satisfies the view relationship, and output the configuration file of the second device.

[0012] According to some embodiments of this application, a network device configuration translation method based on semantic similarity includes step S1, which includes:

[0013] S101. Equipment manual parsing, including obtaining the first equipment-specific model and the second equipment-specific model respectively from the basic information in the first equipment manual and the second equipment manual based on the auxiliary framework Nassim;

[0014] S102. Context information extraction, including extracting semantic information from the first device-specific model obtained in step S101 as first context information, and extracting semantic information from the second device-specific model obtained in step S101 as second context information;

[0015] S103. Context encoding, including pre-training the SBERT model with the sentence target and the NLI dataset to obtain an improved SBERT model, encoding the first context information obtained in step S102 through the improved SBERT model to generate a first context embedding vector, and encoding the second context information obtained in step S102 through the improved SBERT model to generate a second context embedding vector.

[0016] S104. Map the first device parameters to the unified device model parameters, and map the second device parameters to the unified device model parameters, including calculating the first context embedding vector and the unified device model embedding vector obtained in step S103 by inter-line cosine similarity to obtain the first parameter mapping, and calculating the second context embedding vector and the unified device model embedding vector obtained in step S103 by inter-line cosine similarity to obtain the second parameter mapping;

[0017] S105. Using the first parameter mapping and the second parameter mapping obtained in step S104, obtain the parameter correspondence results of the first device and the second device.

[0018] According to some embodiments of this application, a network device configuration translation method based on semantic similarity includes, in step S2, constructing a configuration tree, which includes:

[0019] Step a. Create an empty node as the root node of the configuration tree, set the depth of the current view to 0, and construct the corresponding node for each command;

[0020] Step b. Determine the number of spaces before the current command in the configuration file and the view depth of the previous command. If the number of spaces before the current command is greater than the view depth of the previous command, connect the corresponding node of the current command to the corresponding node of the previous command, and the corresponding node of the current command becomes the child node of the corresponding node of the previous command. If the number of spaces before the current command is equal to the view depth of the previous command, connect the corresponding node of the current command to the parent node of the corresponding node of the previous command, and the corresponding node of the current command becomes the sibling node of the corresponding node of the previous command. If the number of spaces before the current command is less than the view depth of the previous command, find the ancestor node upwards from the parent node of the previous command based on the difference between the number of spaces and the depth, and connect the corresponding node of the current command to the ancestor node of the corresponding node of the previous command, and become the child node of the ancestor node of the corresponding node of the previous command.

[0021] Step c. Repeat step b until all commands in the configuration file are traversed sequentially to obtain the constructed configuration tree.

[0022] According to some embodiments of this application, a network device configuration translation method based on semantic similarity is provided. In step b, the configuration file separates different configured items by enabling view commands. The depth of entering the view is shown by adding the number of indentation spaces before the command. Entering a view indicates configuring a new item, which is one or more of an interface, VPN, or protocol function.

[0023] According to some embodiments of this application, a network device configuration translation method based on semantic similarity, in step S2, the statement corresponds to:

[0024] Step a. Parse the configuration file command of the configuration file to obtain the command corresponding to the configuration file command in the first device, and obtain the parameters used in the configuration file command to form a parameter list. The correctness of the parameter order after translation is ensured by maintaining the order of the parameters in the parameter list.

[0025] Step b. Find the parameters in the second device for all parameters in the parameter list through the parameter correspondence results, and use the string matching method to find the command format of the corresponding parameter in the second device in the specific model of the second device according to the corresponding parameter in the second device. Iterate through the parameter list in turn. After the iteration is completed, one or more command formats and the corresponding parameters in the second device are obtained. Fill the corresponding parameters in the second device into the corresponding command format through the command filling method to obtain the second parameter list.

[0026] Step c. Based on the second parameter list, return to the configuration tree and search for the command node containing the parameters in the second parameter list. Search in the order of sibling nodes of different commands, parent node, sibling nodes of the parent node of different commands, parent node of the parent node, and so on. Fill the selected parameters into the corresponding command in the second device to generate the second command.

[0027] Step d. Create a virtual empty parent node, connect the generated second command to the virtual empty parent node as its child node, and traverse each level of the configuration tree from top to bottom. When the traversal of the current level of the configuration tree is completed, connect all corresponding nodes of the current level to the corresponding nodes generated by the previous level node. After the configuration tree traversal is completed, the corresponding result of the statement is obtained.

[0028] According to some embodiments of this application, a network device configuration translation method based on semantic similarity, step S4 further includes, before sorting multiple command blocks, using a recursive algorithm to transform each command block into a tree-structured CLI model hierarchy that satisfies view relationships. The recursive algorithm starts construction from the deepest level of sub-command blocks contained in each command block. The CLI model hierarchy uses the root node of the constructed subtree to represent this subtree to complete the sorting task of the upper level. Each sub-command block corresponds to a child node in the subtree. The hierarchical structure is constructed using the auxiliary framework NAssim as the standard for sentence sorting.

[0029] According to some embodiments of this application, a network device configuration translation method based on semantic similarity is provided, wherein step S4 includes:

[0030] S401. An index is created for each child node in the CLI model hierarchy using a hash algorithm;

[0031] S402. For the lowest-level command block, traverse each sub-command, establish a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the lowest-level command tree. For non-lowest-level command blocks, traverse each sub-command, establish a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the non-lowest-level command tree.

[0032] S403. Connect the lowest-level command tree to the root node of a non-lowest-level command tree to form a subtree, obtain the statement sorting that corresponds to the device statements of the second device and satisfies the view relationship, and output the configuration file of the second device.

[0033] The present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program; the processor is used to execute the computer program in the memory to implement the above-described method.

[0034] The present invention also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements the above-described method.

[0035] This invention proposes a network device configuration translation method based on semantic similarity, which can be applied to configuration files of network devices from different manufacturers. Addressing issues of parameter correspondence, statement correspondence, and statement ordering during network device configuration translation, this method helps network device configuration translators complete the translation work more conveniently and quickly, improving efficiency. It also achieves scalability, enabling faster learning of new configuration commands when introducing new models or even devices from new manufacturers, reducing the cost of network device configuration translation. This method solves the problem of existing methods being unable to achieve "one-to-one," "one-to-many," and "many-to-many" configuration commands. A statement ordering algorithm is designed to organize the configuration file format according to the command tree to meet grammatical requirements, greatly improving work efficiency. Attached Figure Description

[0036] Figure 1 This is a flowchart illustrating a network device configuration translation method based on semantic similarity according to the present invention. Detailed Implementation

[0037] The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and should not be construed as limiting the scope of the invention.

[0038] Example 1

[0039] This embodiment provides a network device configuration translation method based on semantic similarity, such as... Figure 1 As shown, it includes the following steps:

[0040] S1. Input the equipment manuals of the first and second devices, and complete the direct correspondence between the parameters of the first and second devices based on the auxiliary frameworks Nassim, SBERT model and unified device model, to obtain the parameter correspondence results of the first and second devices;

[0041] S101. Equipment manual parsing, including obtaining the first equipment-specific model and the second equipment-specific model respectively from the basic information in the first equipment manual and the second equipment manual based on the auxiliary framework Nassim;

[0042] S102. Context information extraction, including extracting semantic information from the first device-specific model obtained in step S101 as first context information, and extracting semantic information from the second device-specific model obtained in step S101 as second context information;

[0043] S103. Context encoding, including pre-training the SBERT model with the sentence target and the NLI dataset to obtain an improved SBERT model, encoding the first context information obtained in step S102 through the improved SBERT model to generate a first context embedding vector, and encoding the second context information obtained in step S102 through the improved SBERT model to generate a second context embedding vector.

[0044] S104. Map the first device parameters to the unified device model parameters, and map the second device parameters to the unified device model parameters, including obtaining the first parameter mapping by using the first context embedding vector obtained in the inter-line cosine similarity calculation step S103 and the unified device model embedding vector, and obtaining the second parameter mapping by using the second context embedding vector obtained in the inter-line cosine similarity calculation step S103 and the unified device model embedding vector.

[0045] S105. Using the first parameter mapping and the second parameter mapping obtained in step S104, obtain the parameter correspondence results of the first device and the second device.

[0046] S2. Combine the device statement of the first device with the parameter correspondence result obtained in step S1 into a command-based configuration file, construct the configuration file into a configuration tree to perform statement correspondence, and obtain the statement correspondence result;

[0047] Building the configuration tree includes:

[0048] Step a. Create an empty node as the root node of the configuration tree, set the depth of the current view to 0, and construct the corresponding node for each command;

[0049] Step b. Determine the number of spaces before the current command in the configuration file and the view depth of the previous command. If the number of spaces before the current command is greater than the view depth of the previous command, connect the corresponding node of the current command to the corresponding node of the previous command, making the current node a child node of the previous command. If the number of spaces before the current command is equal to the view depth of the previous command, connect the corresponding node of the current command to the parent node of the corresponding node of the previous command, making the current node a sibling node of the previous command. If the number of spaces before the current command is less than the view depth of the previous command, search upwards from the parent node of the previous command based on the difference between the number of spaces and the depth, and connect the corresponding node of the current command to the ancestor node of the corresponding node of the previous command, making the current node a child node of the ancestor node of the previous command. The configuration file separates different configured items by enabling view commands, and the depth of the view is indicated by the number of spaces before the command. Entering a view indicates configuring a new item, which can be one or more of the following: an interface, VPN, or protocol function.

[0050] Step c. Repeat step b until all commands in the configuration file are traversed in turn to obtain the constructed configuration tree.

[0051] The corresponding statements include:

[0052] Step a. Parse the configuration file command to obtain the corresponding command in the first device, and obtain the parameters used in the configuration file command to form a parameter list. The correctness of the parameter order after translation is ensured by maintaining the order of the parameters in the parameter list.

[0053] Step b. Find the corresponding parameters in the second device for all parameters in the parameter list through the parameter correspondence results, and use the string matching method to find the command format of the corresponding parameter in the second device in the specific model of the second device according to the corresponding parameter in the second device. Iterate through the parameter list in turn. After completing the iteration, one or more command formats and the corresponding parameters in the second device are obtained. Fill the corresponding parameters in the second device into the corresponding command format through the command filling method to obtain the second parameter list.

[0054] Step c. Return to the configuration tree, find the command node in the configuration tree that contains the parameters in the second parameter list, and search in the order of sibling nodes of different commands, parent node, sibling nodes of the parent node of different commands, parent node of the parent node, and so on. Fill the selected parameters into the corresponding command in the second device to generate the second command.

[0055] Step d. Create a virtual empty parent node, connect the generated second command to the virtual empty parent node as its child node, and traverse each level of the configuration tree from top to bottom. When the traversal of the current level of the configuration tree is completed, connect all the corresponding nodes of the current level to the corresponding nodes generated by the nodes of the previous level. After the configuration tree traversal is completed, the corresponding result of the statement is obtained.

[0056] S3. Combine the parameter correspondence results obtained in step S1 with the statement correspondence results obtained in step S2 to obtain multiple command blocks;

[0057] S4. Sort the multiple command blocks obtained in step S3 to obtain the sorted statements that correspond to the device statements of the second device and satisfy the view relationship, and output the configuration file of the second device;

[0058] Before sorting multiple command blocks, a recursive algorithm is used to transform each command block into a tree-structured CLI model hierarchy that satisfies the view relationship. The recursive algorithm starts building from the deepest level of sub-command blocks contained in each command block. The CLI model hierarchy uses the root node of the completed subtree to represent this subtree to complete the sorting task of the next level. Each sub-command block corresponds to a child node in the subtree. The hierarchical structure is built using the auxiliary framework NAssim as the standard for statement sorting.

[0059] Specifically, S401. An index is created for each child node in each CLI model hierarchy using a hash algorithm;

[0060] S402. For the lowest-level command block, traverse each sub-command, create a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the lowest-level command tree. For non-lowest-level command blocks, traverse each sub-command, create a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the non-lowest-level command tree.

[0061] S403. Connect the lowest-level command tree to the root node of a non-lowest-level command tree to form a subtree, obtain the statement sorting that corresponds to the device statements of the second device and satisfies the view relationship, and output the configuration file of the second device.

[0062] This embodiment also provides an electronic device, including a memory and a processor. The memory stores a computer program; the processor executes the computer program in the memory to implement the above-described method.

[0063] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.

[0064] Example 2

[0065] This embodiment provides a network device configuration translation method based on semantic similarity, including the following steps:

[0066] S1. Input the equipment manuals of the first and second devices, and complete the direct correspondence between the parameters of the first and second devices based on the auxiliary frameworks Nassim, SBERT model and unified device model, to obtain the parameter correspondence results of the first and second devices;

[0067] Specifically:

[0068] S101. Equipment manual parsing, including obtaining the first equipment-specific model and the second equipment-specific model respectively from the basic information in the first equipment manual and the second equipment manual based on the auxiliary framework Nassim;

[0069] S102. Context information extraction, including extracting semantic information from the first device-specific model obtained in step S101 as the first context information, as shown in formula (1):

[0070] c1( )=[ , ,..., (1)

[0071] Among them, c1( () indicates the first context information extracted. Let i1 represent the first device parameter, where i1∈{0,1,...,nM1-1}, and nM1 is the number of parameters in the first device parameter. A text sequence representing the first device parameter. This indicates the number of sequences extracted from a specific model of the first device;

[0072] Semantic information is extracted from the second device-specific model obtained in step S101 as the second context information, as shown in formula (2):

[0073] c2( )=[ , ,..., (2)

[0074] Among them, c2( ) represents the extracted second context information. Let i2 represent the second device parameter, where i2∈{0,1,...,nM1-1}, and nM2 is the number of parameters in the second device parameter. A text sequence representing the second device parameters. This indicates the number of sequences extracted from a specific model of the second device;

[0075] S103. Context encoding, including pre-training the SBERT model with the sentence target and the NLI dataset to obtain an improved SBERT model, and encoding the first context information obtained in step S102 through the improved SBERT model to generate the first context embedding vector, as shown in formula (3):

[0076] ( , )→( , )∈( , (3)

[0077] in, The parameters in the basic information related to the supplier-specific model, V1∈M1, This refers to the parameters in the basic information related to the unified device model. , ) represents the parameter pair of the first context information, ( , ) represents the first context embedding vector pair. This represents the number of sequences extracted from the basic information related to the supplier-specific model. This represents the number of sequences extracted from the basic information related to the unified device model;

[0078] The second context information obtained in step S102 is encoded by improving the SBERT model, and the second context embedding vector is generated as shown in formula (4):

[0079] ( , )→( , )∈( , (4)

[0080] in, The parameters in the basic information related to the supplier-specific model, V2∈M2, This refers to the parameters in the basic information related to the unified equipment model. , ) represents the parameter pair of the second context information, ( , ) represents the second context embedding vector pair. This represents the number of sequences extracted from the basic information related to the supplier-specific model. This indicates the number of sequences extracted from the basic information related to the unified equipment model;

[0081] S104. Map the first device parameter to the unified device model parameter, and map the second device parameter to the unified device model parameter, including the first context embedding vector obtained in step S103 of inter-line cosine similarity calculation and the unified device model embedding vector, to obtain the first parameter mapping. The inter-line cosine similarity calculation of the first device parameter and the unified device model parameter is shown in formula (5):

[0082] Sim( , ) =w·( (5)

[0083] Where w is the weight vector, w= <w0,w1,..., > (st )

[0084] The second parameter mapping is obtained by using the second context embedding vector obtained in step S103 of the inter-line cosine similarity calculation and the unified device model embedding vector. The inter-line cosine similarity calculation of the second device parameter and the unified device model parameter is shown in formula (6).

[0085] Sim( , ) =w'·( (6)

[0086] Where w' is the weight vector, w'= <w’0,w’2,..., > (st );

[0087] S105. Using the first parameter mapping and the second parameter mapping obtained in step S104, obtain the parameter correspondence results of the first device and the second device;

[0088] This embodiment uses Python to implement a prototype system of the method, constructs a parameter-corresponding dataset, and conducts experiments on the time of parameter-corresponding commands and command parsing time. Specifically, it uses Huawei's publicly available device-specific model dataset to construct a dataset corresponding to HUAWEI VDM-NOKIA VDM parameters, as shown in Table 1.

[0089] Table 1 Datasets corresponding to HUAWEI VDM-NOKIA VDM parameters

[0090]

[0091] S2. Combine the device statement of the first device with the parameter correspondence result obtained in step S1 into a command-based configuration file, build the configuration file into a configuration tree to perform statement correspondence, and obtain the statement correspondence result. Converting the configuration file into a configuration tree can solve the problem of configuring different things with the same parameters in the configuration file.

[0092] Specifically, building the configuration tree includes:

[0093] Step a. Create an empty node as the root node of the configuration tree, set the depth of the current view to 0, and construct the corresponding node for each command;

[0094] Step b. Determine the number of spaces before the current command in the configuration file and the view depth of the previous command. If the number of spaces before the current command is greater than the view depth of the previous command, it means the previous command enabled a new view, and the current command is within the new view. In this case, connect the corresponding node of the current command to the corresponding node of the previous command, making the corresponding node of the current command a child node of the corresponding node of the previous command. If the number of spaces before the current command is equal to the view depth of the previous command, it means the current command and the previous command are in the same view. In this case, connect the corresponding node of the current command to the parent node of the corresponding node of the previous command, making the corresponding node of the current command a sibling node of the corresponding node of the previous command. If the number of spaces before the current command is less than the view depth of the previous command, it means the current command and the previous command are not closely related, but belong to a higher-level view. In this case, search upwards from the parent node of the previous command based on the difference between the number of spaces and the depth, and connect the corresponding node of the current command to the ancestor node of the corresponding node of the previous command, making it a child node of the ancestor node of the corresponding node of the previous command.

[0095] The configuration file separates different things by enabling the view command. The depth of entering the view is indicated by adding the number of indentation spaces before the command. Entering a view means configuring a new thing, which can be one or more of the following: interface, VPN, or protocol function.

[0096] Step c. Repeat step b until all commands in the configuration file are traversed sequentially to obtain the constructed configuration tree;

[0097] Specifically, the corresponding statements include:

[0098] Step a. Parse the configuration file command to obtain the corresponding command in the first device, and obtain the parameters used in the configuration file command to form a parameter list. The correctness of the parameter order after translation is ensured by maintaining the order of the parameters in the parameter list.

[0099] Step b. Find the corresponding parameters in the second device for all parameters in the parameter list through the parameter correspondence results, and use the string matching method to find the command format of the corresponding parameter in the second device in the specific model of the second device according to the corresponding parameter in the second device. Iterate through the parameter list in turn. After completing the iteration, one or more command formats and the corresponding parameters in the second device are obtained. Fill the corresponding parameters in the second device into the corresponding command format through the command filling method to obtain the second parameter list.

[0100] Step c. Based on the second parameter list, return to the configuration tree and search for the command node containing the parameters in the second parameter list. Search in the order of sibling nodes of different commands, parent nodes, sibling nodes of parent nodes of different commands, parent nodes of parent nodes, and so on. Fill the selected parameters into the corresponding command in the second device to generate the second command.

[0101] Step d. Create a virtual empty parent node, connect the generated second command to the virtual empty parent node as its child node, and traverse each level of the configuration tree from top to bottom. When the traversal of the current level of the configuration tree is completed, connect all the corresponding nodes of the current level to the corresponding nodes generated by the nodes of the previous level. After the configuration tree traversal is completed, the corresponding result of the statement is obtained.

[0102] S3. Combine the parameter correspondence results obtained in step S1 with the statement correspondence results obtained in step S2 to obtain multiple command blocks;

[0103] S4. Sort the multiple command blocks obtained in step S3 to obtain the sorted statements that correspond to the device statements of the second device and satisfy the view relationship, and output the configuration file of the second device;

[0104] It also includes using a recursive algorithm to transform each command block into a tree-structured CLI model hierarchy that satisfies view relationships before sorting multiple command blocks. The recursive algorithm starts building from the deepest level of sub-command blocks contained in each command block. The CLI model hierarchy uses the root node of the completed subtree to represent this subtree to complete the sorting task of the next level. Each sub-command block corresponds to a child node in the subtree. The hierarchical structure is built using the auxiliary framework NAssim as the standard for statement sorting.

[0105] Step S4 includes:

[0106] S401. An index is created for each child node in the CLI model hierarchy using a hash algorithm, so that the corresponding child node can be quickly retrieved by the subcommand name;

[0107] S402. For the lowest-level command block, traverse each sub-command, create a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the lowest-level command tree. For non-lowest-level command blocks, traverse each sub-command, create a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the non-lowest-level command tree.

[0108] S403. Treat the root node of the non-bottom-level command tree as a command, connect the bottom-level command tree to the root node of the non-bottom-level command tree to form a subtree, obtain the statement sorting that corresponds to the device statement of the second device and satisfies the view relationship, and output the configuration file of the second device.

[0109] In network device configuration translation, heuristic algorithms are designed based on the relationship between parameters and commands to complete the command mapping task. Parameters depend on commands for existence, and the commands containing the parameters can be found based on the parameters. Therefore, potential command mappings can be found through the corresponding parameters. However, command mapping is different from parameter mapping. Command mapping is not limited to a one-to-one situation; multiple situations can occur. The reason for other situations is that the correspondence between commands and parameters is not an absolute one-to-one. A command usually contains multiple parameters. Multiple parameters in one command on an existing device may require multiple commands to cover in a new device. In this case, command mapping will result in a one-to-many situation. If the models of the existing and new devices are interchanged, a many-to-one situation will occur. Combining the one-to-many and many-to-one situations may result in a many-to-many situation. Therefore, the number of sentences before and after translation may change.

[0110] Furthermore, relying solely on parameters to complete statement mapping is difficult. First, some commands do not use parameters, and all tokens in these commands are keywords, making it impossible to determine the mapping between parameterless commands through parameters. Second, the auxiliary framework NAssim completes parameter mapping based on the parameter section of the page, and a parameter in the parameter section may appear in multiple command formats on the same page, making it impossible to determine which command to use based on parameters.

[0111] Therefore, this embodiment proposes a new method to address the issue of "many-to-many" command correspondence. Based on the result of the parameter correspondence, the parameters of the new device are found, and further, the command containing the parameters is located. The existing parameters are then filled into the new command. Adhering to the principles of ensuring the syntactic correctness of the new command and filling in as many parameters as possible from the existing device into the new device, the parameters are retrieved from the existing device to find the command for the new device and filled into the corresponding command. "One-to-one," "one-to-many," and "many-to-one" can all be considered special cases within the "many-to-many" scenario; therefore, the method proposed in this embodiment can cover all four scenarios.

[0112] Building upon existing parameter mapping methods, this invention proposes a semantic similarity-based network device configuration translation method. This method enables parameter mapping between different devices and translates configuration file statements, solving the problem that existing methods cannot achieve "one-to-many," "many-to-one," and "many-to-many" relationships in configuration commands. Finally, a statement sorting algorithm is designed to organize the configuration file format according to the command tree to meet grammatical requirements. Experiments show that the average configuration translation time increases linearly with the amount of input configuration command trees, translating 100 commands on average takes 5.3 seconds. In contrast, manually filtering 100 commands and mapping parameters would take approximately 3 days, significantly improving work efficiency. Furthermore, this invention's method supports parameterless command mapping, while existing methods require at least one parameter.

[0113] Based on the above embodiments, this application also provides an electronic device, which includes: one or more processors, a memory, and one or more programs; wherein the one or more programs are stored in the memory, and the one or more programs include instructions that, when executed by the electronic device, cause the electronic device to perform the method provided in the above embodiments.

[0114] Based on the above embodiments, this application also provides a computer storage medium storing a computer program, which, when executed by a computer, causes the computer to perform the methods provided in the above embodiments.

[0115] The storage medium can be any available medium that a computer can access. For example, but not limited to, a computer-readable medium can include RAM, ROM, EEPROM, CDROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.

[0116] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0117] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0118] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0119] The embodiments of the present invention are given for illustrative and descriptive purposes only, and are not intended to be exhaustive or to limit the invention to the forms disclosed. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described in order to better illustrate the principles and practical application of the invention, and to enable those skilled in the art to understand the invention and to design various embodiments with various modifications suitable for a particular purpose.

Claims

1. A method for translating network device configurations based on semantic similarity, characterized in that, Includes the following steps: S1. Input the equipment manuals of the first and second devices, and complete the direct correspondence between the parameters of the first and second devices based on the auxiliary frameworks Nassim, SBERT model and unified device model, to obtain the parameter correspondence results of the first and second devices; S2. Combine the device statement of the first device with the parameter correspondence result obtained in step S1 into a command-based configuration file, construct the configuration file into a configuration tree to perform statement correspondence, and obtain the statement correspondence result; In step S2, constructing the configuration tree includes: Step a. Create an empty node as the root node of the configuration tree, set the depth of the current view to 0, and construct the corresponding node for each command; Step b. Determine the number of spaces before the current command in the configuration file and the view depth of the previous command. If the number of spaces before the current command is greater than the view depth of the previous command, connect the corresponding node of the current command to the corresponding node of the previous command, and the corresponding node of the current command becomes the child node of the corresponding node of the previous command. If the number of spaces before the current command is equal to the view depth of the previous command, connect the corresponding node of the current command to the parent node of the corresponding node of the previous command, and the corresponding node of the current command becomes the sibling node of the corresponding node of the previous command. If the number of spaces before the current command is less than the view depth of the previous command, find the ancestor node upwards from the parent node of the previous command based on the difference between the number of spaces and the depth, and connect the corresponding node of the current command to the ancestor node of the corresponding node of the previous command, and become the child node of the ancestor node of the corresponding node of the previous command. Step c. Repeat step b until all commands in the configuration file are traversed sequentially to obtain the constructed configuration tree; The statements correspond to: Step a. Parse the configuration file command of the configuration file to obtain the command corresponding to the configuration file command in the first device, and obtain the parameters used in the configuration file command to form a parameter list. The correctness of the parameter order after translation is ensured by maintaining the order of the parameters in the parameter list. Step b. Find the parameters in the second device for all parameters in the parameter list through the parameter correspondence results, and use the string matching method to find the command format of the corresponding parameter in the second device in the specific model of the second device according to the corresponding parameter in the second device. Iterate through the parameter list in turn. After the iteration is completed, one or more command formats and the corresponding parameters in the second device are obtained. Fill the corresponding parameters in the second device into the corresponding command format through the command filling method to obtain the second parameter list. Step c. Return to the configuration tree, find the command node in the configuration tree that contains the parameters in the second parameter list, and search in the order of sibling nodes of different commands, parent node, sibling nodes of the parent node of different commands, parent node of the parent node, and so on, and fill the selected parameters into the corresponding command in the second device to generate the second command. Step d. Create a virtual empty parent node, connect the generated second command to the virtual empty parent node as a child node of the virtual empty parent node, and traverse each level of the command node of the configuration tree from top to bottom. When the traversal of the command node of the current level of the configuration tree is completed, connect all the corresponding nodes of the current level to the corresponding nodes generated by the nodes of the previous level. After the configuration tree traversal is completed, the corresponding result of the statement is obtained. S3. Combine the parameter correspondence results obtained in step S1 with the statement correspondence results obtained in step S2 to obtain multiple command blocks; S4. Sort the multiple command blocks obtained in step S3 to obtain the sorted statement that corresponds to the device statement of the second device and satisfies the view relationship, and output the configuration file of the second device.

2. The network device configuration translation method based on semantic similarity according to claim 1, characterized in that, Step S1 includes: S101. Equipment manual parsing, including obtaining the first equipment-specific model and the second equipment-specific model respectively from the basic information in the first equipment manual and the second equipment manual based on the auxiliary framework Nassim; S102. Context information extraction, including extracting semantic information from the first device-specific model obtained in step S101 as first context information, and extracting semantic information from the second device-specific model obtained in step S101 as second context information; S103. Context encoding, including pre-training the SBERT model with the sentence target and the NLI dataset to obtain an improved SBERT model, encoding the first context information obtained in step S102 through the improved SBERT model to generate a first context embedding vector, and encoding the second context information obtained in step S102 through the improved SBERT model to generate a second context embedding vector. S104. Map the first device parameters to the unified device model parameters, and map the second device parameters to the unified device model parameters, including calculating the first context embedding vector and the unified device model embedding vector obtained in step S103 by inter-line cosine similarity to obtain the first parameter mapping, and calculating the second context embedding vector and the unified device model embedding vector obtained in step S103 by inter-line cosine similarity to obtain the second parameter mapping; S105. Using the first parameter mapping and the second parameter mapping obtained in step S104, obtain the parameter correspondence results of the first device and the second device.

3. The network device configuration translation method based on semantic similarity according to claim 2, characterized in that, In step b, the configuration file separates different configured items by enabling view commands, and the depth of entering the view is indicated by adding the number of indentation spaces before the command. Entering a view indicates configuring a new item, which is one or more of the following: interface, VPN, or protocol function.

4. The network device configuration translation method based on semantic similarity according to claim 3, characterized in that, Step S4 further includes, before sorting multiple command blocks, using a recursive algorithm to transform each command block into a tree-structured CLI model hierarchy that satisfies the view relationship. The recursive algorithm starts from the deepest level of sub-command blocks contained in each command block. The CLI model hierarchy uses the root node of the constructed subtree to represent this subtree to complete the sorting task of the upper level. Each sub-command block corresponds to a child node in the subtree. The hierarchical structure is constructed using the auxiliary framework NAssim as the standard for statement sorting.

5. The network device configuration translation method based on semantic similarity according to claim 4, characterized in that, Step S4 includes: S401. An index is created for each child node in the CLI model hierarchy using a hash algorithm; S402. For the lowest-level command block, traverse each sub-command, establish a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the lowest-level command tree. For non-lowest-level command blocks, traverse each sub-command, establish a corresponding node, find the child node of each sub-command in the CLI model hierarchy, record the parent node of the child node, and store it in the parent node list. After traversal, compare whether each child node in the CLI model hierarchy exists in the parent node list. For the existing child node, set it as the root node of the command tree, and construct the other sub-commands as the child nodes of the root node to obtain the non-lowest-level command tree. S403. Connect the lowest-level command tree to the root node of a non-lowest-level command tree to form a subtree, obtain the statement sorting that corresponds to the device statements of the second device and satisfies the view relationship, and output the configuration file of the second device.

6. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program; the processor is configured to execute the computer program in the memory to implement the method according to any one of claims 1 to 5.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Translating configuration files among network devices

    CN1615480A

  • Network configuration command generation system and method based on natural language

    CN116545854A

  • Systems and methods for gauging differences between network configurations

    US20220391662A1