Next Article in Journal
Wavelet-Based P-Wave Detection in High-Rate GNSS Data: A Novel Approach for Rapid Earthquake Monitoring in Tsunamigenic Settings
Previous Article in Journal
RST-YOLOv8: An Improved Chip Surface Defect Detection Model Based on YOLOv8
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Enhancing Bidirectional Modbus TCP ↔ RTU Gateway Performance: A UDP Mechanism and Markov Chain Approach

1
Shandong Key Laboratory of Space Debris Monitoring and Low-Orbit Satellite Networking, Qingdao University of Technology, Qingdao 266520, China
2
National Astronomical Observatories, Chinese Academy of Sciences, Beijing 100101, China
*
Author to whom correspondence should be addressed.
Sensors 2025, 25(13), 3861; https://doi.org/10.3390/s25133861 (registering DOI)
Submission received: 27 April 2025 / Revised: 11 June 2025 / Accepted: 17 June 2025 / Published: 21 June 2025
(This article belongs to the Section Internet of Things)

Abstract

:
In the Industrial Internet of Things (IIoT) field, the diversity of devices and protocols leads to interconnection challenges. Conventional Modbus Transmission Control Protocol (TCP) to Remote Terminal Unit (RTU) gateways suffer from high overhead and latency of the TCP protocol stack. To enhance real-time communication while ensuring reliability, this study applies Markov chain theory to analyze User Datagram Protocol (UDP) transmission characteristics. An Advanced UDP (AUDP) protocol is proposed by integrating a Cyclic Redundancy Check (CRC) check mechanism, retransmission mechanism, Transaction ID matching mechanism, and exponential backoff mechanism at the UDP application layer. Based on AUDP, a Modbus AUDP-RTU gateway is designed with a lightweight architecture to achieve bidirectional conversion between Modbus AUDP and Modbus RTU. Experimental validation and Markov chain-based modeling demonstrate that the proposed gateway significantly reduces communication latency compared to Modbus TCP-RTU and exhibits higher reliability than Modbus UDP-RTU.

1. Introduction

In recent years, with the development of the Industrial Internet of Things (IIOT), machine-to-machine (M2M) communication technology has been widely adopted in industrial fields. However, the fragmented nature of IoT solutions compels industrial systems to integrate multi-source heterogeneous technologies for automated control, thereby urgently requiring the establishment of efficient interoperability mechanisms to ensure seamless collaboration among heterogeneous devices. Consequently, many organizations are developing new and existing IoT standards, platforms, and communication protocols to meet the demands of emerging Industry 4.0 [1]. Currently popular communication protocols include Modbus, CAN (Controller Area Network), PROFINET (Process Field Network), etc. [2]. Among these, Modbus has gained significant favor among industry organizations and equipment manufacturers due to its lightweight simplicity and ease of use [3]. With the increasing number of connected devices in industrial IoT, there is a growing demand for higher capacity in communication bus connections. The Modbus can connect up to 247 slave devices at once, surpassing most communication protocols, thus highlighting its high practical value. Therefore, developing a high-performance Modbus protocol conversion gateway is not only a technical challenge but also a practical necessity in the industrial field.
The Modbus protocol, developed by Modicon as a master–slave communication architecture [4], was initially designed to provide a lightweight solution for control data transmission between controllers and sensors via serial links. Modbus dominated industrial distributed control systems (DCSs) from the 1990s to the early 2000s. Although the industrial sector has gradually been migrating toward service-oriented protocols such as Open Platform Communications Unified Architecture (OPC UA) and Message Queuing Telemetry Transport (MQTT), Modbus continues to play a pivotal role at the field level, particularly for the large installed base of legacy PLCs and remote I/O devices that remain in operation [5]. Modbus RTU and Modbus ASCII—two serial-based variants of the protocol—enable efficient communication between sensor/actuator-level devices and supervisory control layers [6]. Schneider Electric later extended the protocol’s applicability through Modbus TCP, which supports heterogeneous network media [7], thereby enabling client–server communication across diverse bus systems and networked industrial devices. The Modbus protocol exhibits inherent limitations in practical implementations. Modbus RTU (serial-based) and Modbus TCP/UDP (Ethernet-based) demonstrate divergent performance characteristics [8]. Specifically, Modbus RTU suffers from lower data rates, constrained transmission distances, and complex cabling compared to its TCP/UDP counterparts. Conversely, Modbus TCP/UDP introduces packet loss vulnerabilities and reduced reliability relative to RTU, alongside challenges in cost and backward compatibility. Consequently, hybrid architectures integrating serial and Ethernet networks are often adopted [9]. While Modbus TCP enhances reliability through congestion control algorithms [10], this comes at the expense of increased latency—particularly pronounced under suboptimal network conditions where TCP latency significantly exceeds that of connectionless UDP [11,12,13]. However, as the demand for industrial automation continues to grow, higher demands are being placed on the real-time reliability of industrial networks [14,15]. The minimal protocol overhead of UDP eliminates handshake-induced delays [16], making it attractive for time-sensitive applications [17]. Yet its lack of built-in reliability mechanisms compromises communication integrity [18]. Furthermore, the protocol incompatibility between serial Modbus and Ethernet-based variants necessitates gateway-mediated protocol conversion to bridge these heterogeneous networks. The existing conversion methods include using visual tools such as Node-RED and hardware protocol conversion gateways to achieve interoperability of heterogeneous data. Node-RED is a programming tool that aggregates hardware devices, Application Programming Interface (API), and online services, enabling the exchange of heterogeneous data through logical orchestration. It plays a significant role in cross-platform human–machine interfaces (HMIs) and has been widely used in IoT systems [19]. However, its reliance on software stack results in higher latency compared to hardware protocol conversion gateways, leading to lower real-time performance. In some scenarios, this may fail to meet the high real-time requirements. Therefore, hardware conversion gateways still have an irreplaceable role to play.
Modbus gateways predominantly support protocol interconversion between Modbus TCP and RTU. From the above discussion, it is clear that under weak network conditions, TCP can exhibit higher latency compared to UDP and cannot accommodate certain high real-time scenarios, while UDP itself lacks reliability. Modbus gateways based on these transport protocols face the same challenges. This study presents a novel gateway design, enabling bidirectional conversion between Modbus UDP and Modbus RTU protocols. Leveraging the low-latency advantages of UDP, the proposed architecture introduces application-layer reliability mechanisms to enhance data transmission robustness, thereby achieving deterministic real-time performance while mitigating the inherent reliability limitations of UDP. The specific objectives encompass the following:
  • Utilizing the connectionless nature of UDP to dramatically reduce data transfer delays on the Ethernet side of the Modbus gateway in weak network conditions.
  • Adopting Markov chain model to analyze Modbus UDP transmission in depth, and proposing an improved UDP protocol, AUDP, i.e., add retransmission, data checking, and confirmation mechanism in the UDP application layer to improve the reliability of UDP transmission itself appropriately.
  • Develop a Modbus AUDP and Modbus RTU protocol conversion module, design a Modbus AUDP to Modbus RTU experimental gateway, and conduct data transmission verification tests.
  • Analyze and compare the test data using the Markov chain model to verify the performance of the experimental gateway, especially under weak network conditions.
The subsequent sections of this paper are organized as follows: Section 2 first introduces the current status of Modbus TCP gateways to highlight issues related to UDP applications. Then, we conduct a theoretical analysis of the real-time performance of Modbus TCP and Modbus UDP, demonstrating the necessity and feasibility of improving Modbus gateways. Finally, we briefly introduce the current applications and principles of Markov chains, which provide the theoretical foundation for the subsequent analyses in this paper, such as supporting the necessity of certain mechanisms in AUDP (Section 3.3.2) and offering theoretical support for the in-depth analysis of the final experimental results (Section 4.3). Section 3 introduces the methodology, including hardware design and software design, and the hardware design includes the design of the overall system framework and hardware architecture, and the software design mainly includes the design of the AUDP mechanism and protocol conversion with the help of Markov chain. Section 4 carries out the experimental validation and analyzes the experimental results based on the Markov chain. Section 5 summarizes the whole paper and looks forward to the direction of future research.

2. Related Works

2.1. Modbus Gateway

The frame structures of the three Modbus protocol variants are illustrated in Figure 1. While these protocols achieve transparent application-layer communication, their incompatibilities at the physical layer, data link layer (frame formats), and transport layer necessitate protocol conversion for cross-domain interoperability. Current research has predominantly focused on Modbus TCP-RTU interconversion. Sadik Tamboli et al. [20] designed a Modbus TCP-RTU gateway to communicate between the S7-1200 and the DSC and Controllogix parts of the system. Chang Cheng et al. [21] developed an STM32F107-based hardware platform with an RT-Thread real-time operating system, implementing protocol conversion between Modbus and Transmission Control Protocol/Internet Protocol (TCP/IP) to interconnect fieldbus networks with Ethernet. Abhay Sharma et al. [22] created a C library and socket programming framework for Modbus RTU-TCP/IP conversion. Adrian Korodi et al. [23] employed Node-RED as a protocol conversion middleware, where Modbus nodes were used to acquire field device data (e.g., PLC register values), followed by data processing (such as unit conversion and JSON formatting), ultimately publishing the transformed data as standardized information models via OPC UA nodes. Tao M et al. [24] designed a dual-line Ethernet protocol conversion gateway that converts Modbus TCP to MQTT protocol, transmits data to the Alibaba Cloud IoT Platform, and enables Modbus TCP data reception with MQTT communication. Sonia Palaguachi et al. [25] proposed an architecture for a hierarchical sensor network using the MQTT protocol for sensor data acquisition, which interacts with the MODBUS protocol to enable information transmission to SCADA systems. Tong W. et al. [26] designed a multi-protocol gateway supporting bidirectional conversion among Modbus RTU, ASCII, and TCP.
However, there is still a big gap in the research on the interoperability conversion between UDP transport and serial links and their reliability enhancement mechanisms. In particular, the research on how to maintain industrial-grade communication reliability under weak network conditions, such as high packet loss rate or out of order rate, has not been fully explored.

2.2. Temporal Properties

Currently, both domestic and international studies employ various performance metrics to evaluate fieldbus systems like Modbus, such as network utilization rate P u t i l , packet loss rate P l o s s , network efficiency P e f f , and throughput Q t h r .
The transmission delay T d e l a y of a fieldbus message is defined as follows: when the source node starts to send a request frame at the timestamp T S , the destination node receives the frame at T D 1 and immediately generates a response to send it after processing, and the source node ultimately receives the response successfully at T D 2 , and the transmission delay T d e l a y is the time interval from T S to T D 2 . It mainly consists of node’s total transmission delay T S S t , channel transmission delay T t r a n s , node reception delay T d r v , and application layer processing delay T p r o c e s s i n g . Here, T S S t includes the waiting delay T w a i t and the frame transmission delay T f r a m e , where T w a i t comprises the queuing delay at source node T q u e u e and blocking delay T b l o c k (which occurs when the transmission channel is occupied by other messages). The transmission delay model is illustrated in Figure 2 above (the upper table for each delay represents the corresponding node or direction).
Based on the transmission delay model listed in Figure 2, the following mathematical model can be listed:
T delay = T D 1 T S + T D 2 T D 1 = T D 2 T S = T SSt + T trans + T drv + T processing
In the above equation, T SSt = T queue S + T block S + T frame S + T queue D + T block D + T frame D , T trans = T trans S D + T trans D S , T drv = T drv D + T drv S , T processing = T processing D + T processing S . The total delay in message transmission for N nodes of the system to complete a periodic communication is
i N nodes j = 1 M ( i ) T delay ( i , j )
Let N be the number of nodes, N n o d e the node set, and M ( i ) the message count per node. Compared to Modbus TCP, Modbus UDP omits the three-way handshake and four-way termination, reducing the total transmission delay T d e l a y e u m in periodic N-node communication. The elimination of redundant control frames increases throughput Q t h r and network efficiency P e f f , while avoiding TCP state machine design accelerates node response and data processing.
The above analysis indicates that Modbus UDP exhibits lower latency than Modbus TCP, thereby achieving enhanced real-time capabilities in the Modbus UDP protocol.

2.3. Markov Chain

Evaluating the P l o s s and P u t i l alone as common metrics for the performance analysis of communication systems is based on static and independent event assumptions, ignoring temporal and spatial correlations. The application of a Markov chain can model the dynamic channel state and can show the temporal correlation and state transfer characteristics of the communication process, so this study analyzes the data transmission process through a Markov chain.
A Markov chain is a discrete stochastic process possessing the Markov property [27]. Formally, given a probability space ( Ω , F, P) and a sequence of random variables X = { X n : n > 0 } indexed by a countable set, where each state X n = S i belongs to state space S, the Markov property requires the conditional probability satisfies
P ( X t + 1 X t , , X 1 ) = P ( X t + 1 X t )
Then X is called a Markov chain.
In a Markov chain, the change in the state of a random variable over time steps is referred to as state transition. The state transition probability, which is the most direct and crucial value reflecting the properties of the Markov chain, is defined as
P j k ( m ) = P { X m + 1 = k X m = j }
The term P j k ( m ) represents the one-step transition probability of a system transitioning from state j at time step m to state k at the next time step. In stochastic processes, these probabilities are typically organized into a matrix form. Assuming the system has n + 1 possible states, the transition matrix P is constructed by arranging all state transition probabilities as
P n , n + 1 p i n i n + 1 = P 0 , 0 P 0 , n P n , 0 P n , n
For an irreducible and positive recurrent Markov chain, there exists a unique stationary distribution π = ( π 0 , π 1 , , π n ) [28], satisfying
π P = π , i = 1 n π ( i ) = 1
Here, π ( i ) represents the probability that the system is in state i under steady-state conditions. The first equation π P = π indicates that the steady-state distribution π is the left eigenvector of the state transition probability matrix P corresponding to the eigenvalue 1. This condition ensures the conservation of the probability distribution: once the system reaches a steady state, the probability distribution remains unchanged after any single transition step. The second equation i = 0 n π ( i ) = 1 imposes a normalization constraint on the probability distribution, guaranteeing that the sum of probabilities over all possible states equals 1. Furthermore, if the Markov chain satisfies irreducibility (all states are mutually reachable) and positive recurrence (the expected return time to any state is finite), the steady-state distribution π exists uniquely. The analytical solution for π can then be obtained by solving the system of linear equations.
In recent years, Markov chains have found extensive applications across diverse domains. Giovanni Sansavini et al. [29] developed a discrete hidden Markov mathematical model and an exponentially weighted moving average (EWMA) model to analyze and predict time delays in Wide-Area Power Systems (WAPS). These predicted delays were then fed into a predictor to mitigate the performance degradation of Load Frequency Control (LFC). Bishop J. [30] applied the Markov chain to the driving cycles. Fei Z. [31] investigated the reachable set synthesis for nonlinear delayed hidden semi-Markov jump systems with actuator saturation and multiple cyber-attacks. This study will employ Markov chains to analyze the transmission of Modbus data.
In this study, a Modbus AUDP and Modbus RTU protocol conversion experimental gateway is designed based on STM32 and W5500, and the reliability and real-time performance of Modbus data transmission based on the experimental gateway are investigated and analyzed by introducing a Markov chain.

3. System Design and Implementation

3.1. Overall Architecture

Figure 3 shows the overall architecture of the system, which is mainly composed of a W5500 Ethernet controller, STM32 microcontroller, and USART to RS485 modules.
The W5500 serves as the core for Ethernet access, integrating a 10/100 M PHY and a hardware-based TCP/IP stack that supports IPv4, TCP, UDP, Internet Control Message Protocol (ICMP), Address Resolution Protocol (ARP), and Point-to-Point Protocol over Ethernet (PPPoE). It incorporates 32 KB of dual-port SRAM for transceiver buffering and manages up to 8 independent hardware sockets simultaneously. Utilizing an Serial Peripheral Interface (SPI) bus with speeds up to 80 MHz, its low-power design features a 1.8 V core voltage and operating current below 120 mA, meeting the stringent energy efficiency requirements of industrial IoT edge devices. W5500 is bound to the designated port through the pre-configured IP address, listens to and accepts Modbus UDP data messages from the host computer, and transfers the messages to STM32 for data processing through SPI communication after the Modbus UDP messages are received. After the Modbus UDP message is received, the message is transmitted to STM32 for data processing through SPI communication, which converts the Modbus UDP message into Modbus RTU message, and then sends the Modbus RTU message to the USART to RS485 module through USART to convert the serial signal into differential signal for RS485 transmission, and then finally transmits the data to the related equipment through RS485 bus. After receiving the data, the related device generates a Modbus RTU response frame and transmits it back to the gateway through RS485 bus, and finally converts the Modbus RTU message into Modbus UDP message and sends it back to the host computer through the signal conversion, data processing, and network connection of the three modules of the gateway.

3.2. Hardware Design

Figure 4 shows the hardware architecture diagram, which includes a USART to RS485 conversion module, USART module, timer module, SPI interface module, SPI driver with DMA module, W5500 register configuration module, and data-processing module.
  • USART to RS48 Module: This is used to convert between USART signals and RS485 bus differential signals to realize the transmission between STM32 microcontroller and RS485 bus.
  • USART Module: This is composed of a software FIFO buffer, USART3 peripheral, and interrupt service mechanism. The data is captured in real-time via receive completion interrupt and stored in the FIFO. Frame termination is determined using idle interrupt. The main loop asynchronously reads FIFO data for protocol parsing/processing, enabling transceiver status monitoring and data flow scheduling.
  • TIMER2: This utilizes TIM2 to configure the auto-reload value (ARR) and prescaler (PSC) to generate timeout interrupts. It detects the end of a Modbus RTU frame transmission by measuring a 3.5-character time interval.
  • SPI Module: It comprises a SPI interface (Mode 0, 8-bit frame @18 MHz) and SPI-DMA driver with double buffering. It enables zero-CPU-overhead full-duplex data transfer between STM32 and W5500 through cyclic DMA channel configuration.
  • W5500 Register Configuration Module: The physical layer (PHY) configuration and interrupt enable of W5500 is realized through the configuration of W5500-related registers by STM32.
  • Data-Processing Module: It performs CRC-16 validation and bidirectional Modbus AUDP/Modbus RTU protocol conversion.
  • Interrupt Management Module: It handles centralized interrupt events (e.g., USART idle, SPI transfer complete, and W5500 status) with priority-based response logic via NVIC, ensuring the timely clearing of interrupt flags through hardware-level register operations.

3.2.1. STM32 Minimum System Schematic

The system adopts the STM32F103C8T6 microcontroller as the core of the gateway, and its minimum system schematic is shown in Figure 5. The system operates at 3.3 V and adopts a dual clock design: the 8 MHz main crystal provides the system clock reference, and the 32.768 kHz low-speed crystal drives the real-time clock (RTC). Both oscillator circuits are stabilized using matched capacitors to optimize performance. A push-button reset circuit ensures reliable reboot, and serial communication is realized through a USART interface, which is connected to a TTL-to-RS485 module for signal conversion. A standard JTAG debugging interface compatible with the J-Link debugger and the Keil MDK development environment is integrated for firmware programming, real-time monitoring, and debugging.
The W5500 Ethernet controller communicates with the STM32 microcontroller via SPI. As shown in Figure 6, the STM32F103C8T6’s PB12 (SCS), PB13 (SCLK), PB14 (MISO), and PB15 (MOSI) pins are directly connected to the corresponding SPI pins of the W5500, enabling seamless data exchange.

3.2.2. Power Supply Module

The USART to RS485 module operates on a 5 V power supply, incorporating a USB-powered 5 V source. For the STM32 microcontroller requiring 3.3 V operation, a dedicated 5 V to 3.3 V voltage regulator circuit is implemented to ensure stable 3.3 V output (see power supply module schematic in Figure 7).

3.2.3. Interface Conversion Module

The interface conversion module enables conversion between USART signals and RS485 differential signals, with automatic transmit/receive state switching. The USART to RS485 circuit (shown in Figure 8) employs the MAX485 chip as the converter, utilizing an NPN transistor to switch transmit/receive states. During data reception, TXD remains at a high level, turning the transistor on. This pulls the RE pin of the MAX485 to a low level (enabled), allowing the RO pin to output received RS485 bus data to the microcontroller. During transmission, TXD outputs a low level, turning the transistor off. The DE pin is then driven high to enable the transmit mode.

3.3. Software Design

The software design is divided into two modules: gateway and host computer. The gateway module is divided into the establishment of UDP communication, the design of protocol conversion, and the realization of AUDP mechanism. The host computer module is divided into data transmission and reception (via socket programming), and the realization of the AUDP mechanism. Figure 9 shows the software design framework.

3.3.1. UDP Communication

The Modbus UDP transport layer operates on UDP. As shown in Figure 10, the UDP communication workflow begins with both the client and server creating sockets via the socket() system call. The server then binds to a specific port using bind() to enable persistent listening and initialize network parameters such as the local IP address and port. The client is dynamically assigned a temporary port by the system. After generating data at the application layer, the client sends packets using sendto(), which triggers the transport layer to append a UDP header, the network layer to encapsulate the destination IP, and the data link layer to construct Ethernet frames (including MAC addresses) before transmission via the physical layer. Upon receiving data, the server decapsulates each layer sequentially, validates the data, and uses the source port in the UDP header to identify the sender and the destination port to route packets correctly. The server then calls recvfrom() to receive the validated data. Finally, both parties close the sockets via close() to release allocated ports and kernel resources.

3.3.2. Implementation of the AUDP Mechanism

To enhance the reliability of UDP-based communication, this study introduces four reliability mechanisms through an in-depth analysis of UDP transmission characteristics: (1) CRC checksum mechanism, (2) retransmission mechanism, (3) Transaction ID matching mechanism, and (4) exponential backoff mechanism.
  • Analysis of UDP Validation Mechanism
UDP employs its own checksum mechanism covering the IP pseudo-header, UDP header, and data fields using a 16-bit 1’s complement summation algorithm, with an undetected error probability denoted as P U D P u n d e t e c t e d :
P undetected UDP = 1 2 16 1.53 × 10 5
In the high-noise environment, where the channel bit error rate reaches up to 10 4 , relying solely on the UDP transport layer’s checksum mechanism severely weakens the error detection capability. Numerous corrupted packets caused by channel interference may go undetected and reach the application layer directly, ultimately triggering unpredictable anomalies in the receiver’s business logic. However, with the addition of a CRC-16 checksum at the application layer, the total undetected probability becomes P u n d e t e c t e d u n d e t e c t e d :
P undetected total = P undetected UDP × P undetected CRC = 1 2 16 × 1 2 16 = 1 2 32 2.33 × 10 10
The undetected error probability has been significantly reduced.
Therefore, this study implements dual-layer validation at both the transport and application layers by appending a two-byte CRC-16 checksum to the end of the Modbus UDP frame as illustrated in Figure 11. After the data is transmitted to the gateway, the received CRC checksum (denoted as ’receive_CRC’) is extracted from the Modbus UDP frame. A new CRC calculation is performed on the data to derive the ’caculate_CRC’. If ’receive_CRC’ matches ’caculate_CRC’, this confirms that the data integrity has been preserved during transmission.
  • Analysis of Retransmission Mechanism
A Markov chain model is constructed for the UDP-based transmission process, where S 1 , S 2 , and S 3 denote the waiting-for-response state, success state, and failure state, respectively. The corresponding state transition probability matrix P is defined as
P = 0 1 β β 1 0 0 γ 0 1 γ
where β is the probability that the request is waiting for a timeout, and γ is the probability that the failure state triggers a retransmission. After the retransmission is introduced, S 2 retransmits the request with probability γ and maintains the failure state with 1 − γ . According to Equation (6), the stationary distribution ( π 1 , π 2 , π 3 ) satisfies ( π 1 , π 2 , π 3 ) P = ( π 1 , π 2 , π 3 ) , where π 2 represents the long-term probability of the system being in the success state, and its value is provided in Equation (10):
π 2 = γ ( 1 β ) β + γ
Figure 12 illustrates the variation of steady-state success rate π 2 with timeout probability β and retransmission probability γ . When β 0 and γ 1 , π 2 approaches 1; conversely, when β 1 or γ 0 , π 2 decreases significantly. This demonstrates that the retransmission mechanism is essential to ensure reliability.
Consequently, this study implements a retransmission mechanism at the application layer of UDP to enhance the reliability of Modbus UDP transmissions.
  • Analysis of Transaction ID Matching Mechanism
Assuming that the transmission process conforms to the Markov property, the following three assumptions are made: (1) After each transmission, the system waits for a response with a timeout period set to T seconds. (2) The network exhibits random delays, and the response arrival time follows a probability density function f ( t ) , and f ( t ) follows an exponential distribution. (3) The network has a P l o s s rate p, where each transmission request is lost with probability p, necessitating retransmission.
A logical error occurs when the delayed response of request n arrives after the timeout period and is incorrectly matched to the subsequent request n + 1 . The probability that the response delay to request n exceeds T is
P delay = T f ( t ) d t
If the response to request n exceeds the timeout period T, and request n + 1 is transmitted within the time window [ T , T + δ t ] , the response n may be incorrectly attributed to request n + 1 . Assuming the request interval is a fixed period τ , the probability of erroneous matching is given by
P error = P delay · Δ t τ Δ t U ( T , T + τ ) 1 2 P delay
Assume each request can be retransmitted up to N times with a retransmission interval of T seconds, where retransmitted requests carry identical payloads to the original request but lack Transaction ID. The response to the k-th retransmission may be erroneously matched to any subsequent request by the error-prone mechanism. Let P delay denote the probability that the response delay exceeds T for both the original request and each retransmission. The total erroneous matching probability P error _ total is then given by
P error _ total = k = 0 N P delay k + 1 · 1 2 = 1 2 P delay 1 P delay R + 1 1 P delay
When Transaction IDs are implemented, the correct matching criteria are defined as follows: (1) Each request is assigned a unique Transaction ID, and a response must carry the matching Transaction ID to be accepted. (2) Let the bit length of the Transaction ID be b, then the ID space size is R = 2 b . (3) Erroneous matching occurs only if the response Transaction ID coincidentally matches the currently pending request ID.
Assuming the ID collision probability caused by malicious attacks or coincidental matches is 1 R , the error probability per individual request becomes
P error _ id = 1 R
For N retransmissions, the total error probability is expressed as
P error _ total = k = 0 N P delay k + 1 · 1 2 = 1 2 P delay 1 P delay R + 1 1 P delay
When 1 R 1 , Equation (17) can be approximated using the Taylor expansion formula:
P error _ total _ id N + 1 R
For b = 16 and R = 2 16 , assuming ( P d e l a y = 0.1), substituting the parameters into Equations (13) and (16) yields a total erroneous matching probability of P error _ total 5.55 % without Transaction ID, while the implementation of Transaction ID reduces this probability to P error _ total _ id 0.0061 % . The significant disparity between P error _ total and P error _ total _ id ( P error _ total P error _ total _ id ) demonstrates that embedding a Transaction ID matching mechanism at the application layer over UDP is essential to enhance transmission reliability, even with timeout-based retransmissions already in place.
According to the above derivation, a 16-bit Transaction ID is assigned to each packet to match the request and response, and the request sent by the upper computer is resent if it does not receive the uplink message from the slave device within the specified time to prevent the loss of the request frame. Referring to the Transaction ID verification mechanism of Modbus TCP, the MBAP of Modbus TCP is transplanted to Modbus UDP (as shown in Figure 11), the request and response matching mechanism is added to Modbus UDP at the application layer, an incremental Transaction ID is generated before each request to ensure the uniqueness of the request, and the request is sent to the gateway. When sending to the gateway, the gateway will record the Transaction ID, and then append it to the Modbus UDP response frame. When the host computer parses the response, it will extract the Transaction ID and verify it. If the request frame is consistent with the Transaction ID in the response frame, it means that it is a valid response; otherwise, it enters the retransmission mechanism.
  • Analysis of Transaction ID Matching Mechanism
To reduce the network load and increase the probability of retransmission, the program waits for a period before each retransmission, with an initial waiting time ‘ base _ delay ’, and doubles the waiting time after each retry.
By integrating the analysis of the UDP validation mechanism, retransmission mechanism, Transaction ID matching mechanism, and exponential backoff mechanism, and to reduce the computational load on the gateway, the reliability mechanism is implemented through collaboration between the host computer and the gateway. Figure 13 shows the schematic diagram of the Modbus AUDP reliability mechanism.

3.3.3. Protocol Conversion Design

For the conversion from Modbus AUDP to Modbus RTU, after the W5500 Ethernet controller receives Modbus AUDP data, it stores the data into the data reception buffer RX_Buffer in the STM32 via SPI communication. For UDP communication based on the W5500 Ethernet controller, the 8-byte header Figure 14 must be skipped before protocol conversion to enable data decapsulation and encapsulation. Upon entering the formal conversion process, the first step is to ensure the received data length is at least 18 bytes (8 bytes UDP header + 7 bytes MBAP header + at least 1 byte PDU + 2 bytes CRC). If the length requirement is met, retain the CRC from the received Modbus UDP frame, perform CRC validation on the remaining data, and compare the result with the retained CRC. If they match, proceed to the next step. Subsequently, extract the MBAP header (bytes 9 to 15), record the Transaction ID from the MBAP header, verify whether the protocol identifier (bytes 11–12) is 0, extract the Unit ID (byte 15) as the Modbus RTU address code, copy the remaining bytes after the Unit ID, and finally append a CRC to complete the conversion from Modbus AUDP to Modbus RTU. The converted data is then transmitted via serial port to the downstream device.
For the conversion from Modbus RTU to Modbus AUDP, after the gateway receives the RTU response frame via the serial port, it performs CRC validation to verify data integrity. The RTU response frame is then decomposed into Slave Address + PDU + CRC Code. The CRC is removed, retaining the Slave ID and PDU. The Slave Address and the previously recorded Transaction ID are used to construct the MBAP header of the Modbus UDP. The PDU portion of the RTU frame is appended to the MBAP header, followed by a CRC calculation on the combined MBAP+PDU data. The resulting CRC is appended to form the complete Modbus UDP frame. This completes the conversion from Modbus RTU to Modbus AUDP, and the data is transmitted back to the upper-level device via the RJ45 Ethernet port. The gateway’s data-processing flowchart and frame encapsulation flowchart are shown in Figure 15 and Figure 16, respectively.

3.3.4. Implementation of the Host-Side Software

Python 3.12.0 boasts mature Modbus open-source libraries (e.g., pymodbus) that can be directly utilized for Modbus communication implementation, significantly reducing the development cycle. Furthermore, Python 3.12.0 ’s rich graphics libraries (e.g., Matplotlib and Tkinter) facilitate user interface design, while its scientific computing ecosystem (e.g., NumPy and Pandas) supports efficient integration with data-processing tools. Consequently, the Modbus data transmission, reception, and processing modules on the host computer are implemented using Python 3.12.0. Figure 17 shows the flowchart of the host computer program. The host sends read register requests to the gateway, and the device returns current data values upon response. The system continuously cycles through the ’send request–receive response–update interface’ process. The user interface, implemented in Python 3.12.0 and running on the host computer, updates and displays the retrieved contents of holding registers in real-time. For example, when the host computer sends a Modbus read holding register request via Python 3.12.0, the slave device receives the request, generates a response frame, and transmits it back to the host, after which the interface dynamically reflects the acquired data. When monitoring is manually stopped, the system safely terminates communication threads and closes the network interfaces to release resources.

4. Experimental Results and Analysis

This section establishes a Request–Response Latency mathematical model and derives the Average Latency delay model using mathematical expectation. Experimental analysis based on both models demonstrates the following: (1) A comparative analysis of the Request–Response Latency between network-side TCP and UDP transmissions reveals comparable real-time performance under non-degraded network conditions, while TCP exhibits significantly higher latency than UDP in weak network conditions. (2) In-depth analysis of Modbus AUDP data transfer processes under weak network conditions, leveraging the Average Latency model and Markov Chain, determines the optimal value of N m a x . (3) Comparative analysis of AUDP and UDP transmissions under weak network conditions provides systematic validation of Modbus AUDP’s real-time responsiveness and transmission reliability. Figure 18 is the photograph of the designed gateway prototype used for experimental testing.

4.1. Request–Response Latency and Average Latency Modeling

Request–Response Latency is defined as the total time from the transmission of a request frame to the completion of response reception, and its components are shown in Equation (17):
Request - Response Latency = R T T + t processing + T out × N
where RTT (Round-Trip Time) and t p r o c e s s i n g represent the round-trip channel latency and application-layer processing time during the final successful retransmission, respectively. T o u t denotes the timeout period: if the host fails to receive a response within T o u t , the retransmission mechanism is triggered, with N being the number of retransmission failures.
During data frame transmission, the randomness of packet loss and retransmission mechanisms leads to probabilistic variations in actual latency across frames. To analyze the overall system performance, expectation must be introduced to model the Average Latency. The Average Latency is defined as the mean value of the total time from sending a request frame to fully receiving its response, which includes the Round-Trip Time (RTT), application processing time t p r o c e s s i n g , and T o u t . Let k be the number of retransmissions required before successful transmission, and let p represent the probability of transmission failure. The probability of success at the k + 1 attempt equals the product of the failure probabilities of the first k retransmissions and the success probability of the ( k + 1 ) -th retransmission. The expected number of Retransmissions is derived as
E ( K ) = k = 1 N max k × p k ( 1 p )
Each retransmission introduces a timeout period, and the expectation E [ K ] represents the average retransmission count. Therefore, by defining D a v g as the Average Latency, the Average Latency can be expressed as
D avg = R T T + t processing + T out × E ( K ) = R T T + t processing + T out × k = 1 N max k × p k ( 1 p )

4.2. Comparison of TCP-Based and UDP-Based Transmission on the Network-Side

To conduct real-time analysis of Modbus UDP and Modbus TCP, data transmission/reception tests were performed for both protocols under ideal conditions (0% packet loss rate and 0% out-of-order rate) and weak network conditions (30% P l o s s rate and 10% out-of-order rate simulated by the weak network simulation tool Clumsy). Latency is measured through Python and Wireshark packet capture: while Python sends requests and receives responses, Wireshark captures the packets; then the Modbus packets captured by Wireshark are filtered out and exported in ‘csv’ format; and finally the exported ’csv’ file is imported into Python to calculate the latency.
Figure 19a shows the Request–Response Latency comparison between 100 Modbus UDP and Modbus TCP requests sent to the slave device under ideal conditions. Figure 19b,c display the packet capture results of 100 Modbus TCP and Modbus UDP requests sent to the gateway under weak network conditions, while Figure 19d compares their Request–Response Latency.
Figure 19a reveals that under ideal conditions, the Request–Response Latency of TCP-based and UDP-based transmissions is nearly identical, with a difference below 1 ms. Figure 19b–d demonstrate that under weak network conditions, UDP-based transmission exhibits smaller latency fluctuations, whereas TCP-based transmission suffers from frequent congestion control mechanism triggers. This results in the Request–Response Latency of Modbus UDP transmissions remaining stable at approximately 5 ms, while the latency for Modbus TCP packet transmissions exhibits significant instability.
Therefore, Modbus UDP demonstrates significant advantages over Modbus TCP in real-time performance under weak network conditions.

4.3. Modbus AUDP Gateway Analysis

As illustrated in Figure 20, the transmission and reception results of Modbus AUDP data under weak network conditions demonstrate that the gateway successfully processed the data. The sender appended a CRC checksum ‘d95c’ to the Modbus UDP request frame, while the gateway generated a corresponding checksum ‘dcec’ for the response frame, implementing dual-layer validation at both the transport and application layers. Furthermore, the application layer ensured data integrity through a Transaction ID matching mechanism: each request was assigned a unique Transaction ID, and responses were validated by matching the Transaction ID during parsing. Upon receiving a response, the system extracted and compared the Transaction ID; only when the ID matched was the response deemed valid, triggering data updates. Retransmission mechanisms were activated immediately upon initial request timeout, dynamically adjusting retry intervals using an exponential backoff algorithm to mitigate network congestion. As shown in the figure, the request successfully retrieved data during the second retransmission interval.
For the Modbus data transmission process under AUDP, let S 0 denote the waiting to send state, S 1 the packet sending state, S 2 the waiting for response state, S 3 the successful reception state, S 4 the retransmission state, and S 5 the communication failure state. The state transitions are illustrated in Figure 21:
Assume each retransmission is independent, with identical success probabilities and no differentiation between retransmission attempts. As shown in Figure 21, any state can transition to another within finite steps, and each state returns to itself in finite expected time. Thus, the system is irreducible and positive recurrent, implying the existence of steady-state probabilities analyzable via Markov chains. Based on Figure 21, the state transition matrix can be constructed as follows:
P = 0 P 01 0 0 0 0 0 0 P 12 0 0 0 0 0 0 P 23 P 24 0 P 30 0 0 0 P 43 0 0 0 0 P 43 0 P 45 P 50 0 0 0 0 0
Substituting the state transition matrix P into the general balance condition Equation (6), the steady-state balance equations are derived as follows:
π 0 = π 3 P 30 + π 5 P 50 π 1 = π 0 P 01 π 2 = π 1 P 12 π 3 = π 2 P 23 + π 4 P 43 π 4 = π 2 P 24 , π 5 = π 4 P 45 i = 0 5 π i = 1
The maximum retransmission count N m a x directly affects the system’s steady-state probabilities. In a network environment with a 20% P l o s s rate, experiments were conducted by transmitting 1000 data frames under different N m a x values. From Figure 18, P 01 = P 12 = P 30 = P 50 = 1, P 43 = 1 − P 45 , P 23 =1 − P 24 . Simplify the above equation to obtain Equation (22):
π 0 = 1 4 + P 24 π 1 = π 2 = π 0 π 3 = π 0 ( 1 P 24 P 45 ) π 4 = π 0 P 24 π 5 = π 0 P 24 P 45 i = 0 5 π i = 1
The steady-state probabilities are determined by the probability of entering retransmission ( P 24 ) and the probability of retransmission failure ( P 45 ) under a packet loss rate of 20% (the experimental values of P 24 and P 45 are listed in Table 1). The steady-state probabilities of each state corresponding to each N m a x are statistically analyzed, with the results summarized in Table 1:
As detailed in Table 1, the steady-state probabilities π 0 , π 1 , π 2 , and π 3 —corresponding to the core communication phases of waiting to send, packet sending, waiting for response, and successful reception—remain nearly constant (23.5–23.6%) as N max increases. This stability indicates that, under the given network conditions, the system spends the majority of its operational time cycling through these essential states, with their combined probability consistently exceeding 93.8%. Such a distribution reflects the protocol’s efficiency and the effectiveness of its retransmission mechanism in maintaining normal operation. The probability of being in the retransmission state ( π 4 ) remains below 6.1% across all tested N max values, suggesting that retransmissions are infrequent and well-managed, thus preventing excessive network congestion. Most notably, the probability of entering the communication failure state ( π 5 ) decreases sharply as N max increases, dropping from 0.36% at N max = 1 to just 0.006% at N max = 6 . This trend demonstrates the significant benefit of allowing more retransmission attempts, as it greatly reduces the likelihood of unrecoverable failures. However, as derived in Equation (19), it is important to note that while increasing N max enhances reliability, it may also lead to increased average transmission delay. Therefore, a practical upper limit of N max = 6 is adopted to balance reliability and latency. In summary, the steady-state analysis in Table 1 quantitatively confirms that the proposed AUDP-based transmission system achieves high reliability and efficiency under weak network conditions, with the vast majority of time spent in controllable states.
To further determine the optimal N M A X , this study employs the entropy weight method to evaluate N M A X [ 1 , 6 ] through composite scoring. The parameters P 24 , P 45 , π 4 , and π 5 are selected as negative indicators, while π 3 (successful reception probability) and π 0 + π 1 + π 2 + π 3 (cumulative probability of essential operational states) serve as positive indicators.
First, normalize the positive and negative indicators:
X i j norm = max ( X j ) X i j max ( X j ) min ( X j ) Negative Indicator X i j norm = X i j min ( X j ) max ( X j ) min ( X j ) Positive Indicator
where X j and X i j represent the value of indicator j in Table 1 and the value of indicator j when N M A X = i, respectively.
Next, calculate the weight values using the following formula:
f i j = x i j norm i = 1 m x i j norm e j = 1 ln n i = 1 m f i j ln f i j d j = 1 e j w j = d j j = 1 n ( 1 e j )
The optimal N M A X is determined through three phases.
e i j and f i j denote the information entropy and proportion of the j-th indicator in Table 1, d j is the differentiation coefficient, n is the sample count, and w j is the weight of the j-th indicator. Take the negative indicator P 24 as an example:
(1)
Normalize it: Substitute into Equation (23) the values of item P 24 under different N max in Table 2, where max ( x j ) = 25.6 % and min ( x j ) = 23.5 % , and x i j is the value to be normalized. The calculated normalized results for item P 24 are
X i , P 24 norm = { 0.4286 , 1.0000 , 0.8571 , 0.3333 , 0.3809 , 0 } .
(2)
From (1), obtain the information entropy e j of item P 24 and the proportion f i j of P 24 at different N max ; the results are
f i j = { 0.1429 , 0.3333 , 0.2857 , 0.1111 , 0.1270 , 0.0001 } ,
so
e j = 1 ln n f i j ln f i j = 0.8532 .
(3)
According to Equation (21),
d j = 1 e j = 0.1468 , w j = d j j = 1 n ( 1 e j ) = 20.55 % .
The same applies for P 45 , π 3 , π 4 , π 5 , and π 0 + π 1 + π 2 + π 3 , and the calculation results are given in Table 2.
Finally, compute the comprehensive score for each N m a x via weighted summation using the following formula:
S i = w j × x i j norm
From Table 3, the highest score is obtained when A = 2. Therefore, the maximum retransmission count in the gateway application layer is set to N m a x = 2.

4.4. Network-Side Comparison of AUDP-Based and UDP/TCP-Based Transmission

After integrating reliability mechanisms into the application layer of Modbus UDP (Modbus AUDP) with the retransmission count N m a x set to 2, a P l o s s rate of 30%, and a out-of-order rate of 10%, the Request–Response Latency slightly increased to approximately 17 ms as shown in Figure 22a. Despite this increase, Modbus AUDP’s latency remains significantly lower than that of TCP-based transmission (Figure 22b).
Under a reduced P l o s s of 20% ( N m a x = 2, no out-of-order rate), 1000 Modbus UDP request were transmitted. As shown in Figure 22c, the communication failure rate of Modbus UDP gateway is 22.6% (95% CI: 20.1–25.3%), whereas that of Modbus AUDP gateway decreases to 0.3% ( P 45 ) at N max = 3 , and the steady-state probability of S 5 also remains at a very low level. The failure rate of Modbus AUDP gaeway is consistently below the lower bound of Modbus UDP gateway’s confidence interval (CI), indicating a significant improvement in reliability.

5. Conclusions

The Modbus AUDP-RTU gateway proposed in this study significantly reduces the communication delay and effectively solves the problem of the low communication reliability of UDP. The modeling analysis of UDP transmission based on Markov chain provides theoretical support for system performance optimization, and the experimental results show that the success rate of data transmission after applying AUDP is increased to more than 98% compared with 77.4% of Modbus UDP-RTU, and the real-time performance is also significantly improved compared with Modbus TCP-RTU, which proves the advantages of the AUDP mechanism in terms of reliability and real-time performance. The proposed Modbus AUDP-RTU gateway offers significant practical value for IoT applications, enabling the efficient and reliable real-time monitoring and control of equipment in real-world factory settings. This solution not only helps enterprises reduce upgrade costs and improve operational efficiency but also lays a solid foundation for the large-scale adoption of Industry 4.0 technologies.
Future research will focus on optimizing the AUDP retransmission mechanism and refining state transition models to achieve adaptive retransmission capabilities. This includes dynamically adjusting maximum retransmission attempts based on network conditions while expanding the gateway’s protocol support to align with Industry 4.0 and IoT standards. In particular, the integration of OPC UA will be considered to enable semantic interoperability and secure machine-to-machine communication through its information modeling and encryption features, while the adoption of MQTT will facilitate lightweight publish–subscribe messaging, optimize bandwidth usage, and support efficient cloud-edge synchronization in IoT environments. These enhancements are expected to bridge legacy Modbus systems with modern industrial frameworks, thereby improving both real-time reliability and cross-platform scalability. In addition, we will also explore the introduction of a Modbus multi-master mechanism to integrate a multi-master coordination framework, enabling orderly concurrency of multiple services while maintaining compatibility with existing Modbus devices.

Author Contributions

Conceptualization, S.Z.; methodology, S.Z. and Q.Z. (Qinghai Zhang); software, S.Z.; validation, S.Z., Q.Z. (Qingjian Zhao) and S.L.; formal analysis, S.Z., X.Z. and Q.Z. (Qinghai Zhang); investigation, S.Z. and Q.Z. (Qingjian Zhao); resources, Q.Z. (Qinghai Zhang), Y.G. and L.S.; data curation, S.Z.; writing—original draft preparation, S.Z.; writing—review and editing, Q.Z. (Qinghai Zhang) and S.Z.; visualization, Q.Z. (Qinghai Zhang), Y.G. and Z.Z.; supervision, Q.Z. (Qinghai Zhang), Y.G. and Z.Z.; project administration, Q.Z. (Qinghai Zhang), Y.G. and Z.Z.; funding acquisition, Q.Z. (Qinghai Zhang), Y.G. and Z.Z. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Open Fund Project of Shandong Key Laboratory of Space Debris Monitoring and Low-orbit Satellite Networking, NO.CK-2024-0049.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The data in this paper is obtained from real control experiments. Because the laboratory test data is not publicly available, if there is a need for them, contact the corresponding author.

Acknowledgments

The authors acknowledge all contributors to this paper. We also extend our gratitude to the editors and reviewers for their constructive feedback on the manuscript.

Conflicts of Interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

References

  1. Calderón, D.; Folgado, F.J.; González, I.; Calderón, A.J. Implementation and Experimental Application of Industrial IoT Architecture Using Automation and IoT Hardware/Software. Sensors 2024, 24, 8074. [Google Scholar] [CrossRef] [PubMed]
  2. Bożek, A.; Rzonca, D. Communication Time Optimization of Register-Based Data Transfer. Electronics 2023, 12, 4917. [Google Scholar] [CrossRef]
  3. Elamanov, S.; Son, H.; Flynn, B.; Yoo, S.K.; Dilshad, N.; Song, J. Interworking between Modbus and internet of things platform for industrial services. Digit. Commun. Netw. 2024, 10, 461–471. [Google Scholar] [CrossRef]
  4. Martins, T.; Oliveira, S.V.G. Enhanced Modbus/TCP Security Protocol: Authentication and Authorization Functions Supported. Sensors 2022, 22, 8024. [Google Scholar] [CrossRef] [PubMed]
  5. Figueroa-Lorenzo, S.; Añorga, J.; Arrizabalaga, S. A Role-Based Access Control Model in Modbus SCADA Systems. A Centralized Model Approach. Sensors 2019, 19, 4455. [Google Scholar] [CrossRef]
  6. Găitan, V.G.; Zagan, I. Experimental Implementation and Performance Evaluation of an IoT Access Gateway for the Modbus Extension. Sensors 2021, 21, 246. [Google Scholar] [CrossRef]
  7. Lin, M.-Y.; Chen, C.-H.; Dong, Z.-B.; Chen, C.-C. Gigabit Modbus user datagram protocol fieldbus network integrated with industrial vision communication. Microprocess. Microsyst. 2022, 94, 104682. [Google Scholar] [CrossRef]
  8. Pandey, B.; Farulla, G.A.; Indaco, M.; Iovino, L.; Prinetto, P. Design and review of water management system using ethernet, Wi-Fi 802.11 n, modbus, and other communication standards. Wirel. Pers. Commun. 2019, 106, 1677–1699. [Google Scholar] [CrossRef]
  9. Hao, Z.; Asadullah, A.; Wawale, S.; Das, S. Application of modbus double-layer communication network technology in intelligent management of urban traffic equipment. Int. J. Syst. Assur. Eng. Manag. 2022, 13, 197–202. [Google Scholar] [CrossRef]
  10. Lorincz, J.; Klarin, Z.; Ožegović, J. A Comprehensive Overview of TCP Congestion Control in 5G Networks: Research Challenges and Future Perspectives. Sensors 2021, 21, 4510. [Google Scholar] [CrossRef]
  11. Lu, S.; Liming, W. Design of embedded system for high-speed data transmission in distributed testing based on UDP/IP protocol. Nucl. Electron. Detect. Technol. 2014, 34, 750–753+779. [Google Scholar] [CrossRef]
  12. Yu, X.; Gan, W.y.; Chu, Z.z. Design and implementation of Modbus UDP based AUV control system. Proc. SPIE 2023, 12940, 8. [Google Scholar] [CrossRef]
  13. Park, T.; Lee, K. Supporting ultra-low latency mixed-criticality communication using hardware-based data plane architecture. J. Netw. Comput. Appl. 2022, 204, 103401. [Google Scholar] [CrossRef]
  14. Gao, M.; Wan, L.; Shen, R.; Gao, Y.; Wang, J.; Li, Y.; Vucetic, B. SparkLink: A short-range wireless communication protocol with ultra-low latency and ultra-high reliability. Innovation 2023, 4, 100386. [Google Scholar] [CrossRef] [PubMed]
  15. Chi, H.R.; Wu, C.K.; Huang, N.F.; Tsang, K.F.; Radwan, A. A survey of network automation for industrial internet-of-things toward industry 5.0. IEEE Trans. Ind. Inform. 2022, 19, 2065–2077. [Google Scholar] [CrossRef]
  16. Zheng, H.; Boyce, J. An improved UDP protocol for video transmission over internet-to-wireless networks. IEEE Trans. Multimed. 2001, 3, 356–365. [Google Scholar] [CrossRef]
  17. Pai, V.U.; Mehta, N.B.; Singh, C. Novel Insights From a Cross-Layer Analysis of TCP and UDP Traffic Over Full-Duplex WLANs. IEEE Trans. Mob. Comput. 2025, 24, 3288–3301. [Google Scholar] [CrossRef]
  18. Mahmoodi Khaniabadi, S.; Javadpour, A.; Gheisari, M.; Zhang, W.; Liu, Y.; Sangaiah, A.K. An intelligent sustainable efficient transmission internet protocol to switch between User Datagram Protocol and Transmission Control Protocol in IoT computing. Expert Syst. 2023, 40, e13129. [Google Scholar] [CrossRef]
  19. Chen, C.-Y.; Wu, S.-H.; Huang, B.-W.; Huang, C.-H.; Yang, C.-F. Web-based Internet of Things on environmental and lighting control and monitoring system using node-RED, MQTT and Modbus communications within embedded Linux platform. Internet Things 2024, 27, 101305. [Google Scholar] [CrossRef]
  20. Tamboli, S.; Rawale, M.; Thoraiet, R.; Agashe, S. Implementation of Modbus RTU and Modbus TCP communication using Siemens S7-1200 PLC for batch process. In Proceedings of the 2015 International Conference on Smart Technologies and Management for Computing, Communication, Controls, Energy and Materials (ICSTM), Avadi, India, 6–8 May 2015; pp. 258–263. [Google Scholar] [CrossRef]
  21. Cheng, C.; Huiming, W.; Hongling, L. Design of embedded gateway for Modbus protocol based on STM32F107 platform. Intergrated Circuit Embed. Syst. 2018, 18, 48–52. [Google Scholar]
  22. Sharma, A.; Airan, S.; Shah, D. Designing C Library for MODBUS-RTU to CANBUS and MODBUS-TCP IOT Converters. In Proceedings of the 2021 Second International Conference on Electronics and Sustainable Communication Systems (ICESC), Coimbatore, India, 4–6 August 2021; pp. 731–737. [Google Scholar] [CrossRef]
  23. Korodi, A.; Silea, I. Achieving interoperability using low-cost middleware OPC UA wrapping structure. Case study in the water industry. In Proceedings of the 2017 IEEE 15th International Conference on Industrial Informatics (INDIN), Emden, Germany, 24–26 July 2017; pp. 1223–1228. [Google Scholar] [CrossRef]
  24. Ma, T.; Yu, H.; Peng, D.; Sun, H. Design of a Modbus TCP-MQTT Protocol Conversion Gateway Based on Dual-Line Ethernet. Appl. Electron. Tech. 2023, 49, 108–113. [Google Scholar] [CrossRef]
  25. Sacoto Cabrera, E.J.; Palaguachi, S.; León-Paredes, G.A.; Gallegos-Segovia, P.L.; Bravo-Quezada, O.G. Industrial Communication Based on MQTT and Modbus Communication Applied in a Meteorological Network. Available online: https://link.springer.com/chapter/10.1007/978-3-030-63665-4_3 (accessed on 15 June 2025).
  26. Tong, W.; Zhang, E.; Shen, J.; Jiang, W.; Li, Z. Modelling and Conversion of Heterogeneous Modbus Protocols Based on UML and MySQL. In Proceedings of the 2024 4th International Conference on Artificial Intelligence, Big Data and Algorithms, Zhengzhou, China, 21–23 June 2024; pp. 654–660. [Google Scholar] [CrossRef]
  27. Vekslerchik, V.E.; Melnik, S.S.; Pritula, G.M.; Usatenko, O.V. Correlation Properties of Additive Linear High-Order Markov Chains. In Proceedings of the 2018 9th International Conference on Ultrawideband and Ultrashort Impulse Signals (UWBUSIS), Odessa, Ukraine, 4–7 September 2018; pp. 150–155. [Google Scholar] [CrossRef]
  28. Kuntz, J.; Thomas, P.; Stan, G.B.; Barahona, M. Stationary distributions of continuous-time Markov chains: A review of theory and truncation-based approximations. Siam Rev. 2021, 63, 3–64. [Google Scholar] [CrossRef]
  29. Mo, H.; Sansavini, G. Hidden Markov model-based smith predictor for the mitigation of the impact of communication delays in wide-area power systems. Appl. Math. Model. 2021, 89, 19–48. [Google Scholar] [CrossRef]
  30. Bishop, J.; Axon, C. Using natural driving experiments and Markov chains to develop realistic driving cycles. Transp. Res. Part 2024, 137, 104507. [Google Scholar] [CrossRef]
  31. Fei, Z.; Wu, Z.; Zhao, X.; Zong, G.; Lin-Shi, X. Reachability-Guaranteed Sliding-Mode Control for Asynchronously Switched Uncertain Systems. IEEE Trans. Autom. Control 2025, 70, 921–932. [Google Scholar] [CrossRef]
Figure 1. Modbus RTU, Modbus TCP, and Modbus UDP frame structure.
Figure 1. Modbus RTU, Modbus TCP, and Modbus UDP frame structure.
Sensors 25 03861 g001
Figure 2. Transmission delay model.
Figure 2. Transmission delay model.
Sensors 25 03861 g002
Figure 3. System overall architecture diagram.
Figure 3. System overall architecture diagram.
Sensors 25 03861 g003
Figure 4. Hardware architecture diagram.
Figure 4. Hardware architecture diagram.
Sensors 25 03861 g004
Figure 5. STM32 minimum system.
Figure 5. STM32 minimum system.
Sensors 25 03861 g005
Figure 6. SPI communication.
Figure 6. SPI communication.
Sensors 25 03861 g006
Figure 7. Power supply module circuit.
Figure 7. Power supply module circuit.
Sensors 25 03861 g007
Figure 8. USART to RS485 circuit.
Figure 8. USART to RS485 circuit.
Sensors 25 03861 g008
Figure 9. Software architecture diagram.
Figure 9. Software architecture diagram.
Sensors 25 03861 g009
Figure 10. UDP communication workflow.
Figure 10. UDP communication workflow.
Sensors 25 03861 g010
Figure 11. Modbus UDP frame structure.
Figure 11. Modbus UDP frame structure.
Sensors 25 03861 g011
Figure 12. Surface plot of the effect of β and γ on π 2 .
Figure 12. Surface plot of the effect of β and γ on π 2 .
Sensors 25 03861 g012
Figure 13. Schematic diagram of the Modbus AUDP reliability mechanism.
Figure 13. Schematic diagram of the Modbus AUDP reliability mechanism.
Sensors 25 03861 g013
Figure 14. UDP data received by W5500.
Figure 14. UDP data received by W5500.
Sensors 25 03861 g014
Figure 15. Gateway data-processing flowchart.
Figure 15. Gateway data-processing flowchart.
Sensors 25 03861 g015
Figure 16. Data encapsulation flowchart.
Figure 16. Data encapsulation flowchart.
Sensors 25 03861 g016
Figure 17. Flowchart of the host computer program.
Figure 17. Flowchart of the host computer program.
Sensors 25 03861 g017
Figure 18. Photograph of the designed gateway prototype used for experimental testing.
Figure 18. Photograph of the designed gateway prototype used for experimental testing.
Sensors 25 03861 g018
Figure 19. (a) Comparison of Request–Response Latency between UDP-based and TCP-based transmissions under 0% packet loss and 0% out-of-order conditions. (b) Packet capture diagram of UDP-based transmission under weak network conditions. (c) Packet capture diagram of TCP-based transmission under weak network conditions. (d) Comparison of Request–Response Latency between UDP-based and TCP-based transmissions under weak network conditions.
Figure 19. (a) Comparison of Request–Response Latency between UDP-based and TCP-based transmissions under 0% packet loss and 0% out-of-order conditions. (b) Packet capture diagram of UDP-based transmission under weak network conditions. (c) Packet capture diagram of TCP-based transmission under weak network conditions. (d) Comparison of Request–Response Latency between UDP-based and TCP-based transmissions under weak network conditions.
Sensors 25 03861 g019
Figure 20. Data transmission and reception diagram.
Figure 20. Data transmission and reception diagram.
Sensors 25 03861 g020
Figure 21. State transition diagram.
Figure 21. State transition diagram.
Sensors 25 03861 g021
Figure 22. (a) Comparison of Request–Response Latency between UDP-based and AUDP-based transmissions under weak network conditions. (b) Comparison of Request–Response Latency between TCP-based and AUDP-based transmissions under weak network conditions. (c) Failure rate comparison of Modbus UDP and AUDP gateways with 20% P l o s s .
Figure 22. (a) Comparison of Request–Response Latency between UDP-based and AUDP-based transmissions under weak network conditions. (b) Comparison of Request–Response Latency between TCP-based and AUDP-based transmissions under weak network conditions. (c) Failure rate comparison of Modbus UDP and AUDP gateways with 20% P l o s s .
Sensors 25 03861 g022
Table 1. Statistical table of steady-state probabilities.
Table 1. Statistical table of steady-state probabilities.
N max P 24 P 45 π 0 = π 1 = π 2 π 3 π 4 π 5 π 0 + π 1 + π 2 + π 3
124.7%6.2%23.55%23.19%5.82%0.36%93.84%
223.5%1.3%23.62%23.54%5.55%0.07%94.4%
323.8%0.3%23.61%23.58%5.64%0.02%94.39%
424.9%0.2%23.55%23.53%5.82%0.01%94.18%
524.8%0.2%23.55%23.53%5.85%0.01%94.18%
625.6%0.1%23.50%23.49%6.02%0.006%93.99%
Table 2. Calculation results of key parameters.
Table 2. Calculation results of key parameters.
Configuration e j d j w j
NMMS_ p 24 0.85320.146820.55%
NMMS_ p 45 0.90300.097013.57%
NMMS_ π 3 0.90320.096813.55%
NMMS_ π 4 0.86020.138019.30%
NMMS_ π 5 0.90330.096713.53%
NMMS_ π 0 + π 1 + π 2 + π 3 0.86070.139319.50%
Table 3. Comprehensive scores and rankings based on the entropy weight method.
Table 3. Comprehensive scores and rankings based on the entropy weight method.
N max Comprehensive Score ( S i )Ranking
10.18026
20.94621
30.93192
40.65593
50.66334
60.43745
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Zhao, S.; Zhang, Q.; Zhao, Q.; Zhang, X.; Guo, Y.; Lu, S.; Song, L.; Zhao, Z. Enhancing Bidirectional Modbus TCP ↔ RTU Gateway Performance: A UDP Mechanism and Markov Chain Approach. Sensors 2025, 25, 3861. https://doi.org/10.3390/s25133861

AMA Style

Zhao S, Zhang Q, Zhao Q, Zhang X, Guo Y, Lu S, Song L, Zhao Z. Enhancing Bidirectional Modbus TCP ↔ RTU Gateway Performance: A UDP Mechanism and Markov Chain Approach. Sensors. 2025; 25(13):3861. https://doi.org/10.3390/s25133861

Chicago/Turabian Style

Zhao, Shuang, Qinghai Zhang, Qingjian Zhao, Xiaoqian Zhang, Yang Guo, Shilei Lu, Liqiang Song, and Zhengxu Zhao. 2025. "Enhancing Bidirectional Modbus TCP ↔ RTU Gateway Performance: A UDP Mechanism and Markov Chain Approach" Sensors 25, no. 13: 3861. https://doi.org/10.3390/s25133861

APA Style

Zhao, S., Zhang, Q., Zhao, Q., Zhang, X., Guo, Y., Lu, S., Song, L., & Zhao, Z. (2025). Enhancing Bidirectional Modbus TCP ↔ RTU Gateway Performance: A UDP Mechanism and Markov Chain Approach. Sensors, 25(13), 3861. https://doi.org/10.3390/s25133861

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Article metric data becomes available approximately 24 hours after publication online.
Back to TopTop