# Rethinking Modbus-UDP for Real-Time IIoT Systems
## 4 Experimental Results
### Round-Trip Time  
The round-trip time of a Modbus transaction is defined as the total time it takes for a request to travel from the master to the slave and the corresponding response from the slave to go back to the master. Being an endpoint-to-endpoint layer-7 delay, it also includes the protocol stack execution time on both the master and slave sides, plus any additional time the slave may need to execute the command it received from the master before it sends its response back. It has been selected for the experiments because it is the most relevant metric to evaluate the performance of a master/slave protocol like Modbus. In fact, it directly affects the throughput it may achieve in terms of transactions and bits per second. Moreover, when the protocol is used to support a real-time control algorithm, its mean value represents the mean latency of data I/O from sensors and to actuators. Finally, its standard deviation, along with its minimum and maximum values, determine average and worst-case sensing and actuation jitter and are directly related to communication timing determinism. Figure 6: TCP and UDP payload throughput, 100 Mb/s full-duplex Ethernet link, iperf3, 60 s measurement window. Figure 7 contains the Modbus-TCP and Modbus-UDP round-trip time histograms generated from \(n=10\),000 samples for data transfers from the slave to the master (RH transactions) and vice versa (WM transactions) as a function of the number of registers \(N\) exchanged. Sub-plots (a) and (b) pertain to Modbus-TCP, while (c) and (d) are for Modbus-UDP. The value \(N=1\) has been chosen because it maximizes protocol overheads, while the values \(N=60\) and \(N=120\) provide information on the influence \(N\) has on the round-trip time as it approaches the maximum number of registers the aforementioned transactions support. The histogram bin width was set to \(100\,\mathrm{\SIUnitSymbolMicro s}\). The corresponding summary information is listed in Table 3. For each test case, from left to right, the table lists the mean round-trip time (\(\mu\)), its standard deviation (\(\sigma\)), and the minimum/maximum values observed during the test. The values of \(\mu\) and \(\sigma\) were calculated from histogram data, so they are affected by the inherent discretization error that corresponds to a bin width of \(100\,\mathrm{\SIUnitSymbolMicro s}\). Moreover, all samples that fell out of the histogram range were attributed to its highest bin. The first conclusion that can be drawn from the histograms is that \(N\) has negligible influence on the round-trip time regardless of the communication protocol. This was to be expected because, when \(N\) goes from 1 to 120, the length of the UDP datagrams or TCP segments to be transmitted increases by \((120-1)*2\,\mathrm{B}=238\,\mathrm{B}=1904\,\mathrm{b}\) due to the fact that each Modbus register is 2 B in size. Hence, at a link speed of \(100\,\mathrm{Mb}/\mathrm{s}\), the additional datagram or segment transmission time is merely \(1904\,\mathrm{b}/100\,\mathrm{Mb}/\mathrm{s}=19.04\,\mathrm{\SIUnitSymbolMicro s}\). This value amounts to about 3.9% of the minimum round-trip time recorded across all experiments, \(490\,\mathrm{\SIUnitSymbolMicro s}\). Figure 7: Modbus-TCP and Modbus-UDP round-trip time histograms for RH and WM transactions as a function of \(N\), the number of registers exchanged. Negligible link error probability, \(n=10\),000 samples per plot. The second much more important observation is that \(\mu_{\text{UDP}}\), the mean round-trip time of Modbus-UDP, is consistently less than 38% of \(\mu_{\text{TCP}}\), the mean round-trip time of Modbus-TCP. Indeed, the maximum \(\mu_{\text{UDP}}\) is 609.60 us and the minimum \(\mu_{\text{TCP}}\) is 1613.60 us, leading to a worst-case ratio of 609.60/1613.60 = 0.38. The fact that Modbus-TCP performs significantly worse than Modbus-UDP is corroborated by the comparison between the maximum (worst) round-trip times observed during the experiments.