Communication protocol interaction architecture and message interaction method thereof
The message processing method based on the communication protocol interaction architecture solves the problems of code redundancy and high coupling in the existing technology, realizes flexible message processing and efficient version management, and improves code consistency and maintainability.
Patent Information
- Application Number
- CN202310914627.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-25
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-07-25
AI Technical Summary
Existing communication protocol development and maintenance methods suffer from code redundancy, high coupling, and high maintenance complexity, making it difficult to flexibly respond to changing business needs, and the message processing of different versions is prone to mutual interference.
The communication protocol interaction architecture is adopted, including a message receiving unit, a message parsing module, a dispatching module, a processing module, and a packet encapsulation module. The feature analysis module realizes message parsing and conversion, isolates different versions and message processing processes, and completes adaptation within the interaction architecture only when the underlying protocol changes.
It improves code consistency and maintainability, reduces information redundancy, isolates the impact of different versions, enhances the flexibility and reusability of message processing, and reduces maintenance difficulty.
Smart Images

Figure CN119383236B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication technology, in particular to a communication protocol interaction architecture and a message interaction method thereof. BACKGROUND
[0002] The communication protocol message format is based on the use scenario, and has various different forms, but generally has a fixed overall format, and the payload occupies some fields in the overall format or does not exist according to specific needs. The overall format determines the general form of the message, which will be reflected in the specific message; the format of the payload will change appropriately according to the specific use purpose of the message.
[0003] With the change of business needs, the communication within or between systems will evolve with the needs, and in the early stage, the corresponding fields in the overall format can be extended according to new needs on the basis of maintaining the original overall format, until the original overall format cannot meet the needs, at which time the overall format has to be changed. However, because the new needs only account for a small part, in order to protect the original work, most of the new message format will still follow the original agreement. Generally, the development team needs to develop according to the new message format, and at the same time, maintain several old versions and even expand new functions to meet the needs of cost, benefit, opportunity and risk, or meet the preferences of different customers for the original system and the new system.
[0004] At present, there are different development forms for the above-mentioned situation, such as independent development and maintenance of different versions, program function switch, selective compilation and construction, code generation and running engine technology, etc.
[0005] The traditional independent development and maintenance of different versions tend to be "waterfall" development, the granularity of architecture division is large, data redundancy and control coupling are uncontrollable, and if a change occurs, several places will be modified, which makes it difficult to ensure that there is no missing place. When the protocol is expanded or changed, copying the original code is usually an option, which increases the maintenance workload of the project, and is also not conducive to the extension of the new developed code to the old version.
[0006] There are also some designs, through a certain "switch" to select the part of the code with changes, such as through a specific value judgment to control the flow (such as the Boolean variable of const), through the compiler switch to selectively compile (such as the macro in C / C++), through the construction tool to selectivity construction (such as the custom makefile file). The first two methods mix all versions of components and code together, and when a version is modified, the impact on other versions must be considered; the latter method separates the two codes that may need to be maintained synchronously, increases the difficulty of maintenance and construction, and increases the overall complexity of the project.
[0007] In recent years, there have also been technologies for automatically generating interactive code through certain template specifications, and technologies for dynamically loading related specification information using a runtime engine. The former is heavily dependent on the capabilities of the code generator, has poor flexibility, and is difficult to handle complex and variable situations; the latter is difficult to meet the performance requirements in performance-limited processors, has limited use scenarios, and is difficult to use universally. SUMMARY
[0008] The application provides a communication protocol interaction architecture and a message interaction method thereof. Through the set communication protocol interaction architecture, the change of a simple underlying protocol is adapted within the interaction architecture, without affecting the upper logic. Even if the content of the specific function protocol changes, it will only affect the corresponding business processing part, effectively preventing the spread of changes.
[0009] The application provides the following technical solutions:
[0010] A communication protocol interaction architecture includes a message receiving unit, a first message parsing module, a first message receiving and dispatching module, a first message receiving and processing module, a second message sending and dispatching module, a second message sending and processing module, a first message packaging module, and a message sending unit, wherein:
[0011] The message receiving unit, the first message parsing module, and the first message receiving and dispatching module are sequentially connected in communication. The first message receiving and dispatching module is connected in communication with a plurality of first message receiving and processing modules. The second message sending and dispatching module is connected in communication with a plurality of second message sending and processing modules. The second message sending and processing module, the first message packaging module, and the message sending unit are sequentially connected in communication.
[0012] The first message parsing module and the first message packaging module are associated with first message unpacking information. The first message receiving and dispatching module and the second message sending and dispatching module are respectively associated with a first message feature analysis module and a second message feature analysis module.
[0013] The first message receiving processing module comprises a second message analysis submodule, a second message receiving processing submodule and a corresponding first message characteristic information submodule; the second message sending processing module comprises a second message packaging submodule, a default first message characteristic information submodule and a corresponding second message characteristic information submodule.
[0014] Further, the message receiving unit is configured to receive message information sent by a corresponding opposite end, wherein the message information comprises message data.
[0015] The first message analysis module is configured to analyze the message information according to the first message unpacking information to obtain a first message, wherein the first message is a description of the message information, and the first message unpacking information describes information for mutual conversion between the message information and the first message.
[0016] The first message receiving dispatching module is configured to call the first message characteristic analysis module to analyze the first message, obtain first message characteristic information, and dispatch the first message to a corresponding first message receiving processing module according to a corresponding relationship between the first message characteristic information and the corresponding first message characteristic information submodule of the first message receiving processing module.
[0017] The second message analysis submodule is configured to convert the first message into a second message, wherein the second message is a description of the first message.
[0018] The second message receiving processing submodule is configured to process the second message or forward the second message to a corresponding second message receiving party.
[0019] The corresponding first message characteristic information submodule records first message characteristic information of a first message to be processed by the current first message receiving processing module.
[0020] The second message sending dispatching module is configured to receive the second message sent by a corresponding second message sending party, call the second message characteristic analysis module to analyze the second message, obtain second message characteristic information, and dispatch the second message to a corresponding second message sending processing module according to a corresponding relationship between the second message characteristic information and the corresponding second message characteristic information submodule of the second message sending processing module.
[0021] The corresponding second message characteristic information submodule records second message characteristic information of a second message to be processed by the current second message sending processing module.
[0022] The default first message characteristic information submodule records default first message characteristic information used when converting the second message into the first message.
[0023] The second message packaging sub-module is configured to convert the second message into the first message according to the default first message characteristic information or the first message characteristic information associated with the second message itself;
[0024] The first message packaging module is configured to convert the first message into the message information according to the first message unpacking information;
[0025] The message sending unit is configured to send the message information to a corresponding opposite end.
[0026] Further, the message information further comprises relevant information of the message data, and the relevant information is used to meet the needs of analysis in a receiving process or to meet the needs of sending in a sending process.
[0027] Further, the first message analysis module is associated with a message extraction unit, and the message extraction unit is configured to extract complete and valid message data from a message data stream.
[0028] Further, when the overall structure of the message data is unchanged, if a new receiving command is to be added, the corresponding first message receiving processing module is added to achieve the new receiving process, and if a new sending command is to be added, the corresponding second message sending processing module is added to achieve the new sending process.
[0029] Further, when the overall structure of the message data is unchanged, if the relevant fields of the message data of a certain function in the existing protocol are to be adjusted or extended, the existing corresponding second message analysis sub-module and second message receiving processing sub-module are adjusted or extended to achieve a new receiving process, and the existing corresponding second message packaging sub-module is adjusted or extended to achieve a new sending process.
[0030] Further, when the protocol version is changed, the first message unpacking information is changed.
[0031] Further, when the running protocol needs to support both new and old overall formats of the message data, the first message unpacking information is changed, and the first message analysis module, the first message packaging module and the corresponding first message characteristic information are changed accordingly.
[0032] A message interaction method of the communication protocol interaction architecture, the method comprising:
[0033] S1: The message receiving unit receives the message information sent by the opposite end, and transmits the message information to the first message analysis module;
[0034] S2: the first message parsing module parses the message information according to the first message unpacking information to obtain a first message, and delivers the first message to the first message receiving and dispatching module;
[0035] S3: the first message receiving and dispatching module calls the first message feature analysis module to analyze the first message to obtain first message feature information, and according to the first message feature information, searches the corresponding first message feature information submodule of the first message receiving and processing module to obtain the corresponding first message receiving and processing module, and dispatches the first message to the corresponding first message receiving and processing module;
[0036] S4: the first message receiving and processing module converts the first message into a second message via the second message parsing submodule, and delivers the second message to the second message receiving and processing submodule;
[0037] S5: the second message receiving and processing submodule processes or forwards the second message to the corresponding second message receiver;
[0038] Wherein, the second message sent by the second message receiving and processing submodule is associated or not associated with the first message feature information according to the need;
[0039] S6: the second message sending and dispatching module receives the second message sent by the corresponding second message sender, and calls the second message feature analysis module to analyze the second message to obtain second message feature information, according to the second message feature information, searches the corresponding second message feature information submodule of the second message sending and processing module to obtain the corresponding second message sending and processing module, and dispatches the second message to the corresponding second message sending and processing module;
[0040] Wherein, the second message sender includes the second message receiving and processing submodule and other modules capable of sending the second message;
[0041] S7: when the second message is associated with the first message feature information, the second message sending and processing module converts the second message into the first message according to the first message feature information associated with the second message via the second message packing submodule, and delivers the first message to the first message packing module;
[0042] When the second message is not associated with the first message feature information, the second message sending and processing module converts the second message into the first message according to the default first message feature information via the second message packing submodule, and delivers the first message to the first message packing module;
[0043] S8: the first message packet module converts the first message into the message information according to the first message unpacking information, and delivers the message information to the message sending unit;
[0044] S9: the message sending unit sends the message data in the message information to the corresponding opposite end.
[0045] Further, when the first message analysis module is associated with a message extraction unit, the S2 further comprises:
[0046] The first message analysis module calls the message extraction unit to extract complete and valid message data from the message data stream.
[0047] The present application has the following beneficial effects:
[0048] The present application realizes that the change of the simple bottom layer protocol can be adapted within the interactive architecture, and will not affect the upper logic. Even if the content of the specific function protocol is changed, only the corresponding business processing part will be affected, effectively preventing the spread of changes. The present application has the following advantages:
[0049] 1. Improve the consistency of the code, sort all related information, reduce information redundancy and disordered storage, and reduce control coupling compared with the existing technology.
[0050] 2. Effectively isolate each message processing flow, and each modification between different versions and different messages will not affect each other.
[0051] 3. Improve the reusability of message processing, and the unchanged message processing process can be directly reused without the need for change.
[0052] 4. Under the division of the interactive architecture of the present application, each module is clear in hierarchy and clear in order, improving the maintainability.
[0053] 5. Improve the flexibility of the architecture, which can easily extend new messages, and different versions of processing can be flexibly matched. BRIEF DESCRIPTION OF DRAWINGS
[0054] Figure 1 It is a schematic diagram of the communication protocol interactive architecture of the present application;
[0055] Figure 2 It is a flowchart of the receiving processing process;
[0056] Figure 3 It is a flowchart of the sending processing process. DETAILED DESCRIPTION
[0057] In order to make the technical problems, technical solutions and advantages of the present application more clear, the following will be described in detail in combination with the drawings and specific embodiments.
[0058] The present application provides a communication protocol interaction architecture, which is composed of a receiving processing procedure, a sending processing procedure and a public information module. Figure 1 As shown in the figure, the receiving processing procedure includes a message receiving unit, a first message analysis module, a first message receiving dispatching module and a first message receiving processing module, and the sending processing procedure includes a second message sending dispatching module, a second message sending processing module, a first message packaging module and a message sending unit.
[0059] Each module and unit in the communication protocol interaction architecture of the present application can be replaced as needed. The modules involved in the present application can be assembled and called by a higher-level module or unit. Each module can be deployed in different threads, processes, systems or clusters as needed, and can be implemented by software or hardware.
[0060] Among them, the message receiving unit, the first message analysis module and the first message receiving dispatching module are sequentially connected in communication, the first message receiving dispatching module is connected in communication with a plurality of first message receiving processing modules; the second message sending dispatching module is connected in communication with a plurality of second message sending processing modules, and the second message sending processing module, the first message packaging module and the message sending unit are sequentially connected in communication.
[0061] The first message analysis module and the first message packaging module are both associated with first message unpacking information, and the first message receiving dispatching module and the second message sending dispatching module are respectively associated with a first message feature analysis module and a second message feature analysis module.
[0062] The first message receiving processing module includes a second message analysis submodule, a second message receiving processing submodule and a corresponding first message feature information submodule; the second message sending processing module includes a second message packaging submodule, a default first message feature information submodule and a corresponding second message feature information submodule.
[0063] The message receiving unit is used to actively or passively receive the message information sent by the corresponding opposite end. The message information includes message data. In some cases, according to the needs, the message information can also include the related information of the message data, which is the description of the message data. According to the related information, the needs of subsequent analysis can be met in the receiving process, and the needs of subsequent sending can be met in the sending process. Taking the UDP (User Datagram Protocol) connection as an example, the related information can be the IP address (Internet Protocol Address) + port of the sender, the IP address and port of the local to which the message data is sent, the message data receiving time, and the like. In some scenarios, such as the subsequent processing does not require information other than the message data, that is, the message data contains all the information required for subsequent processing, the message information can not include the related information.
[0064] Here, the message data can exactly contain a complete message data according to different scenarios, or can be part of a continuous message data stream. Optionally, the first message analysis module is associated with a message extraction unit, and the message extraction unit is used to extract complete and valid message data from the message data stream.
[0065] The first message analysis module is used to analyze the message information according to the first message unpacking information to obtain the first message.
[0066] The first message is a description of the message information, which can be obtained by analyzing the message information through the first message analysis module, or can be converted into the message information by the first message packaging module. The first message contains the first message feature information, according to which the first message feature information can provide path selection basis for the subsequent first message receiving processing module.
[0067] The first message unpacking information describes the mutual conversion information between the message information and the first message, which is used in the receiving and sending processes. The first message analysis module can analyze the message information to obtain the first message according to the first message unpacking information, and the first message packaging module can also convert the first message into the message information according to the first message unpacking information.
[0068] The first message receiving and dispatching module is used to call the first message feature analysis module to analyze the first message, obtain the first message feature information, and dispatch the first message to the corresponding first message receiving processing module according to the corresponding relationship between the first message feature information and the corresponding first message feature information submodule of the first message receiving processing module.
[0069] The corresponding first message feature information submodule records the first message feature information of the first message to be processed by the current first message receiving processing module.
[0070] The second message analysis submodule is configured to convert the first message into a second message, which is a description of the first message and contains relevant information in the first message and other runtime information not in the first message but related to the first message. The second message contains second message feature information, which can be used to provide path selection basis for the second message sending processing module.
[0071] The second message receiving processing submodule is configured to process or forward the second message to a corresponding second message receiver, such as other units for further processing. When the second message is forwarded, a corresponding first message feature information to be used can also be associated, so as to replace the default first message feature information with the first message feature information in the second message sending processing module.
[0072] The second message sending dispatching module is configured to receive the second message sent by a corresponding second message sender, and call the second message feature analysis module to analyze the second message to obtain second message feature information. According to the corresponding relationship between the second message feature information and the corresponding second message feature information submodule of the second message sending processing module, the second message is dispatched to the corresponding second message sending processing module.
[0073] The second message sender indicates all units capable of sending messages, which can be in the modules or units described in the architecture, such as the second message receiving processing submodule, or can be outside the modules or units described in the architecture.
[0074] The corresponding second message feature information submodule records the second message feature information of the second message to be processed by the current second message sending processing module.
[0075] The default first message feature information submodule records the default first message feature information used when converting the second message into the first message.
[0076] The second message packaging submodule is configured to convert the second message into the first message according to the default first message feature information or the first message feature information associated with the second message itself. If it is found that the second message itself is associated with a first message feature information, the associated first message feature information will be used to replace the default first message feature information for conversion.
[0077] The first message packaging module is configured to convert the first message into the packet information according to the first message unpacking information.
[0078] The packet sending unit is configured to send the packet information to a corresponding opposite end (i.e. a corresponding receiver).
[0079] The operation of the current architecture when the specific protocol is changed includes:
[0080] 1. If a new receive command is to be added while the overall structure of the message data remains unchanged, it is done by adding a corresponding first message receive processing module. If a new send command is to be added, it is done by adding a corresponding second message send processing module.
[0081] 2. If, when the overall structure of the message data remains unchanged, it is necessary to adjust or extend the relevant fields of the message data for a certain function in an existing protocol, the new receiving process is implemented by adjusting or extending the existing corresponding second message parsing submodule and second message receiving and processing submodule, and the new sending process is implemented by adjusting or extending the existing corresponding second message packet encapsulation submodule. Simultaneously, the corresponding existing second messages are also modified accordingly.
[0082] 3. If the protocol version changes, simply modify the information in the first message unpacking package.
[0083] If the message header changes from 0x5a to 0x5b, only the first message decapsulation packet information needs to be modified. For example, if the original message header was {Message Header: 0x5a, CRC Check (Cyclic Redundancy Check): CRC-8 / ITU, Message Trailer: 0xa5}, the modified message header will be {Message Header: 0x5b, CRC Check: CRC-8 / ITU, Message Trailer: 0xa5}.
[0084] 4. When the running protocol needs to support both the old and new overall formats of message data simultaneously, it can be achieved by changing the first message decapsulation packet information. For example, the message header in the first message decapsulation packet information can be changed to a form similar to {Message header value range: [0x5a, 0x5b], CRC check: CRC-8 / ITU, Message tail: 0xa5}, and the first message parsing module, the first message encapsulation module and the corresponding first message feature information can be modified accordingly.
[0085] In other cases, the corresponding changes can be made, and they will not be described in detail in this invention.
[0086] This invention, through its established communication protocol interaction architecture, ensures that changes to the underlying protocol can be adapted within the architecture itself without affecting higher-level logic. Even if specific functional protocol content changes, only the corresponding business processing parts will be affected, effectively preventing the spread of changes. It has the following advantages:
[0087] 1. Improve code consistency by organizing all relevant information in an orderly manner, reducing information redundancy and disordered storage, and reducing control coupling compared to existing technologies.
[0088] 2. Each message processing flow is effectively isolated, and modifications between different versions and different messages do not affect each other.
[0089] 3. The reusability of message processing is improved, and unchanged message processing procedures can be directly reused without modification.
[0090] 4. Under the division of the interactive architecture of the present application, each module is clear in hierarchy and clear in order, improving maintainability.
[0091] 5. The flexibility of the architecture is improved, and new messages can be easily extended, and different versions of processing can be flexibly matched.
[0092] The embodiment of the present application also provides a message interaction method of the communication protocol interactive architecture described above. To illustrate the interactive method of the present application, it is assumed that the following message formats exist:
[0093]
[0094] When the command word is 0x1, it indicates a time query or setting instruction, and at this time the load format is as follows:
[0095]
[0096] When the command word is 0x81, it indicates a reply to the time query or setting instruction, and at this time the load format is as follows:
[0097] Field Length Explanation Query or set 1 byte 0 for reply to query, other values for reply to set Time 4 bytes Unsigned integer, big-endian, representing the current time in seconds of the century
[0098] The receiving processing procedure is as shown in Figure 2 , including:
[0099] S1: The message receiving unit receives the message information sent by the opposite end and transmits the message information to the first message analysis module.
[0100] In the present application, the receiving unit can receive the message information sent by the opposite end through TCP (Transmission Control Protocol) connection, UDP, SPI (Serial Peripheral Interface), RS232 (a serial bus standard), RS485 (a serial bus standard) connection, or message queue.
[0101] In one example, optionally, the message information includes message data and its related information, and the related information includes the ID (Identity document) of the opposite end, and the subsequent processing can distinguish the corresponding opposite end according to the ID.
[0102] Assuming that the packet receiving unit receives a binary packet stream data [0x5a, 0x01, 0x01, 0x01, 0x00, 0x32, 0xa5, 0x5a] sent by the peer of No. 1, it will transmit the packet and the ID of the peer to the first message analysis module.
[0103] S2: The first message analysis module analyzes the packet information according to the first message unpacking information to obtain the first message, and delivers the first message to the first message receiving and dispatching module.
[0104] When the first message analysis module is associated with the packet extraction unit, this step S2 further includes: the first message analysis module calls the packet extraction unit to extract complete and valid packet data from the packet data stream.
[0105] For example, the first message analysis module extracts a packet [0x5a, 0x01, 0x01, 0x01, 0x00, 0x32, 0xa5] according to the first message unpacking information {packet header: 0x5a, CRC check: CRC-8 / ITU, packet tail: 0xa5} by calling the packet stream extraction unit module, and then converts it into a first message {peer ID: 1, command word: 0x01, packet serial number: 0x01, load: [0x00]} and sends it to the first message receiving and dispatching module.
[0106] S3: The first message receiving and dispatching module calls the first message feature analysis module associated therewith to analyze the first message and obtain the first message feature information {command word: 0x01}; and according to the first message feature information, it looks up the corresponding first message feature information submodule of the first message receiving and processing module to obtain the corresponding first message receiving and processing module, and dispatches the first message to the corresponding first message receiving and processing module.
[0107] S4: The first message receiving and processing module converts the first message into a second message via the second message analysis submodule, and delivers the second message to the second message receiving and processing submodule.
[0108] For example, the second message is {peer ID: 1, command: query or set time, packet serial number: 0x01, time: null}.
[0109] S5: The second message receiving and processing submodule processes the second message or forwards it to the corresponding second message receiving party (for example, forwards it to other business units for processing).
[0110] The second message sent by the second message receiving and processing submodule may or may not be associated with the first message feature information according to needs.
[0111] The sending processing process is as shown in Figure 3 .
[0112] S6: The second message sending dispatching module receives the second message sent by the corresponding second message sender, and calls the second message feature analysis module to analyze the second message to obtain second message feature information. According to the second message feature information, the corresponding second message feature information submodule of the second message sending processing module is searched to obtain the corresponding second message sending processing module, and the second message is dispatched to the corresponding second message sending processing module.
[0113] The second message sender includes a second message receiving processing submodule and other modules capable of sending a second message.
[0114] For simplicity, it is assumed that the above-mentioned second message receiving processing submodule receives a query instruction, obtains the current time, assembles the second message {Peer ID: 1, Command: Query or Set Time Reply, Message Sequence Number: 0x01, Time: 0x12345678}, and then gives it to the second message sending dispatching module. The second message sending dispatching module first calls the second message feature analysis unit to obtain the current message feature {Command: Query or Set Time Reply}, and then sends it to the corresponding second message sending processing module after searching.
[0115] S7: When the second message is associated with the first message feature information, the second message sending processing module converts the second message into a first message according to the first message feature information associated with the second message via the second message packaging submodule, and delivers the first message to the first message packaging module.
[0116] When the second message is not associated with the first message feature information, the second message sending processing module converts the second message into a first message according to the default first message feature information via the second message packaging submodule, and delivers the first message to the first message packaging module.
[0117] For example, the converted first message is {Peer ID: 1, Command Word: 0x81, Message Sequence Number: 0x01, Payload: [0x00, 0x12, 0x34, 0x56, 0x78]}.
[0118] S8: The first message packaging module converts the first message into message information according to the first message unpacking information, and delivers the message information to the message sending unit.
[0119] For example, the message data byte sequence of the message information is [0x5a, 0x81, 0x01, 0x05, 0x00, 0x12, 0x34, 0x56, 0x78, 0x03, 0xa5], and the corresponding peer information (peer ID) is sent to the message sending unit.
[0120] S9: The packet sending unit sends the packet data in the processed packet information to the corresponding opposite end.
[0121] For example, according to the relevant information (i.e. the ID of the opposite end) in the packet information, the packet data is sent to the No. 1 opposite end.
[0122] The packet interaction method of the embodiment includes all contents of the communication protocol interaction architecture of the foregoing embodiment. For brief description, the part not mentioned in the embodiment can refer to the corresponding content in the foregoing embodiment, which will not be described herein again.
[0123] The above is the preferred embodiment of the present application. It should be noted that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should also be considered as the protection scope of the present application.
Claims
1. A communication protocol interaction architecture, characterized by, The application relates to a message receiving and sending device, which comprises a message receiving unit, a first message analysis module, a first message receiving and dispatching module, a first message receiving processing module, a second message sending dispatching module, a second message sending processing module, a first message packaging module and a message sending unit. The message receiving unit, the first message analysis module and the first message receiving and dispatching module are sequentially connected in communication, the first message receiving and dispatching module is connected in communication with a plurality of the first message receiving processing modules; the second message sending dispatching module is connected in communication with a plurality of the second message sending processing modules, and the second message sending processing module, the first message packaging module and the message sending unit are sequentially connected in communication; The first message analysis module and the first message packaging module are both associated with first message unpacking information, and the first message receiving and dispatching module and the second message sending dispatching module are respectively associated with first message characteristic analysis modules and second message characteristic analysis modules; The first message receiving processing module comprises a second message analysis sub-module, a second message receiving processing sub-module and corresponding first message characteristic information sub-modules; the second message sending processing module comprises a second message packaging sub-module, a default first message characteristic information sub-module and corresponding second message characteristic information sub-modules; The message receiving unit is used for receiving message information sent by a corresponding opposite end, and the message information comprises message data; The first message analysis module is used for analyzing the message information according to the first message unpacking information to obtain a first message, the first message is a description of the message information, and the first message unpacking information describes information of mutual conversion between the message information and the first message; The first message receiving and dispatching module is used for calling the first message characteristic analysis module to analyze the first message, obtaining first message characteristic information, and dispatching the first message to corresponding first message receiving processing modules according to a corresponding relationship between the first message characteristic information and corresponding first message characteristic information sub-modules of the first message receiving processing modules; The second message analysis sub-module is used for converting the first message into a second message, and the second message is a description of the first message; The second message receiving processing sub-module is used for processing the second message or forwarding the second message to a corresponding second message receiving party; The corresponding first message characteristic information sub-modules record first message characteristic information of the first message to be processed by the current first message receiving processing module; The second message sending dispatching module is used for receiving the second message sent by a corresponding second message sending party, calling the second message characteristic analysis module to analyze the second message, obtaining second message characteristic information, and dispatching the second message to corresponding second message sending processing modules according to a corresponding relationship between the second message characteristic information and corresponding second message characteristic information sub-modules of the second message sending processing modules; The corresponding second message characteristic information sub-modules record second message characteristic information of the second message to be processed by the current second message sending processing module. The default first message characteristic information sub-module records the default first message characteristic information used when converting the second message into the first message; The second message packaging sub-module is configured to convert the second message into the first message according to the default first message characteristic information or the first message characteristic information associated with the second message itself; The first message unpackaging module is configured to convert the first message into the message information according to the first message unpackaging information; The message sending unit is configured to send the message information to a corresponding opposite end.
2. The communication protocol interaction architecture of claim 1, wherein, The message information further includes related information of message data, which is used to meet the needs of analysis in the receiving process or to meet the needs of sending in the sending process.
3. The communication protocol interaction architecture of claim 2, wherein, The first message analysis module is associated with a message extraction unit, which is configured to extract complete and valid message data from a message data stream.
4. The communication protocol interaction architecture according to claim 2 or 3, characterized in that, When the overall structure of the message data is unchanged, if a new receiving command is to be added, a corresponding first message receiving processing module is added to achieve this, and if a new sending command is to be added, a corresponding second message sending processing module is added to achieve this.
5. The communication protocol interaction architecture of claim 4, wherein, When the overall structure of the message data is unchanged, if the related fields of the message data of a certain function in the existing protocol are to be adjusted or extended, the existing corresponding second message analysis sub-module and second message receiving processing sub-module are adjusted or extended to achieve a new receiving process, and the existing corresponding second message packaging sub-module is adjusted or extended to achieve a new sending process.
6. The communication protocol interaction architecture of claim 5, wherein, When the protocol version is changed, the first message unpackaging information is changed.
7. The communication protocol interaction architecture of claim 6, wherein, When the running protocol needs to support both new and old overall formats of message data, the first message unpackaging information is changed, and the first message analysis module, the first message packaging module and the corresponding first message characteristic information are changed accordingly.
8. A message interaction method applied to the communication protocol interaction architecture of any one of claims 1-7, characterized in that, The method comprises: S1: The message receiving unit receives message information sent by an opposite end and delivers the message information to the first message analysis module; S2: The first message analysis module analyzes the message information according to the first message unpackaging information to obtain a first message, and delivers the first message to the first message receiving dispatching module; S3: The first message receiving dispatching module calls the first message characteristic analysis module to analyze the first message to obtain first message characteristic information, and according to the first message characteristic information, looks up the corresponding first message characteristic information sub-module of the first message receiving processing module to obtain a corresponding first message receiving processing module, and dispatches the first message to the corresponding first message receiving processing module; S4: The first message receiving processing module converts the first message into a second message via the second message analysis sub-module, and delivers the second message to the second message receiving processing sub-module; S5: The second message receiving processing sub-module processes the second message or forwards the second message to a corresponding second message receiving end. The second message sent by the second message receiving processing sub-module is associated with or not associated with the first message feature information according to needs; S6: The second message sending dispatching module receives the second message sent by the corresponding second message sender, and calls the second message feature analysis module to analyze the second message to obtain second message feature information. According to the second message feature information, the corresponding second message feature information submodule of the second message sending processing module is searched to obtain the corresponding second message sending processing module, and the second message is dispatched to the corresponding second message sending processing module; The second message sender includes the second message receiving processing sub-module and other modules capable of sending the second message; S7: When the second message is associated with the first message feature information, the second message sending processing module converts the second message into the first message according to the first message feature information associated with the second message via the second message packaging submodule, and delivers the first message to the first message packaging module; When the second message is not associated with the first message feature information, the second message sending processing module converts the second message into the first message according to the default first message feature information via the second message packaging submodule, and delivers the first message to the first message packaging module; S8: The first message packaging module converts the first message into the message information according to the first message unpacking information, and delivers the message information to the message sending unit; S9: The message sending unit sends the message data in the message information to the corresponding opposite end.
9. The method of claim 8, wherein, When the first message analysis module is associated with a message extraction unit, S2 further includes: The first message analysis module calls the message extraction unit to extract complete and valid message data from the message data stream.
Citation Information
Patent Citations
Message communication method and device based on industrial Internet protocol architecture
CN110809008A
Terminal distribution information acquisition method, data acquisition device and communication system
WO2012106861A1