WO2016090957A1 - Decoding method and apparatus, and computer storage medium - Google Patents

Decoding method and apparatus, and computer storage medium Download PDF

Info

Publication number
WO2016090957A1
WO2016090957A1 PCT/CN2015/087642 CN2015087642W WO2016090957A1 WO 2016090957 A1 WO2016090957 A1 WO 2016090957A1 CN 2015087642 W CN2015087642 W CN 2015087642W WO 2016090957 A1 WO2016090957 A1 WO 2016090957A1
Authority
WO
WIPO (PCT)
Prior art keywords
decoding
message
information
format
code stream
Prior art date
Application number
PCT/CN2015/087642
Other languages
French (fr)
Chinese (zh)
Inventor
许艳芳
Original Assignee
深圳市中兴微电子技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市中兴微电子技术有限公司 filed Critical 深圳市中兴微电子技术有限公司
Publication of WO2016090957A1 publication Critical patent/WO2016090957A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • the present invention relates to a codec technology in the field of communication protocols, and in particular, to a decoding method, apparatus, and computer storage medium.
  • the communication protocol is also constantly updated, and the application protocol needs to be updated accordingly.
  • most of the processing of standard protocol documents is to convert standard protocol documents into C, C++ and other languages through manual translation, and by manual decoding, not only a lot of manpower and time is wasted, but also error-prone. Therefore, many manufacturers analyze the standard protocol documents according to their own needs, establish their own codec system, in order to realize the automatic codec of the standard protocol documents related to themselves; when the standard protocol documents are upgraded, through the established codec system By directly reading the standard protocol document, the codec library can be upgraded, which greatly improves the efficiency of the codec.
  • Protocol documents describe the protocol information in the form of a table, such as the 24008x series of protocol documents. Since they do not have a unified syntax and a fixed format, it brings a lot of difficulties to automatically extract such protocol information.
  • the main purpose of the embodiments of the present invention is to provide a decoding method, an apparatus, and a computer storage medium, which can automatically decode and improve protocol documents described in a tabular form. Decoding efficiency.
  • An embodiment of the present invention provides a decoding method, where the method includes:
  • the code stream to be decoded is decoded based on the information stored in the database.
  • the protocol related information includes at least: message description information, cell description information, and enumeration description information.
  • the protocol-related information is extracted from the standard protocol document, and the protocol-related information is saved in the database in a corresponding data structure format, including:
  • the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
  • the decoding according to the information stored in the database, the code stream to be decoded, includes:
  • the optional decoding process includes:
  • the optional start node is obtained.
  • the option tag value actually obtained by the current code stream is matched with the standard optional tag value in the database, if it matches Successfully, get the current node, call the required decoding interface to decode.
  • the required decoding process includes:
  • the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
  • An embodiment of the present invention further provides a decoding apparatus, where the decoding apparatus includes an extraction module and a decoding module, where
  • the extracting module is configured to extract protocol related information from a standard protocol document, and save the protocol related information to a database in a corresponding data structure format;
  • the decoding module is configured to decode a code stream to be decoded based on information stored in the database.
  • the protocol related information includes at least: message description information, cell description information, and enumeration description information.
  • the extraction module includes a setting submodule, a reading submodule, and a storage submodule;
  • the setting submodule is configured to preset a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
  • the reading submodule configured to read the standard protocol document from the protocol document Extracting message description information, cell description information, and enumeration description information;
  • the storage submodule is configured to store the message description information, the cell description information, and the enumeration description information in a corresponding storage format into a database based on the first storage format.
  • the decoding module includes an obtaining submodule, a determining submodule, and a processing submodule;
  • the acquiring submodule is configured to: after receiving the code stream to be decoded, obtain relevant parameters required for decoding from the code stream;
  • the determining submodule is configured to determine a message name corresponding to the code stream according to the relevant parameters required for decoding
  • the processing submodule is configured to acquire a message node corresponding to the message name by using the message name as a key, loop through the child nodes under the message, and obtain a format attribute value of the child node, if the child If the format attribute value of the node is optional, it will jump to the optional decoding process, otherwise it will enter the mandatory decoding process until the end of the code stream or the end of the node, and the current message decoding ends.
  • the optional decoding process includes:
  • the optional start node is obtained.
  • the option tag value actually obtained by the current code stream is matched with the standard optional tag value in the database, if the matching is successful. Get the current node and call the required decoding interface to decode.
  • the required decoding process includes:
  • the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, Continue to decode, otherwise, the current decoding process is ended; if the message format attribute value does not include the length information, the length information does not need to be decoded; Until the decoding length is 0, the current message decoding ends.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores a computer program, and the computer program is used to execute the decoding method described above.
  • the decoding method, device and computer storage medium provided by the embodiments of the present invention extract protocol related information from a standard protocol document, and save the protocol related information in a database in a corresponding data structure format; based on the information stored in the database
  • the code stream to be decoded is decoded.
  • automatic decoding of the protocol document described in the form of a table can be realized, and the problem that the protocol described in the tabular form cannot be automatically decoded can be solved.
  • the decoding efficiency of the protocol document described in the form of a table is also improved, and the efficiency of maintenance and upgrade of the decoding library can be improved.
  • the method according to an embodiment of the invention is particularly suitable for decoding a protocol document described in tabular form, such as a network layer protocol document.
  • FIG. 1 is a schematic flowchart of a decoding method according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a storage format of a message description table according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of a storage format of a cell description table according to an embodiment of the present disclosure
  • FIG. 4 is a schematic diagram of a storage format of an enumeration description according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of an array storage format according to an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention.
  • FIG. 1 is a schematic flowchart of a decoding method according to an embodiment of the present invention. As shown in FIG. 1 , the method mainly includes the following steps:
  • Step 101 Extract protocol related information from a standard protocol document, and save the protocol related information into a database in a corresponding data structure format.
  • the standard protocol document mainly refers to a document that describes the contents of the protocol in a tabular form, such as the 24008x series protocol.
  • the protocol related information at least includes: message description information, cell description information, and enumeration description information.
  • the protocol-related information is extracted from the standard protocol document, and the protocol-related information is saved in the database in a corresponding data structure format, including:
  • the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
  • the message description information, the cell description information, and the enumeration description information are respectively stored in a database in a corresponding storage format.
  • the message description information may be stored in a message description table, and the cell description information may be stored in a cell description table, and the enumeration description information may be saved in an enumeration description table.
  • the message description table may be stored in a database, a cell description table, an enumeration description table, and an array type storage format, which may be stored in another database.
  • the message description table, the cell description table, the enumeration description table, and the array type storage format can also be stored in the same database.
  • FIG. 2 is a schematic diagram of a storage format of a message description table according to an embodiment of the present invention.
  • the message description table storage format is specifically:
  • the cell description below the message is taken as a child node.
  • each cell attribute includes: an option tag value (IEI), a cell name (Name), Category, Presence, Length, and the corresponding chapter number.
  • IIEI option tag value
  • Name a cell name
  • Category a cell name
  • Presence a cell name
  • Length a chapter number
  • FIG. 3 is a schematic diagram of a storage format of a cell description table according to an embodiment of the present invention.
  • the cell description table storage format is specifically:
  • the chapter number is used as the first level key value, and the byte is used as the second level key value, and the cells in each byte are used as child nodes.
  • each cell attribute includes: Name, Length (Len), Type (bArry), Enumeration Flag (bEnum), and Reference Member Name (Member).
  • the storage format of the enumeration description table provided by the embodiment of the present invention is as shown in FIG. 4, and the enumeration description table storage format is specifically:
  • the chapter number is used as the first level key value, and the cell name is used as the second level key value, and each enumeration value is used as a child node;
  • each enumeration value attribute includes: enumeration value (Val), enumeration description (Caption).
  • the enumeration value is expressed in decimal.
  • the array type storage format provided by the embodiment of the present invention is as shown in FIG. 5, and the array type storage format is specifically:
  • the structure name is used as the key value, and the structure cell is used as the child node.
  • the array attribute includes: a cell name (Name), a cell length (Len), a cell type (Mem Type), and an enumeration flag bit (bEnum).
  • the cell type is divided into a general type, a length type, and a dependent length type.
  • the algorithm for extracting the message description table mainly includes the following steps:
  • the information in the message description table is read in the cells of the row.
  • reading the information in the message description table according to the cells of the row may include:
  • the four tables are specifically: "Table 10.2/3GPP TS 24.008: Message types for Mobility Management”, "Table 10.3/3GPP TS 24.008: Message types for Call Control And call related SS messages”, "Table 10.4/3GPP TS 24.008: Message types for GPRS mobility management", "Table 10.4a/3GPP TS 24.008: Message types for GPRS session management", the value of the 10th column of each row can be taken as a message Name, and then look up the message name + message content as the key, the first table from the found location is the message description table of the message, and then read the information in the message description table according to the cell of the row, when read In the chapter number, it indicates that this member has finished reading and continues to read the next member until the reading of the first table ends.
  • the algorithm flow for extracting the cell description table may include:
  • the chapter number found is the directory, and the chapter is found to obtain the first table of the chapter; the information in the first table is sequentially read in units of cells.
  • the first table is a cell description table of the current member.
  • the first keyword (octet) is read, it indicates that the cell reading of the current byte ends, and the cell of the next byte is continuously read until the reading of the first table ends.
  • the number of columns of the current byte represents the number of cells of the current byte, if any If you merge, merge them in a small number of columns and save them in an array.
  • the algorithm flow for extracting the enumerated cell value and the enumeration description information may include:
  • the chapter number is used as the search condition, and when the chapter number found is the directory (ie "title"), the chapter is found;
  • the second table is an enumeration description table of the current IE
  • the information in the second table is sequentially read in units of cells.
  • the information in the second table is sequentially read in units of cells, including:
  • the second table is read according to the cell, and when the second keyword "(OCTET" is read, the cell name of the current member is obtained; wherein the character preceding the keyword is the cell name.
  • Step 102 Decode a code stream to be decoded based on information stored in the database.
  • the decoding of the code stream to be decoded based on the information stored in the database may include:
  • the related parameters required for decoding include: Protocol Discriminator (PD) information, and message type (MsgType) information.
  • PD Protocol Discriminator
  • MsgType message type
  • the obtaining the relevant parameters required for decoding from the code stream may include:
  • the determining, according to the required parameters related to the decoding, a message name corresponding to the code stream including:
  • the global mapping table refers to a mapping from MsgType to a message name.
  • the optional decoding process includes:
  • the optional start node is obtained.
  • the option tag value (IEI value) actually obtained by the current code stream is matched with the standard optional tag value in the database. If the match is successful, the current node is obtained, and the required decoding interface is decoded.
  • the IEI value actually obtained by the code stream is matched with the standard IEI value in the database, and if the actual IEI value is within the standard IEI value range, the matching is successful.
  • the required decoding process includes:
  • the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
  • the length must be decoded first, and then The length of the decoding is judged. If the comparison is successful, the following cell continues to be decoded, otherwise the return fails until the decoding length is 0, and the current message decoding ends.
  • the embodiment provides a method for extracting protocol-related information from a layer three standard protocol document and saving the data in an abstracted data structure format to the database, the method mainly includes The following steps:
  • Step 201 Open a word document about the layer three standard protocol, open a macro environment based on the word document, and extract detailed information in the word document by using a VBS language in the macro environment.
  • VBS language is an abbreviation of Visual Basic Script.
  • the layer three standard protocol may be the 24008 protocol.
  • Step 202 Find a message description table according to the message type definition table, and read the message description information.
  • step 202 specifically includes the following steps:
  • Step 202a Cycle through the message type definition table and read the first information in the last cell (Cell) of each row;
  • the information in the last cell of each row is a message name defined by the message type definition table, that is, the first information is a message name.
  • Step 202b Perform a search by using the message name + message content acquired in step 202a as a key, determine the first table under the keyword as a message description table of the message, and cyclically read the cell in units of cells. The contents of the first table are described until the current message description table is read.
  • the message description table is composed of a plurality of members, wherein each member occupies one or more rows of the table.
  • the content in the first table is cyclically read in units of cells, and when the cell containing the chapter number is read, it indicates that the current member has finished reading. In addition, if it is a member of multiple lines, it needs to be merged and saved to the defined variables.
  • Step 202c Loop two steps of step 202a and step 202b until the messages in all message type definition tables are read.
  • Step 203 Save the message description information read in step 202 into a variable, and store the variable information in a database.
  • variable information includes: an option tag value (IEI value), a name, a type, a chapter number, a length, and a format.
  • IIE value option tag value
  • the format mainly includes the following: T, TV, V, TLV, LV, LV-E, TLV-E.
  • variable information is saved in the database, including:
  • the message name is the key value, and the node content under the key value corresponds to the variable information.
  • Step 204 Read cell description information of each member.
  • the cell description information of the member may be read by the following steps:
  • Step 204a Cycle through the chapter number information.
  • step 202 reads the message description message
  • the chapter information of each member is uniformly saved into an array, and the chapter number information in the array is obtained cyclically.
  • Step 204b The chapter number is a keyword, and the searched keyword is "title" information, and the first table below the keyword is searched, and the first table is determined as the cell description table of the current member.
  • Step 204c Find a cell description table of the current member, and obtain a width of a bit.
  • the obtaining the width of the bit bit includes: first obtaining the width of the cell description table of the current member, and dividing the width of the cell description table of the current member by 8, thereby obtaining the width of the bit, where The width of the bit can be expressed as "len".
  • the first keyword may be "Octet”.
  • Step 204e Looping step 204d until the reading of the first table ends.
  • Step 204f Save the read cell description information into the structure variable array.
  • the structure mainly includes: a cell name, a cell length, a cell type, whether to include enumeration description information, and an array structure.
  • the cell type mainly includes a general type, an array type, an extended type, and an infinite extended type.
  • Step 205 Save the cell description information read in step 204 to the database.
  • the chapter number is a key value
  • each byte is a child node
  • each cell description information is saved as a child node content in a database.
  • Step 206 Read enumeration description information of each member, and store the enumeration description information in a database.
  • the enumeration description information can be read by the following steps:
  • Step 206a cyclically obtain chapter number information in the array, the chapter number is a search keyword, and the searched keyword is "title" information, and the second table below the keyword is searched, and the cell is read in units of cells.
  • the character in front of it is the cell name, continue to read the next cell, and read 0' or 1' to save until it reads non-zero' or Non-1', convert the previously saved binary stream to a decimal integer, then read the next unit
  • the cell if not empty, is the description of the current enumeration value until the second table is read.
  • the second keyword is "(OCTET).
  • Step 206b cyclically read the structure array, and save the chapter name as a key value, the cell name as a member name, and each enumeration value of the cell as a child node to be saved in the database.
  • Step 207 Store the preset array in the database.
  • the structure name is used as the key value
  • the structure cell is a child node
  • the preset array information is saved in the database.
  • the database may be an Extensible Markup Language (XML) file.
  • XML Extensible Markup Language
  • the message description information, the cell description information, and the enumeration information are read from the protocol document, and the message description information, the cell description information, and the enumeration information are stored in a database,
  • the preset array information is stored in the database; there is no order.
  • this embodiment provides a specific process for automatic decoding, including:
  • Step 301 After receiving the code stream, obtain PD information and message type (MsgType) information from the code stream, and determine a message name corresponding to the code stream according to the PD information and the MsgType information.
  • MsgType message type
  • the determining, according to the PD information and the MsgType information, a message name corresponding to the code stream including:
  • the global mapping table refers to a mapping from MsgType to a message name.
  • the first byte of the code stream contains PD information, and the second or third byte of the code stream contains MsgType information.
  • Step 302 Search the message start node in the “Message Description Table” with the message name as a key, find a message description table, and cyclically read each IE child node in the message description table.
  • the message description table is part of the database.
  • Step 303 Step 302: When the IE sub-node is read, the message format, the message length information, and the member chapter number are obtained. If the message format includes the length information, the length information is decoded first, and then the length information is Comparing with the standard length information, if the length information is within the standard length range, the decoding is continued; otherwise, the current decoding process is ended;
  • the length information if the length information is not included in the message format, the length information does not need to be decoded.
  • the standard length range is pre-stored in a database.
  • Step 304 Using the obtained member chapter number as a key, find the corresponding chapter under the element (Element) node and the chapter under the enumeration (Enum) node from the "cell description table", and read the member chapter in a loop. Each node below the number.
  • the "cell description table” is a part of a database, and the “cell description table” stores a cell description table, an enumeration description table, and an array of structures.
  • the “message description table” and the “cell description table” may exist as independent databases or may be located in the same database.
  • the current node type is determined, and then different decoding is performed according to the node type. That is to say, different types of nodes correspond to different decoding interfaces.
  • the node type may be a general type, or a general extension type, or a wireless extension type, or an array type.
  • Step 305 When the node type is a general type, it may be directly decoded according to the length of the node. If the description value needs to be enumerated, the enumeration description value is obtained from the cell description table according to the currently decoded value.
  • Step 306 When the node is of the general extension type, it decodes the extension bit of one bit. If it is 0, it returns to step 304. If it is 1, it needs to jump out the same byte as the current byte number. For example, octet3 needs to jump out of octet3a. , octet3b...., etc., until jumping to byte octet4, repeating back to step 304.
  • Step 307 When the node is of the wireless extension type, it decodes a bit extension bit. If it is 0, it decodes in the current byte cycle; if it is 1, it jumps out the same byte as the current byte number.
  • Step 308 When the node is an array type, the structure name is used as a key, and the corresponding node below the array is found, and the node is cyclically read.
  • nodes there are three types of nodes that are cyclically read in step 308: a general type, a length type, and a dependent length type; wherein, for a general type, it can be directly decoded according to the length; for a length type, it is decoded according to the length and saved to the length variable, To facilitate the use of the following nodes; for the dependent length type, the decoding is performed according to the decoded length until the end of the code stream.
  • Step 309 Repeat the above 8 steps until the current message node is empty or the code stream is empty, and it is judged that the decoding ends.
  • the present invention Based on the message description table storage format, the cell description table storage format, the enumeration description storage format, and the array storage format described above, the present invention also proposes a decoding apparatus.
  • FIG. 6 is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention. As shown in FIG. 6, the decoding apparatus includes an extraction module 61 and a decoding module 62.
  • the extracting module 61 is configured to extract protocol related information from a standard protocol document, and save the protocol related information into a database in a corresponding data structure format;
  • the decoding module 62 is configured to decode a code stream to be decoded based on information stored in the database.
  • the protocol related information at least includes: message description information, cell description information, Enumerate the description information.
  • the extraction module 61 includes a setting submodule 611, a reading submodule 612, and a storage submodule 613;
  • the setting sub-module 611 is configured to preset a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format. ;
  • the reading sub-module 612 is configured to read the standard protocol document, and extract message description information, cell description information, and enumeration description information from the protocol document;
  • the storage submodule 613 is configured to store the message description information, the cell description information, and the enumeration description information into a database in a corresponding storage format based on the first storage format.
  • the decoding module 62 includes an obtaining submodule 621, a determining submodule 622, and a processing submodule 623;
  • the acquiring sub-module 621 is configured to: after receiving the code stream to be decoded, obtain relevant parameters required for decoding from the code stream;
  • the determining sub-module 622 is configured to determine a message name corresponding to the code stream according to the relevant parameters required for decoding;
  • the processing sub-module 623 is configured to acquire, by using the message name as a key, a message node corresponding to the message name, loop through the child nodes under the message, and obtain a format attribute value of the child node, if If the format attribute value of the child node is optional, it jumps to the optional decoding process, otherwise it enters the mandatory decoding process until the end of the code stream or the end of the node, and the current message decoding ends.
  • the optional decoding process includes:
  • the optional start node is obtained, and each time the option is decoded, starting from the optional start node, the option tag value actually obtained through the current code stream is selected from the standard in the database.
  • the item tag value is matched. If the match is successful, the current node is obtained, and the required decoding interface is decoded.
  • the required decoding process includes:
  • the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
  • the extraction module 61 and the decoding module 62 may be a central processing unit (CPU), a microprocessor (MPU, a Micro Processor Unit), a digital signal processor (DSP, Digital) in a terminal to which the decoding device belongs.
  • CPU central processing unit
  • MPU microprocessor
  • DSP digital signal processor
  • FPGA Field Programmable Gate Array
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the foregoing decoding method.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner such as: multiple units or components may be combined, or Can be integrated into another system, or some features can be ignored or not executed.
  • the coupling, or direct coupling, or communication connection of the components shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, and may be electrical, mechanical or other forms. of.
  • the units described above as separate components may or may not be physically separated.
  • the components displayed as the unit may be, or may not be, physical units, that is, may be located in one place, or may be distributed to multiple network units; some or all of the units may be selected according to actual needs to implement the solution of the embodiment. purpose.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be separately used as one unit, or two or more units may be integrated into one unit;
  • the unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing storage device includes the following steps:
  • the foregoing storage medium includes: a removable storage device, a read-only memory (ROM), a magnetic disk, or an optical disk, and the like, which can store program codes.
  • the above-described integrated unit of the present invention may be stored in a computer readable storage medium if it is implemented in the form of a software function module and sold or used as a standalone product.
  • the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product stored in a storage medium, including a plurality of instructions.
  • a computer device (which may be a personal computer, server, or network device, etc.) is caused to perform all or part of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.
  • protocol related information is extracted from a standard protocol document, and the association is The related information is saved in the database in the corresponding data structure format; the code stream to be decoded is decoded based on the information stored in the database; thus, automatic decoding of the protocol document described in a tabular form can be realized, and the table format is solved.
  • the described protocol cannot achieve the problem of automated decoding.

Abstract

Disclosed is a decoding method. The method comprises: extracting protocol related information from a standard protocol file, and storing the protocol related information into a database by using a corresponding data structure format; and decoding a to-be-decoded code stream according to the information stored in the database. Also disclosed are a decoding apparatus and a computer storage medium.

Description

一种解码方法、装置及计算机存储介质Decoding method, device and computer storage medium 技术领域Technical field
本发明涉及通信协议领域中的编解码技术,具体涉及一种解码方法、装置及计算机存储介质。The present invention relates to a codec technology in the field of communication protocols, and in particular, to a decoding method, apparatus, and computer storage medium.
背景技术Background technique
随着通信行业技术的快速发展,通信协议也随之不断更新,进而要求应用协议也需进行相应的更新。目前,对于标准协议文档的处理,大多是通过手动翻译将标准协议文档转换为C、C++等语言,而通过手动解码,不仅浪费了很多人力和时间,而且容易出错。因此,很多厂家根据自己的需求来分析标准协议文档,建立自身的编解码系统,以求实现对与自身相关的标准协议文档的自动化编解码;当标准协议文档升级时,通过建立的编解码系统直接读取标准协议文档,即可实现编解码库的升级,大大提高了编解码的效率。With the rapid development of the communication industry technology, the communication protocol is also constantly updated, and the application protocol needs to be updated accordingly. At present, most of the processing of standard protocol documents is to convert standard protocol documents into C, C++ and other languages through manual translation, and by manual decoding, not only a lot of manpower and time is wasted, but also error-prone. Therefore, many manufacturers analyze the standard protocol documents according to their own needs, establish their own codec system, in order to realize the automatic codec of the standard protocol documents related to themselves; when the standard protocol documents are upgraded, through the established codec system By directly reading the standard protocol document, the codec library can be upgraded, which greatly improves the efficiency of the codec.
目前,针对抽象语法标记(Abstract Syntax Notation,简称ASN)、中国智能物流骨干网(China Smart Logistic Network,简称CSN)等协议的描述语言,均已有成熟的编解码系统,能方便地从这类协议文档中提取信息。但是,有些协议文档是以表格的形式描述协议信息的,例如24008x系列的协议文档,由于他们没有统一的语法及固定的格式,进而给自动提取这类协议信息带来了很多困难。At present, the description languages of protocols such as Abstract Syntax Notation (ASN) and China Smart Logistic Network (CSN) have mature codec systems, which can be easily obtained from such Extract information from the protocol document. However, some protocol documents describe the protocol information in the form of a table, such as the 24008x series of protocol documents. Since they do not have a unified syntax and a fixed format, it brings a lot of difficulties to automatically extract such protocol information.
发明内容Summary of the invention
有鉴于此,本发明实施例的主要目的在于提供一种解码方法、装置及计算机存储介质,能实现对以表格形式描述的协议文档的自动解码,提高 解码效率。In view of this, the main purpose of the embodiments of the present invention is to provide a decoding method, an apparatus, and a computer storage medium, which can automatically decode and improve protocol documents described in a tabular form. Decoding efficiency.
为达到上述目的,本发明实施例的技术方案是这样实现的:To achieve the above objective, the technical solution of the embodiment of the present invention is implemented as follows:
本发明实施例提供了一种解码方法,所述方法包括:An embodiment of the present invention provides a decoding method, where the method includes:
从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中;Extracting protocol-related information from the standard protocol document, and saving the protocol-related information to the database in a corresponding data structure format;
基于所述数据库所储存的信息对待解码的码流进行解码。The code stream to be decoded is decoded based on the information stored in the database.
上述方案中,所述协议相关信息至少包括:消息描述信息、信元描述信息、枚举描述信息。In the foregoing solution, the protocol related information includes at least: message description information, cell description information, and enumeration description information.
上述方案中,所述从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中,包括:In the above solution, the protocol-related information is extracted from the standard protocol document, and the protocol-related information is saved in the database in a corresponding data structure format, including:
预先设置第一存储格式;其中,所述第一存储格式包括消息描述表存储格式、信元描述表存储格式、枚举描述表存储格式、以及数组类型存储格式;Setting a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
读取所述标准协议文档,从所述协议文档中提取消息描述信息、信元描述信息、枚举描述信息;Reading the standard protocol document, and extracting message description information, cell description information, and enumeration description information from the protocol document;
基于所述第一存储格式,将所述消息描述信息、所述信元描述信息、以及所述枚举描述信息以对应的存储格式存储到数据库中。And based on the first storage format, storing the message description information, the cell description information, and the enumeration description information in a corresponding storage format into a database.
上述方案中,所述基于所述数据库所储存的信息对待解码的码流进行解码,包括:In the above solution, the decoding, according to the information stored in the database, the code stream to be decoded, includes:
接收待解码的码流后,从所述码流中获取解码所需相关参数;After receiving the code stream to be decoded, obtaining relevant parameters required for decoding from the code stream;
根据所述解码所需相关参数确定与所述码流对应的消息名称;Determining a message name corresponding to the code stream according to the relevant parameters required for decoding;
以所述消息名称为关键字,获取与所述消息名称相对应的消息节点,循环解析消息下的子节点,并获取子节点的格式属性值,如果所述子节点的格式属性值为可选项,则跳转到可选项解码流程,否则进入必选项解码流程,直到码流结束或节点结束,当前消息解码结束。 Obtaining, by using the message name as a key, a message node corresponding to the message name, cyclically parsing the child node under the message, and obtaining a format attribute value of the child node, if the format attribute value of the child node is an optional item Then, jump to the optional decoding process, otherwise enter the mandatory decoding process until the end of the code stream or the end of the node, the current message decoding ends.
上述方案中,所述可选项解码流程,包括:In the foregoing solution, the optional decoding process includes:
首先获取可选项开始节点,每次解码可选项时,均从所述可选项开始节点开始,将实际通过当前码流获取的可选项标记值与数据库中的标准可选项标记值进行匹配,如果匹配成功,获取当前节点,调用必选项解码接口解码。First, the optional start node is obtained. Each time the option is decoded, starting from the optional start node, the option tag value actually obtained by the current code stream is matched with the standard optional tag value in the database, if it matches Successfully, get the current node, call the required decoding interface to decode.
上述方案中,所述必选项解码流程,包括:In the above solution, the required decoding process includes:
如果消息格式属性值中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;如果消息格式属性值中不包含长度信息,则不需要对所述长度信息进行解码;直到解码长度为0,则当前消息解码结束。If the length information is included in the message format attribute value, the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
本发明实施例还提供了一种解码装置,所述解码装置包括提取模块和解码模块;其中,An embodiment of the present invention further provides a decoding apparatus, where the decoding apparatus includes an extraction module and a decoding module, where
所述提取模块,配置为从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中;The extracting module is configured to extract protocol related information from a standard protocol document, and save the protocol related information to a database in a corresponding data structure format;
所述解码模块,配置为基于所述数据库所储存的信息对待解码的码流进行解码。The decoding module is configured to decode a code stream to be decoded based on information stored in the database.
上述方案中,所述协议相关信息至少包括:消息描述信息、信元描述信息、枚举描述信息。In the foregoing solution, the protocol related information includes at least: message description information, cell description information, and enumeration description information.
上述方案中,所述提取模块包括设置子模块、读取子模块和存储子模块;其中,In the above solution, the extraction module includes a setting submodule, a reading submodule, and a storage submodule; wherein
所述设置子模块,配置为预先设置第一存储格式;其中,所述第一存储格式包括消息描述表存储格式、信元描述表存储格式、枚举描述表存储格式、以及数组类型存储格式;The setting submodule is configured to preset a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
所述读取子模块,配置为读取所述标准协议文档,从所述协议文档中 提取消息描述信息、信元描述信息、枚举描述信息;The reading submodule configured to read the standard protocol document from the protocol document Extracting message description information, cell description information, and enumeration description information;
所述存储子模块,配置为基于所述第一存储格式,将所述消息描述信息、所述信元描述信息、以及所述枚举描述信息以对应的存储格式存储到数据库中。The storage submodule is configured to store the message description information, the cell description information, and the enumeration description information in a corresponding storage format into a database based on the first storage format.
上述方案中,所述解码模块包括获取子模块、确定子模块以及处理子模块;其中,In the above solution, the decoding module includes an obtaining submodule, a determining submodule, and a processing submodule; wherein
所述获取子模块,配置为接收待解码的码流后,从所述码流中获取解码所需相关参数;The acquiring submodule is configured to: after receiving the code stream to be decoded, obtain relevant parameters required for decoding from the code stream;
所述确定子模块,配置为根据所述解码所需相关参数确定与所述码流对应的消息名称;The determining submodule is configured to determine a message name corresponding to the code stream according to the relevant parameters required for decoding;
所述处理子模块,配置为以所述消息名称为关键字,获取与所述消息名称相对应的消息节点,循环解析消息下的子节点,并获取子节点的格式属性值,如果所述子节点的格式属性值为可选项,则跳转到可选项解码流程,否则进入必选项解码流程,直到码流结束或节点结束,当前消息解码结束。The processing submodule is configured to acquire a message node corresponding to the message name by using the message name as a key, loop through the child nodes under the message, and obtain a format attribute value of the child node, if the child If the format attribute value of the node is optional, it will jump to the optional decoding process, otherwise it will enter the mandatory decoding process until the end of the code stream or the end of the node, and the current message decoding ends.
上述方案中,所述可选项解码流程,包括:In the foregoing solution, the optional decoding process includes:
首先获取可选项开始节点,每次解码可选项时,均从所述可选项开始节点开始,将实际通过当前码流获取的可选项标记值与数据库中标准可选项标记值进行匹配,如果匹配成功,获取当前节点,调用必选项解码接口解码。First, the optional start node is obtained. Each time the option is decoded, starting from the optional start node, the option tag value actually obtained by the current code stream is matched with the standard optional tag value in the database, if the matching is successful. Get the current node and call the required decoding interface to decode.
上述方案中,所述必选项解码流程,包括:In the above solution, the required decoding process includes:
如果消息格式属性值中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;如果消息格式属性值中不包含长度信息,则不需要对所述长度信息进行解码; 直到解码长度为0,则当前消息解码结束。If the length information is included in the message format attribute value, the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, Continue to decode, otherwise, the current decoding process is ended; if the message format attribute value does not include the length information, the length information does not need to be decoded; Until the decoding length is 0, the current message decoding ends.
本发明实施例还提供了一种计算机存储介质,所述计算机存储介质中存储有计算机程序,所述计算机程序用于执行以上所述的解码方法。The embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores a computer program, and the computer program is used to execute the decoding method described above.
本发明实施例提供的解码方法、装置及计算机存储介质,从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中;基于所述数据库所储存的信息对待解码的码流进行解码。如此,能够实现对以表格形式描述的协议文档的自动解码,解决了以表格形式描述的协议无法实现自动化解码的问题。另外,也提高了对以表格形式描述的协议文档的解码效率、进而也能提高解码库的维护和升级的效率。此外,本发明实施例所述方法尤其适用于对以表格形式描述的协议文档的解码,例如网络层协议文档。The decoding method, device and computer storage medium provided by the embodiments of the present invention extract protocol related information from a standard protocol document, and save the protocol related information in a database in a corresponding data structure format; based on the information stored in the database The code stream to be decoded is decoded. In this way, automatic decoding of the protocol document described in the form of a table can be realized, and the problem that the protocol described in the tabular form cannot be automatically decoded can be solved. In addition, the decoding efficiency of the protocol document described in the form of a table is also improved, and the efficiency of maintenance and upgrade of the decoding library can be improved. Furthermore, the method according to an embodiment of the invention is particularly suitable for decoding a protocol document described in tabular form, such as a network layer protocol document.
附图说明DRAWINGS
图1为本发明实施例提供的解码方法的流程示意图;1 is a schematic flowchart of a decoding method according to an embodiment of the present invention;
图2为本发明实施例提供的消息描述表存储格式示意图;2 is a schematic diagram of a storage format of a message description table according to an embodiment of the present invention;
图3为本发明实施例提供的信元描述表存储格式示意图;FIG. 3 is a schematic diagram of a storage format of a cell description table according to an embodiment of the present disclosure;
图4为本发明实施例提供的枚举描述存储格式示意图;4 is a schematic diagram of a storage format of an enumeration description according to an embodiment of the present invention;
图5为本发明实施例提供的数组存储格式示意图;FIG. 5 is a schematic diagram of an array storage format according to an embodiment of the present invention;
图6为本发明实施例提供的解码装置的组成结构示意图。FIG. 6 is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention.
具体实施方式detailed description
为了能够更加详尽地了解本发明的特点与技术内容,下面结合附图对本发明的实现进行详细阐述,所附附图仅供参考说明之用,并非用来限定本发明。The invention will be described in detail with reference to the accompanying drawings, and the accompanying drawings are only for the purpose of illustration.
图1为本发明实施例提供的解码方法的流程示意图,如图1所示,所述方法主要包括以下步骤: FIG. 1 is a schematic flowchart of a decoding method according to an embodiment of the present invention. As shown in FIG. 1 , the method mainly includes the following steps:
步骤101:从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中。Step 101: Extract protocol related information from a standard protocol document, and save the protocol related information into a database in a corresponding data structure format.
这里,所述标准协议文档主要是指以表格形式描述协议内容的文档,例如24008x系列协议。Here, the standard protocol document mainly refers to a document that describes the contents of the protocol in a tabular form, such as the 24008x series protocol.
优选地,所述协议相关信息至少包括:消息描述信息、信元描述信息、枚举描述信息。Preferably, the protocol related information at least includes: message description information, cell description information, and enumeration description information.
优选地,所述从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中,包括:Preferably, the protocol-related information is extracted from the standard protocol document, and the protocol-related information is saved in the database in a corresponding data structure format, including:
预先设置第一存储格式;其中,所述第一存储格式包括消息描述表存储格式、信元描述表存储格式、枚举描述表存储格式、以及数组类型存储格式;Setting a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
读取所述标准协议文档,从所述协议文档中提取消息描述信息、信元描述信息、枚举描述信息;Reading the standard protocol document, and extracting message description information, cell description information, and enumeration description information from the protocol document;
基于所述第一存储格式,将所述消息描述信息、所述信元描述信息、以及所述枚举描述信息分别以对应的存储格式存储到数据库中。And based on the first storage format, the message description information, the cell description information, and the enumeration description information are respectively stored in a database in a corresponding storage format.
这里,所述消息描述信息可以保存于消息描述表中,所述信元描述信息可以保存于信元描述表中,所述枚举描述信息可以保存于枚举描述表中。其中,消息描述表可以存储于一个数据库中,信元描述表、枚举描述表、以及数组类型存储格式,可以存储于另一个数据库中。当然,消息描述表、信元描述表、枚举描述表、以及数组类型存储格式也可以存储于同一个数据库中。Here, the message description information may be stored in a message description table, and the cell description information may be stored in a cell description table, and the enumeration description information may be saved in an enumeration description table. The message description table may be stored in a database, a cell description table, an enumeration description table, and an array type storage format, which may be stored in another database. Of course, the message description table, the cell description table, the enumeration description table, and the array type storage format can also be stored in the same database.
本发明实施例提供的消息描述表存储格式示意图如图2所示,所述消息描述表存储格式,具体为:FIG. 2 is a schematic diagram of a storage format of a message description table according to an embodiment of the present invention. The message description table storage format is specifically:
以消息名称作为键值,消息下面的信元描述作为子节点。With the message name as the key value, the cell description below the message is taken as a child node.
其中,每个信元属性包括:可选项标记值(IEI)、信元名称(Name)、 类别(Type)、可选属性(Presence)、长度(Length)、对应的章节号(Chapter)。Among them, each cell attribute includes: an option tag value (IEI), a cell name (Name), Category, Presence, Length, and the corresponding chapter number.
显然,在图2中,消息名称为<IMSI_DETACH_INDICATION>的消息中含有5个信元。Obviously, in Figure 2, the message with the message name <IMSI_DETACH_INDICATION> contains 5 cells.
本发明实施例提供的信元描述表存储格式示意图如图3所示,所述信元描述表存储格式,具体为:FIG. 3 is a schematic diagram of a storage format of a cell description table according to an embodiment of the present invention. The cell description table storage format is specifically:
以章节号作为第一级键值,以字节作为第二级键值,每个字节里的信元作为子节点。The chapter number is used as the first level key value, and the byte is used as the second level key value, and the cells in each byte are used as child nodes.
其中,每个信元属性包括:名称(Name)、长度(Len)、类型(bArry)、枚举标志位(bEnum)、引用成员名称(Member)。Among them, each cell attribute includes: Name, Length (Len), Type (bArry), Enumeration Flag (bEnum), and Reference Member Name (Member).
本发明实施例提供的枚举描述表存储格式示意图,如图4所示,所述枚举描述表存储格式,具体为:The storage format of the enumeration description table provided by the embodiment of the present invention is as shown in FIG. 4, and the enumeration description table storage format is specifically:
以章节号作为第一级键值,以信元名称作为第二级键值,每个枚举值作为子节点;The chapter number is used as the first level key value, and the cell name is used as the second level key value, and each enumeration value is used as a child node;
其中,每个枚举值属性包括:枚举值(Val)、枚举描述(Caption)。Among them, each enumeration value attribute includes: enumeration value (Val), enumeration description (Caption).
其中,所述枚举值用十进制表示。Wherein, the enumeration value is expressed in decimal.
本发明实施例提供的数组类型存储格式如5所示,所述数组类型存储格式,具体为:The array type storage format provided by the embodiment of the present invention is as shown in FIG. 5, and the array type storage format is specifically:
以结构体名称作为键值,以结构体信元作为子节点。The structure name is used as the key value, and the structure cell is used as the child node.
其中,所述数组属性包括:信元名称(Name)、信元长度(Len)、信元类型(Mem Type)、枚举标志位(bEnum)。The array attribute includes: a cell name (Name), a cell length (Len), a cell type (Mem Type), and an enumeration flag bit (bEnum).
其中,信元类型分为一般类型、长度类型、依赖长度类型。具体地,MemType=0表示一般类型、MemType=1表示长度类型、MemType=2表示依赖长度类型。Among them, the cell type is divided into a general type, a length type, and a dependent length type. Specifically, MemType=0 indicates a general type, MemType=1 indicates a length type, and MemType=2 indicates a dependent length type.
在一实施例中,提取消息描述表的算法,主要包括以下步骤:In an embodiment, the algorithm for extracting the message description table mainly includes the following steps:
获取消息名称; Get the message name;
以消息名称+消息内容为关键字,在所述数据库中进行查找,并确定此消息的消息描述表;Searching in the database with the message name + message content as a key, and determining a message description table of the message;
按照行的单元格读取所述消息描述表中的信息。The information in the message description table is read in the cells of the row.
在一实施例中,按照行的单元格读取所述消息描述表中的信息,可以包括:In an embodiment, reading the information in the message description table according to the cells of the row may include:
当读到章节号时,说明当前成员读取完毕,继续读取下一个成员,直到所述第一张表读取结束。When the chapter number is read, it indicates that the current member has finished reading and continues to read the next member until the reading of the first table ends.
以读取24008协议文档中的四个表格为例,所述四个表格具体为:“Table 10.2/3GPP TS 24.008:Message types for Mobility Management”、“Table 10.3/3GPP TS 24.008:Message types for Call Control and call related SS messages”、“Table 10.4/3GPP TS 24.008:Message types for GPRS mobility management”、“Table 10.4a/3GPP TS 24.008:Message types for GPRS session management”,可取每行第10列的值作为消息名称,然后以消息名称+消息内容作为关键字查找,从找到位置的第一张表就是此消息的消息描述表,然后按照行的单元格读取所述消息描述表中的信息,当读到章节号时,说明此成员读取完毕,继续读取下一个成员,直到所述第一张表读取结束。Taking four tables in the 24008 protocol document as an example, the four tables are specifically: "Table 10.2/3GPP TS 24.008: Message types for Mobility Management", "Table 10.3/3GPP TS 24.008: Message types for Call Control And call related SS messages", "Table 10.4/3GPP TS 24.008: Message types for GPRS mobility management", "Table 10.4a/3GPP TS 24.008: Message types for GPRS session management", the value of the 10th column of each row can be taken as a message Name, and then look up the message name + message content as the key, the first table from the found location is the message description table of the message, and then read the information in the message description table according to the cell of the row, when read In the chapter number, it indicates that this member has finished reading and continues to read the next member until the reading of the first table ends.
在一实施例中,提取信元描述表的算法流程,可以包括:In an embodiment, the algorithm flow for extracting the cell description table may include:
以章节号作为搜索条件,搜到的章节号为目录时,说明找到了此章节,获取此章节的第一张表;以单元格为单位,依次读取所述第一张表中的信息。When the chapter number is used as the search condition, the chapter number found is the directory, and the chapter is found to obtain the first table of the chapter; the information in the first table is sequentially read in units of cells.
其中,所述第一张表为当前成员的信元描述表。The first table is a cell description table of the current member.
具体地,读到第一关键词(octet)时,说明当前字节的信元读取结束,继续读取下一字节的信元,直到所述第一张表读取结束。Specifically, when the first keyword (octet) is read, it indicates that the cell reading of the current byte ends, and the cell of the next byte is continuously read until the reading of the first table ends.
需要说明的是,当前字节的列数代表所述当前字节的信元数,如果有 合并,则按列数少的进行合并,保存到数组中。It should be noted that the number of columns of the current byte represents the number of cells of the current byte, if any If you merge, merge them in a small number of columns and save them in an array.
在一实施例中,提取枚举信元值和枚举描述信息的算法流程,可以包括:In an embodiment, the algorithm flow for extracting the enumerated cell value and the enumeration description information may include:
以章节号作为搜索条件,搜到的章节号为目录(即“标题”)时,说明找到了此章节;The chapter number is used as the search condition, and when the chapter number found is the directory (ie "title"), the chapter is found;
获取此章节的第二张表;其中,所述第二张表为当前IE的枚举描述表;Obtaining a second table of the chapter; wherein the second table is an enumeration description table of the current IE;
以单元格为单位,依次读取所述第二张表中的信息。The information in the second table is sequentially read in units of cells.
具体地,以单元格为单位,依次读取所述第二张表中的信息,包括:Specifically, the information in the second table is sequentially read in units of cells, including:
按照单元格读取所述第二张表,读到第二关键词“(OCTET”时,获取当前成员的信元名称;其中,截取此关键字前面的字符即为信元名称。The second table is read according to the cell, and when the second keyword "(OCTET" is read, the cell name of the current member is obtained; wherein the character preceding the keyword is the cell name.
读到‘0’或‘1’组成字串后,转换为十进制;After reading the word string of ‘0’ or ‘1’, it is converted to decimal;
读到不是‘0’或‘1’组成字串,如果信元没有换行,说明为当前枚举值的描述信息,保存到数组中;Reads a string that is not ‘0’ or ‘1’. If the cell does not have a newline, the description information of the current enumeration value is saved in the array;
继续读取下一个信元,直到所述第二张表读取结束。The next cell continues to be read until the second table reading ends.
步骤102:基于所述数据库所储存的信息对待解码的码流进行解码。Step 102: Decode a code stream to be decoded based on information stored in the database.
在一实施例中,所述基于所述数据库所储存的信息对待解码的码流进行解码,可以包括:In an embodiment, the decoding of the code stream to be decoded based on the information stored in the database may include:
接收待解码的码流后,从所述码流中获取解码所需相关参数;After receiving the code stream to be decoded, obtaining relevant parameters required for decoding from the code stream;
根据所述解码所需相关参数确定与所述码流对应的消息名称;Determining a message name corresponding to the code stream according to the relevant parameters required for decoding;
以所述消息名称为关键字,获取与所述消息名称相对应的消息节点,循环解析消息下的子节点,并获取子节点的格式属性值,如果所述子节点的格式属性值为可选项,则跳转到可选项解码流程,否则进入必选项解码流程,直到码流结束或节点结束,当前消息解码结束。Obtaining, by using the message name as a key, a message node corresponding to the message name, cyclically parsing the child node under the message, and obtaining a format attribute value of the child node, if the format attribute value of the child node is an optional item Then, jump to the optional decoding process, otherwise enter the mandatory decoding process until the end of the code stream or the end of the node, the current message decoding ends.
其中,所述解码所需相关参数包括:协议鉴别符(Protocol Discriminator,PD)信息、以及消息类型(MsgType)信息。 The related parameters required for decoding include: Protocol Discriminator (PD) information, and message type (MsgType) information.
在一实施例中,所述从所述码流中获取解码所需相关参数,可以包括:In an embodiment, the obtaining the relevant parameters required for decoding from the code stream may include:
通过所述码流的第一个字节获取PD信息;Obtaining PD information by using the first byte of the code stream;
根据PD信息,确定码流中的第二个和第三个字节中的一个字节为MsgType信息。Based on the PD information, it is determined that one of the second and third bytes in the code stream is MsgType information.
具体地,所述根据所述解码所需相关参数确定与所述码流对应的消息名称,包括:Specifically, the determining, according to the required parameters related to the decoding, a message name corresponding to the code stream, including:
根据所述PD信息确定与所述PD信息对应的全局映射表;Determining, according to the PD information, a global mapping table corresponding to the PD information;
根据所述MsgType信息,并从所述全局映射表中确定与所述码流对应的消息名称。Determining, according to the MsgType information, a message name corresponding to the code stream from the global mapping table.
这里,所述全局映射表是指从MsgType到消息名称的映射。Here, the global mapping table refers to a mapping from MsgType to a message name.
这里,在数据库中,针对各类PD均设置有不同的全局映射表。Here, in the database, different global mapping tables are set for each type of PD.
其中,所述可选项解码流程,包括:The optional decoding process includes:
首先获取可选项开始节点,每次解码可选项时,均从所述可选项开始节点开始,将实际通过当前码流获取的可选项标记值(IEI值)与数据库中标准可选项标记值进行匹配,如果匹配成功,获取当前节点,调用必选项解码接口解码。First, the optional start node is obtained. Each time the option is decoded, starting from the optional start node, the option tag value (IEI value) actually obtained by the current code stream is matched with the standard optional tag value in the database. If the match is successful, the current node is obtained, and the required decoding interface is decoded.
这里,实际通过码流获取的IEI值与数据库中的标准IEI值进行匹配,如果所述实际IEI值在所述标准IEI值范围内,说明匹配较成功。Here, the IEI value actually obtained by the code stream is matched with the standard IEI value in the database, and if the actual IEI value is within the standard IEI value range, the matching is successful.
其中,所述必选项解码流程,包括:The required decoding process includes:
如果消息格式属性值中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;如果消息格式属性值中不包含长度信息,则不需要对所述长度信息进行解码;直到解码长度为0,则当前消息解码结束。If the length information is included in the message format attribute value, the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
也就是说,如果当前消息格式是带有“L”的,需先解码长度,然后再 对解码长度进行判断,如果比较成功,则继续解码下面信元,否则返回失败,直到解码长度为0,则当前消息解码结束。In other words, if the current message format is "L", the length must be decoded first, and then The length of the decoding is judged. If the comparison is successful, the following cell continues to be decoded, otherwise the return fails until the decoding length is 0, and the current message decoding ends.
例如,当所述格式为“TLV”或“LV”时,需先解码一个字节长度;当所述格式为“TLV-E”或“LV-E”时,需先解码两个字节长度。For example, when the format is "TLV" or "LV", the length of one byte must be decoded first; when the format is "TLV-E" or "LV-E", the length of two bytes must be decoded first. .
为了更好地理解本发明所述解码方法,本实施例提供了一种从层三标准协议文档中提取协议相关信息,并以抽象出来的数据结构格式保存到数据库中的方法,该方法主要包括以下步骤:In order to better understand the decoding method of the present invention, the embodiment provides a method for extracting protocol-related information from a layer three standard protocol document and saving the data in an abstracted data structure format to the database, the method mainly includes The following steps:
步骤201:打开关于所述层三标准协议的word文档,基于所述word文档打开宏环境,并在所述宏环境中通过VBS语言提取所述word文档中的详细信息。Step 201: Open a word document about the layer three standard protocol, open a macro environment based on the word document, and extract detailed information in the word document by using a VBS language in the macro environment.
这里,所述VBS语言是可视化Basic脚本语言(Visual Basic Script)的简称。Here, the VBS language is an abbreviation of Visual Basic Script.
这里,可以通过“ALT+F11”快捷键来打开宏环境。Here, you can open the macro environment with the "ALT+F11" shortcut.
这里,所述层三标准协议可以是24008协议。Here, the layer three standard protocol may be the 24008 protocol.
步骤202:根据消息类型定义表查找消息描述表,并读取消息描述信息。Step 202: Find a message description table according to the message type definition table, and read the message description information.
本实施例中,步骤202具体还包括以下步骤:In this embodiment, step 202 specifically includes the following steps:
步骤202a:循环查找消息类型定义表,读取每行最后一个单元格(Cell)中的第一信息;Step 202a: Cycle through the message type definition table and read the first information in the last cell (Cell) of each row;
其中,所述每行最后一个单元格中的信息为所述消息类型定义表定义的消息名称,即所述第一信息为消息名称。The information in the last cell of each row is a message name defined by the message type definition table, that is, the first information is a message name.
步骤202b:以步骤202a中获取的消息名称+消息内容为关键字进行查找,将所述关键字下的第一张表确定为此消息的消息描述表,并以单元格为单位循环读取所述第一张表中的内容,直到当前消息描述表读取结束。Step 202b: Perform a search by using the message name + message content acquired in step 202a as a key, determine the first table under the keyword as a message description table of the message, and cyclically read the cell in units of cells. The contents of the first table are described until the current message description table is read.
这里,消息描述表由多个成员组成,其中,每个成员占表格的一行或者多行。 Here, the message description table is composed of a plurality of members, wherein each member occupies one or more rows of the table.
本实施例中,以单元格为单位,循环读取所述第一张表中的内容,当读到包含有章节号的单元格时,说明当前成员已经读取结束。另外,如果是占多行的成员,需要合并后保存到定义的变量中。In this embodiment, the content in the first table is cyclically read in units of cells, and when the cell containing the chapter number is read, it indicates that the current member has finished reading. In addition, if it is a member of multiple lines, it needs to be merged and saved to the defined variables.
例如,以读取24008协议文档为例,当单元格中包含“10.”或“9.”时,说明当前成员已经读取结束。也就是说,可以具体根据协议文档中的章节添加条件。For example, taking the 24008 protocol document as an example, when the cell contains "10." or "9.", it indicates that the current member has finished reading. That is to say, conditions can be added specifically according to the chapters in the protocol document.
步骤202c:循环步骤202a、步骤202b两个步骤,直到所有消息类型定义表中的消息读取完为止。Step 202c: Loop two steps of step 202a and step 202b until the messages in all message type definition tables are read.
步骤203:将步骤202中所读取的消息描述信息保存到变量中,并将变量信息存储到数据库中。Step 203: Save the message description information read in step 202 into a variable, and store the variable information in a database.
本实施例中,所述变量信息包括:可选项标记值(IEI值)、名称、类型、章节号、长度、格式。In this embodiment, the variable information includes: an option tag value (IEI value), a name, a type, a chapter number, a length, and a format.
其中,格式主要包括以下几种:T、TV、V、TLV、LV、LV-E、TLV-E。Among them, the format mainly includes the following: T, TV, V, TLV, LV, LV-E, TLV-E.
本实施例中,把变量信息保存到数据库中,包括:In this embodiment, the variable information is saved in the database, including:
以消息名称为键值,键值下的节点内容和变量信息对应。The message name is the key value, and the node content under the key value corresponds to the variable information.
步骤204:读取各成员的信元描述信息。Step 204: Read cell description information of each member.
本实施例中,可以通过如下步骤读取成员的信元描述信息:In this embodiment, the cell description information of the member may be read by the following steps:
步骤204a:循环获取章节号信息。Step 204a: Cycle through the chapter number information.
这里,步骤202读取消息描述消息时,将每个成员的章节信息会统一保存到一个数组中,循环获取数组中的章节号信息。Here, when step 202 reads the message description message, the chapter information of each member is uniformly saved into an array, and the chapter number information in the array is obtained cyclically.
步骤204b:以章节号为关键字,并且搜索到的关键字是“标题”信息,查找关键字下面的第一张表格,将所述第一张表格确定为当前成员的信元描述表格。Step 204b: The chapter number is a keyword, and the searched keyword is "title" information, and the first table below the keyword is searched, and the first table is determined as the cell description table of the current member.
步骤204c:找到所述当前成员的信元描述表,获取比特位(bit)的宽度。 Step 204c: Find a cell description table of the current member, and obtain a width of a bit.
这里,获取比特位的宽度,包括:首先获取所述当前成员的信元描述表的宽度,将所述当前成员的信元描述表的宽度除以8,即得到比特位的宽度,这里,所述bit的宽度可以用“len”表示。Here, the obtaining the width of the bit bit includes: first obtaining the width of the cell description table of the current member, and dividing the width of the cell description table of the current member by 8, thereby obtaining the width of the bit, where The width of the bit can be expressed as "len".
步骤204d):以单元格为单位,循环读取所述第一张表格,读到第一关键词后,说明当前字节信元读取结束。Step 204d): cyclically reading the first table in units of cells, and after reading the first keyword, indicating that the current byte cell reading ends.
这里,所述第一关键词可以是“Octet”。Here, the first keyword may be "Octet".
这里,将每个单元格宽度除以比特位的宽度,即可得到当前信元占几个比特位。Here, by dividing the width of each cell by the width of the bit, it is obtained that the current cell occupies several bits.
步骤204e:循环步骤204d直到所述第一张表格读取结束。Step 204e: Looping step 204d until the reading of the first table ends.
步骤204f:将读取的信元描述信息保存到结构体变量数组中。Step 204f: Save the read cell description information into the structure variable array.
这里,所述结构体主要包括:信元名称、信元长度、信元类型、是否包括枚举描述信息、数组结构体。Here, the structure mainly includes: a cell name, a cell length, a cell type, whether to include enumeration description information, and an array structure.
其中,所述信元类型主要包括一般类型、数组类型、扩展类型,无限扩展类型。The cell type mainly includes a general type, an array type, an extended type, and an infinite extended type.
步骤205:将步骤204所读取的信元描述信息保存到数据库中。Step 205: Save the cell description information read in step 204 to the database.
本实施例中,以章节号为键值,每个字节为子节点,每个信元描述信息作为子节点内容保存到数据库中。In this embodiment, the chapter number is a key value, each byte is a child node, and each cell description information is saved as a child node content in a database.
步骤206:读取各成员的枚举描述信息,并将所述枚举描述信息存储到数据库中。Step 206: Read enumeration description information of each member, and store the enumeration description information in a database.
本实施例中,可通过如下步骤读取枚举描述信息:In this embodiment, the enumeration description information can be read by the following steps:
步骤206a:循环获取数组中的章节号信息,以章节号为搜索关键字,并且搜索到的关键字是“标题”信息,查找关键字下面的第二张表,以单元格为单位读取所述第二张表,读到第二关键词后,获取其前面的字符即为信元名称,继续读取下个单元格,读到0’或1’保存起来,直到读到非0’或非1’,把前面保存的二进制码流转换为十进制整数,接着读下个单元 格,如果不为空,则为当前枚举值的的描述信息,直到所述第二张表读取完成。Step 206a: cyclically obtain chapter number information in the array, the chapter number is a search keyword, and the searched keyword is "title" information, and the second table below the keyword is searched, and the cell is read in units of cells. After reading the second table, after reading the second keyword, the character in front of it is the cell name, continue to read the next cell, and read 0' or 1' to save until it reads non-zero' or Non-1', convert the previously saved binary stream to a decimal integer, then read the next unit The cell, if not empty, is the description of the current enumeration value until the second table is read.
这里,所述第二关键词是“(OCTET”。Here, the second keyword is "(OCTET".
步骤206b:循环读取结构体数组,以章节号为键值、信元名称为成员名、信元每个枚举值作为一个子节点保存到数据库中。Step 206b: cyclically read the structure array, and save the chapter name as a key value, the cell name as a member name, and each enumeration value of the cell as a child node to be saved in the database.
步骤207:将预设的数组存储到数据库中。Step 207: Store the preset array in the database.
本实施例中,以结构体名称为键值,结构体信元为子节点,将预设的数组信息保存到数据库中。In this embodiment, the structure name is used as the key value, and the structure cell is a child node, and the preset array information is saved in the database.
本实施例中,所述数据库可以为可扩展标识语言(XML,Extensible Markup Language,XML)文件。In this embodiment, the database may be an Extensible Markup Language (XML) file.
上述实施例仅为本发明的一个优选实施例。需要说明的是,从协议文档中读取消息描述信息、信元描述信息、以及枚举信息,以及将所述消息描述信息、所述信元描述信息、以及所述枚举信息存储到数据库、将预设的数组信息存储到所述数据库中;并不存在先后顺序,。The above embodiments are merely a preferred embodiment of the present invention. It should be noted that the message description information, the cell description information, and the enumeration information are read from the protocol document, and the message description information, the cell description information, and the enumeration information are stored in a database, The preset array information is stored in the database; there is no order.
为了更好地理解本发明所述解码方法,本实施例提供了一种自动解码的具体流程,包括:In order to better understand the decoding method of the present invention, this embodiment provides a specific process for automatic decoding, including:
步骤301:接收到码流后,从所述码流中获取PD信息,以及消息类型(MsgType)信息;根据所述PD信息以及所述MsgType信息确定与所述码流对应的消息名称。Step 301: After receiving the code stream, obtain PD information and message type (MsgType) information from the code stream, and determine a message name corresponding to the code stream according to the PD information and the MsgType information.
在一实施例中,所述根据所述PD信息以及所述MsgType信息确定与所述码流对应的消息名称,包括:In an embodiment, the determining, according to the PD information and the MsgType information, a message name corresponding to the code stream, including:
根据所述PD信息确定与所述PD信息对应的全局映射表;Determining, according to the PD information, a global mapping table corresponding to the PD information;
根据所述MsgType信息,并从所述全局映射表中确定与所述码流对应的消息名称。Determining, according to the MsgType information, a message name corresponding to the code stream from the global mapping table.
这里,所述全局映射表是指从MsgType到消息名称的映射。 Here, the global mapping table refers to a mapping from MsgType to a message name.
这里,在数据库中,针对各类PD均设置有不同的全局映射表。Here, in the database, different global mapping tables are set for each type of PD.
其中,码流的第一个字节包含有PD信息,码流的第二个或者第三个字节中包含有MsgType信息。The first byte of the code stream contains PD information, and the second or third byte of the code stream contains MsgType information.
步骤302:以所述消息名称为关键字,在“消息描述表”中查找消息开始节点,找到消息描述表,循环读取所述消息描述表中的每个IE子节点。Step 302: Search the message start node in the “Message Description Table” with the message name as a key, find a message description table, and cyclically read each IE child node in the message description table.
这里,消息描述表为数据库的一部分。Here, the message description table is part of the database.
步骤303:步骤302读取IE子节点时,获取消息格式、消息长度信息、成员章节号,如果消息格式中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;Step 303: Step 302: When the IE sub-node is read, the message format, the message length information, and the member chapter number are obtained. If the message format includes the length information, the length information is decoded first, and then the length information is Comparing with the standard length information, if the length information is within the standard length range, the decoding is continued; otherwise, the current decoding process is ended;
本实施例中,如果消息格式中不包含长度信息,则不需要对所述长度信息进行解码。In this embodiment, if the length information is not included in the message format, the length information does not need to be decoded.
其中,所述标准长度范围预先存储于数据库中。Wherein, the standard length range is pre-stored in a database.
步骤304:以所获取的成员章节号为关键字,从“信元描述表”中找到信元(Element)节点下对应的章节和枚举(Enum)节点下的章节,循环读取此成员章节号下面的每个节点。Step 304: Using the obtained member chapter number as a key, find the corresponding chapter under the element (Element) node and the chapter under the enumeration (Enum) node from the "cell description table", and read the member chapter in a loop. Each node below the number.
这里,所述“信元描述表”为数据库的一部分,所述“信元描述表”存储有信元描述表、枚举描述表和结构体数组。Here, the "cell description table" is a part of a database, and the "cell description table" stores a cell description table, an enumeration description table, and an array of structures.
需要说明的是,所述“消息描述表”、所述“信元描述表”均可以作为独立的数据库存在,也可以位于同一个数据库中。It should be noted that the “message description table” and the “cell description table” may exist as independent databases or may be located in the same database.
对步骤304中的节点进行解码时,首先,判断当前节点类型,然后根据节点类型进行不同的解码。也就是说,不同类型的节点对应有不同的解码接口。When decoding the node in step 304, first, the current node type is determined, and then different decoding is performed according to the node type. That is to say, different types of nodes correspond to different decoding interfaces.
这里,所述节点类型,可能为一般类型、或一般扩展类型、或无线扩展类型、或数组类型。 Here, the node type may be a general type, or a general extension type, or a wireless extension type, or an array type.
步骤305:节点类型为一般类型时,直接根据节点长度解码即可,如果需要枚举描述值,根据当前解码的值从信元描述表中获取枚举描述值。Step 305: When the node type is a general type, it may be directly decoded according to the length of the node. If the description value needs to be enumerated, the enumeration description value is obtained from the cell description table according to the currently decoded value.
步骤306:节点为一般扩展类型时,解码一个bit的扩展位,如果为0,则回到步骤304;如果为1,则需要跳出和当前字节号相同的字节,比如:octet3需要跳出octet3a、octet3b….等,直到跳到字节为octet4时,重复回到步骤304。Step 306: When the node is of the general extension type, it decodes the extension bit of one bit. If it is 0, it returns to step 304. If it is 1, it needs to jump out the same byte as the current byte number. For example, octet3 needs to jump out of octet3a. , octet3b...., etc., until jumping to byte octet4, repeating back to step 304.
步骤307:节点为无线扩展类型时,解码一个bit扩展位,如果为0,则在当前字节循环解码;如果为1,则跳出和当前字节号相同的字节。Step 307: When the node is of the wireless extension type, it decodes a bit extension bit. If it is 0, it decodes in the current byte cycle; if it is 1, it jumps out the same byte as the current byte number.
步骤308:节点为数组类型时,则以结构体名称为关键字,找到数组下面对应的节点,循环读取节点。Step 308: When the node is an array type, the structure name is used as a key, and the corresponding node below the array is found, and the node is cyclically read.
这里,步骤308中循环读取的节点有三种类型:一般类型、长度类型、依赖长度类型;其中,对于一般类型,可直接根据长度解码;对于长度类型,根据长度解码后保存到长度变量中,以方便下面节点使用;对于依赖长度类型,根据解码出的长度进行解码,直到码流结束。Here, there are three types of nodes that are cyclically read in step 308: a general type, a length type, and a dependent length type; wherein, for a general type, it can be directly decoded according to the length; for a length type, it is decoded according to the length and saved to the length variable, To facilitate the use of the following nodes; for the dependent length type, the decoding is performed according to the decoded length until the end of the code stream.
步骤309:重复循环以上8个步骤,直到当前消息节点为空或者码流为空,判断解码结束。Step 309: Repeat the above 8 steps until the current message node is empty or the code stream is empty, and it is judged that the decoding ends.
在上文所述消息描述表存储格式、信元描述表存储格式、枚举描述存储格式、数组存储格式的基础上,本发明还提出了一种解码装置。Based on the message description table storage format, the cell description table storage format, the enumeration description storage format, and the array storage format described above, the present invention also proposes a decoding apparatus.
图6为本发明实施例提供的解码装置的组成结构示意图,如图6所示,所述解码装置包括提取模块61和解码模块62;其中,FIG. 6 is a schematic structural diagram of a decoding apparatus according to an embodiment of the present invention. As shown in FIG. 6, the decoding apparatus includes an extraction module 61 and a decoding module 62.
所述提取模块61,配置为从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中;The extracting module 61 is configured to extract protocol related information from a standard protocol document, and save the protocol related information into a database in a corresponding data structure format;
所述解码模块62,配置为基于所述数据库所储存的信息对待解码的码流进行解码。The decoding module 62 is configured to decode a code stream to be decoded based on information stored in the database.
优选地,所述协议相关信息至少包括:消息描述信息、信元描述信息、 枚举描述信息。Preferably, the protocol related information at least includes: message description information, cell description information, Enumerate the description information.
在一具体实施例中,所述提取模块61包括设置子模块611、读取子模块612和存储子模块613;其中,In a specific embodiment, the extraction module 61 includes a setting submodule 611, a reading submodule 612, and a storage submodule 613;
所述设置子模块611,配置为预先设置第一存储格式;其中,所述第一存储格式包括消息描述表存储格式、信元描述表存储格式、枚举描述表存储格式、以及数组类型存储格式;The setting sub-module 611 is configured to preset a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format. ;
所述读取子模块612,配置为读取所述标准协议文档,从所述协议文档中提取消息描述信息、信元描述信息、枚举描述信息;The reading sub-module 612 is configured to read the standard protocol document, and extract message description information, cell description information, and enumeration description information from the protocol document;
所述存储子模块613,配置为基于所述第一存储格式,将所述消息描述信息、所述信元描述信息、以及所述枚举描述信息以对应的存储格式存储到数据库中。The storage submodule 613 is configured to store the message description information, the cell description information, and the enumeration description information into a database in a corresponding storage format based on the first storage format.
在一具体实施例中,所述解码模块62包括获取子模块621、确定子模块622以及处理子模块623;其中,In a specific embodiment, the decoding module 62 includes an obtaining submodule 621, a determining submodule 622, and a processing submodule 623;
所述获取子模块621,配置为接收待解码的码流后,从所述码流中获取解码所需相关参数;The acquiring sub-module 621 is configured to: after receiving the code stream to be decoded, obtain relevant parameters required for decoding from the code stream;
所述确定子模块622,配置为根据所述解码所需相关参数确定与所述码流对应的消息名称;The determining sub-module 622 is configured to determine a message name corresponding to the code stream according to the relevant parameters required for decoding;
所述处理子模块623,配置为以所述消息名称为关键字,获取与所述消息名称相对应的消息节点,循环解析消息下的子节点,并获取子节点的格式属性值,如果所述子节点的格式属性值为可选项,则跳转到可选项解码流程,否则进入必选项解码流程,直到码流结束或节点结束,当前消息解码结束。The processing sub-module 623 is configured to acquire, by using the message name as a key, a message node corresponding to the message name, loop through the child nodes under the message, and obtain a format attribute value of the child node, if If the format attribute value of the child node is optional, it jumps to the optional decoding process, otherwise it enters the mandatory decoding process until the end of the code stream or the end of the node, and the current message decoding ends.
其中,所述可选项解码流程,包括:The optional decoding process includes:
首先获取可选项开始节点,每次解码可选项时,均从所述可选项开始节点开始,将实际通过当前码流获取的可选项标记值与数据库中标准可选 项标记值进行匹配,如果匹配成功,获取当前节点,调用必选项解码接口解码。First, the optional start node is obtained, and each time the option is decoded, starting from the optional start node, the option tag value actually obtained through the current code stream is selected from the standard in the database. The item tag value is matched. If the match is successful, the current node is obtained, and the required decoding interface is decoded.
其中,所述必选项解码流程,包括:The required decoding process includes:
如果消息格式属性值中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;如果消息格式属性值中不包含长度信息,则不需要对所述长度信息进行解码;直到解码长度为0,则当前消息解码结束。If the length information is included in the message format attribute value, the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
本领域技术人员应当理解,图6所示的解码装置中的各单元的实现功能可参照前述解码方法的相关描述而理解。It will be understood by those skilled in the art that the implementation functions of the units in the decoding apparatus shown in FIG. 6 can be understood by referring to the related description of the foregoing decoding method.
实际应用中,所述提取模块61和解码模块62可由解码装置所属终端中的中央处理器(CPU,Central Processing Unit)、微处理器(MPU,Micro Processor Unit)、数字信号处理器(DSP,Digital Signal Processor)或现场可编程门阵列(FPGA,Field Programmable Gate Array)实现。In an actual application, the extraction module 61 and the decoding module 62 may be a central processing unit (CPU), a microprocessor (MPU, a Micro Processor Unit), a digital signal processor (DSP, Digital) in a terminal to which the decoding device belongs. Signal Processor) or Field Programmable Gate Array (FPGA) implementation.
本发明实施例还提供了一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行前述的解码方法。The embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the foregoing decoding method.
在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, such as: multiple units or components may be combined, or Can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, or direct coupling, or communication connection of the components shown or discussed may be indirect coupling or communication connection through some interfaces, devices or units, and may be electrical, mechanical or other forms. of.
上述作为分离部件说明的单元可以是、或也可以不是物理上分开的, 作为单元显示的部件可以是、或也可以不是物理单元,即可以位于一个地方,也可以分布到多个网络单元上;可以根据实际的需要选择其中的部分或全部单元来实现本实施例方案的目的。The units described above as separate components may or may not be physically separated. The components displayed as the unit may be, or may not be, physical units, that is, may be located in one place, or may be distributed to multiple network units; some or all of the units may be selected according to actual needs to implement the solution of the embodiment. purpose.
另外,在本发明各实施例中的各功能单元可以全部集成在一个处理单元中,也可以是各单元分别单独作为一个单元,也可以两个或两个以上单元集成在一个单元中;上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may be separately used as one unit, or two or more units may be integrated into one unit; The unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储设备、只读存储器(ROM,Read-Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to the program instructions. The foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing storage device includes the following steps: The foregoing storage medium includes: a removable storage device, a read-only memory (ROM), a magnetic disk, or an optical disk, and the like, which can store program codes.
或者,本发明上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储设备、ROM、磁碟或者光盘等各种可以存储程序代码的介质。Alternatively, the above-described integrated unit of the present invention may be stored in a computer readable storage medium if it is implemented in the form of a software function module and sold or used as a standalone product. Based on such understanding, the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product stored in a storage medium, including a plurality of instructions. A computer device (which may be a personal computer, server, or network device, etc.) is caused to perform all or part of the methods described in various embodiments of the present invention. The foregoing storage medium includes various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above is only the preferred embodiment of the present invention and is not intended to limit the scope of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the invention are intended to be included within the scope of the invention.
工业实用性Industrial applicability
本发明实施例中,从标准协议文档中提取协议相关信息,并将所述协 议相关信息以相应数据结构格式保存到数据库中;基于所述数据库所储存的信息对待解码的码流进行解码;如此,能够实现对以表格形式描述的协议文档的自动解码,解决了以表格形式描述的协议无法实现自动化解码的问题。 In the embodiment of the present invention, protocol related information is extracted from a standard protocol document, and the association is The related information is saved in the database in the corresponding data structure format; the code stream to be decoded is decoded based on the information stored in the database; thus, automatic decoding of the protocol document described in a tabular form can be realized, and the table format is solved. The described protocol cannot achieve the problem of automated decoding.

Claims (13)

  1. 一种解码方法,所述方法包括:A decoding method, the method comprising:
    从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中;Extracting protocol-related information from the standard protocol document, and saving the protocol-related information to the database in a corresponding data structure format;
    基于所述数据库所储存的信息对待解码的码流进行解码。The code stream to be decoded is decoded based on the information stored in the database.
  2. 根据权利要求1所述的方法,其中,所述协议相关信息至少包括:消息描述信息、信元描述信息、枚举描述信息。The method according to claim 1, wherein the protocol related information comprises at least: message description information, cell description information, and enumeration description information.
  3. 根据权利要求2所述的方法,其中,所述从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中,包括:The method of claim 2, wherein the extracting the protocol-related information from the standard protocol document and saving the protocol-related information to the database in a corresponding data structure format comprises:
    预先设置第一存储格式;其中,所述第一存储格式包括消息描述表存储格式、信元描述表存储格式、枚举描述表存储格式、以及数组类型存储格式;Setting a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
    读取所述标准协议文档,从所述协议文档中提取消息描述信息、信元描述信息、枚举描述信息;Reading the standard protocol document, and extracting message description information, cell description information, and enumeration description information from the protocol document;
    基于所述第一存储格式,将所述消息描述信息、所述信元描述信息、以及所述枚举描述信息以对应的存储格式存储到数据库中。And based on the first storage format, storing the message description information, the cell description information, and the enumeration description information in a corresponding storage format into a database.
  4. 根据权利要求2所述的方法,其中,所述基于所述数据库所储存的信息对待解码的码流进行解码,包括:The method of claim 2, wherein the decoding of the code stream to be decoded based on information stored by the database comprises:
    接收待解码的码流后,从所述码流中获取解码所需相关参数;After receiving the code stream to be decoded, obtaining relevant parameters required for decoding from the code stream;
    根据所述解码所需相关参数确定与所述码流对应的消息名称;Determining a message name corresponding to the code stream according to the relevant parameters required for decoding;
    以所述消息名称为关键字,获取与所述消息名称相对应的消息节点,循环解析消息下的子节点,并获取子节点的格式属性值,如果所述子节点的格式属性值为可选项,则跳转到可选项解码流程,否则进入必选项解码流程,直到码流结束或节点结束,当前消息解码结束。 Obtaining, by using the message name as a key, a message node corresponding to the message name, cyclically parsing the child node under the message, and obtaining a format attribute value of the child node, if the format attribute value of the child node is an optional item Then, jump to the optional decoding process, otherwise enter the mandatory decoding process until the end of the code stream or the end of the node, the current message decoding ends.
  5. 根据权利要求4所述的方法,其中,所述可选项解码流程,包括:The method of claim 4, wherein the optional decoding process comprises:
    首先获取可选项开始节点,每次解码可选项时,均从所述可选项开始节点开始,将实际通过当前码流获取的可选项标记值与数据库中的标准可选项标记值进行匹配,如果匹配成功,获取当前节点,调用必选项解码接口解码。First, the optional start node is obtained. Each time the option is decoded, starting from the optional start node, the option tag value actually obtained by the current code stream is matched with the standard optional tag value in the database, if it matches Successfully, get the current node, call the required decoding interface to decode.
  6. 根据权利要求4所述的方法,其中,所述必选项解码流程,包括:The method of claim 4, wherein the mandatory decoding process comprises:
    如果消息格式属性值中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;如果消息格式属性值中不包含长度信息,则不需要对所述长度信息进行解码;直到解码长度为0,则当前消息解码结束。If the length information is included in the message format attribute value, the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, The decoding is continued, otherwise, the current decoding process is ended; if the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
  7. 一种解码装置,所述解码装置包括提取模块和解码模块;其中,A decoding device, the decoding device comprising an extraction module and a decoding module; wherein
    所述提取模块,配置为从标准协议文档中提取协议相关信息,并将所述协议相关信息以相应数据结构格式保存到数据库中;The extracting module is configured to extract protocol related information from a standard protocol document, and save the protocol related information to a database in a corresponding data structure format;
    所述解码模块,配置为基于所述数据库所储存的信息对待解码的码流进行解码。The decoding module is configured to decode a code stream to be decoded based on information stored in the database.
  8. 根据权利要求7所述的解码装置,其中,所述协议相关信息至少包括:消息描述信息、信元描述信息、枚举描述信息。The decoding apparatus according to claim 7, wherein the protocol related information at least includes message description information, cell description information, and enumeration description information.
  9. 根据权利要求7所述的解码装置,其中,所述提取模块包括设置子模块、读取子模块和存储子模块;其中,The decoding device according to claim 7, wherein the extraction module comprises a setting submodule, a reading submodule, and a storage submodule; wherein
    所述设置子模块,配置为预先设置第一存储格式;其中,所述第一存储格式包括消息描述表存储格式、信元描述表存储格式、枚举描述表存储格式、以及数组类型存储格式;The setting submodule is configured to preset a first storage format, where the first storage format includes a message description table storage format, a cell description table storage format, an enumeration description table storage format, and an array type storage format;
    所述读取子模块,配置为读取所述标准协议文档,从所述协议文档中提取消息描述信息、信元描述信息、枚举描述信息; The reading submodule is configured to read the standard protocol document, and extract message description information, cell description information, and enumeration description information from the protocol document;
    所述存储子模块,配置为基于所述第一存储格式,将所述消息描述信息、所述信元描述信息、以及所述枚举描述信息以对应的存储格式存储到数据库中。The storage submodule is configured to store the message description information, the cell description information, and the enumeration description information in a corresponding storage format into a database based on the first storage format.
  10. 根据权利要求7所述的解码装置,其中,所述解码模块包括获取子模块、确定子模块以及处理子模块;其中,The decoding device according to claim 7, wherein the decoding module comprises an acquisition submodule, a determination submodule, and a processing submodule; wherein
    所述获取子模块,配置为接收待解码的码流后,从所述码流中获取解码所需相关参数;The acquiring submodule is configured to: after receiving the code stream to be decoded, obtain relevant parameters required for decoding from the code stream;
    所述确定子模块,配置为根据所述解码所需相关参数确定与所述码流对应的消息名称;The determining submodule is configured to determine a message name corresponding to the code stream according to the relevant parameters required for decoding;
    所述处理子模块,配置为以所述消息名称为关键字,获取与所述消息名称相对应的消息节点,循环解析消息下的子节点,并获取子节点的格式属性值,如果所述子节点的格式属性值为可选项,则跳转到可选项解码流程,否则进入必选项解码流程,直到码流结束或节点结束,当前消息解码结束。The processing submodule is configured to acquire a message node corresponding to the message name by using the message name as a key, loop through the child nodes under the message, and obtain a format attribute value of the child node, if the child If the format attribute value of the node is optional, it will jump to the optional decoding process, otherwise it will enter the mandatory decoding process until the end of the code stream or the end of the node, and the current message decoding ends.
  11. 根据权利要求10所述的解码装置,其中,所述可选项解码流程,包括:The decoding device according to claim 10, wherein the optional decoding process comprises:
    首先获取可选项开始节点,每次解码可选项时,均从所述可选项开始节点开始,将实际通过当前码流获取的可选项标记值与数据库中标准可选项标记值进行匹配,如果匹配成功,获取当前节点,调用必选项解码接口解码。First, the optional start node is obtained. Each time the option is decoded, starting from the optional start node, the option tag value actually obtained by the current code stream is matched with the standard optional tag value in the database, if the matching is successful. Get the current node and call the required decoding interface to decode.
  12. 根据权利要求10所述的解码装置,其中,所述必选项解码流程,包括:The decoding apparatus according to claim 10, wherein the required decoding process comprises:
    如果消息格式属性值中包含有长度信息,则先对所述长度信息进行解码,然后,将所述长度信息与标准长度信息进行比较,若所述长度信息在所述标准长度范围之内,则继续进行解码,否则,结束当前解码流程;如 果消息格式属性值中不包含长度信息,则不需要对所述长度信息进行解码;直到解码长度为0,则当前消息解码结束。If the length information is included in the message format attribute value, the length information is first decoded, and then the length information is compared with the standard length information, and if the length information is within the standard length range, Continue decoding, otherwise, end the current decoding process; If the length information is not included in the message format attribute value, the length information does not need to be decoded; until the decoding length is 0, the current message decoding ends.
  13. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1至6任一项所述的方法。 A computer storage medium having stored therein computer executable instructions for performing the method of any one of claims 1 to 6.
PCT/CN2015/087642 2014-12-12 2015-08-20 Decoding method and apparatus, and computer storage medium WO2016090957A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410768045.3 2014-12-12
CN201410768045.3A CN105740292B (en) 2014-12-12 2014-12-12 A kind of coding/decoding method and device

Publications (1)

Publication Number Publication Date
WO2016090957A1 true WO2016090957A1 (en) 2016-06-16

Family

ID=56106609

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/087642 WO2016090957A1 (en) 2014-12-12 2015-08-20 Decoding method and apparatus, and computer storage medium

Country Status (2)

Country Link
CN (1) CN105740292B (en)
WO (1) WO2016090957A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307012A (en) * 2019-07-30 2021-02-02 中科云谷科技有限公司 Mass industrial data storage and reading method
CN113542377A (en) * 2021-07-02 2021-10-22 中科亿海微电子科技(苏州)有限公司 Method and system for downloading code streams of different formats to FPGA
CN113542377B (en) * 2021-07-02 2024-04-19 中科亿海微电子科技(苏州)有限公司 Method and system for downloading different format code streams to FPGA

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113438231B (en) * 2021-06-23 2023-10-13 北京天融信网络安全技术有限公司 Industrial protocol decoding method and device, electronic equipment and storage medium
CN116192998B (en) * 2023-02-24 2023-10-31 广芯微电子(广州)股份有限公司 Method, device and equipment for decoding power transmission protocol information packet

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102117271A (en) * 2009-12-31 2011-07-06 Tcl集团股份有限公司 Method and terminal for playing falsely-encapsulated audio/video files
CN103441839A (en) * 2013-08-15 2013-12-11 国家电网公司 Method and system for using quantum cryptography in safe IP communication
CN104079450A (en) * 2014-06-23 2014-10-01 北京邮电大学 Method and device for generating characteristic pattern set

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100505743C (en) * 2003-12-12 2009-06-24 华为技术有限公司 Method for realizing general message interpreter
US7900208B2 (en) * 2005-11-30 2011-03-01 Oracle International Corporation Uniform framework for standardization and transmission of documents electronically
CN101175038B (en) * 2007-10-16 2010-10-27 华为技术有限公司 Data stream information transmission method, communication system and equipment
CN101222736B (en) * 2008-01-24 2011-06-22 中兴通讯股份有限公司 Method for acquiring assigned single plate interactive message code stream inside of base station
CN101511094B (en) * 2009-03-06 2011-02-02 北京泰合佳通信息技术有限公司 Dynamic decode method for GSM/TD wireless network null port protocol
CN102270223B (en) * 2011-06-22 2017-03-29 中兴通讯股份有限公司 The generation method in source codec storehouse, device and source codec method, device
US20140278957A1 (en) * 2013-03-13 2014-09-18 Deja.io, Inc. Normalization of media object metadata

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102117271A (en) * 2009-12-31 2011-07-06 Tcl集团股份有限公司 Method and terminal for playing falsely-encapsulated audio/video files
CN103441839A (en) * 2013-08-15 2013-12-11 国家电网公司 Method and system for using quantum cryptography in safe IP communication
CN104079450A (en) * 2014-06-23 2014-10-01 北京邮电大学 Method and device for generating characteristic pattern set

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307012A (en) * 2019-07-30 2021-02-02 中科云谷科技有限公司 Mass industrial data storage and reading method
CN113542377A (en) * 2021-07-02 2021-10-22 中科亿海微电子科技(苏州)有限公司 Method and system for downloading code streams of different formats to FPGA
CN113542377B (en) * 2021-07-02 2024-04-19 中科亿海微电子科技(苏州)有限公司 Method and system for downloading different format code streams to FPGA

Also Published As

Publication number Publication date
CN105740292B (en) 2019-06-28
CN105740292A (en) 2016-07-06

Similar Documents

Publication Publication Date Title
TWI729472B (en) Method, device and server for determining feature words
US10102274B2 (en) Corpus search systems and methods
CN103390258B (en) Updating and inquiring method and management system of laboratory object information and based on information code
CN102647414B (en) Protocol analysis method, protocol analysis device and protocol analysis system
EP3125509A1 (en) Application information sharing method and apparatus
WO2016090957A1 (en) Decoding method and apparatus, and computer storage medium
CN111339382A (en) Character string data retrieval method and device, computer equipment and storage medium
CN104850241A (en) Mobile terminal and text input method thereof
US8635242B2 (en) Processing queries on hierarchical markup data using shared hierarchical markup trees
CN115858796A (en) Fault knowledge graph construction method and device
CN112347767B (en) Text processing method, device and equipment
CN101794318A (en) URL (Uniform Resource Location) analyzing method and equipment
CN110705226A (en) Spreadsheet creating method and device and computer equipment
CN110597896A (en) Data display method, data display device and terminal equipment
CN102567365A (en) Input method and input system based on labeling specific to a keyword
CN104104972A (en) Multimedia playing method, apparatus and system
CN104794046B (en) The method and system of symbolic program running log
CN112069305B (en) Data screening method and device and electronic equipment
CN108664546A (en) Xml data structure conversion method and device
CN107291521B (en) Method and apparatus for compiling computer language
US10229105B1 (en) Mobile log data parsing
CN115114322A (en) Artificial intelligence SQL script data processing method and device based on deep learning and medium
CN111710365B (en) Ontology-based protein/gene synonym table construction method
CN112667632B (en) Metadata processing method and device
CN105188154B (en) A kind of method, apparatus and system being automatically brought into operation smart machine

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15868530

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15868530

Country of ref document: EP

Kind code of ref document: A1