CN114938397A - Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium - Google Patents

Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium Download PDF

Info

Publication number
CN114938397A
CN114938397A CN202210538376.2A CN202210538376A CN114938397A CN 114938397 A CN114938397 A CN 114938397A CN 202210538376 A CN202210538376 A CN 202210538376A CN 114938397 A CN114938397 A CN 114938397A
Authority
CN
China
Prior art keywords
protocol
unpacking
type
kaitai
field
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202210538376.2A
Other languages
Chinese (zh)
Inventor
方元
章渠丰
董守镏
文昱博
贺伟东
张若琦
雷东琦
叶佩炜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Mulian Internet Of Things Technology Co ltd
Original Assignee
Zhejiang Mulian Internet Of Things Technology Co ltd
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 Zhejiang Mulian Internet Of Things Technology Co ltd filed Critical Zhejiang Mulian Internet Of Things Technology Co ltd
Priority to CN202210538376.2A priority Critical patent/CN114938397A/en
Publication of CN114938397A publication Critical patent/CN114938397A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/18Protocol analysers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • H04L49/9057Arrangements for supporting packet reassembly or resequencing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Communication Control (AREA)

Abstract

The invention discloses a method, a system and a readable storage medium for unpacking and packing a high-efficiency protocol based on kaitai.e. the invention compiles a corresponding protocol structure description file according to a protocol data format needing to be processed; the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file; judging whether the packaging or unpacking needs to be executed according to the instruction; if the packaging is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a packaging function to restore the protocol description structure body into an original data stream; if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function. The invention writes a uniform protocol format description file, uses a protocol format compiler to efficiently generate a data structure for describing a protocol format, and processes an original data stream through the generated data structure. So as to save development time and simplify subsequent maintenance operation.

Description

Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium
Technical Field
The invention relates to the field of computer software communication, in particular to a kaitai-based efficient protocol unpacking and packing method, a system and a readable storage medium.
Background
Chinese patent CN101944025A published in 12.1.2011 provides a method for automatically packaging and unpacking TCP/UDP data based on PYTHON language, which defines a communication data structure in the form of an XML file, forms a conversion relation mapping table and a resident memory, where a one-to-one correspondence relationship is established between a data packet and a configuration structure, and completes packaging and unpacking through the conversion relation mapping table. The packaging process is that the data of each field of the protocol is generated according to the conversion relation mapping table and then combined to form a complete data message. The unpacking process is to split a complete data message into a plurality of fields according to the conversion relation mapping table.
The invention can accelerate the development and test speed of the TCP/UDP data communication program, and enables programmers to concentrate on the development of the service logic of the program, and the testers do not need to use one byte by one byte to test the communication data, thereby improving the accuracy and efficiency of the test. However, in the development of the technical solution, when a developer writes communication software for the PLC, the developer needs to define a data structure describing a protocol format, assemble and transmit a data packet, and when receiving PLC reply data, the developer needs to unpack the data packet. In this process, developers spend a lot of time defining the data structures describing the protocol. And the defined maintenance is complex, the definition method of different personnel is different, and the maintenance time cost of other personnel is high.
The PLC is a Programmable Logic Controller (PLC), which is a digital operation Controller with a microprocessor and used for automation control, and can load control instructions into a memory at any time for storage and execution. The programmable controller consists of functional units such as a CPU, an instruction and data memory, an input/output interface, a power supply, a digital-analog converter and the like. Early programmable logic controllers only had logic control functions and were named programmable logic controllers, and later, with the continuous development, these computer modules with simple functions at first had various functions including logic control, sequential control, analog control, multi-computer communication, and the like.
The programmable logic controller used in industry at present is equivalent to or close to the host computer of a compact computer, and the advantages of the programmable logic controller in terms of expandability and reliability enable the programmable logic controller to be widely applied to various industrial control fields at present. In a computer direct control system, a centralized distributed control system DCS, or a field bus control system FCS, a large number of PLC controllers are used. Many manufacturers of PLC, such as Siemens, Schneider, Mitsubishi, Taida, and the like, almost all manufacturers relating to the field of industrial automation have the PLC products provided.
Disclosure of Invention
In view of the above problems, it is an object of the present invention to provide a kaitai-based efficient protocol unpacking and packing method, system and readable storage medium, which can efficiently generate a data structure describing a protocol format by using a protocol format compiler by writing a uniform protocol format description file, and process an original data stream through the generated data structure. So as to save development time and simplify subsequent maintenance operation.
The invention provides a high-efficiency protocol unpacking and packing method based on kaitai in a first aspect, which comprises the following steps:
compiling a corresponding protocol structure description file according to a protocol data format to be processed;
the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file;
judging whether the packaging or unpacking needs to be executed according to the instruction;
if the package is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a package function to restore the protocol description structure into an original data stream;
if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function.
In this scheme, the protocol structure description file includes the following information:
meta: metadata;
seq: an object in a protocol format;
types: a type of customization;
enums: an enumeration type field in seq.
In this embodiment, the meta includes: the name of the protocol described by the file, the detailed description information and the default data storage mode of the protocol.
In the scheme, the Seq consists of objects, and each object represents a field in the protocol;
the Seq comprises: id. size, type;
where id denotes a field name, size denotes a field length, and type denotes a field type.
In the scheme, the field type is a predefined character string, a common type of shaping, a self-defined type or a logic judgment statement.
In the scheme, different meanings corresponding to all possible values are listed under each object of the Enums part.
The second aspect of the present invention provides a kaitai-based high-efficiency protocol unpacking and packing system, which includes a memory and a processor, wherein the memory includes a kaitai-based high-efficiency protocol unpacking and packing method program, and when being executed by the processor, the kaitai-based high-efficiency protocol unpacking and packing method program implements the following steps:
compiling a corresponding protocol structure description file according to a protocol data format to be processed;
the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file;
judging whether the packaging or unpacking needs to be executed according to the instruction;
if the package is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a package function to restore the protocol description structure into an original data stream;
if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function.
In this scheme, the protocol structure description file includes the following information:
meta: metadata;
seq: an object in a protocol format;
types: a type of customization;
enums: an enumeration type field in seq.
In this embodiment, the meta includes: the name, the detailed description information and the default data storage mode of the protocol described by the file;
the Seq consists of objects, each object represents a field in the protocol;
the Seq comprises: id. size, type;
wherein id represents a field name, size represents a field length, and type represents a field type;
the field type is a predefined character string, a common type of shaping, or a self-defined type, or a logic judgment statement;
the Enums section lists different meanings for all possible values under each object.
A third aspect of the present invention provides a computer-readable storage medium, where the computer-readable storage medium includes a program for a kaitai-based high-efficiency protocol unpacking and packing method, and when the program for the kaitai-based high-efficiency protocol unpacking and packing method is executed by a processor, the method implements the steps of any one of the above-mentioned steps.
The invention discloses a method, a system and a readable storage medium for unpacking and packing a high-efficiency protocol based on kaitai. The method can save development time, only a developer needs to write the protocol format description file, and the data structure is automatically generated by the compiler. Because the uniform protocol format is adopted to describe the file, the subsequent maintenance is simple and convenient. The protocol format description file supports various conditional statements and various data types, which are enough to describe a complex protocol.
Drawings
FIG. 1 is a flow chart of a kaitai-based efficient protocol unpacking and packing method according to the present application;
fig. 2 shows a block diagram of a kaitai-based high-efficiency protocol unpacking and packaging system of the present invention.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a more particular description of the invention will be rendered by reference to the appended drawings. It should be noted that the embodiments and features of the embodiments of the present application may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention, however, the present invention may be practiced in other ways than those specifically described herein, and therefore the scope of the present invention is not limited by the specific embodiments disclosed below.
Fig. 1 shows a kaitai-based efficient protocol unpacking and packing method of the present application.
As shown in fig. 1, the present invention provides a kaitai-based high-efficiency protocol unpacking and packing method, which includes the following steps:
s102: compiling a corresponding protocol structure description file according to a protocol data format to be processed;
s104: the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file;
s106: judging whether the packaging or unpacking needs to be executed according to the instruction;
if the packaging is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a packaging function to restore the protocol description structure body into an original data stream;
if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function.
It should be noted that the Kaitai, i.e., the Kaitai Struct, is a declarative language for describing various binary data structures, i.e., binary file formats, network stream packet formats, and the like.
The main idea is to describe a specific format in the Kaitai Struct language (file) and then can compile it into a source file in one of the supported programming languages. These modules will include code generated for a parser that can read the described data structure from a file or stream and grant access to it in an easily understood API.
It should be noted that the protocol is a communication protocol, and the communication protocol refers to rules and conventions that must be followed by two entities to complete communication or service. Data communication systems in a plurality of different geographical locations interconnected by communication channels and devices must have a common language between them to enable their co-operation for information exchange and resource sharing. What, how and when to communicate must follow certain mutually acceptable rules. This rule is the communication protocol.
It should be noted that the protocol format description file is composed of different objects, the objects may also include object key value pairs, each protocol format description file must contain a Meta object and a Seq object, the Meta object is mainly used to add a relevant description to the protocol format description file, and the Seq object is mainly used to describe the protocol format in sequence.
According to an embodiment of the present invention, the protocol structure description file includes the following information:
meta: metadata;
seq: an object in a protocol format;
types: a type of customization;
enums: an enumeration type field in seq.
According to an embodiment of the present invention, the meta includes: the name, detailed description information and default data storage mode of the protocol described by the file.
It should be noted that, as a specific example, a Meta object is illustrated:
meta:
id:foxboro
title:Foxboro protocol
endian:be
the meta object contains three object key value pairs of id, title and endian. The meaning is protocol identification, protocol name and protocol byte order. The meaning of this object above is that the protocol identifier representing the protocol format description file is foxboro, the protocol name is foxboro protocol, and the protocol endian is big endian.
According to the embodiment of the invention, the Seq is composed of objects, and each object represents a field in a protocol;
the Seq comprises: id. size, type;
it should be noted that, as a specific embodiment, the following illustrates a Seq object:
Figure BDA0003647338050000051
Figure BDA0003647338050000061
there may be multiple elements under the Seq object, the elements describe the protocol format in sequence, each element has attributes of id, type, size, etc., id is identifier, type is data type, the value of type may be signed (s1, s2, s4, s8), unsigned (u1, u2, u3, u4), string type (str), etc. The Size indicates the data length, and when the data type does not contain the data length, the Size attribute is used to indicate the data length. The above object describes a data format with a data length of 8 bytes (1+3+2+ 2):
the 1 st byte of this data is the header _ len (header length), the data type is unsigned, and the length is 1 byte
Bytes 2-4 are reserved fields with a length of 3 bytes
Bytes 5-6 are length, data type is unsigned, length is 2 bytes
Bytes 7-8 are sequence numbers, data type is unsigned, length is 2 bytes, and endianness is little endian (le).
Where id denotes a field name, size denotes a field length, and type denotes a field type.
According to the embodiment of the invention, the field type is a predefined character string, a common type of shaping, or a self-defined type, or a logic judgment statement.
According to the embodiment of the present invention, the Enums part lists different meanings corresponding to all possible values under each object.
As a specific embodiment, the following description is given by using a specific protocol format description file:
Figure BDA0003647338050000062
Figure BDA0003647338050000071
Figure BDA0003647338050000081
the above-mentioned protocol format description file (KSY), meta section is the name and detailed description information of the protocol described by this file. The Endian indicates whether the default data storage mode of the protocol is big end or small end.
The Seq part is the main part describing the format of the protocol and is composed of a plurality of objects, each object represents a field in the protocol, id represents the field name, size represents the field length, and type represents the field type. The field type can be a common type such as a predefined character string, a reshaping and the like, and can also be a custom type. Or a logic judgment statement, such as a switch-case or if statement shown in a file, is used to describe a more complex protocol.
The Types part represents the type of customization, the structure is similar to the seq part, and the parts can be nested in multiple layers.
The Enums part represents the enumerated type field in the seq part, and each object in the part lists different meanings corresponding to all possible values.
It should be noted that Types and enum are selectable objects of the protocol format description file, and when a type attribute of a certain element in a seq object is a custom type, a format of the custom type needs to be described in the Types object, for example:
Figure BDA0003647338050000091
in the above example, the seq object contains a local _ time element, which is a custom type with the type name time, so that the structure of the time type needs to be defined in the type object.
When a certain element in the seq object has an enum attribute, the attribute needs to be defined in the enum object, for example:
Figure BDA0003647338050000092
Figure BDA0003647338050000101
in the above example, the seq object contains a packet _ type element having an enum attribute, which indicates that this element is enumerable, and the name of the enumeration set is packet _ types, so it is necessary to define the enumeration type contained in the packet _ types in the items object. When the value of packet _ type is 2, it means that packet _ type is request, and so on.
It should be noted that, taking the above protocol description structure as an example, the group packing function is as follows:
def_write(self):
bytebuff=b”
bytebuff+=self._io.write_u1(self.header_len)
bytebuff+=bytearray(self.reserved)
bytebuff+=self._io.write_u2be(self.length)
bytebuff+=self._io.write_u2le(self.seq)
return bytebuff
the data is sequentially restored to a byte stream, and the data processing function is as follows
def write_u1(self,data):
return data.to_bytes(1,"big")
def write_u2be(self,data):
return data.to_bytes(2,byteorder="big",signed="unsigned")
def write_u2le(self,data):
return data.to_bytes(2,byteorder="little",signed="unsigned")
The unpacking function is as follows:
def_read(self):
self.header_len=self._io.read_u1()
self.reserved=self._io.read_bytes(3)
self.length=self._io.read_u2be()
self.seq=self._io.read_u2le()
the byte stream is parsed in sequence, involving the following data processing functions:
def read_u1(self):
return KaitaiStream.packer_u1.unpack(self.read_bytes(1))[0]
def read_u2be(self):
return KaitaiStream.packer_u2be.unpack(self.read_bytes(2))[0]
def read_u2le(self):
return KaitaiStream.packer_u2le.unpack(self.read_bytes(2))[0]
FIG. 2 is a block diagram of a kaitai-based efficient protocol unpacking and packing system according to the present application.
As shown in fig. 2, the present invention provides a kaitai-based high-efficiency protocol unpacking and packing system, where the kaitai-based high-efficiency protocol unpacking and packing system includes a memory 21 and a processor 22, the memory 21 includes a kaitai-based high-efficiency protocol unpacking and packing method program, and when executed by the processor 22, the kaitai-based high-efficiency protocol unpacking and packing method program implements the following steps:
compiling a corresponding protocol structure description file according to a protocol data format to be processed;
the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file;
judging whether the packaging or unpacking needs to be executed according to the instruction;
if the package is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a package function to restore the protocol description structure into an original data stream;
if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function.
It should be noted that the Kaitai, i.e., Kaitai Struct, is a declarative language for describing various binary data structures, i.e., binary file formats, network stream packet formats, and so on.
The main idea is to describe a specific format in the Kaitai Struct language (file) and then compile it into a source file in a supported programming language. These modules will include code generated for a parser that can read the described data structure from a file or stream and grant access to it in an easily understood API.
It should be noted that the protocol is a communication protocol, and the communication protocol refers to rules and conventions that must be followed by two entities to complete communication or service. Data communication systems in a plurality of different geographical locations interconnected by communication channels and devices must have a common language between them to enable their co-operation for information exchange and resource sharing. What, how and when to communicate must follow certain mutually acceptable rules. This rule is the communication protocol.
According to an embodiment of the present invention, the protocol structure description file includes the following information:
meta: metadata;
seq: an object in a protocol format;
types: a type of customization;
enums: an enumeration type field in seq.
According to an embodiment of the present invention, the meta includes: the name, the detailed description information and the default data storage mode of the protocol described by the file;
the Seq consists of objects, each object represents a field in the protocol;
the Seq comprises: id. size, type;
wherein id represents a field name, size represents a field length, and type represents a field type;
the field type is a common type of a predefined character string and a shaping, or a self-defined type, or a logic judgment statement;
the Enums section lists different meanings for all possible values under each object.
As a specific embodiment, the following description is given with a specific protocol format description file:
Figure BDA0003647338050000121
Figure BDA0003647338050000131
Figure BDA0003647338050000141
the above-mentioned protocol format description file (KSY), meta part is the name and detailed description information of the protocol described in this file. The Endian indicates whether the default data storage mode of the protocol is big end or small end.
The Seq part is a main part for describing the protocol format and is composed of a plurality of objects, each object represents a field in the protocol, id represents the field name, size represents the field length, and type represents the field type. The field type can be a common type such as a predefined character string, a reshaping and the like, and can also be a custom type. Or a logic judgment statement, such as a switch-case or if statement shown in a file, is used to describe a more complex protocol.
The Types part represents the type of customization, the structure is similar to the seq part, and the parts can be nested in multiple layers.
The Enums part represents the enumerated type field in the seq part, and each object in the part lists different meanings corresponding to all possible values.
A third aspect of the present invention provides a computer-readable storage medium, where the computer-readable storage medium includes a kaitai-based high-efficiency protocol unpacking and packaging method program, and when the kaitai-based high-efficiency protocol unpacking and packaging method program is executed by a processor, the steps of the kaitai-based high-efficiency protocol unpacking and packaging method described in any one of the above are implemented.
The invention discloses a method, a system and a readable storage medium for unpacking and packing a high-efficiency protocol based on kaitai. The method can save development time, only a developer needs to write the protocol format description file, and the data structure is automatically generated by the compiler. Because the uniform protocol format is adopted to describe the file, the subsequent maintenance is simple and convenient. The protocol format description file supports various conditional statements and various data types, which are enough to describe a complex protocol.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described device embodiments are merely illustrative, for example, the division of the unit is only a logical functional division, and there may be other division ways in actual implementation, such as: multiple units or components may be combined, or may be integrated into another system, or some features may be omitted, or not implemented. In addition, the coupling, direct coupling or communication connection between the components shown or discussed may be through some interfaces, and the indirect coupling or communication connection between the devices or units may be electrical, mechanical or other forms.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units; can be located in one place or distributed on a plurality of network units; some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, all the functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately regarded as one unit, or two or more units may be integrated into one unit; the integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will understand that: all or part of the steps of implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer-readable storage medium, and when executed, executes the steps including the method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Alternatively, the 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 functional module and sold or used as a separate product. Based on such understanding, the technical solutions of the embodiments of the present invention may be essentially implemented or a part contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present invention. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.

Claims (10)

1. A kaitai-based high-efficiency protocol unpacking and packing method, which is characterized by comprising the following steps:
compiling a corresponding protocol structure description file according to a protocol data format to be processed;
the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file;
judging whether the packaging or unpacking needs to be executed according to the instruction;
if the packaging is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a packaging function to restore the protocol description structure body into an original data stream;
if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function.
2. The method of claim 1, wherein the protocol structure description file comprises the following information:
meta: metadata;
seq: an object in a protocol format;
types: a type of customization;
enums: an enumeration type field in seq.
3. The kaitai-based high efficiency protocol unpacking and packing method according to claim 2, wherein the meta includes: the name, detailed description information and default data storage mode of the protocol described by the file.
4. The method for kaitai-based efficient protocol unpacking and packing according to claim 2 or 3, wherein the Seq consists of objects, each object representing a field in the protocol;
the Seq comprises: id. size, type;
where id denotes a field name, size denotes a field length, and type denotes a field type.
5. The method of claim 4, wherein the field type is a predefined string, a common type for shaping, or a custom type, or a logical judgment statement.
6. The method of claim 5, wherein the Enums part enumerates under each object different meanings for all possible values.
7. A kaitai-based high-efficiency protocol unpacking and packing system is characterized in that the system comprises a memory and a processor, wherein the memory comprises a kaitai-based high-efficiency protocol unpacking and packing method program, and when the processor executes the program, the method comprises the following steps:
compiling a corresponding protocol structure description file according to a protocol data format to be processed;
the protocol structure compiler produces a corresponding protocol description structure body according to the protocol structure description file;
judging whether the packaging or unpacking needs to be executed according to the instruction;
if the packaging is required to be executed, filling in each field data of the protocol according to the actual situation, and then calling a packaging function to restore the protocol description structure body into an original data stream;
if unpacking is needed, an unpacking function is called to read and decompose the original data stream, and then the values of all the fields are automatically filled according to the unpacking function.
8. The kaitai-based efficient protocol unpacking and packing system according to claim 7, wherein the protocol structure description file includes the following information:
meta: metadata;
seq: an object in a protocol format;
types: a type of customization;
enums: enumerated type field in seq.
9. The kaitai-based high-efficiency protocol unpacking and packaging system according to claim 7 or 8, wherein the meta comprises: the name, the detailed description information and the default data storage mode of the protocol described by the file;
the Seq consists of objects, each object represents a field in the protocol;
the Seq comprises: id. size, type;
wherein id represents a field name, size represents a field length, and type represents a field type;
the field type is a common type of a predefined character string and a shaping, or a self-defined type, or a logic judgment statement;
the Enums section lists different meanings for all possible values under each object.
10. A computer-readable storage medium, comprising a kaitai-based high-efficiency protocol unpacking method program, wherein the kaitai-based high-efficiency protocol unpacking method program, when executed by a processor, implements the steps of the kaitai-based high-efficiency protocol unpacking method according to any one of claims 1 to 6.
CN202210538376.2A 2022-05-17 2022-05-17 Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium Pending CN114938397A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210538376.2A CN114938397A (en) 2022-05-17 2022-05-17 Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210538376.2A CN114938397A (en) 2022-05-17 2022-05-17 Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium

Publications (1)

Publication Number Publication Date
CN114938397A true CN114938397A (en) 2022-08-23

Family

ID=82865251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210538376.2A Pending CN114938397A (en) 2022-05-17 2022-05-17 Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium

Country Status (1)

Country Link
CN (1) CN114938397A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116346531A (en) * 2023-05-26 2023-06-27 云南自由贸易试验区苇航智能科技有限责任公司 Adaptation method based on CANBUS communication protocol

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050065953A1 (en) * 2003-09-19 2005-03-24 Bower Shelley K. System and method for changing defined elements in a previously compiled program using a description file
CN101944025A (en) * 2010-09-16 2011-01-12 福建鑫诺通讯技术有限公司 Automatic TCP/UDP (Transmission Control Protocol/User Datagram Protocol) data packing and unpacking method based on PYTHON language
CN106412086A (en) * 2016-10-31 2017-02-15 武汉斗鱼网络科技有限公司 Method and system for automatically generating communication codes by employing protocol description file
CN107861720A (en) * 2017-11-17 2018-03-30 江苏中威科技软件系统有限公司 The processing method of block data chained file data
CN109194617A (en) * 2018-08-01 2019-01-11 杭州电子科技大学 The automatically parsing of XML message, packaging method and device
CN111090417A (en) * 2019-11-14 2020-05-01 杭州中恒电气股份有限公司 Binary file analysis method, device, equipment and medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050065953A1 (en) * 2003-09-19 2005-03-24 Bower Shelley K. System and method for changing defined elements in a previously compiled program using a description file
CN101944025A (en) * 2010-09-16 2011-01-12 福建鑫诺通讯技术有限公司 Automatic TCP/UDP (Transmission Control Protocol/User Datagram Protocol) data packing and unpacking method based on PYTHON language
CN106412086A (en) * 2016-10-31 2017-02-15 武汉斗鱼网络科技有限公司 Method and system for automatically generating communication codes by employing protocol description file
CN107861720A (en) * 2017-11-17 2018-03-30 江苏中威科技软件系统有限公司 The processing method of block data chained file data
CN109194617A (en) * 2018-08-01 2019-01-11 杭州电子科技大学 The automatically parsing of XML message, packaging method and device
CN111090417A (en) * 2019-11-14 2020-05-01 杭州中恒电气股份有限公司 Binary file analysis method, device, equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116346531A (en) * 2023-05-26 2023-06-27 云南自由贸易试验区苇航智能科技有限责任公司 Adaptation method based on CANBUS communication protocol
CN116346531B (en) * 2023-05-26 2023-09-22 云南自由贸易试验区苇航智能科技有限责任公司 Adaptation method based on CANBUS communication protocol

Similar Documents

Publication Publication Date Title
EP2811353B1 (en) Support device, recording medium having support program recorded thereon, and method for generating executable program
Whitby-Strevens The transputer
Bomans et al. The Argonne/GMD macros in FORTRAN for portable parallel programming and their implementation on the Intel iPSC/2
WO1998024020A2 (en) Method and system for generating software code
CN111404883A (en) Method and device for analyzing Internet of things equipment universal protocol
EP3751412A1 (en) A computer-implemented method to generate an opc ua information model
WO2017205009A1 (en) System and method for data compatibility across heterogeneous machine architectures
CN114938397A (en) Kaitai-based high-efficiency protocol unpacking and packing method, system and readable storage medium
CN112417515A (en) Configuration software protocol processing method and system
Podlubne et al. Model-based approach for automatic generation of hardware architectures for robotics
WO2023213295A1 (en) Custom component control system and method, and device and storage medium
CN113132371A (en) Message conversion method, device, computer readable storage medium and processor
Wienke et al. A meta-model and toolchain for improved interoperability of robotic frameworks
KR102407941B1 (en) User interface generation method of electronic device calling function or procedure of external device based on remote procedure call(rpc), program and electronic device thereof
CN115390846A (en) Compiling construction method and device, electronic equipment and storage medium
US11429358B2 (en) Representing asynchronous state machine in intermediate code
CN111061481A (en) Data format conversion method and device
CN114546670A (en) Coroutine-based functional asynchronous data distribution system and method
JP4776602B2 (en) Programming device for controller, controller and controller management system
JP2007036937A (en) Device and program for supporting protocol conversion programming
Gray et al. Pluggability issues in the multi protocol
CN114721325B (en) Multi-platform multi-version PLC engineering compatible method
CN113259233B (en) DDS-based automation gateway of heterogeneous communication protocol
CN110018959B (en) Embedded application debugging method and system
US20240184541A1 (en) Method and Apparatus for Executing Workflow Task Across Control Objects

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination