WO2017128299A1 - Method and system for parsing multi-protocol message based on file mode - Google Patents

Method and system for parsing multi-protocol message based on file mode Download PDF

Info

Publication number
WO2017128299A1
WO2017128299A1 PCT/CN2016/072806 CN2016072806W WO2017128299A1 WO 2017128299 A1 WO2017128299 A1 WO 2017128299A1 CN 2016072806 W CN2016072806 W CN 2016072806W WO 2017128299 A1 WO2017128299 A1 WO 2017128299A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
data
message
protocol
message file
Prior art date
Application number
PCT/CN2016/072806
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 瑞斯康微电子(深圳)有限公司
Priority to PCT/CN2016/072806 priority Critical patent/WO2017128299A1/en
Publication of WO2017128299A1 publication Critical patent/WO2017128299A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/40Network security protocols

Definitions

  • the present invention belongs to the field of data communication technologies, and in particular, to a file method based multi-protocol message parsing method and system.
  • the technical problem to be solved by the present invention is to provide a file method-based multi-protocol message parsing method and system, which aims to solve the problem that it is easy to cause reception by using the robin search respective protocol in the existing single channel multi-protocol single processing mode.
  • the present invention provides a method for parsing multi-protocol messages based on a file method, which includes the following steps:
  • Step S1 initializing an algorithm memory resource, and initializing a data message file handle
  • Step S2 reading a data stream containing various protocols from the communication port, and storing the data stream in a data buffer area in the memory;
  • Step S3 reading data in the data cache area, and writing the data into a message file as a file, and cleaning up the old message file to obtain an updated message file;
  • Step S4 sharing the message file to all protocol stack parsers
  • step S5 steps S2-S4 are repeated until all the data is read;
  • Step S6 Each protocol stack parser reads the data in the updated message file by using the allocated file handle, and determines whether the protocol message exists in the data;
  • Step S7 if yes, after the processing according to the protocol, respond to the application of the message, and repeat steps S6-S7; if not, repeat steps S6-S7.
  • step S3 is specifically:
  • Read the data in the data cache area and use the file processing algorithm to write the data from the file write pointer to the SDRAM/RAM message file in the form of a file, and update the pointer written by the file; and clean up the old The message file gets the updated message file.
  • step S6 the process of reading the data in the message file in the step S6 is specifically:
  • Each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle.
  • the invention also provides a file-based multi-protocol message parsing system, comprising:
  • a memory initialization unit configured to initialize an algorithm memory resource, and initialize a data message file handle
  • a data stream storage unit configured to read a data stream from the communication port, and store the data stream in a data cache area in the memory
  • a message file writing unit configured to read data in the data buffer area, and write the data into a message file in a file form, and at the same time, clean up the old message file to obtain an updated message file;
  • a message file reading unit configured to share the message file to all protocol stack parsers, and each protocol stack parser uses the allocated file handle to read data in the updated message file;
  • the message file parsing unit is configured to determine whether the protocol message exists in the data, and if yes, respond to the application according to the protocol.
  • message file writing unit is specifically:
  • Read the data in the data cache area and use the file processing algorithm to write the data from the file write pointer to the SDRAM/RAM message file in the form of a file, and update the pointer written by the file; and clean up the old The message file gets the updated message file.
  • Each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle.
  • the present invention has the beneficial effects that the method and system for parsing multi-protocol messages based on the file mode are implemented by the file-sharing packet to implement multi-protocol concurrent parsing.
  • Fast processing of the received cached data stream avoiding the problem of data loss caused by excessive buffering of the received buffer due to the excessive resource overhead caused by the repeated search of the respective protocols in the existing same channel multi-protocol single processing mode, reducing the cache
  • the overflow probability greatly improves the response speed and efficiency.
  • the file method it completely isolates the protocol application and the communication layer, making the software program more hierarchical, easy to maintain, and easy to expand.
  • FIG. 1 is a flowchart of a method for parsing a multi-protocol message based on a file according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a file-based multi-protocol message parsing system according to an embodiment of the present invention.
  • the main implementation idea of the present invention is that a data stream composed of data including various protocols is provided to each protocol parser in a file manner, and a data stream is cached by a file method, and each protocol parser uses a file sharing method to access a single channel.
  • the protocol data stream if the protocol stack parser reads the packet data containing the protocol, the response packet is processed according to the protocol; the protocols do not interfere with each other, and the packet zero is lost, and the protocol parser is completely independent.
  • Step S1 initializing an algorithm memory resource and a file algorithm parameter, and initializing a data message file handle
  • Step S2 reading a data stream containing various protocols from the communication port, and storing the data stream in a data buffer area in the memory;
  • Step S3 reading data in the data cache area, and writing the data into a message file as a file, and cleaning up the old message file to obtain an updated message file;
  • the step S3 is specifically: reading data in the data buffer area, and using a file processing algorithm to generate a data message file that can be accessed by other protocols; specifically, the entire data stream is maintained and managed by the file information. And providing an interface for protocol access; more specifically, writing the data from the file write pointer to the SDRAM/RAM in the form of a file (Synchronous Dynamic Random Access Memory, Synchronous Dynamic Random Access Memory / Random Access Memory, random access memory) message file, and update the pointer written by the file; and follow the FIFO (First Int First) Out, first-in, first-out queue) thoughts, clean up old message files, and get updated message files.
  • FIFO First Int First
  • the data message file manages the file content and file length through a write pointer and a read pointer; the file length is maintained by the write pointer, and when the data stream is written to the data file, the data will be Write the data file from the write pointer and update the write pointer; when the written pointer exceeds the maximum length of the file system limit (this can adjust the maximum length according to the cached resources), the old data will be discarded through the FIFO. And update the write pointer to reduce the pressure on the cache.
  • Step S4 sharing the message file to all protocol stack parsers, and each protocol stack parser that needs to access the file can access the file;
  • step S5 steps S2-S4 are repeated until all the data is read;
  • Step S6 Each protocol stack parser reads the data in the updated message file by using the allocated file handle, and determines whether the protocol message exists in the data;
  • the method for obtaining a data stream by using multiple file stacks by means of file reading is: the data stream containing different protocols is included in the same communication channel, and multiple protocols need to extract their own protocol data messages from the data stream; specifically, first, Each protocol is applied to the filed data file requesting access.
  • the data message file system allocates a file handle for each access; then, each protocol application uses the file handle information to extract the protocol that has not been accessed. The latest data stream, while updating the access information for this protocol file handle.
  • each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle;
  • the device analyzes the read data according to the protocol characteristics, and determines whether the file data obtained from the file has the protocol message.
  • Step S7 if yes, after the processing according to the protocol, respond to the application of the message, and repeat steps S6-S7; if not, repeat steps S6-S7.
  • each independent protocol can implement the respective parsing according to steps S6-S7, and complete the response of each protocol packet, so that multiple protocols can be independently parsed.
  • the present invention also provides a file-based multi-protocol message parsing system, as shown in FIG. 2, including:
  • the memory initialization unit 1 is configured to initialize an algorithm memory resource and initialize a data message file handle
  • a data stream storage unit 2 configured to read a data stream from the communication port, and store the data stream in a data cache area in the memory;
  • the message file writing unit 3 is configured to read the data in the data buffer area, and write the data into the message file as a file, and clean up the old message file to obtain the updated message file. ;
  • a message file reading unit 4 configured to share the message file to all protocol stack parsers, and each protocol stack parser uses the allocated file handle to read data in the updated message file;
  • the packet file parsing unit 5 is configured to determine whether the protocol packet exists in the data, and if yes, respond to the application of the packet after processing according to the protocol.
  • the invention is mainly applied in the field of communication, such as data acquisition, data communication, etc.; and is particularly suitable for multiple protocol parsing of a single channel.
  • the shared access is performed through the filed message to implement multi-protocol concurrent parsing, which reduces resource overhead and saves processing time, improves response speed, quickly processes received buffered data stream, reduces buffer overflow probability, and discards invalid Protocol data.
  • the file method it completely isolates the protocol application and the communication layer, making the software program more hierarchical, easy to maintain, and easy to expand; each protocol can search the data stream by accessing the data file without causing data. Packets are lost; each protocol can be packaged separately, easy to extend and migrate; each protocol is independent, even when the same protocol is used by multiple applications, it can be used independently, which can better divide the software hierarchy.

Abstract

The present invention is applicable to the technical field of data communications, and provides a method for parsing a multi-protocol message based on a file mode, comprising: 1. initializing an algorithm memory resource and a file handle; 2. reading a data stream from a communication port and storing same in a data buffer region in the memory; 3. reading data in the data buffer region, and writing the data into a message file, and meanwhile cleaning an old message file to obtain an updated message file; 4. sharing the message file with all protocol stack parsers; 5. repeating steps 2 to 4; 6. each protocol stack parser using an allocated file handle to read data in the updated message file, and determining whether there is a message with the protocol in the data; and 7. if so, responding to the application of the message after processing the message according to the protocol. The method provided by the present invention solves the problem that, in the existing single processing mode, searching each protocol in turn easily causes the receiving buffer to overflow, thereby leading to data loss.

Description

一种基于文件方式的多协议报文解析方法与系统  Multi-protocol message parsing method and system based on file mode 技术领域Technical field
本发明属于数据通信技术领域,尤其涉及一种基于文件方式的多协议报文解析方法与系统。 The present invention belongs to the field of data communication technologies, and in particular, to a file method based multi-protocol message parsing method and system.
背景技术Background technique
在一个通信通道,由于调试或其他因素,需要支持多种协议,解析通信数据时有采用单一处理模式的技术,即来一包数据,先用一种协议去解析,不对,再用下一种协议解析,依此类推,这种处理模式在通信任务繁重下,需要轮番搜索对应的协议,资源开销很大,容易造成接收缓存溢出导致数据丢失;特别在双向多主多从的通信时,由于软件层次无法划分,容易造成报文丢失。In a communication channel, due to debugging or other factors, it is necessary to support multiple protocols. When parsing communication data, there is a technology that uses a single processing mode, that is, a packet of data is first parsed by a protocol, and then the next one is used. Protocol analysis, and so on, this processing mode requires a lot of communication to search for the corresponding protocol under the heavy communication task, and the resource overhead is large, which is easy to cause the data to be lost due to the overflow of the receiving buffer; especially in the communication of the two-way multi-master multi-slave, The software level cannot be divided, which is easy to cause packet loss.
同时采用单一处理模式,很难将软件的层次划分清楚,耦合性较强,不容易扩展,移植性差。At the same time, using a single processing mode, it is difficult to clearly classify the software, the coupling is strong, it is not easy to expand, and the portability is poor.
技术问题technical problem
本发明所要解决的技术问题在于提供一种基于文件方式的多协议报文解析方法与系统,旨在解决在现有的同一信道多协议单一处理模式下,因采用轮番搜索各自协议而容易造成接收缓存溢出从而导致数据丢失的问题。 The technical problem to be solved by the present invention is to provide a file method-based multi-protocol message parsing method and system, which aims to solve the problem that it is easy to cause reception by using the robin search respective protocol in the existing single channel multi-protocol single processing mode. A buffer overflow that causes data loss.
技术解决方案Technical solution
本发明提供了一种基于文件方式的多协议报文解析方法,包括下述步骤:The present invention provides a method for parsing multi-protocol messages based on a file method, which includes the following steps:
步骤S1,初始化算法内存资源,并初始化数据报文文件句柄;Step S1, initializing an algorithm memory resource, and initializing a data message file handle;
步骤S2,从通信口读取包含有各种协议的数据流,并将所述数据流存放于所述内存中的数据缓存区域;Step S2, reading a data stream containing various protocols from the communication port, and storing the data stream in a data buffer area in the memory;
步骤S3,读取所述数据缓存区域中的数据,并将所述数据以文件形式写入报文文件,同时清理陈旧的报文文件,得到更新后的报文文件;Step S3, reading data in the data cache area, and writing the data into a message file as a file, and cleaning up the old message file to obtain an updated message file;
步骤S4,将所述报文文件共享给所有协议栈解析器;Step S4, sharing the message file to all protocol stack parsers;
步骤S5,重复步骤S2-S4,直到所有的数据都读取完毕;In step S5, steps S2-S4 are repeated until all the data is read;
步骤S6,每个协议栈解析器利用分配的文件句柄读取更新后的报文文件中的数据,并判断所述数据是否存在该协议报文;Step S6: Each protocol stack parser reads the data in the updated message file by using the allocated file handle, and determines whether the protocol message exists in the data;
步骤S7,若存在,则根据协议处理后,响应报文的应用,并重复步骤S6-S7;若不存在,则重复步骤S6-S7。Step S7, if yes, after the processing according to the protocol, respond to the application of the message, and repeat steps S6-S7; if not, repeat steps S6-S7.
进一步地,所述步骤S3具体为:Further, the step S3 is specifically:
读取数据缓存区域中的数据,并利用文件化处理算法,以文件的形式将所述数据从文件写指针处开始写入SDRAM/RAM报文文件,同时更新文件写的指针;并清理陈旧的报文文件,得到更新后的报文文件。Read the data in the data cache area, and use the file processing algorithm to write the data from the file write pointer to the SDRAM/RAM message file in the form of a file, and update the pointer written by the file; and clean up the old The message file gets the updated message file.
进一步地,所述步骤S6中读取报文文件中的数据的过程具体为:Further, the process of reading the data in the message file in the step S6 is specifically:
每个协议栈解析器利用文件系统分配的文件句柄,调用文件读取函数读取更新后的报文文件中的数据;并更新该协议文件句柄的读指针。Each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle.
本发明还提供了一种基于文件方式的多协议报文解析系统,包括:The invention also provides a file-based multi-protocol message parsing system, comprising:
内存初始化单元,用于初始化算法内存资源,并初始化数据报文文件句柄;a memory initialization unit, configured to initialize an algorithm memory resource, and initialize a data message file handle;
数据流存放单元,用于从通信口读取数据流,并将所述数据流存放于所述内存中的数据缓存区域;a data stream storage unit, configured to read a data stream from the communication port, and store the data stream in a data cache area in the memory;
报文文件写入单元,用于读取所述数据缓存区域中的数据,并将所述数据以文件形式写入报文文件,同时清理陈旧的报文文件,得到更新后的报文文件;a message file writing unit, configured to read data in the data buffer area, and write the data into a message file in a file form, and at the same time, clean up the old message file to obtain an updated message file;
报文文件读取单元,用于将所述报文文件共享给所有协议栈解析器,每个协议栈解析器利用分配的文件句柄读取更新后的报文文件中的数据;a message file reading unit, configured to share the message file to all protocol stack parsers, and each protocol stack parser uses the allocated file handle to read data in the updated message file;
报文文件解析单元,用于判断所述数据是否存在该协议报文,若存在,则根据协议处理后,响应报文的应用。The message file parsing unit is configured to determine whether the protocol message exists in the data, and if yes, respond to the application according to the protocol.
进一步地,所述报文文件写入单元具体为:Further, the message file writing unit is specifically:
读取数据缓存区域中的数据,并利用文件化处理算法,以文件的形式将所述数据从文件写指针处开始写入SDRAM/RAM报文文件,同时更新文件写的指针;并清理陈旧的报文文件,得到更新后的报文文件。Read the data in the data cache area, and use the file processing algorithm to write the data from the file write pointer to the SDRAM/RAM message file in the form of a file, and update the pointer written by the file; and clean up the old The message file gets the updated message file.
进一步地,所述读取报文文件中的数据的过程具体为:Further, the process of reading data in the message file is specifically:
每个协议栈解析器利用文件系统分配的文件句柄,调用文件读取函数读取更新后的报文文件中的数据;并更新该协议文件句柄的读指针。Each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle.
有益效果Beneficial effect
本发明与现有技术相比,有益效果在于:本发明提供的一种基于文件方式的多协议报文解析方法与系统,通过文件化后的报文进行共享访问来实现多协议并发解析报文;快速处理接收的缓存数据流,避免在现有的同一信道多协议单一处理模式下,因采用轮番搜索各自协议造成资源开销过大容易造成接收缓存溢出而导致的数据丢失的问题,降低了缓存溢出概率,大大提高响应速度和效率;另外,通过文件化的方法,它将协议应用和通信层彻底隔离,使软件程序更有层次,变得易维护,易扩展。 Compared with the prior art, the present invention has the beneficial effects that the method and system for parsing multi-protocol messages based on the file mode are implemented by the file-sharing packet to implement multi-protocol concurrent parsing. Fast processing of the received cached data stream, avoiding the problem of data loss caused by excessive buffering of the received buffer due to the excessive resource overhead caused by the repeated search of the respective protocols in the existing same channel multi-protocol single processing mode, reducing the cache The overflow probability greatly improves the response speed and efficiency. In addition, through the file method, it completely isolates the protocol application and the communication layer, making the software program more hierarchical, easy to maintain, and easy to expand.
附图说明DRAWINGS
图1是本发明实施例提供的基于文件方式的多协议报文解析方法的流程图;1 is a flowchart of a method for parsing a multi-protocol message based on a file according to an embodiment of the present invention;
图2是本发明实施例提供的基于文件方式的多协议报文解析系统的示意图。FIG. 2 is a schematic diagram of a file-based multi-protocol message parsing system according to an embodiment of the present invention.
本发明的实施方式Embodiments of the invention
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
本发明的主要实现思想为:把包含有各种协议的数据组成的数据流以文件方式提供给各协议解析器,通过文件方式缓存数据流,各协议解析器利用文件共享的方式访问单通道多协议数据流,若协议栈解析器读到包含该协议的报文数据,则根据该协议处理后,响应报文的应用;协议之间互不干扰,实现报文零丢失,各协议解析器完全独立。 The main implementation idea of the present invention is that a data stream composed of data including various protocols is provided to each protocol parser in a file manner, and a data stream is cached by a file method, and each protocol parser uses a file sharing method to access a single channel. The protocol data stream, if the protocol stack parser reads the packet data containing the protocol, the response packet is processed according to the protocol; the protocols do not interfere with each other, and the packet zero is lost, and the protocol parser is completely independent.
下面介绍这种基于文件方式的多协议报文解析方法,其流程图如图1所示;具体包括下述步骤: The following describes the file method-based multi-protocol packet parsing method, and the flowchart thereof is shown in FIG. 1; specifically, the following steps are included:
步骤S1,初始化算法内存资源和文件化算法参数,并初始化数据报文文件句柄;Step S1, initializing an algorithm memory resource and a file algorithm parameter, and initializing a data message file handle;
步骤S2,从通信口读取包含有各种协议的数据流,并将所述数据流存放于所述内存中的数据缓存区域;Step S2, reading a data stream containing various protocols from the communication port, and storing the data stream in a data buffer area in the memory;
步骤S3,读取所述数据缓存区域中的数据,并将所述数据以文件形式写入报文文件,同时清理陈旧的报文文件,得到更新后的报文文件;Step S3, reading data in the data cache area, and writing the data into a message file as a file, and cleaning up the old message file to obtain an updated message file;
所述步骤S3具体为:读取数据缓存区域中的数据,并利用文件化处理算法,生成一个可以供其他协议访问的数据报文文件;具体地,整个数据流通过文件信息来维护和管理,并为协议访问提供接口;更具体地,以文件的形式将所述数据从文件写指针处开始写入SDRAM/RAM(Synchronous Dynamic Random Access Memory,同步动态随机存储器/ Random Access Memory,随机存取存储器)报文文件,同时更新文件写的指针;并按照FIFO(First Int First Out,先进先出队列)思想,清理陈旧的报文文件,得到更新后的报文文件。The step S3 is specifically: reading data in the data buffer area, and using a file processing algorithm to generate a data message file that can be accessed by other protocols; specifically, the entire data stream is maintained and managed by the file information. And providing an interface for protocol access; more specifically, writing the data from the file write pointer to the SDRAM/RAM in the form of a file (Synchronous Dynamic Random Access Memory, Synchronous Dynamic Random Access Memory / Random Access Memory, random access memory) message file, and update the pointer written by the file; and follow the FIFO (First Int First) Out, first-in, first-out queue) thoughts, clean up old message files, and get updated message files.
下面具体介绍这种文件化处理算法的思想:本数据报文文件通过一个写指针和读指针来管理文件内容和文件长度;文件长度通过写指针维护,当数据流写入数据文件时,数据会从写指针处开始写数据文件,并更新写指针;当写的指针超过文件系统限制的最大长度(这个可根据缓存的资源情况,调整最大长度)的时候,会通过FIFO将陈旧的数据丢弃,并更新写指针,来减小缓存的压力。The following describes the idea of this file processing algorithm: the data message file manages the file content and file length through a write pointer and a read pointer; the file length is maintained by the write pointer, and when the data stream is written to the data file, the data will be Write the data file from the write pointer and update the write pointer; when the written pointer exceeds the maximum length of the file system limit (this can adjust the maximum length according to the cached resources), the old data will be discarded through the FIFO. And update the write pointer to reduce the pressure on the cache.
步骤S4,将所述报文文件共享给所有协议栈解析器,此时每个要访问这个文件的协议栈解析器可以访问这个文件;Step S4, sharing the message file to all protocol stack parsers, and each protocol stack parser that needs to access the file can access the file;
步骤S5,重复步骤S2-S4,直到所有的数据都读取完毕;In step S5, steps S2-S4 are repeated until all the data is read;
步骤S6,每个协议栈解析器利用分配的文件句柄读取更新后的报文文件中的数据,并判断所述数据是否存在该协议报文;Step S6: Each protocol stack parser reads the data in the updated message file by using the allocated file handle, and determines whether the protocol message exists in the data;
多种协议栈通过文件读取的方式获取数据流的方法为:在同一通信信道包含不同协议的数据流,多个协议的需要从这个数据流中提取自己协议数据报文;具体地,首先,每个协议应用在请求访问的这个经过文件化处理的数据文件时,这个数据报文文件系统为每个访问分配一个文件句柄;然后,每个协议应用通过文件句柄信息,提取本协议未访问过的最新数据流,同时更新本协议文件句柄的访问信息。The method for obtaining a data stream by using multiple file stacks by means of file reading is: the data stream containing different protocols is included in the same communication channel, and multiple protocols need to extract their own protocol data messages from the data stream; specifically, first, Each protocol is applied to the filed data file requesting access. The data message file system allocates a file handle for each access; then, each protocol application uses the file handle information to extract the protocol that has not been accessed. The latest data stream, while updating the access information for this protocol file handle.
上述步骤S6具体为:每个协议栈解析器利用文件系统分配的文件句柄,调用文件读取函数读取更新后的报文文件中的数据,并更新该协议文件句柄的读指针;协议栈解析器根据协议特征分析读取的数据,判断从文件中获取的文件数据是否有该协议报文。 The above step S6 is specifically: each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle; The device analyzes the read data according to the protocol characteristics, and determines whether the file data obtained from the file has the protocol message.
步骤S7,若存在,则根据协议处理后,响应报文的应用,并重复步骤S6-S7;若不存在,则重复步骤S6-S7。Step S7, if yes, after the processing according to the protocol, respond to the application of the message, and repeat steps S6-S7; if not, repeat steps S6-S7.
即每个独立协议都可以按照步骤S6-S7实现各自的解析,完成各协议报文的响应,这样可以支持多个协议独立的解析。That is, each independent protocol can implement the respective parsing according to steps S6-S7, and complete the response of each protocol packet, so that multiple protocols can be independently parsed.
本发明还提供了一种基于文件方式的多协议报文解析系统,如图2所示,包括:The present invention also provides a file-based multi-protocol message parsing system, as shown in FIG. 2, including:
内存初始化单元1,用于初始化算法内存资源,并初始化数据报文文件句柄;The memory initialization unit 1 is configured to initialize an algorithm memory resource and initialize a data message file handle;
数据流存放单元2,用于从通信口读取数据流,并将所述数据流存放于所述内存中的数据缓存区域;a data stream storage unit 2, configured to read a data stream from the communication port, and store the data stream in a data cache area in the memory;
报文文件写入单元3,用于读取所述数据缓存区域中的数据,并将所述数据以文件形式写入报文文件,同时清理陈旧的报文文件,得到更新后的报文文件;The message file writing unit 3 is configured to read the data in the data buffer area, and write the data into the message file as a file, and clean up the old message file to obtain the updated message file. ;
报文文件读取单元4,用于将所述报文文件共享给所有协议栈解析器,每个协议栈解析器利用分配的文件句柄读取更新后的报文文件中的数据;a message file reading unit 4, configured to share the message file to all protocol stack parsers, and each protocol stack parser uses the allocated file handle to read data in the updated message file;
报文文件解析单元5,用于判断所述数据是否存在该协议报文,若存在,则根据协议处理后,响应报文的应用。The packet file parsing unit 5 is configured to determine whether the protocol packet exists in the data, and if yes, respond to the application of the packet after processing according to the protocol.
本发明主要应用在通信领域,如数据采集,数据通信等;特别适用于单一通道的多种协议解析。在资源较紧张或者在同一通道需要几种协议情况时,对多种协议在同一通道解析提供了一种处理办法。具体地,通过文件化后的报文进行共享访问来实现多协议并发解析报文,减小资源开销和节省处理时间,提高响应速度,快速处理接收的缓存数据流,降低缓存溢出概率,丢弃无效协议数据。另外,通过文件化的方法,它将协议应用和通信层彻底隔离,使软件程序更有层次,变得易维护,易扩展;每种协议可以通过访问数据文件全程搜索数据流,不会造成数据报文丢失;每种协议可以单独封装,易于扩展和移植;各协议应用独立,甚至同一协议被多个应用程序使用时也可以独立使用,能较好地划分软件的层次。The invention is mainly applied in the field of communication, such as data acquisition, data communication, etc.; and is particularly suitable for multiple protocol parsing of a single channel. Providing a way to resolve multiple protocols in the same channel when resources are tight or when several protocols are required on the same channel. Specifically, the shared access is performed through the filed message to implement multi-protocol concurrent parsing, which reduces resource overhead and saves processing time, improves response speed, quickly processes received buffered data stream, reduces buffer overflow probability, and discards invalid Protocol data. In addition, through the file method, it completely isolates the protocol application and the communication layer, making the software program more hierarchical, easy to maintain, and easy to expand; each protocol can search the data stream by accessing the data file without causing data. Packets are lost; each protocol can be packaged separately, easy to extend and migrate; each protocol is independent, even when the same protocol is used by multiple applications, it can be used independently, which can better divide the software hierarchy.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. Within the scope.

Claims (6)

  1. 一种基于文件方式的多协议报文解析方法,其特征在于,包括下述步骤: A multi-protocol message parsing method based on a file method, which is characterized in that it comprises the following steps:
    步骤S1,初始化算法内存资源,并初始化数据报文文件句柄;Step S1, initializing an algorithm memory resource, and initializing a data message file handle;
    步骤S2,从通信口读取包含有各种协议的数据流,并将所述数据流存放于所述内存中的数据缓存区域;Step S2, reading a data stream containing various protocols from the communication port, and storing the data stream in a data buffer area in the memory;
    步骤S3,读取所述数据缓存区域中的数据,并将所述数据以文件形式写入报文文件,同时清理陈旧的报文文件,得到更新后的报文文件;Step S3, reading data in the data cache area, and writing the data into a message file as a file, and cleaning up the old message file to obtain an updated message file;
    步骤S4,将所述报文文件共享给所有协议栈解析器;Step S4, sharing the message file to all protocol stack parsers;
    步骤S5,重复步骤S2-S4,直到所有的数据都读取完毕;In step S5, steps S2-S4 are repeated until all the data is read;
    步骤S6,每个协议栈解析器利用分配的文件句柄读取更新后的报文文件中的数据,并判断所述数据是否存在该协议报文;Step S6: Each protocol stack parser reads the data in the updated message file by using the allocated file handle, and determines whether the protocol message exists in the data;
    步骤S7,若存在,则根据协议处理后,响应报文的应用,并重复步骤S6-S7;若不存在,则重复步骤S6-S7。Step S7, if yes, after the processing according to the protocol, respond to the application of the message, and repeat steps S6-S7; if not, repeat steps S6-S7.
  2. 如权利要求1所述的多协议报文解析方法,其特征在于,所述步骤S3具体为:The multi-protocol packet parsing method according to claim 1, wherein the step S3 is specifically:
    读取数据缓存区域中的数据,并利用文件化处理算法,以文件的形式将所述数据从文件写指针处开始写入SDRAM/RAM报文文件,同时更新文件写的指针;并清理陈旧的报文文件,得到更新后的报文文件。Read the data in the data cache area, and use the file processing algorithm to write the data from the file write pointer to the SDRAM/RAM message file in the form of a file, and update the pointer written by the file; and clean up the old The message file gets the updated message file.
  3. 如权利要求1所述的多协议报文解析方法,其特征在于,所述步骤S6中读取报文文件中的数据的过程具体为:The method for parsing data in a message file according to claim 1, wherein the process of reading data in the message file in the step S6 is specifically:
    每个协议栈解析器利用文件系统分配的文件句柄,调用文件读取函数读取更新后的报文文件中的数据;并更新该协议文件句柄的读指针。Each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle.
  4. 一种基于文件方式的多协议报文解析系统,其特征在于,包括:A file-based multi-protocol message parsing system, comprising:
    内存初始化单元,用于初始化算法内存资源,并初始化数据报文文件句柄;a memory initialization unit, configured to initialize an algorithm memory resource, and initialize a data message file handle;
    数据流存放单元,用于从通信口读取包含有各种协议的数据流,并将所述数据流存放于所述内存中的数据缓存区域;a data stream storage unit, configured to read a data stream containing various protocols from the communication port, and store the data stream in a data cache area in the memory;
    报文文件写入单元,用于读取所述数据缓存区域中的数据,并将所述数据以文件形式写入报文文件,同时清理陈旧的报文文件,得到更新后的报文文件;a message file writing unit, configured to read data in the data buffer area, and write the data into a message file in a file form, and at the same time, clean up the old message file to obtain an updated message file;
    报文文件读取单元,用于将所述报文文件共享给所有协议栈解析器,每个协议栈解析器利用分配的文件句柄读取更新后的报文文件中的数据;a message file reading unit, configured to share the message file to all protocol stack parsers, and each protocol stack parser uses the allocated file handle to read data in the updated message file;
    报文文件解析单元,用于判断所述数据是否存在该协议报文,若存在,则根据协议处理后,响应报文的应用。The message file parsing unit is configured to determine whether the protocol message exists in the data, and if yes, respond to the application according to the protocol.
  5. 如权利要求4所述的多协议报文解析系统,其特征在于,所述报文文件写入单元具体为:The multi-protocol message parsing system according to claim 4, wherein the message file writing unit is specifically:
    读取数据缓存区域中的数据,并利用文件化处理算法,以文件的形式将所述数据从文件写指针处开始写入SDRAM/RAM报文文件,同时更新文件写的指针;并清理陈旧的报文文件,得到更新后的报文文件。Read the data in the data cache area, and use the file processing algorithm to write the data from the file write pointer to the SDRAM/RAM message file in the form of a file, and update the pointer written by the file; and clean up the old The message file gets the updated message file.
  6. 如权利要求4所述的多协议报文解析系统,其特征在于,所述读取报文文件中的数据的过程具体为:The multi-protocol message parsing system according to claim 4, wherein the process of reading data in the message file is specifically:
    每个协议栈解析器利用文件系统分配的文件句柄,调用文件读取函数读取更新后的报文文件中的数据;并更新该协议文件句柄的读指针。Each protocol stack parser uses the file handle allocated by the file system, calls the file read function to read the data in the updated message file, and updates the read pointer of the protocol file handle.
PCT/CN2016/072806 2016-01-29 2016-01-29 Method and system for parsing multi-protocol message based on file mode WO2017128299A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/072806 WO2017128299A1 (en) 2016-01-29 2016-01-29 Method and system for parsing multi-protocol message based on file mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/072806 WO2017128299A1 (en) 2016-01-29 2016-01-29 Method and system for parsing multi-protocol message based on file mode

Publications (1)

Publication Number Publication Date
WO2017128299A1 true WO2017128299A1 (en) 2017-08-03

Family

ID=59397173

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/072806 WO2017128299A1 (en) 2016-01-29 2016-01-29 Method and system for parsing multi-protocol message based on file mode

Country Status (1)

Country Link
WO (1) WO2017128299A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112350996A (en) * 2020-10-15 2021-02-09 中国船舶重工集团公司第七一六研究所 Communication message analysis system and method adaptable to protocol upgrading
CN115277881A (en) * 2022-06-17 2022-11-01 奇安信科技集团股份有限公司 Network message analysis method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040030754A1 (en) * 2002-06-12 2004-02-12 Programmable Products, Inc High-speed file server
CN102104541A (en) * 2009-12-21 2011-06-22 索乐弗莱尔通讯公司 Header processing engine
CN102769658A (en) * 2011-12-06 2012-11-07 北京安天电子设备有限公司 Method and device for restoring network files
CN103236938A (en) * 2013-03-27 2013-08-07 广东全通教育股份有限公司 Method and system for user action collection based on cache memory and asynchronous processing technology
CN105743894A (en) * 2016-01-29 2016-07-06 瑞斯康微电子(深圳)有限公司 Multi-protocol message parsing method and system based on file mode

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040030754A1 (en) * 2002-06-12 2004-02-12 Programmable Products, Inc High-speed file server
CN102104541A (en) * 2009-12-21 2011-06-22 索乐弗莱尔通讯公司 Header processing engine
CN102769658A (en) * 2011-12-06 2012-11-07 北京安天电子设备有限公司 Method and device for restoring network files
CN103236938A (en) * 2013-03-27 2013-08-07 广东全通教育股份有限公司 Method and system for user action collection based on cache memory and asynchronous processing technology
CN105743894A (en) * 2016-01-29 2016-07-06 瑞斯康微电子(深圳)有限公司 Multi-protocol message parsing method and system based on file mode

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112350996A (en) * 2020-10-15 2021-02-09 中国船舶重工集团公司第七一六研究所 Communication message analysis system and method adaptable to protocol upgrading
CN115277881A (en) * 2022-06-17 2022-11-01 奇安信科技集团股份有限公司 Network message analysis method and device

Similar Documents

Publication Publication Date Title
CN110402568B (en) Communication method and device
EP1581875B1 (en) Using direct memory access for performing database operations between two or more machines
US7320041B2 (en) Controlling flow of data between data processing systems via a memory
US8949472B2 (en) Data affinity based scheme for mapping connections to CPUs in I/O adapter
AU2014200239B2 (en) System and method for multiple sender support in low latency fifo messaging using rdma
US7461180B2 (en) Method and apparatus for synchronizing use of buffer descriptor entries for shared data packets in memory
US7409468B2 (en) Controlling flow of data between data processing systems via a memory
US20100023595A1 (en) System and method of multi-path data communications
US20110225391A1 (en) Hash processing in a network communications processor architecture
US8873550B2 (en) Task queuing in a multi-flow network processor architecture
JP2015512083A (en) Explicit flow control for implicit memory registration
WO2012119420A1 (en) Data packet concurrent processing method and device
US9274586B2 (en) Intelligent memory interface
CN101063963A (en) File movement method supporting data zero-copy technique
WO2017128299A1 (en) Method and system for parsing multi-protocol message based on file mode
Tianhua et al. The design and implementation of zero-copy for linux
Lu et al. Impact of hpc cloud networking technologies on accelerating hadoop rpc and hbase
Barak et al. Performance of the Communication Layers of TCP/IP with the Myrinet Gigabit LAN
JP2002084311A (en) Packet transmission equipment
WO2012119384A1 (en) Method, device and system for mounting file system
US20080307127A1 (en) Method for Managing Under-Runs and a Device Having Under-Run Management Capabilities
JP2007528078A (en) Method and system for coalescing coherence messages
WO2022024562A1 (en) Parallel and distributed computing system
CN213028113U (en) Network security data acquisition and storage system
Schneidenbach et al. Architecture and Implementation of the Socket Interface on Top of GAMMA

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: 16887183

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: 16887183

Country of ref document: EP

Kind code of ref document: A1