A communication method, system, device, and computer-readable storage medium

By separating the I/O thread pool and the independent business thread pool, and combining zero-copy and hardware primitive atomic operations, the problems of high CPU utilization and poor real-time performance of existing communication management devices under high concurrency are solved, and efficient and stable communication processing is achieved.

CN122309082APending Publication Date: 2026-06-30YUNDA INTELLIGENT STORAGE TECH (HEBEI) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
YUNDA INTELLIGENT STORAGE TECH (HEBEI) CO LTD
Filing Date
2026-04-07
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing communication management devices suffer from high CPU utilization due to frequent lock contention under high concurrency conditions, which fails to meet real-time requirements and also suffer from low data copying efficiency and memory fragmentation.

Method used

It adopts a design that separates the I/O thread pool and the independent business thread pool, and combines zero-copy technology, lock-free circular queues and hardware primitive atomic operations. It uses the Strand serialization executor to achieve asynchronous serial and multi-device parallel communication, avoiding lock contention.

Benefits of technology

It improves communication efficiency, reduces CPU utilization and memory fragmentation, ensures stability and real-time performance under high concurrency, and meets the real-time requirements of remote signaling changes in energy storage systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309082A_ABST
    Figure CN122309082A_ABST
Patent Text Reader

Abstract

This invention discloses a communication method, system, device, and computer-readable storage medium, applied in the field of network communication technology. The method includes: an I / O thread pool receiving messages sent by an external terminal device and loading the messages into a memory pool using zero-copy technology; sending the messages to an independent service thread pool using a serialization executor corresponding to the current communication connection; the independent service thread pool being a collection of task processing threads independent of I / O scheduling; the independent service thread pool performing protocol parsing on the messages, constructing the corresponding communication messages based on the parsing results, and distributing the communication messages to the corresponding lock-free circular queues; and the I / O thread pool communicating based on the priority of the communication messages in the lock-free circular queues using an atomic operation mechanism based on hardware primitives. This invention improves communication efficiency by introducing atomic variables based on hardware primitives to replace traditional mutex locks, achieving asynchronous serial processing within a single device and fully parallel processing between multiple devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network communication, and in particular to a communication method, system, device, and computer-readable storage medium. Background Technology

[0002] The most readily available front-end communication management device (also known as a communication management unit, station control layer gateway, or protocol converter) primarily employs the following technical architecture: network communication uses blocking synchronous I / O (input / output) or a multi-threaded + mutex model. Data transfer between threads commonly uses std::queue (standard queue) or a self-developed circular buffer in conjunction with std::mutex / std::condition_variable (mutex or mutex condition variable) to implement a producer-consumer pattern. Due to the extensive use of mutexes or condition variables to protect shared queues, session states, and transmission buffers, frequent lock contention occurs when hundreds of terminal devices are connected, leading to a sharp increase in CPU (central processing unit) utilization. Remote signaling change reporting latency is typically between 50ms and 300ms, failing to meet the real-time requirement of ≤30ms for energy storage frequency regulation.

[0003] It is evident that improving communication efficiency is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a communication method, system, device and computer-readable storage medium, which solves the technical problem of low communication efficiency in the prior art.

[0005] To solve the above-mentioned technical problems, the present invention provides a communication method, comprising: The I / O thread pool receives messages sent by external terminal devices and loads the messages into the memory pool using zero-copy technology. The I / O thread pool uses the serialization executor corresponding to the current communication connection to send the message to the independent service thread pool; wherein, the independent service thread pool is a set of task processing threads independent of I / O scheduling; the communication connection is the connection between each external terminal device and the I / O thread pool; The independent business thread pool performs protocol parsing on the message, constructs the corresponding communication message based on the parsing result, and distributes the communication message to the corresponding lock-free circular queue; wherein, the lock-free circular queue includes a preset number of priority queues; The I / O thread pool communicates through an atomic operation mechanism based on hardware primitives, according to the priority of the communication message in the lock-free circular queue.

[0006] Optionally, before the I / O thread pool receives a message sent by an external terminal device and loads the message into the memory pool using zero-copy technology, the method further includes: The I / O thread pool establishes long connections with at least two external terminal devices through the underlying driver and assigns a unique communication connection identifier to each long connection; The I / O thread pool associates the serialization executor with each communication connection identifier.

[0007] Optionally, the independent business thread pool performs protocol parsing on the message, constructs the corresponding communication message based on the parsing result, and distributes the communication message to the corresponding lock-free circular queue, including: The independent business thread pool determines the instruction type corresponding to the communication message; The independent business thread pool stores the communication message into the corresponding priority queue in the lock-free circular queue through an atomic operation mechanism based on hardware primitives, according to the instruction type.

[0008] Optionally, the independent business thread pool performs protocol parsing on the message and constructs the corresponding communication message based on the parsing result, including: The independent business thread pool determines the selected data mapping model based on the protocol type corresponding to the message; wherein, the data mapping model is a lookup table generated during the software compilation stage by automatically parsing the description file, used to establish a mapping between the logical names of data objects and data attribute nodes and their runtime memory addresses; The independent business thread pool performs protocol parsing on the message based on the data mapping model, locates the corresponding data object and data attribute node, and constructs the communication message based on the data object and data attribute node.

[0009] Optionally, the independent business thread pool performs protocol parsing on the message based on the data mapping model, locates the corresponding data object and data attribute node, and constructs the communication message based on the data object and data attribute node, including: If it is uplink telemetry data or teleindication data, then a telemetry message is constructed in the business thread and asynchronously delivered to the I / O thread pool through the corresponding serialization executor to write to the network socket and send to the main station; If the command is a remote control, remote adjustment, or setting command issued by the master station, after executing the corresponding control logic in the business thread, a response message or execution message is constructed and delivered to the I / O thread pool through the serialization executor.

[0010] Optionally, after the I / O thread pool communicates via an atomic operation mechanism based on hardware primitives according to the priority of the communication message in the lock-free circular queue, the method further includes: When the I / O thread pool detects an abnormal communication connection of the external terminal device, it executes a graceful shutdown process and asynchronously waits for all messages delivered by the serialization executor through the communication connection to be executed and for the associated atomic task counter to be zero before releasing the memory and system resources occupied by the communication connection.

[0011] Optionally, the I / O thread pool communicates based on the priority of the communication message in the lock-free circular queue through an atomic operation mechanism based on hardware primitives, including: The memory state is modified atomically through the atomic operation mechanism based on hardware primitives; the memory state includes atomic updates to session sequence number, connection state, and global connection count.

[0012] The present invention also provides a communication system, comprising: An I / O thread pool is used to receive messages sent by external terminal devices, load the messages into a memory pool using zero-copy technology, and send the messages to an independent business thread pool using a serialization executor corresponding to the current communication connection. The independent business thread pool is a collection of task processing threads independent of I / O scheduling. The communication connection is a connection between each external terminal device and the I / O thread pool. Communication is performed based on the priority of the communication messages in the lock-free circular queue using an atomic operation mechanism based on hardware primitives. An independent business thread pool is used to perform protocol parsing on the message, construct the corresponding communication message based on the parsing result, and distribute the communication message to the corresponding lock-free circular queue; wherein, the lock-free circular queue includes a preset number of priority queues.

[0013] The present invention also provides a communication device, comprising: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the communication method described above.

[0014] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the communication method described above.

[0015] The present invention also provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the above-described communication method.

[0016] As can be seen, this invention receives messages sent by external terminal devices through an I / O thread pool and loads the messages into a memory pool using zero-copy technology. The I / O thread pool uses a serialization executor corresponding to the current communication connection to send the messages to an independent business thread pool. The independent business thread pool is a collection of task processing threads independent of I / O scheduling. Each communication connection is between each external terminal device and the I / O thread pool. The independent business thread pool performs protocol parsing on the messages, constructs the corresponding communication messages based on the parsing results, and distributes the communication messages to the corresponding lock-free circular queues. The lock-free circular queues include a preset number of priority queues. The I / O thread pool communicates based on the priority of the communication messages in the lock-free circular queues using an atomic operation mechanism based on hardware primitives. The beneficial effects of this invention are as follows: by establishing a private execution domain for each physical device through Strand (serialization executor), the problem of business logic sequence is solved. Furthermore, by introducing atomic variables based on hardware primitives (CAS) to replace traditional mutex locks, lock-free processing is achieved, enabling asynchronous serial processing within a single device and fully parallel processing between multiple devices. This completely eliminates the problems of high CPU utilization and deteriorated real-time performance caused by lock contention under high concurrency, supports the stability of the system under extremely high concurrency, and thus improves communication efficiency.

[0017] In addition, the present invention also provides a communication system, device and computer-readable storage medium, which also have the above-mentioned beneficial effects. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0019] Figure 1 A flowchart of a communication method provided in an embodiment of the present invention; Figure 2 A flowchart illustrating the system logic architecture of a communication method provided in an embodiment of the present invention; Figure 3 An asynchronous isolation and atomic synchronization architecture diagram provided in this embodiment of the invention; Figure 4 A flowchart of zero-copy message processing provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of a multi-priority lock-free scheduling method provided in an embodiment of the present invention; Figure 6 A resource release flowchart based on atomic counting is provided for an embodiment of the present invention; Figure 7 A schematic diagram of the structure of a communication system provided in an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of a communication device provided in an embodiment of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Some terms that appear in the description of the embodiments of this application are subject to the following interpretation: Boost.Asio represents a cross-platform C++ network programming library for providing an asynchronous event-driven input / output (I / O) model; io_context represents the core of the asynchronous event loop, responsible for managing operating system I / O services and scheduling registered asynchronous tasks; Moodycamel specifically refers to a high-performance lock-free concurrent queue implementation (based on moodycamel::ConcurrentQueue) used to achieve zero-lock data transfer between multiple threads; Strand represents an asynchronous execution serializer used to ensure that tasks submitted to it are executed strictly in sequence in a multi-threaded environment, thereby eliminating race conditions; std::promise / future represents a synchronous notification mechanism for asynchronous operations, which in this device is used to ensure that resources are gracefully released after all asynchronous tasks are completed; Tcmalloc represents a high-performance memory allocator (Thread-Caching Malloc) that optimizes memory allocation efficiency and reduces memory fragmentation by reducing lock contention in multi-threaded environments. HTTP stands for HyperText Transfer Protocol, which is mainly used in this device for management interface communication of non-business paths; Mutex stands for Mutex lock, a traditional mechanism for multi-threaded synchronization; this device implements a "mutex lock-free" design for business paths through an asynchronous architecture; IEC 61850 stands for "Communication Networks and Systems for Substations," an international standard that covers data modeling and communication specifications between devices in the field of power automation. MMS stands for Manufacturing Message Specification, which is an application layer protocol used for station control layer interaction in the IEC 61850 standard. CID stands for Configured IED Description, which defines the device's logical nodes, data objects, and communication parameters. Modbus represents a standard communication protocol used in industrial applications, including Modbus TCP based on Ethernet and Modbus RTU based on serial communication. TCP stands for Transmission Control Protocol, which provides connection-oriented, reliable byte stream transmission services. RTU stands for Remote Terminal Unit, which typically refers to industrial control terminal equipment accessed via a serial link; DL / T645 represents the Chinese standard for communication protocols of multi-functional energy meters, used for the acquisition and monitoring of energy data; JSON stands for Lightweight Data Interchange Format (JavaScript Object Notation), used for parameter configuration and hot-reloading of this device; PCS stands for Power Conversion System, which is responsible for the AC / DC energy conversion between the battery cells and the power grid. BMS stands for Battery Management System, which is responsible for monitoring, protecting, and balancing the status of energy storage battery packs. Zero-Copy refers to zero-copy technology, which uses std::unique_ptr ownership transfer to realize the flow of messages between modules, avoiding physical memory copying; CAS is based on the atomic operation mechanism of hardware primitives; Basic utility libraries: Boost.Asio network library, Tcmalloc memory allocator, Moodycamel lock-free queue, C++ standard library (STL); Standard communication protocols: IEC 61850, IEC 104, Modbus TCP / RTU, DL / T 645 protocol itself; General hardware / concepts: PCS (Power Conversion System), BMS (Battery Management System), Thread Pool, Asynchronous I / O, HTTP Interface.

[0022] Please refer to Figure 1 , Figure 1 A flowchart illustrating a communication method provided in an embodiment of the present invention. The method may include: S101, the I / O thread pool receives messages sent by external terminal devices and loads the messages into the memory pool using zero-copy technology.

[0023] In this embodiment, the I / O thread pool is specifically responsible for high-frequency low-level network data transmission and reception (system call level operations). The I / O thread pool contains multiple event loop contexts (io_context), and the pool size is equal to or close to the number of CPU physical cores. Each I / O thread occupies an exclusive event loop context and runs continuously. All network input / output operations, timer operations, and serial port operations are asynchronously submitted to the event loop context in the thread pool for execution. In this embodiment, the asynchronous operation of receiving new connections is submitted to the I / O thread pool. When a terminal device (such as a PCS, BMS, multi-function meter, etc.) initiates a connection request and establishes a connection, an independent session object is created for the terminal device. This object holds information such as network sockets, protocol state machines, point table caches, reporting queues, and sending queues. At the same time, a dedicated serializer executor is allocated to this session object. This serializer executor is bound to a specific event loop context in the I / O thread pool to ensure that all I / O operations related to this device are executed strictly in sequence, avoiding concurrency conflicts. This embodiment utilizes `std::unique_ptr` to transfer ownership in an asynchronous callback chain, achieving zero-copy physical memory throughout the entire process of packet reception from the network card to protocol parsing and forwarding. Based on Boost.Asio's multi-threaded asynchronous event-driven network core, this embodiment employs an I / O thread pool composed of multiple `io_context`s (asynchronous event loop cores) in conjunction with an independent business thread pool (a collection of task processing threads independent of the I / O scheduling core). All network I / O, timer, and serial port operations are asynchronously and non-blockingly submitted to the I / O thread pool. The post / dispatch action assigns a specific task (such as sending a packet or closing a connection) to the thread pool driven by the `io_context` for execution. The specific execution may include calling the underlying asynchronous send function, updating the socket state, or triggering a timer task. By holding the buffer through `std::unique_ptr` and transferring ownership between modules, packet parsing is directly based on the original buffer data, avoiding any memory copying. In this embodiment, all device objects and session objects use std::shared_ptr and std::weak_ptr to manage their lifecycles, avoiding dangling pointers and memory leaks.

[0024] It should be further explained that, based on any of the above embodiments, in order to achieve lock-free processing, before the I / O thread pool receives the message sent by the external terminal device and loads the message into the memory pool using zero-copy technology, the process may further include: the I / O thread pool establishing long connections with at least two external terminal devices through the underlying driver, and assigning a unique communication connection identifier to each long connection; the I / O thread pool associating a serialization executor with each communication connection identifier. In this embodiment, the I / O thread pool establishes long connections with multiple external devices through the underlying driver and assigns a unique Session ID (communication connection identifier) ​​to each connection. Based on this Session ID, the system associates a unique Strand (serialization executor) in memory as the controller for all business logic of that device. This embodiment provides an independent Session object for each device, and all operations are strictly executed serially within the Strand of this Session, completely avoiding multi-threaded race conditions.

[0025] S102, the I / O thread pool uses the serialization executor corresponding to the current communication connection to send the message to the independent business thread pool; wherein, the independent business thread pool is a set of task processing threads independent of I / O scheduling; the communication connection is the connection between each external terminal device and the I / O thread pool.

[0026] In this embodiment, a dedicated business thread pool is responsible for time-consuming protocol parsing, logic calculation, and state machine maintenance. This dedicated thread pool is independent of the task processing thread set of the I / O scheduling core, and its role is to decouple the underlying communication from the upper-layer business. This separation ensures that the time-consuming business logic does not block network response, thus achieving extremely fast response under high concurrency. The dedicated business thread pool contains several worker threads (the number of threads can be configured according to the load, typically 1 to 2 times the number of CPU cores), dedicated to executing computationally intensive tasks such as protocol parsing, data model access, control logic processing, and reporting message construction. In this embodiment, the I / O thread pool does not directly parse the protocol; instead, ownership of the message is delivered to the dedicated business thread pool through Strand (serialization executor). Strand ensures that messages from the same physical device maintain logical serial order even in a multi-threaded environment.

[0027] S103, the independent business thread pool performs protocol parsing on the message, constructs the corresponding communication message based on the parsing result, and distributes the communication message to the corresponding lock-free circular queue; the lock-free circular queue includes a preset number of priority queues.

[0028] In this embodiment, after receiving a task, the independent business thread pool calls the mapping model generated during compilation for fast parsing. Upon receiving an uplink message, the I / O thread pool directly encapsulates the data pointer in the socket buffer into a message object using a zero-copy method and delivers it to the independent business thread pool via a lock-free concurrent queue. After retrieving the message object from the queue, the independent business thread pool calls the corresponding protocol parsing state machine to parse it according to the protocol type of the session object (e.g., IEC61850, Modbus, IEC104, etc.). During the parsing process, when accessing the IEC61850 data model, the corresponding data object (DO) and data attribute (DA) nodes are directly located through the C++ mapping table automatically generated during compilation. The lock-free circular queue in this embodiment (based on `moodycamel::ConcurrentQueue`) enables lock-free high-concurrency data flow under the producer-consumer model.

[0029] It should be further explained that, to improve the accuracy of storing communication packets in the lock-free circular queue, the aforementioned independent business thread pool performs protocol parsing on the packets, constructs the corresponding communication packets based on the parsing results, and distributes the communication packets to the corresponding lock-free circular queue. This may include: the independent business thread pool determining the instruction type corresponding to the communication packet; and the independent business thread pool storing the communication packet in the corresponding priority queue in the lock-free circular queue based on the instruction type using an atomic operation mechanism based on hardware primitives. In this embodiment, the independent business thread pushes the instruction into the multi-level lock-free transmission queue according to the instruction type (such as remote control / telephony). The enqueueing process is also based on CAS contention to update the write pointer, ensuring the non-blocking nature of concurrent writes by multiple threads. It can be understood that when it is necessary to send communication packets to the terminal device, a multi-priority lock-free transmission queue mechanism is used to achieve efficient scheduling. Each session object can maintain three independent lock-free concurrent queues, corresponding to high, medium, and low priorities: The high-priority queue stores messages with extremely high real-time requirements, such as verification frames and heartbeat responses; the medium-priority queue stores critical control commands and their response messages, such as remote control, remote adjustment, and point setting; and the low-priority queue stores ordinary messages such as routine telemetry acquisition, parameter queries, and log reporting. Independent business threads deliver the encapsulated message objects to the corresponding priority queues based on the message's importance and real-time requirements.

[0030] It should be further explained that, to improve the efficiency and accuracy of parsing, the aforementioned independent business thread pool performs protocol parsing on the messages and constructs the corresponding communication messages based on the parsing results. This can include: the independent business thread pool determining and selecting a data mapping model based on the protocol type corresponding to the message; wherein, the data mapping model is a lookup table generated during the software compilation phase by automatically parsing the description file, used to establish a mapping between the logical names of data objects and data attribute nodes and their runtime memory addresses; the independent business thread pool performs protocol parsing on the messages based on the data mapping model, locates the corresponding data objects and data attribute nodes, and constructs communication messages based on the data objects and data attribute nodes. It is understandable that existing solutions typically parse XML (Extensible Markup Language) at runtime or manually maintain point tables. This process is moved to the compilation phase, automatically parsing the CID file and generating C++ code through a script, thereby eliminating the risk of errors from manually configuring point tables. Furthermore, because the code is statically compiled, its runtime efficiency is far higher than traditional dynamic parsing solutions.

[0031] It should be further explained that, in order to improve the accuracy of communication messages, the aforementioned independent service thread pool performs protocol parsing on the messages based on a data mapping model, locates the corresponding data objects and data attribute nodes, and constructs the communication messages based on the data objects and data attribute nodes. This can include: if it is uplink telemetry data or tele-signaling data, a telemetry message is constructed in the service thread and asynchronously delivered to the I / O thread pool via the corresponding serializer to be written into a network socket and sent to the master station; if it is a remote control, remote adjustment, or setting command issued by the master station, a response message or execution message is constructed after executing the corresponding control logic in the service thread, and delivered to the I / O thread pool via the serializer. The communication messages in this embodiment can be telemetry messages, response messages, execution messages, etc.

[0032] It should be further noted that, based on any of the above embodiments, in order to improve the accuracy of the data mapping model construction, the data mapping model construction process may include: during the device software compilation and construction stage, fully automatic generation of the IEC61850 data model is achieved through a custom CMake build script, and the specific steps are as follows: 1. Build a script to automatically scan the project directory and find the latest device capability description file (CID file). 2. Use the model generation tool provided by the open-source library libiec61850 to generate the initial static_model.c and static_model.h source files based on the CID file; 3. Execute the preset repair script to automatically perform path correction, generate C++ mapping tables for data objects and data attributes, and encapsulate the extern "C" external interface in the generated model file. 4. Compile and link the repaired model file together with other business source code to form the final executable program (data mapping model).

[0033] When the site point table changes, only the CID file needs to be replaced and the firmware recompiled. There is no need to manually run the model generator, modify the header file path, or maintain the mapping table, which greatly shortens the project delivery cycle.

[0034] S104, the I / O thread pool communicates based on the priority of communication messages in the lock-free circular queue through an atomic operation mechanism based on hardware primitives.

[0035] In this embodiment, if a state update is involved, the memory state is directly modified through a CAS (Compare-and-Swap) atomic operation without the need to acquire a mutex lock. After parsing, if an instruction needs to be issued, the business thread pushes it into a multi-level lock-free send queue according to the instruction type (e.g., remote control / telephony). The enqueueing process is also based on CAS contention to update the write pointer, ensuring the non-blocking nature of concurrent writes by multiple threads. After communication, a callback-driven closed-loop delivery can also be included. When the I / O thread pool completes the transmission of the previous frame and triggers the callback, the callback function uses CAS to atomically update the read pointer, extracts the next high-priority message from the lock-free queue, and physically delivers it, completing the entire bidirectional closed loop. It can be understood that after the serialization executor in the I / O thread pool completes a write operation or detects a socket writable event, it first performs a safety check on the current state of the session object (e.g., whether the connection is normal or the shutdown process has not been entered) through an atomic compare-and-swap operation. If the state allows transmission, packets can be retrieved in a strict high-medium-low priority order: first, a packet is retrieved from the high-priority queue; if available, it is immediately written asynchronously to the network socket; if the high-priority queue is empty, a packet is retrieved from the medium-priority queue; and only if the medium-priority queue is empty is a packet retrieved from the low-priority queue. If all queues are empty, the system waits for the next writable event to trigger. This mechanism ensures that critical packets are still prioritized for transmission even during network congestion or a backlog of low-priority packets, while maintaining a first-in, first-out order within the same priority level.

[0036] It should be further explained that, based on any of the above embodiments, the I / O thread pool communicates through an atomic operation mechanism based on hardware primitives, according to the priority of communication messages in the lock-free circular queue. This can include: modifying the memory state atomically through the atomic operation mechanism based on hardware primitives; the memory state includes atomic updates to the session sequence number, link state, and global connection count. This embodiment can directly modify the memory state through CAS (Compare and Swap) atomic operations without needing to acquire a mutex lock. When the independent business thread pool performs parsing, if it involves sequence number (V(S) / V(R)) or link state switching, it calls the underlying CAS (Compare and Swap) primitive for atomic updates, ensuring that the global state is absolutely safe even if multiple Strands run simultaneously. In this embodiment, except for state waiting for the HTTP management interface, this device does not use mutex locks in any business processing path, relying entirely on Strand serialization execution, atomic operations, and lock-free queues to achieve thread safety.

[0037] It should be further explained that, based on any of the above embodiments, after the I / O thread pool communicates based on the priority of communication messages in the lock-free circular queue through an atomic operation mechanism based on hardware primitives, it may further include: when the I / O thread pool detects an abnormal communication connection of the external terminal device, it executes a graceful shutdown process and asynchronously waits for all messages delivered by the serialization executor through the communication connection to be executed and for the associated atomic task counter to be zero before releasing the memory and system resources occupied by the communication connection. This embodiment utilizes std::promise / future in conjunction with smart pointers to ensure that resources are released only after all suspended tasks have completely finished in complex asynchronous callback networks. This solves the problems of dangling pointer crashes and slow memory growth commonly encountered by front-end machines in frequent disconnections and reconnections and complex network environments. When the I / O thread pool detects an abnormal connection to the terminal device (such as a heartbeat timeout or the peer closing the socket), the following graceful shutdown process is executed: 1. Immediately stop submitting new asynchronous read / write operations to the serializer executor of the device; 2. Create an asynchronous commitment-future mechanism object and save the future object in the session object; 3. Submit a shutdown task through the serializer executor of the device. This task waits for all queued tasks in the serializer to complete before setting the commitment to the completed state; 4. The main shutdown logic asynchronously waits for the future object to be ready. Only after confirming that all asynchronous tasks have been safely completed does it release the shared smart pointer resource of the session object. Furthermore, considering the characteristic that the client of the IEC61850 protocol control object does not actively release resources, this embodiment introduces a fixed-capacity (preferably 15) Least Recently Used (LRU) cache mechanism: when creating a new control object, first check if the cache is full; if full, remove the oldest, least recently used object and release its resources; then insert the new object at the head of the cache, effectively preventing the control object from growing indefinitely and causing abnormal memory usage. This embodiment utilizes the std::promise / std::future mechanism to notify the associated worker thread when the connection is broken or an exception occurs, and asynchronously waits for all pending tasks to be completed before releasing the shared_ptr, ensuring zero resource leaks.

[0038] It should be further noted that the high-performance memory allocator tcmalloc is used by default instead of the glibc default allocator during the linking phase, and no mutex locks are used in any business processing path (except for the HTTP management interface). In actual deployments of multiple 360MW-level energy storage power stations, this embodiment can stably connect a single device to 162 terminal devices (72 PCS, 72 BMS, and 18 multi-function meters) and run continuously for more than 240 days without restarting; the average uplink latency of remote signaling is only 6.8ms (optimal ≤5ms), and the average latency of the entire remote control process is ≤50ms; in stress testing, even with thousands of frames of messages backlogged in the low-priority queue, the average downlink latency of high-priority verification frames is still ≤5ms, and the latency of medium-priority remote control commands is stably controlled within 30ms; under the same hardware and load conditions, the average CPU utilization rate is reduced by 68% and memory utilization is reduced by 62% compared to traditional solutions, with memory growth of ≤5MB in 72 hours of full-load testing and almost no memory fragmentation.

[0039] The above test data fully verifies the significant technical effects resulting from the organic combination of technical features such as separation of I / O thread pool and business thread pool, multi-priority lock-free send queue, zero copy, serialization of serializer executor, automatic model generation, and tcmalloc optimization.

[0040] It should be noted that the system built based on this method has a fixed number of worker threads (default CPU core count × 2) that run io_context::run() for an extended period, combined with work_guard to prevent premature exit; memory allocator optimization: in the Linux environment, the tcmalloc memory allocator is linked by default, which significantly reduces memory fragmentation and lock contention in multi-threaded memory allocation; multi-protocol server simultaneous support capability: IEC61850 MMS Server (based on the latest version of libiec61850 to implement complete Report, Control, and GOOSE subscriptions, based on libiec61850, with custom scripts automatically parsing CID files and generating and repairing data model code during the compilation stage), IEC60870-5-104 Server (master / slave dual mode), Modbus TCP / RTUServer, DL / T 645-1997 / 2007 multi-function meter protocol. Supports all five remote functions: remote signaling (including SOE), telemetry, remote control, remote adjustment, and remote pulse (power pulse). All protocol CID files are automatically parsed and code generated: during the compilation and build phase, a custom CMake + bash script automatically parses CID files, generates static_model.c / h and corrects paths, performs extern "C" encapsulation, and generates DO / DA mapping tables. JSON configuration files allow for flexible settings of whether to enable periodic recall, recall interval, and recall type (general category, time-stamped category, etc.). Full JSON configuration is driven: device lists, protocol parameters, mapping relationships, log levels, thread counts, etc., are all hot-loaded via JSON files, eliminating the need for recompilation.

[0041] An embodiment of the present invention provides a communication method, which may include: S101, an I / O thread pool receives a message sent by an external terminal device and loads the message into a memory pool using zero-copy technology; S102, the I / O thread pool uses a serialization executor corresponding to the current communication connection to send the message to an independent business thread pool; wherein, the independent business thread pool is a set of task processing threads independent of I / O scheduling; the communication connection is a connection between each external terminal device and the I / O thread pool; S103, the independent business thread pool performs protocol parsing on the message, constructs a communication message corresponding to the message based on the parsing result, and distributes the communication message to the corresponding lock-free circular queue; wherein, the lock-free circular queue includes a preset number of priority queues; S104, the I / O thread pool communicates based on the priority of the communication message in the lock-free circular queue through an atomic operation mechanism based on hardware primitives. This invention establishes a private execution domain for each physical device through a Strand serializer, solving the problem of business logic sequence. Furthermore, it introduces atomic variables based on hardware primitives to replace traditional mutex locks, achieving lock-free processing of asynchronous serial within a single device and fully parallel between multiple devices. This completely eliminates the problems of high CPU utilization and deteriorated real-time performance caused by lock contention under high concurrency, supports the stability of the system under extremely high concurrency, and thus improves communication efficiency.

[0042] With the rapid growth of new energy grid connection scale and energy storage power station capacity, the number of intelligent devices connected to the station (such as PCS, BMS, protection and control devices, electricity meters, temperature control and fire protection devices, etc.) has reached hundreds, and there are many types of communication protocols (IEC61850, IEC104, Modbus, DL / T645, etc.), which puts forward extremely high requirements for the real-time performance, concurrency and reliability of remote signaling, telemetry, remote control, remote adjustment and remote pulse signals.

[0043] Existing front-end / communication management devices generally suffer from the following defects: they adopt a blocking I / O + mutex lock design, which leads to high CPU utilization and large response latency due to frequent lock contention under high concurrency; multiple data copies result in severe memory fragmentation, and performance degrades significantly after long-term operation; multi-threaded resource management is complex and prone to memory leaks or dangling pointers; different protocol modules are highly coupled, and adding a new protocol requires significant code modifications; existing devices generally do not optimize the memory allocator, which easily leads to severe memory fragmentation after long-term operation, causing system restarts.

[0044] To overcome the shortcomings of existing technologies, this invention provides a multi-protocol high-performance front-end communication method based on the Boost.Asio lock-free asynchronous architecture, which realizes high concurrency, low latency, zero copy, and five-remote acquisition and control of hundreds of heterogeneous terminal devices.

[0045] For a clearer understanding of this invention, please refer to the following details. Figure 2 , Figure 2 The flowchart illustrating the system logic architecture of a communication method provided in this embodiment of the invention specifically includes four logical layers from bottom to top. The bottom layer is the external terminal device layer, containing monitored physical devices such as energy storage converters, battery management systems, and electricity meters. Above this is the communication and interface layer, responsible for direct interaction with devices, integrating a protocol driver cluster supporting multiple protocols such as IEC 61850, IEC 104, and Modbus, as well as an HTTP server for management. The core is the asynchronous processing core layer, which includes a dedicated high-frequency network I / O thread pool, a dedicated independent business thread pool for protocol parsing and business logic, a multi-level lock-free transmission queue connecting the two and implementing priority scheduling, and a data acquisition queue for buffering uplink data. The top layer is the upper-level system layer, providing services to SCADA systems, control clients, etc. The entire system's workflow is a bidirectional closed loop. In the uplink data processing path, the raw messages generated by the external devices are first received by the I / O thread pool in an asynchronous, non-blocking manner. Subsequently, the I / O thread pool does not parse in place. Instead, it asynchronously delivers the message processing task to an independent business thread pool by connecting a dedicated Strand to the device, thus ensuring the serial execution of tasks on the same device. Under Strand scheduling, the independent business thread pool calls the static data mapping model generated during compilation for fast, lock-free protocol parsing. The extracted standardized data is finally written to an in-memory database for monitoring by the upper-level SCADA system. In the downlink control processing path, control commands are sent by the client through the interface. After verification, the independent business thread pool places the command into the corresponding priority queue of a multi-level lock-free transmission queue (e.g., remote control commands are placed into the high-priority queue) according to the command type using CAS atomic operations. When the I / O thread pool is ready, its callback function is triggered, and a lock-free polling scheduler prioritizes the extraction of commands to be sent from the high-priority queue, also using CAS operations. Finally, the I / O thread pool asynchronously sends the commands to the protocol driver cluster through the corresponding Strand, ultimately encapsulating them into protocol messages and sending them to the target external device to execute physical actions, thus completing the "perception-decision-control" closed loop. The core innovation of this architecture lies in achieving asynchronous isolation between computation and I / O by separating I / O from the business thread pool; achieving device-level logical isolation and lock-free serial scheduling by binding Strand to each device; and achieving microsecond-level priority scheduling of critical control instructions through multi-level lock-free queues based on CAS operations.

[0046] For easier understanding, please refer to Figure 3 , Figure 3 This is a diagram illustrating an asynchronous isolation and atomic synchronization architecture provided in an embodiment of the present invention. Figure 2 The macroscopic topology of the device was demonstrated, clarifying the two-way path for data acquisition and transmission as well as control command issuance; Figure 3 Yes Figure 2 This in-depth breakdown of the asynchronous kernel layer reveals how Strand (serializer executor) and CAS (atomic operation) jointly replace the traditional mutex lock mechanism, providing underlying concurrency control support for bidirectional business flows in a multi-threaded environment. The execution steps include: Step 1 (Establishing a physical connection pool): The I / O thread pool establishes long connections with multiple external devices through the underlying driver and assigns a unique Session ID to each connection. Step 2 (Binding a Strand logical domain): Based on this Session ID, the system associates a unique Strand (serializer executor) in memory. Step 3 (Cross-thread asynchronous delivery): When the I / O thread pool receives a data packet, it does not parse it in-place but asynchronously delivers the parsing task to an independent business thread pool via Strand. Step 4 (Atomic state synchronization): When the independent business thread pool performs parsing, if sequence number (V(S) / V(R)) or link state switching is involved, it calls the underlying CAS (Compare and Swap) primitive for atomic updates, ensuring that the global state is absolutely safe even if multiple Strands run simultaneously. Step 5 (Instruction Reverse Injection): When the business layer generates control instructions, the sending task is also reverse-scheduled back to the I / O thread pool through Strand, completing the bidirectional closed loop.

[0047] For easier understanding, please refer to Figure 4 , Figure 4A zero-copy message processing flowchart provided for embodiments of the present invention may include: Step 1: System initialization. In this stage, the system pre-allocates a contiguous memory pool based on Tcmalloc, providing a physical basis for subsequent zero-copy operations; simultaneously, it loads the protocol data model automatically generated during the compilation stage, preparing for high-speed parsing. When the external terminal device sends the original message, the process proceeds to Step 2: Data capture and zero-copy. The I / O thread pool asynchronously receives the message and uses std::unique_ptr to load the data into the pre-allocated memory pool by transferring ownership, realizing zero-copy transfer from kernel mode to user mode and avoiding memory copying overhead. Step 3: Asynchronous task dispatch. The I / O thread pool does not perform protocol parsing, but dispatches the task carrying the message data to an independent business thread pool through a dedicated Strand bound to the device connection. The core function of the Strand is to ensure that all tasks from the same device are serialized and scheduled for execution in the independent business thread pool, achieving device-level logical isolation. Step 4: Business parsing and state maintenance begin execution. Under Strand's scheduling, the independent business thread pool calls the pre-loaded protocol model for fast mapping and parsing. During the parsing process, any updates to the global state or session sequence number are completed through CAS / atomic operations, thus achieving lock-free state maintenance and completely eliminating the contention overhead caused by traditional mutex locks. After parsing, if a command needs to be issued, the process proceeds to the crucial step 5: lock-free enqueueing. The independent business thread pool places the constructed messages to be sent into the corresponding priority sub-queues of the multi-level lock-free queue according to their business type (such as remote control, telemetry). The enqueueing process is implemented by competing to update the write pointer of the queue through CAS operations, ensuring lock-free operation and thread safety during multi-threaded concurrent writing, which is one of the key innovations supporting high concurrency. Finally, the process is closed by step 6: callback-driven delivery. When the network send callback in the I / O thread pool is triggered, it competes to update the read pointer of the multi-level lock-free queue through CAS operations, safely retrieving the highest priority message to be sent. Subsequently, the I / O thread pool again asynchronously sends tasks via Strand scheduling, physically delivering the message to the target external terminal device. This callback event-driven mechanism, based on lock-free contention for message acquisition, is another major innovation in achieving low-latency delivery. In summary, this diagram demonstrates how the asynchronous division of labor between the I / O thread pool and the independent business thread pool, the serialization isolation provided by Strand, the lock-free synchronization of CAS atomic operations, and the priority scheduling of multi-level lock-free queues organically collaborate to form the core mechanism for achieving high-concurrency, low-latency communication processing. Figure 3 A static thread isolation model is defined; Figure 4 Based on this model, the dynamic timing of message processing is further refined. Figure 4The key role of CAS in steps 5 (lock-free enqueue) and 6 (callback-driven retrieval) is clearly demonstrated—that is, by atomically updating the queue pointer, absolute safety and extremely low latency of data exchange are ensured when the I / O thread pool and the business thread pool interact frequently.

[0048] For easier understanding, please refer to Figure 5 , Figure 5 This diagram illustrates a multi-priority lock-free scheduling mechanism provided in an embodiment of the invention. The multi-priority lock-free transmission queue is a lock-free circular queue, divided into three logical sub-queues: a high-priority queue, a medium-priority queue, and a low-priority queue. The high-priority queue stores basic management messages such as heartbeat frames and link verification frames to maintain the availability of the communication link. The medium-priority queue stores key instructions that directly control device actions, such as remote control, remote adjustment, and setting commands and their responses. The low-priority queue stores regular data messages with relatively relaxed real-time requirements, such as periodically uploaded telemetry data and ordinary query responses. This scheduler is typically built into the event loop of the I / O thread pool and runs continuously in a lock-free manner. The scheduler follows a strict and uninterrupted priority polling order: First, it checks the high-priority queue. If a message exists in it, it is immediately extracted and submitted to the I / O sending interface via a CAS atomic operation, ensuring the basic stability of the communication link is guaranteed with the highest priority. If the high-priority queue is empty, it checks the medium-priority queue. Once a critical command such as a remote control is found to be sent, it is also extracted and sent immediately without locking via a CAS operation, ensuring that control commands still have a near-instantaneous transmission opportunity even in the context of massive data. Only when both the high-priority and medium-priority queues are empty does the scheduler finally process the periodic data in the low-priority queue. This achieves high data throughput while completely avoiding any impact of regular data on the transmission delay of critical commands.

[0049] For easier understanding, please refer to Figure 6 , Figure 6The following is a flowchart of a resource release process based on atomic counting, provided in this embodiment of the invention: Step 1 (Triggering a destruction instruction): The management thread (or HTTP Server) issues a specific "connection destruction" request. At this time, the system immediately stops the Session from receiving new messages. Step 2 (Atomic count self-check): The business thread loads the atomic task counter corresponding to the Session using the CAS primitive. This counter records in real time the total number of tasks currently in I / O wait or Strand scheduling. Step 3 (Establishing a synchronization barrier): The system creates a std::promise object and its associated std::future. The destruction thread does not immediately release memory; instead, it calls `future.wait()` to enter a non-blocking suspended state, forming a safety barrier. Step 4 (Callback-triggered decrement): As the last suspended asynchronous callback (such as physical send completion or timeout return) completes, the callback function atomically decrements the task counter using a CAS operation. Step 5 (Zeroing notification and complete destruction): When CAS detects that the counter has reached zero, it triggers `promise.set_value()` to wake up the destruction thread. At this point, the system is certain that no thread is referencing the memory block, thus performing physical memory release (Tcmalloc reclamation) and closing the Socket handle. Figure 4 This constitutes the core processing logic of the present invention. Figure 5 As Figure 4 The zoom-in view of the "instruction issuance" stage shows in detail how CAS is used to maintain the competitive balance of multiple priority queues; Figure 6 Then targeting Figure 4 The resource recycling section at the end demonstrates how to use atomic counting and the Promise mechanism to achieve graceful release of asynchronous resources.

[0050] Compared with the prior art, the present invention has the following significant advantages: 1. Actual measurements show that a single device can stably connect to 162 terminal devices (72 PCS, 72 BMS, and 18 multi-function meters). The average delay for remote signaling change reporting is 6.8ms (optimal ≤5ms), and the entire remote control process is ≤50ms, which fully meets the requirements of primary frequency regulation and rapid reactive power response of energy storage power stations. 2. The entire system has almost no mutex locks. Under the same hardware and load conditions, the average CPU utilization is reduced by 68% and memory usage is reduced by 62% compared to traditional solutions, making it suitable for long-term high-load operation. 3. Zero-copy + lock-free queue + tcmalloc combination, memory growth ≤5MB in 72-hour full load stress test, with almost no fragmentation; 4. The protocol module is completely decoupled. The new protocol only needs to implement a unified interface to be connected, which has extremely strong scalability; 5. All configurations are in JSON format, supporting runtime hot reloading, allowing for device adaptation without recompiling on-site.

[0051] The following describes a communication system provided by an embodiment of the present invention. The communication system described below can be referred to in correspondence with the communication method described above.

[0052] Please refer to the details. Figure 7 , Figure 7 A schematic diagram of a communication system provided in an embodiment of the present invention may include: I / O thread pool 100 is used to receive messages sent by external terminal devices, load the messages into a memory pool using zero-copy technology, and send the messages to an independent service thread pool using a serialization executor corresponding to the current communication connection. The independent service thread pool is a set of task processing threads independent of I / O scheduling. The communication connection is a connection between each external terminal device and the I / O thread pool. Communication is performed based on the priority of the communication messages in the lock-free circular queue using an atomic operation mechanism based on hardware primitives. An independent business thread pool 200 is used to perform protocol parsing on the message, construct the corresponding communication message based on the parsing result, and distribute the communication message to the corresponding lock-free circular queue; wherein, the lock-free circular queue includes a preset number of priority queues.

[0053] An embodiment of the present invention provides a communication system, which may include: an I / O thread pool 100, used to receive messages sent by external terminal devices, load the messages into a memory pool using zero-copy technology; and send the messages to an independent service thread pool using a serialization executor corresponding to the current communication connection; wherein, the independent service thread pool is a set of task processing threads independent of I / O scheduling; the communication connection is a connection between each external terminal device and the I / O thread pool; and communication is performed based on the priority of the communication messages in the lock-free circular queue through an atomic operation mechanism based on hardware primitives; an independent service thread pool 200, used to perform protocol parsing on the messages, construct the communication messages corresponding to the messages based on the parsing results, and distribute the communication messages to the corresponding lock-free circular queues; wherein, the lock-free circular queues include a preset number of priority queues. This invention establishes a private execution domain for each physical device through a Strand serializer, solving the problem of business logic sequence. Furthermore, it introduces atomic variables based on hardware primitives to replace traditional mutex locks, achieving lock-free processing of asynchronous serial within a single device and fully parallel between multiple devices. This completely eliminates the problems of high CPU utilization and deteriorated real-time performance caused by lock contention under high concurrency, supports the stability of the system under extremely high concurrency, and thus improves communication efficiency.

[0054] The following describes a communication device provided by an embodiment of the present invention. The communication device described below can be referred to in correspondence with the communication method described above.

[0055] Please refer to Figure 8 , Figure 8 A schematic diagram of the structure of a communication device provided in an embodiment of the present invention may include: Memory 10 is used to store computer programs; Processor 20 is used to execute computer programs to implement the above-described communication method.

[0056] The memory 10, processor 20, and communication interface 30 all communicate with each other through the communication bus 40.

[0057] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions: The I / O thread pool receives messages sent by external terminal devices and loads the messages into the memory pool using zero-copy technology. The I / O thread pool uses the serialization executor corresponding to the current communication connection to send messages to the independent business thread pool; the independent business thread pool is a collection of task processing threads independent of I / O scheduling; the communication connection is the connection between each external terminal device and the I / O thread pool; An independent business thread pool performs protocol parsing on the messages, constructs the corresponding communication messages based on the parsing results, and distributes the communication messages to the corresponding lock-free circular queues; the lock-free circular queues include a preset number of priority queues; The I / O thread pool communicates based on the priority of communication messages in a lock-free circular queue through an atomic operation mechanism based on hardware primitives.

[0058] In one possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.

[0059] Furthermore, memory 10 may include read-only memory and random access memory, providing instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores operating systems and operating instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and handling hardware-based tasks.

[0060] Processor 20 can be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic device. Processor 20 can be a microprocessor or any conventional processor. Processor 20 can call programs stored in memory 10.

[0061] The communication interface 30 can be an interface for the communication module, used to connect with other devices or systems.

[0062] Of course, it should be noted that, Figure 8 The structure shown does not constitute a limitation on the communication device in the embodiments of the present invention. In practical applications, the communication device may include more than Figure 8 More or fewer components as shown, or combinations of certain components.

[0063] The computer-readable storage medium provided in the embodiments of the present invention is described below. The computer-readable storage medium described below and the communication method described above can be referred to in correspondence.

[0064] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described communication method.

[0065] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0066] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0067] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0068] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0069] The foregoing has provided a detailed description of a communication method, apparatus, device, and computer-readable storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A communication method, characterized in that, include: The I / O thread pool receives messages sent by external terminal devices and loads the messages into the memory pool using zero-copy technology. The I / O thread pool uses the serialization executor corresponding to the current communication connection to send the message to the independent service thread pool; wherein, the independent service thread pool is a set of task processing threads independent of I / O scheduling; the communication connection is the connection between each external terminal device and the I / O thread pool; The independent business thread pool performs protocol parsing on the message, constructs the corresponding communication message based on the parsing result, and distributes the communication message to the corresponding lock-free circular queue; wherein, the lock-free circular queue includes a preset number of priority queues; The I / O thread pool communicates through an atomic operation mechanism based on hardware primitives, according to the priority of the communication message in the lock-free circular queue.

2. The communication method according to claim 1, characterized in that, Before the I / O thread pool receives a message sent by an external terminal device and loads the message into the memory pool using zero-copy technology, the process also includes: The I / O thread pool establishes long connections with at least two external terminal devices through the underlying driver and assigns a unique communication connection identifier to each long connection; The I / O thread pool associates the serialization executor with each communication connection identifier.

3. The communication method according to claim 1, characterized in that, The independent business thread pool performs protocol parsing on the message, constructs the corresponding communication message based on the parsing result, and distributes the communication message to the corresponding lock-free circular queue, including: The independent business thread pool determines the instruction type corresponding to the communication message; The independent business thread pool stores the communication message into the corresponding priority queue in the lock-free circular queue through an atomic operation mechanism based on hardware primitives, according to the instruction type.

4. The communication method according to any one of claims 1 to 3, characterized in that, The independent business thread pool performs protocol parsing on the message and constructs the corresponding communication message based on the parsing result, including: The independent business thread pool determines the selected data mapping model based on the protocol type corresponding to the message; wherein, the data mapping model is a lookup table generated during the software compilation stage by automatically parsing the description file, used to establish a mapping between the logical names of data objects and data attribute nodes and their runtime memory addresses; The independent business thread pool performs protocol parsing on the message based on the data mapping model, locates the corresponding data object and data attribute node, and constructs the communication message based on the data object and data attribute node.

5. The communication method according to claim 4, characterized in that, The independent business thread pool performs protocol parsing on the message based on the data mapping model, locates the corresponding data object and data attribute node, and constructs the communication message based on the data object and data attribute node, including: If it is uplink telemetry data or teleindication data, then a telemetry message is constructed in the business thread and asynchronously delivered to the I / O thread pool through the corresponding serialization executor to write to the network socket and send to the main station; If the command is a remote control, remote adjustment, or setting command issued by the master station, after executing the corresponding control logic in the business thread, a response message or execution message is constructed and delivered to the I / O thread pool through the serialization executor.

6. The communication method according to claim 1, characterized in that, After the I / O thread pool communicates via an atomic operation mechanism based on hardware primitives according to the priority of the communication message in the lock-free circular queue, the process further includes: When the I / O thread pool detects an abnormal communication connection of the external terminal device, it executes a graceful shutdown process and asynchronously waits for all messages delivered by the serialization executor through the communication connection to be executed and for the associated atomic task counter to be zero before releasing the memory and system resources occupied by the communication connection.

7. The communication method according to claim 1, characterized in that, The I / O thread pool communicates based on the priority of the communication message in the lock-free circular queue through an atomic operation mechanism based on hardware primitives, including: The memory state is modified atomically through the atomic operation mechanism based on hardware primitives; the memory state includes atomic updates to session sequence number, connection state, and global connection count.

8. A communication system, characterized in that, include: An I / O thread pool is used to receive messages sent by external terminal devices, load the messages into a memory pool using zero-copy technology, and send the messages to an independent business thread pool using a serialization executor corresponding to the current communication connection. The independent business thread pool is a collection of task processing threads independent of I / O scheduling. The communication connection is a connection between each external terminal device and the I / O thread pool. Communication is performed based on the priority of the communication messages in the lock-free circular queue using an atomic operation mechanism based on hardware primitives. An independent business thread pool is used to perform protocol parsing on the message, construct the corresponding communication message based on the parsing result, and distribute the communication message to the corresponding lock-free circular queue; wherein, the lock-free circular queue includes a preset number of priority queues.

9. A communication device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the communication method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the communication method as described in any one of claims 1 to 7.