Method and device for shortening execution time of configuration file in network equipment
By dynamically learning and predicting the probability of command occurrence, we optimize the command search matching during configuration file execution in network devices, solving the problem of time-consuming configuration file execution, and achieving shortening of time and efficiency improvement.
Patent Information
- Application Number
- CN202411350938.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2044-09-26
AI Technical Summary
In network devices, the time for commands to find matches during configuration file execution accounts for a very high proportion, which makes the configuration file execution time long and makes it difficult for the existing technology to effectively optimize.
By dynamically learning the probability of the next command of each command, a lookup table is established to record the number of occurrences of the next command of each command, and based on this probability, predict the matching command of the statement to be executed, and priority is given to the prediction command. If successful, it will be executed directly.
It effectively shortens the time-consuming execution of configuration files, improves processing efficiency, saves search and matching time, and meets practical application needs.
Smart Images

Figure CN119316281A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network device system management, in particular to a method and a device for shortening the execution time of a configuration file in a network device. Background Art
[0002] In network devices, a common way to store configuration is to use command line configuration files; the advantage of this method is that it has excellent compatibility, is not limited by device implementation solutions, and can be upgraded smoothly.
[0003] Many command lines are registered in network devices. The registered information usually includes the format definition of the command and the processing function to be executed. The format definition of a command is a special string containing multiple fields, each of which can be a keyword or a parameter. The input text that a parameter can match is variable, and special symbols are often used to define the matching rules. For example, in OLT devices: [...|...|...] means that the parameter can match one of a group of options, and <...> means that it can match any input.
[0004] The user inputs a text statement through the command line terminal, which is parsed by the command line kernel and then searches for a matching command in the command line list registered in the system. This requires matching the input statement with the format of each registered command line, which is a complex pattern matching process that is difficult to optimize using conventional means. After finding a matching command line, the processing function and parameter list corresponding to the input statement can be obtained, and then the corresponding processing can be performed.
[0005] The configuration file is used to store the user's configuration, which contains a large number of command statements. After the device restarts, the configuration is restored by executing each command statement in the file in sequence. This process is very time-consuming, and the process of searching and matching each statement with the registered command line list accounts for a very high proportion of the entire configuration execution time.
[0006] Therefore, how to optimize the command search and matching process during the execution of the network device configuration file, thereby shortening the execution time of the entire configuration file, is a problem that needs to be solved urgently by those skilled in the art. Summary of the invention
[0007] The purpose of the present invention is to provide a method and device for shortening the execution time of a configuration file in a network device, and based on dynamic learning and prediction, optimize the command search and matching process during the execution of the network device configuration file, thereby shortening the execution time of the entire configuration file.
[0008] To achieve the above objectives, in a first aspect, an embodiment of the present invention provides a method for shortening the execution time of a configuration file in a network device, the method comprising: during the execution of the configuration file, dynamically learning the probability of occurrence of the next command of each command; predicting the predicted command that can be matched by the next statement to be executed based on the probability, and matching it; when the match is successful, directly executing the matched predicted command.
[0009] In combination with the first aspect, in one embodiment, the dynamic learning of the probability of occurrence of the next command of each command includes: establishing a lookup table to record the probability of occurrence of the next command of each command in the commands that have been executed; the lookup table is generated by dynamic learning, and each time a command is executed, the lookup table is updated using a combination of the command and the previous command.
[0010] In combination with the first aspect, in one embodiment, the index of the lookup table is each command that has been executed in the current configuration file; the content of the table entry is a set of the next commands of each command in the current configuration file, sorted from large to small according to the number of times they appear; the elements of the set are the next command and the count of the number of times the command appears.
[0011] In combination with the first aspect, in one implementation, the matchable predicted command is one or several commands.
[0012] In combination with the first aspect, in one embodiment, a predicted command that can be matched by the next statement to be executed is predicted based on the probability and matched, including: when executing the next statement, using the previous command as an index to search in the lookup table; if found, using one or several commands ranked high in the set of corresponding table items as predicted commands to match the statement to be executed; if not found, matching the statement to be executed with the full set of registered command lines.
[0013] In a second aspect, an embodiment of the present invention further provides a device for shortening the execution time of a configuration file in a network device, the device comprising a learning module and a prediction and execution module;
[0014] The learning module is used to: dynamically learn the occurrence probability of the next command of each command during the execution of the configuration file;
[0015] The prediction and execution module is used to: predict the predicted command that can be matched by the next statement to be executed based on the probability, and match it with the predicted command; when the match is successful, directly execute the matched predicted command.
[0016] In conjunction with the second aspect, in one implementation, the learning module dynamically learns the occurrence probability of the next command of each command, specifically including the following operations:
[0017] The learning module records the probability of the next command of each command in the executed commands by establishing a lookup table; the lookup table is generated by dynamic learning, and each time a command is executed, the lookup table is updated by using the combination of the command and the previous command.
[0018] In combination with the second aspect, in one embodiment, the index of the lookup table established by the learning module is each command that has been executed in the current configuration file; the content of the table items of the lookup table is a set of the next commands of each command in the current configuration file, sorted from large to small according to the number of times they appear; the elements of the set are the next command and the count of the number of times the command appears.
[0019] In combination with the second aspect, in one implementation, the predicted command predicted by the prediction and execution module is one or more commands.
[0020] In conjunction with the second aspect, in one implementation, the prediction and execution module predicts the predicted command that can be matched by the next statement to be executed based on the probability, and matches it, specifically including the following operations:
[0021] When executing the next statement, the prediction and execution module uses the previous command as an index to search in the lookup table;
[0022] If found, one or more commands ranked high in the corresponding table entry set are used as predicted commands to match the statement to be executed;
[0023] If not found, the statement to be executed is matched against the full set of registered command lines.
[0024] The beneficial effects brought by the technical solution provided in the embodiments of the present application include:
[0025] This embodiment utilizes the characteristic that the command statements in the configuration file have a fixed format. During the execution process, the probability of the next command of each command is dynamically learned, and based on this, the predicted command that is most likely to match the next statement to be executed is predicted, and then the predicted command is matched first; when the match is successful (that is, when the prediction hits), the process of matching with the entire set of registered command lines can be skipped, which effectively saves the search and matching time, thereby greatly shortening the execution time of the configuration file, improving processing efficiency, and meeting actual application needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A flow chart of an embodiment of a method for shortening the execution time of a configuration file in a network device of the present application;
[0027] Figure 2This is a specific example diagram of command matching during the execution of a configuration file;
[0028] Figure 3 A flowchart of a method for shortening the execution time of a configuration file in a network device in an example;
[0029] Figure 4 A schematic diagram of functional modules of an embodiment of an apparatus for shortening the execution time of a configuration file in a network device of the present application. DETAILED DESCRIPTION
[0030] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, the technical solutions of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0031] However, it should be noted that the examples to be introduced below are only some specific examples, and are not intended to limit the embodiments of the present invention to the following specific steps, values, conditions, data, sequences, etc. All other embodiments obtained by ordinary technicians in this field without creative work based on the embodiments in this application are within the scope of protection of this application.
[0032] Embodiment 1
[0033] See also Figure 1 As shown, this embodiment provides a method for shortening the execution time of a configuration file in a network device, and the method includes the following steps:
[0034] A. During the execution of the configuration file, dynamically learn the probability of the next command of each command;
[0035] B. Predicting a predicted command that can be matched by the next statement to be executed based on the probability, and matching it; when the match is successful, directly executing the matched predicted command.
[0036] It is understandable that the command statements in the configuration file (or configuration script) are not randomly distributed, but are arranged in a fixed format (generally a fixed sequence of multi-layer nesting plus iteration). Regardless of the format, it basically meets the following characteristics: the next command of each command is fixed most of the time. Therefore, based on this premise, this embodiment proposes a solution: utilizing the characteristic that the command statements in the configuration file have a fixed format, during the execution process, dynamically learn the probability of occurrence of the next command of each command, and based on this, predict the one or several commands that are most likely to match the next statement to be executed, and then give priority to matching with the predicted command; when the prediction hits, the matching with the full set of registered command lines can be skipped, so as to achieve the purpose of shortening the time consumption.
[0037] Furthermore, as an optional implementation, in this embodiment, when dynamically learning the probability of occurrence of the next command of each command, a lookup table can be established to record the probability of occurrence of the next command of each command in the commands that have been executed; the lookup table is generated by dynamic learning, and each time a command is executed, the lookup table is updated using a combination of the command and the previous command.
[0038] In this embodiment, the index of the lookup table is each command that has been executed in the current configuration file; the content of the table item is the set of the next command of each command in the current configuration file, sorted from largest to smallest according to the number of times it has appeared; the elements of the set are the next command and the count of the command's appearance. For example: in the command sequence AAABB that has been executed, the next command of A is A for 2 times and the next command is B for 1 time, that is, the content of table item A is the set {A:2,B:1}. And, it can be understood that the lookup table is initially empty and will be gradually updated through learning during the execution of the configuration file.
[0039] For example, in an actual application, dynamically learning the occurrence probability of the next command of each command in step A specifically includes the following operations:
[0040] A1. Each time a configuration file is executed, a lookup table is created.
[0041] A2. Whenever a statement is executed, the previous command is used as an index to search in the lookup table. If the query is not found, a new entry is added to the current lookup table and the process goes to step A3. If the query is found, the process goes directly to step A3.
[0042] A3. Add the current command to the next command set of the corresponding table entry, and update the count and sort. Specifically, if the current command does not exist in the set, add it to the end of the set, and the count (the count of the command appearance) is 1; if the current command already exists in the set, add 1 to the count of the corresponding command, and if the count exceeds the count of the previous command, move the sort of the current command forward until the entire set satisfies the count order from large to small.
[0043] Further, as an optional implementation, step B in this embodiment may include:
[0044] B1. When executing the next statement, use the previous command as an index to search in the lookup table. If found, go to step B2; if not found, go to step B3.
[0045] B2. Use one or more commands ranked high in the corresponding table set as predicted commands to match the statement to be executed; if the match fails, go to step B3; if the match succeeds, execute the matched command. It can be understood that in actual operation, the number of selected predicted commands can be set and adjusted according to specific application requirements, and this embodiment does not make specific limitations.
[0046] B3. According to the traditional method, the statement to be executed is matched with the complete set of registered command lines, and the matched commands are executed.
[0047] It can be understood that in this embodiment, the command that is most likely to match the next statement (i.e., one or several commands ranked high in the set of corresponding table items) will be predicted based on the existing lookup table, and these predicted commands will be matched first; if the match is successful, that is, the prediction hits, the process of matching the entire set of command lines can be skipped and the process of processing function execution can be directly entered, which can save a lot of time.
[0048] For example, see Figure 2 As shown, Figure 2 The following is a specific example of command matching during the execution of a configuration file. Figure 2 As shown in the figure, suppose that command A in the configuration file has been executed and the next question mark statement is to be executed. Then, using command A to look up the table, we can see that among the statements that have been executed, the next command of command A appears the most frequently, 15 times in total; followed by B, 7 times in total (such as Figure 2 As shown in the upper part of the lookup table). For the next question mark statement, it is predicted that the most likely matches are commands A and B, so A and B are matched first. Assuming that B is successfully matched in the end, the count of the next command of A in the update lookup table is 8 (as shown in the upper part of the lookup table). Figure 2 Assume that the next question mark statement after B is executed, and then use command B to look up the table, we can see that among the statements that have been executed, the next command of command B appears most frequently, 10 times in total; followed by C, 5 times in total (such as Figure 2 The next question mark statement after B is predicted to be most likely to match commands B and C, so it is matched with B and C first. The probability of prediction hits is actually very high when using this solution. Most of the time, statements only need to match a small number of predicted commands, rather than all registered command sets, which can greatly shorten the execution time of the configuration file.
[0049] In order to better understand the overall process of the first embodiment of the method for shortening the execution time of a configuration file in a network device of the present application, Figure 3As shown, a specific example is used to illustrate the overall implementation process of the above embodiment 1. Figure 3 As shown, a method for shortening the execution time of a configuration file in a network device includes:
[0050] S301, after starting to execute the configuration file, establish and initialize the lookup table;
[0051] S302, use the previous command as an index to search in the lookup table, if found, go to step S303; if not found, go to step S304; it can be understood that when the first command is executed, since it has no previous command and the lookup table is empty at this time, it will not be found in the lookup table, so it will go to step S304 to match the full set of command lines in a traditional way, and then complete the learning and update the lookup table;
[0052] S303, using one or more commands ranked high in the set of corresponding entries as predicted commands, and matching them with the statement to be executed; if the match fails, proceed to step S304; if the match succeeds, proceed to step S305;
[0053] S304, in a conventional manner, matching the statement to be executed with the full set of registered command lines, and proceeding to step S305;
[0054] S305, execute the matched command and go to step S306;
[0055] S306, use the previous command as an index to search in the search table, if not found, go to step S307; if found, go to step S308;
[0056] S307, adding a new entry to the current lookup table, and proceeding to step S308;
[0057] S308, adding the current command to the next command set of the corresponding entry, and updating the count and sorting;
[0058] S309: Determine whether to continue executing the next statement. If so, return to step S302; otherwise, terminate the execution of the configuration file.
[0059] From the above content, it can be seen that this solution utilizes the fixed format of command statements in the configuration file. During the execution process, it dynamically learns the probability of the next command of each command, and based on this, predicts one or several commands that are most likely to match the next statement to be executed, and then prioritizes matching with the predicted commands; when the match is successful (that is, when the prediction hits), the process of matching with the entire set of registered command lines can be skipped, effectively saving search and matching time, thereby greatly shortening the time spent on configuration file execution, improving execution efficiency, and meeting actual application needs.
[0060] Embodiment 2
[0061] join Figure 4 As shown, based on the same inventive concept, an embodiment of the present invention further provides a device for shortening the execution time of a configuration file in a network device, the device comprising: a learning module and a prediction and execution module.
[0062] The learning module is used to dynamically learn the probability of the next command of each command during the execution of the configuration file. The prediction and execution module is used to predict the predicted command that can be matched by the next statement to be executed based on the probability and match it; when the match is successful, directly execute the matched predicted command.
[0063] It can be understood that in this embodiment, the learning module can dynamically learn the probability of occurrence of the next command of each command during the execution of the configuration file, and the prediction and execution module can predict one or more commands that are most likely to match the next statement to be executed based on the learned probability, and then give priority to matching the predicted commands; when the match is successful (that is, when the prediction hits), the process of matching with the entire set of registered command lines can be skipped, effectively saving the search and matching time, thereby greatly shortening the time spent on configuration file execution, improving execution efficiency, and meeting actual application needs.
[0064] It should be noted that the various variations and specific examples in the aforementioned method embodiments are also applicable to the device of this embodiment. Through the detailed description of the aforementioned method, those skilled in the art can clearly know the implementation method of the device in this embodiment, so for the sake of brevity of the specification, they will not be described in detail here.
[0065] Note: The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0066] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.
[0067] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.
[0068] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.
[0069] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.
[0070] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.
[0071] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for shortening the execution time of a configuration file in a network device, characterized in that: The method includes: During the execution of the configuration file, the probability of the next command of each command is dynamically learned; Based on the probability, a predicted command that can be matched by the next statement to be executed is predicted and matched; when the match is successful, the matched predicted command is directly executed.
2. The method for shortening the execution time of a configuration file in a network device according to claim 1, characterized in that: The dynamically learning the occurrence probability of the next command of each command includes: A lookup table is established to record the occurrence probability of the next command of each command in the executed commands; the lookup table is generated by dynamic learning, and each time a command is executed, the lookup table is updated by using the combination of the command and the previous command.
3. The method for shortening the execution time of a configuration file in a network device according to claim 2, characterized in that: The index of the lookup table is each command that has been executed in the current configuration file; the content of the table entry is a set of the next commands of each command in the current configuration file, sorted from largest to smallest according to the number of times it has appeared; the elements of the set are the next command and the count of the number of times the command has appeared.
4. The method for shortening the execution time of a configuration file in a network device according to claim 3, characterized in that: The matchable predicted command is one or more commands.
5. The method for shortening the execution time of a configuration file in a network device according to claim 4, characterized in that: Predicting a predicted command that can be matched by the next statement to be executed based on the probability and matching it includes: When the next statement is executed, the previous command is used as an index to search in the lookup table; If found, one or more commands ranked high in the corresponding table entry set are used as predicted commands to match the statement to be executed; If not found, the statement to be executed is matched against the full set of registered command lines.
6. A device for shortening the execution time of a configuration file in a network device, characterized in that: The device includes a learning module and a prediction and execution module; The learning module is used to: dynamically learn the occurrence probability of the next command of each command during the execution of the configuration file; The prediction and execution module is used to: predict the predicted command that can be matched by the next statement to be executed based on the probability, and match it with the predicted command; when the match is successful, directly execute the matched predicted command.
7. The device for shortening the execution time of a configuration file in a network device according to claim 6, characterized in that: The learning module dynamically learns the probability of the next command of each command, specifically including the following operations: The learning module records the probability of the next command of each command in the executed commands by establishing a lookup table; the lookup table is generated by dynamic learning, and each time a command is executed, the lookup table is updated by using the combination of the command and the previous command.
8. The device for shortening the execution time of a configuration file in a network device according to claim 7, characterized in that: The index of the lookup table established by the learning module is each command that has been executed in the current configuration file; the content of the table items of the lookup table is a set of the next commands of each command in the current configuration file, sorted from large to small according to the number of times they have appeared; the elements of the set are the next command and the count of the number of times the command has appeared.
9. The device for shortening the execution time of a configuration file in a network device according to claim 8, characterized in that: The predicted command predicted by the prediction and execution module is one or more commands.
10. The device for shortening the execution time of a configuration file in a network device according to claim 9, characterized in that: The prediction and execution module predicts the predicted command that can be matched by the next statement to be executed based on the probability, and matches it. The following operations are included: When executing the next statement, the prediction and execution module uses the previous command as an index to search in the lookup table; If found, one or more commands ranked high in the corresponding table entry set are used as predicted commands to match the statement to be executed; If not found, the statement to be executed is matched against the full set of registered command lines.
Citation Information
Patent Citations
Method and device for analyzing command
CN107426041A
Equipment control method and system based on multi-control command analysis and related equipment
CN115941371A
Network configuration command generation system and method based on natural language
CN116545854A
Semiconductor device, method of controlling the same, and control program therefor
JP2011034408A
Method for improving data transmission speed in datastorage system and disc drive using the same
KR1020050024935A