Router operation is safeguarded demanded storage and the command interpretation method with configuration order
Technical field
The present invention is a kind of new router operation maintenance and the demanded storage and the command interpretation method of configuration order, particularly a kind of method that adopts tree-like hierarchical structure to do router demanded storage and command interpretation.
Background technology
Along with the development of Internet, the computer in the global range all competitively is connected into Internet to share information, the incomparable facility that enjoy network is brought.Follow increasing of the main frame number that is connected into network, single network can not be satisfied the demand, particularly the main frame that ought be connected into network more and more disperses, when the geographical position is more and more far away, the different ownership of difference in geographical location and computer, the control of information resources makes people begin progressively main frame to be divided into some sub-networks, and is that unit is connected into Internet with the sub-network.In network interconnection, a subnet need be known the position of another sub-network even all-ones subnet, so that the computer of subnet inside can mutual communication.Router is the network equipment that satisfies this demand, and it is responsible for seeking the purpose subnet address and is responsible for packet is forwarded to the purpose subnet.
Present network configuration is increasingly sophisticated, simultaneously, owing to be connected into the different situations of the main frame of Internet, possible some machinery requirement shutdown, perhaps change configuration, like this, different variations also just may take place in the situation that is connected into the subnet of Internet.Router not only needs the awareness network topological structure as seeking route and the correct equipment of transmitting packet, also needs to know the real-time change of network configuration.In order to realize this two main functions, the Routing Protocol that people have developed IGP and EGP specially comes the awareness network structure.IGP (Interior Gateway Protocol) Interior Gateway Protocol, it is exactly Routing Protocol at a relatively independent autonomous networks internal operation, be responsible for resolving the network configuration of network internal, EGP (External Gateway Protocol) Exterior Gateway Protocol, the router that moves between relatively independent autonomous networks is responsible for resolving the network configuration between the network exactly.
These Routing Protocols have been arranged, also needed to carry out certain operations and configuration, could allow the whole network topology of the correct understanding of router.Because router is made a special networks equipment, its major function is the forwarding for addressing that realizes network and packet, is not to have clear and definite man-machine interface as other the network equipment, and it is not with display, is not with keyboard, mouse yet.Thereby, to the operation of router, also just be different from other the network equipment, perhaps our common computer equipment.
Except needs router is operated, made outside its function of finishing route and forwarding, also need the work that router is safeguarded.Because any one equipment all needs to be serviced, router is no exception.Some problems occurred such as router, we need debug router, perhaps it are carried out the upgrading or the renewal of software.These maintenances, the same with operation to router, all can not import by keyboard, mouse, export by display, because router itself is not with these equipment.
Router generally only provides Operation and Maintenance and the configuration of carrying out with command line mode by the standard terminal.That is to say, to all operations of router, nearly all be by on the accurate terminal of another station symbol, finishes Operation and Maintenance to router by the order of input delegation delegation.Router will be known the implication of the order that the user imports, and just must at first parse the implication of these orders, and then calls different functional entity fill orders.
Because the function that router need be finished is quite complicated, because a router can be played the part of different functional roles in different network node positions.Thereby the command set of router is also very huge, and general all has the hundreds of bar to thousands of more than.To so huge command set, router not only to consider interpreted command accurately, fast, also to consider the convenient of the expansion of command set and modification.That is to say, command interpretation in router operation service portion part not only wants to mate fast and accurately and to find out the meaning of order in the order of nearly thousand complexity in a short relatively time, also want can the compatible router operational maintenance command modification and expansion.When one needs modification or expands an order, and in router, to react apace.
In the solution that existing router operation is safeguarded, all be that whole order is divided into several independent command words generally, be unit encapsulates with the command word, in the content of encapsulation, comprised the calling logic relation of command word.It had both comprised its left command word, had comprised its right command word again, and from the beginning an order of finishing need find tail in this chained list relation,, only in strict accordance with the logical relation of its appointment, could form an order of finishing that is.
The storage format and the command interpretation mode of this command word encapsulation, programmed logic more complicated when having caused command search, all command words are rambling to be left among the internal memory, organizes by the company's table relation in the command word encapsulation merely.Simultaneously, the modification of order will almost be impossible realize, because, this needs the manual command word encapsulation accurately that finds in thousands of command words encapsulate, change left and right sides command word relation then, go to revise all relevant command words simultaneously again, make whole order obtain complete modification.
Numerous and diverse logical relation, disorderly orderliness makes the command interpretation of router partly seem and chaotic lacks extended capability.As a perfect product, should overcome these shortcomings, make the order line command interpretation of router partly be relatively independent of other parts of Operation and Maintenance, and clear and definite and succinct interface arranged that the while is extended command set easily with other parts.
Summary of the invention
The objective of the invention is to overcome the shortcoming of existing route device demanded storage and interpretation scheme, provide a kind of new router operation to safeguard and the demanded storage of configuration order and the method for command interpretation, make it to carry out commands match fast, easily and search; Make the online modification of command set can realize with expansion.
The object of the present invention is achieved like this, and a kind of router operation is safeguarded and the demanded storage and the command interpretation method of configuration order, is characterized in:
(1) the whole command set of router is broken, adopt the command tree mode of tree hierarchy relation to preserve, carry out index, deletion or add order by the order level;
(2) command tree is independently left on rapid memory memory (FLASH) or the nonvolatile random-access memory (NVRAM);
(3) after command interpretation is finished, number come advising process to call the function that corresponding functional modules realizes user's request by obtaining command execution.
The form of the employing multidimensional chained list of said command tree, the reorientation of multidimensional order chained list is to deposit tree-like method with the structure array to realize, it is the node that each element is represented command tree in the array, association in the tree between the node is to use the subscript of array to represent, will have these two information of the structure array of command tree and array element sum and write in the computer command script document on FLASH or the NVRAM.
At first define a dummy argument and come the whole multidimensional order of index chained list, what dummy argument was pointed is the head pointer of ground floor order chained list, by traveling through this chained list, obtain all command words of ground floor order in the whole router command set, each element in the ground floor chained list except that the pointer that comprises with the next element of layer chained list, has also comprised the command word full name, the meaning of command word, the head pointer of the order chained list of following one deck order of command word.
The online updating of command set is realized by update command script file mode.
The specific practice of said command set online updating is: at first generate new command set outside router, cover FLASH or the original computer command script document of NVRAM, go up computer command script document reading order tree from FLASH or NVRAM once more by the command interpretation part.
Advantage of the present invention is:
1, owing to set up storage and the explanation that the command tree of a clear and definite tree hierarchy relation is realized ordering among the present invention, makes it to carry out commands match fast, easily and search;
2, since command set data of the present invention independently deposit, make command set online modification and be expanded into possibility;
3, after command interpretation is finished, be number to come advising process to call the function that the corresponding function module is realized user's request by obtaining command execution, command interpretation part like this is relatively independent, has improved the maintainability of router operation maintenance and configuration-system.
Description of drawings
The invention will be further described below in conjunction with accompanying drawing.
Fig. 1 is the legend of command tree.
Fig. 2 is a multidimensional chain hoist pennants.
Fig. 3 is the logical flow chart of look-up command.
Embodiment
For can search out fast, commands match and searching easily, we need at first carry out detailed research to order line itself.Find that by studying us the router command set has following high-definition characteristics:
Characteristics 1: be exactly that order line has very significantly level, promptly an order line is made up of several command words and some parameters.These are had the structure of level, and we can come index as setting up chained list originally, also can similarly set up a command tree and come index.Because our front of shortcoming of list structure was analyzed, worthless, so for the tree hierarchy storage? we find that storage mode comes hold-over command if we adopt tree hierarchy, when order line is mated and searched, will have natural convenience.We can be finishing first order command word in the order line as the ground floor node of command tree, second level command word in the complete order row is as the second layer node of command tree, and by that analogy, simultaneously we also in the order with parameter be mapped in the command tree according to the form of command word.
Characteristics 2: be exactly that the tree-like level of the order of router operation maintenance command is not dark, this makes preserving with the command tree form of order become possibility.In other words, be exactly in the router order, if order is divided into level, we will find that the level of order can be too not dark, the command word of each layer neither be too many simultaneously, belongs to a kind of and distribute more uniformly.
By above two characteristics, we think can adopt so a kind of command index method, exactly whole command set is broken, and preserves in the mode of tree hierarchy command tree.When needs carry out command interpretation, in command tree, carry out index according to the order level.Simultaneously, because command set has adopted command tree level storage, make and to revise or seem convenient unusually during extended command set.If revise certain order, as long as go on, find the order that will revise along command tree, make amendment; If increase order, only need be along existing order branch, the leaf or the branch place interpolation command word of adding at needs; If delete command as long as find the command word that will delete along command tree, is deleted this command word leaf and is got final product.
The legend of command tree as shown in Figure 1.
Fig. 1 is the command tree of following command set
disable
enable
show?buffer
show?clock
show?flash?all
show?flash?chips
show?flash?detailed
Because shown in Figure 1 only is visual, a pro forma command tree.Want actual and preserve it, also it must be converted into the logic data structure of a definite form.For this reason, we can adopt the form of multidimensional chained list to come hold-over command.
Fig. 2 is the multidimensional chain hoist pennants with four levels.
Here at first define a dummy argument and come the whole order chained list of index.What dummy argument was pointed is the head pointer of ground floor order chained list, by traveling through this chained list, can obtain all command words of ground floor order in the whole router command set.Each element in the ground floor chained list except comprising the pointer with the next element of layer chained list, has comprised the command word full name, the meaning of command word, the head pointer of the order chained list of following one deck order of command word.Like this, when command lookup, just can come look-up command by the string matching of carrying out command word full name in input command and the chained list, obtain down the chain list index of one deck order after the coupling again, the coupling of following one deck order is until the coupling of finishing whole order.
The logic flow of look-up command is described below:
1, command string is resolved into several command words, coupling is word for word resolved in layering;
2, obtain that the inlet of command tree is a dummy argument in the internal memory, obtain the inlet of ground floor command word chained list;
3, the whole layer of traversal chained list obtains this layer command word and compares one by one, the command word of checking input whether with command set in the command word coupling;
4,, this layer order and the order note that travels through out returned, and report an error if do not match;
5, if mate, obtain the command byte period of coupling;
6, check whether be that order finishes;
If 7, return after obtaining command execution number;
8, if not, viewing command sign, whether parameter;
If 9, enter parameter type and detect;
10, if not, obtain down one deck command pointer;
11, repeated for 3 to 10 steps, finish until command analysis.
Its logic flow is seen Fig. 3,
An important consideration of the present invention is exactly the correlation that as far as possible reduces between each module.Command execution and command interpretation part is carried out by definition command and number is reduced correlation, so, to command interpretation, it will also will reduce correlation with the command tree of command set itself as far as possible, be that the command interpretation part also should be relatively independent, irrelevant with the order that will carry out.Therefore, we leave command tree separately on FLASH or the NVRAM.The command tree of multidimensional chained list to be saved in the continuous linear memory block of a slice among FLASH or the NVRAM, need carry out reorientation the chained list of command tree.
To the reorientation of multidimensional command tree chained list, be exactly of the mapping of multidimensional storage of linked list in fact in a slice order FLASH or NVRAM address.We adopt to deposit tree-like method with the structure array and realize, promptly each element is represented a node of command tree in the array, and the association in the tree between the node is to use the subscript of array to represent.To there be these two information of the structure array of command tree and array element sum like this and write in the computer command script document on FLASH or the NVRAM, finish the physical store of command set.The command interpretation part will directly be read in the internal memory the computer command script document of this array on FLASH or NVRAM, just can the travel all over command tree.
The invention still further relates to a bit, is exactly the online updating of the command set emphasized again and again.Because command set is to be stored in the relatively independent computer command script document of a slice among FLASH or the NVRAM, we can come the update command collection by the mode of update command script file.Specific practice is exactly, at first outside router device, generate new command set, cover FLASH or the original computer command script document of NVRAM, notification command explains that part goes up computer command script document reading order tree from FLASH or NVRAM once more, has so just realized the online upgrading of order.