Summary of the invention
The objective of the invention is provides a kind of network management monitoring protocol of repeater adaptive parsing method in order to overcome the problem and shortage of above-mentioned existence, solved network management monitoring protocol of repeater resolving code transplantability bad with the problem autgmentability difference.
A kind of network management monitoring protocol of repeater adaptive parsing method, carry out according to the following steps: after the protocol class object receives the outside original data stream that transmits, elder generation's all external interfaces of initialization, if interface initialization mistake occurs and then error code is turned back to previous step, the laggard line data format conversion processing of interface initialization success; If Data Format Transform mistake occurs and then error code turned back to previous step, data shift the parsing of successfully laggard capable protocol frame command header; If the resolve command head mistake occurs and then error code turned back to previous step, carry out the agreement authentication process after the success of resolve command head; If the agreement authentication mistake occurs and then error code is turned back to previous step, the dissection process of the laggard line command body of agreement authentication success; If the resolve command body mistake occurs and then error code turned back to previous step, then carry out the Data Update of protocol object after the success of resolve command body and handle; Appearance is wrong to turn back to previous step with error code if protocol data upgrades, and protocol data upgrades and successfully then generates the protocol class output interface, resolves thereby finish protocol data, and original data stream is resolved and generated the protocol class object the most at last;
Client layer only needs the display interface of invocation protocol class to get final product when the display protocol data, and need not to understand the detailed information of protocol data, if increased the discharging-directly station network management monitoring parameter in the network management monitoring protocol of repeater, when resolving, import its parameter attribute into the protocol class object, the protocol class object can carry out adaptive analytic according to the attribute of parameter, the present invention has constructed a kind of adaptive parsing method, when making increase in network management monitoring protocol of repeater, deletion, modification monitoring parameter, the network management monitoring protocol of repeater resolving code need not to revise among the present invention.
Described Data Format Transform is handled and is to carry out the data inverible transform according to the requirement of network management monitoring protocol of repeater, for example some protocol requirement replaces to 0 x 5E and 0 x 5D with the 0 x 7E that removes frame head and postamble part in the protocol frame, and the Data Format Transform among the present invention strictly observes network management monitoring protocol of repeater and carries out.
Described resolve command header parsing is to carry out according to the requirement of network management monitoring protocol of repeater the analyzing and processing of protocol frame frame header divided data, because protocol frame frame header separation structure relative fixed, therefore in the protocol class object, be provided with protocol frame frame head structure member among the present invention, need during parsing to get final product according to the extraction that network management monitoring protocol of repeater requires to carry out data.
Described agreement authentication process is to carry out the agreement authentication process according to the requirement of network management monitoring protocol of repeater, whether the information of the protocol frame frame head part that judgement obtains when requiring to carry out the agreement authentication in network management monitoring protocol of repeater and the information of protocol requirement is consistent, if unanimity thinks that then authentication passes through, if inconsistently then judge failed authentication.
The dissection process of described command body is to carry out according to the requirement of network management monitoring protocol of repeater the dissection process of command body, the requirement of parsing in different network management monitoring protocol of repeater for the protocol frame command body is not necessarily identical, judge but all return, indicate the extraction of the data of carrying out follow-up monitoring parameter object by these according to some sign of protocol frame head part.
The Data Update of described protocol object is handled the data that are to extract from the original agreement frame data according to the requirement of network management monitoring protocol of repeater monitoring repeater parameter correspondence.
Described protocol encapsulation is handled the protocol data frame that is to use according to the requirement of network management monitoring protocol of repeater the network management monitoring protocol of repeater class object structure protocol compliant standard that has existed.
Protocol parameter among the present invention has taken into full account the otherness of different parameters when design, come out and be kept in the object of parameter self the various various boundary conditions of parameter are abstract, numerous and diverse parameter testing verification etc. is operated in self the method for parameter and realize, this kind method for designing has improved the independence of protocol analysis part, make that the portability of this part software is good and increase at network management monitoring protocol of repeater, deletion and energy adaptive analytic and need not to revise resolving code when revising the monitoring repeater parameter.
Embodiment
A kind of network management monitoring protocol of repeater adaptive parsing method, carry out according to the following steps: after the protocol class object receives the outside original data stream that transmits, elder generation's all external interfaces of initialization, if interface initialization mistake occurs and then error code is turned back to previous step, the laggard line data format conversion processing of interface initialization success; If Data Format Transform mistake occurs and then error code turned back to previous step, data shift the parsing of successfully laggard capable protocol frame command header; If the resolve command head mistake occurs and then error code turned back to previous step, carry out the agreement authentication process after the success of resolve command head; If the agreement authentication mistake occurs and then error code is turned back to previous step, the dissection process of the laggard line command body of agreement authentication success; If the resolve command body mistake occurs and then error code turned back to previous step, then carry out the Data Update of protocol object after the success of resolve command body and handle; Appearance is wrong to turn back to previous step with error code if protocol data upgrades, and protocol data upgrades and successfully then generates the protocol class output interface, resolves thereby finish protocol data, and original data stream is resolved and generated the protocol class object the most at last;
Client layer only needs the display interface of invocation protocol class to get final product when the display protocol data, and need not to understand the detailed information of protocol data, if increased the discharging-directly station network management monitoring parameter in the network management monitoring protocol of repeater, when resolving, import its parameter attribute into the protocol class object, the protocol class object can carry out adaptive analytic according to the attribute of parameter, the present invention has constructed a kind of adaptive parsing method, when making increase in network management monitoring protocol of repeater, deletion, modification monitoring parameter, the network management monitoring protocol of repeater resolving code need not to revise among the present invention.
Described Data Format Transform is handled and is to carry out the data inverible transform according to the requirement of network management monitoring protocol of repeater, for example some protocol requirement replaces to 0 x 5E and 0 x 5D with the 0 x 7E that removes frame head and postamble part in the protocol frame, and the Data Format Transform among the present invention strictly observes network management monitoring protocol of repeater and carries out.
Described resolve command header parsing is to carry out according to the requirement of network management monitoring protocol of repeater the analyzing and processing of protocol frame frame header divided data, because protocol frame frame header separation structure relative fixed, therefore in the protocol class object, be provided with protocol frame frame head structure member among the present invention, need during parsing to get final product according to the extraction that network management monitoring protocol of repeater requires to carry out data.
Described agreement authentication process is to carry out the agreement authentication process according to the requirement of network management monitoring protocol of repeater, whether the information of the protocol frame frame head part that judgement obtains when requiring to carry out the agreement authentication in network management monitoring protocol of repeater and the information of protocol requirement is consistent, if unanimity thinks that then authentication passes through, if inconsistently then judge failed authentication.
The dissection process of described command body is to carry out according to the requirement of network management monitoring protocol of repeater the dissection process of command body, the requirement of parsing in different network management monitoring protocol of repeater for the protocol frame command body is not necessarily identical, judge but all return, indicate the extraction of the data of carrying out follow-up monitoring parameter object by these according to some sign of protocol frame head part.
The Data Update of described protocol object is handled the data that are to extract from the original agreement frame data according to the requirement of network management monitoring protocol of repeater monitoring repeater parameter correspondence.
Described protocol encapsulation is handled the protocol data frame that is to use according to the requirement of network management monitoring protocol of repeater the network management monitoring protocol of repeater class object structure protocol compliant standard that has existed.
In Fig. 1, the protocol class object receive outside transmit the original data stream of coming in after, elder generation's all external interfaces of initialization, the format conversion processing of the laggard line data of interface initialization success, carry out the parsing of protocol frame command header after the Data Format Transform success, command header is resolved successfully laggard capable agreement authentication process, the dissection process of the laggard line command body of agreement authentication process success, the data member that carries out protocol object after the dissection process success of command body upgrades to be handled, and the data member of protocol class object upgrades successfully back realization protocol class output interface.The protocol class object has not only comprised protocol monitor parameter member, a plurality of external interfaces have also been comprised, client layer only needs the display interface of invocation protocol class to get final product when the display protocol layer data, and need not to understand the detailed information of protocol data, if increase in the network management monitoring protocol of repeater or revised the discharging-directly station network management monitoring parameter, import its parameter attribute into the protocol class object during parsing, the protocol class object can carry out adaptive analytic according to the attribute of parameter, and this moment, the protocol analysis code need not to revise.Therefore client layer becomes easy to learn to calling of protocol class and need not to pay close attention to the realization and the change of protocol layer.
In Fig. 2, at first state a protocol class object, Data Update interface by protocol class imports more new data stream of monitoring parameter member into, the inspection of carrying out again after the data flow cache before the Data Update will be upgraded, check in the regular monitoring parameter object that is kept in advance in the protocol class, if then carrying out protocol frame after the Data Update inspection success encapsulates and realizes finally obtaining the protocol frame data flow by external passing interface.
In Fig. 3, initial data is flowed through after the parsing interface of protocol class resolves, and judges its analysis result, then returns error code if resolve failure, returns error code for analyzing reason usefulness, successfully then obtains the protocol class object if resolve.
In Fig. 4, the protocol class object is judged its encapsulated result after the protocol encapsulation interface encapsulation of protocol class, if error code is then returned in the encapsulation failure, returns error code for analyzing reason, successfully then obtains the protocol frame data flow if encapsulate.
In table 1, protocol class is by following member composition: the object member of monitoring parameter (can be basic data type in the agreement, the monitoring parameter class object of also abstract belt restraining), protocol class has two member methods the most basic: protocol analysis and protocol encapsulation, all operations all are encapsulated in these two member methods, protocol class also has four important interface: the one, and protocol frame data flow receiving interface, the one, protocol frame data flow output interface, the one, protocol class is to the coffret of client layer, and another is the Data Update interface of client layer to protocol class.These four interfaces with data respectively according to two kinds of forms: a kind of is that byte stream adds data length, another form is protocol frame to be carried out corresponding character string conversion generate a kind of new form, the data of transmitting in the agreement are directly come out with string representation, separated with decollator between monitoring parameter, identify (Unified coding when design) in the uniform data that adds monitoring parameter before the monitoring parameter, when client layer shows, reduced like this and protocol-dependent data transaction.
Table 1 protocol class is formed table.
<<metaclass〉〉 protocol class |
+ monitoring parameter 1:unsigned char=0+monitoring parameter 2:float=0.0+monitoring parameter 3:wchar_t=0+monitoring parameter 4:short=0+monitoring parameter 5:unsigned long=0+monitoring parameter 6:unsigned char=0+monitoring parameter 7:bool=false |
+ resolve (): bool+encapsulation (): bool<<signal _ protocol frame data flow receiving interface ()<<signal _ protocol frame data flow output interface ()<<signal _ protocol class to the coffret () of client layer<<signal _ client layer is to the Data Update interface () of protocol class |