A Study of Iot MQTT Control Packet Behavior and Its Effect On Communication Delays
A Study of Iot MQTT Control Packet Behavior and Its Effect On Communication Delays
A Study of Iot MQTT Control Packet Behavior and Its Effect On Communication Delays
MOBMU-311
© 2017, Society for Imaging Science and Technology
MQTT Network
The MQTT network was designed with flexibility in mind.
The layout enabled multiple publisher and subscriber nodes at
Figure 4 TSERI Labs Publish/Subscribe Nodes
geographically separated locations to connect simultaneously to
the AWS EC2 Mosquito Broker. The system operated in a live
Python MQTT network traffic environment to achieve an accurate representation
Python is open source software utilized by the Eclipse PAHO of real world conditions. Wireshark collected TCP and MQTT
project to implement MQTT protocols [20]. In this experiment, traffic at the client nodes, while TSHARK collected the same type
Python code was used to publish and subscribe to topics from a of traffic at the broker.
Raspberry Pi.
Elastic Compute Cloud (EC2)
Amazon Web Services (AWS) offers a cloud based compute
platform called Elastic Compute Cloud (EC2) [18] which is used
as the server for this project. This compute instance was launched
with Ubuntu Sever 16.04 and hosts the Eclipse Mosquitto™
broker used to implement the MQTT v3.1.1 protocol over a TCP
connection.
Windows Platform Systems
Four Windows based systems were used to perform
publishing and subscribing duties. A Windows 7 platform
computer referred to as TSERI Labs is located on campus at
UTSA, while two Windows 10 platform desktops, referred to as
the pink box and the black box, are geographically separated from
the TSERI Lab. A fourth Windows 10 laptop is used to access
the Mosquitto™ Broker for coordinating TShark network traffic
captures. All the Windows based systems contain the LabVIEW
Publisher and Subscriber VIs designed for this experiment, as
well as Wireshark for network traffic analysis.
Raspberry Pi Figure 5 MQTT Network Architecture
A Raspberry Pi is used as a publisher and subscriber [19],
implementing the Python based MQTT API created by the Eclipse
PAHO project [20]. Sensor Network
The sensor network gathered environmental information and
Vaisala Weather Transmitter reported the data to the myRIO. From that point, the publisher
Vaisala WXT520 Weather Transmitter offers six weather software residing on the myRIO organized and published the data
parameters including wind speed and direction, precipitation, to which clients could then subscribe. This data was captured and
atmospheric pressure, temperature and relative humidity [26]. stored for use with this study. The VIs created to run on the
The WXT520 outputs to serial data collected by the myRIO using Windows systems used in this study, accessed the data captured
RS-232 interface. from the sensor network and published to the MQTT Network.
Pyranometer
Kipp and Zonen CMP11 Pyranometer is a “radiometer
designed for measuring short-wave irradiance on a plane surface”
[27]. This pyranometer’s micro-Volt output is amplified to a 4-
20mA signal. Using a translation table, the analog signal is
converted to irradiance prior to publishing. The analog signal is
captured and processed by the myRIO.
myRIO
National Instruments myRIO is an embedded hardware
device with multiple, configurable, digital and analog IO [28].
This device gathers and formats all the sensor network data prior
to publishing. Sample data gathered in the field by this device is
used in the experiment.
Figure 6 Sensor Network Architecture
QoS-0 or Qos-1 with asynchronous publication. Figure 9 two sections; delay at the node, and round trip time. From the
demonstrates this behavior as the published data was held perspective of the sending node, RTT includes the delay at the
constant at 238 Bytes, while the publishing interval was decreased receiving node as well as the propagation delay to send data and
from 65ms to 5ms. The IRTT was recorded at 62.5ms and the receive the corresponding acknowledgement. Having described
Maximum Segment Size (MSS) negotiated by the TCP was 1460 the publishing behavior for QoS-0 and Qos-1 with a sliding
Bytes. It is shown that the segment length is broken up at 10ms window, the remaining experiments include an examination of
due to the segment exceeding the MSS. IRTT to set a baseline delay pattern, testing the effects of packet
length on delay, and an analysis of delay in the presence of heavy
Measuring Delay network traffic.
Visually, the measured delay involved in the process of
sending and receiving packets at the Client and Server is shown Initial Round Trip Time (IRTT) Test
in Fig. 10. The packet capture software is used will capture two As previously stated, the initial round trip time is recorded
packets per publish interval in normal network conditions. These when the Client establishes a connection with the Server by way
packets include the published data and either the MQTT or TCP of the TCP three-way handshake. Through deep packet
acknowledgement. In the special case of QoS-2 multiple packets inspection, the IRTT has potential to be a good indication of
will be sent in the exchange between the client and server as connection latency and may be used to establish a baseline for
discussed in section 2.3. The calculated delay will be split up into measuring delay shifts during an MQTT session. The IRTT test
performed for this study involved a TCP connection loop in which allows Jumbo frames [33] with a MSS value of 8960 established
a connection was established and then terminated at two second by the Server. Packet inspection revealed that indeed the limits
intervals. Each connection and termination cycle required a 6- per publishing interval rest at roughly 8 Kbytes and breaching this
packet exchange. 10,000 packets were captured, yielding ≈ 1600 limit leads to unpredictable behavior and data loss.
IRTT samples per test. The tests were performed at the TSERI Determining a round trip time for QoS-0 proves difficult due
labs and Pink Box locations to establish reference points for each to the lack of a MQTT acknowledgment from the Server. A TCP
node with the intention of illustrating that the propagation acknowledgment is sent from the Server however, and it provides
difference two geographically separated nodes might experience a close approximation to the round-trip time when the publishing
has a minimal effect on the distribution of the IRTT. Figure 11 interval is greater than two times the IRTT. At publishing
establishes the IRTT distributions for both Clients. Outliers intervals near or below the IRTT threshold, these
totaling less than 10% of the data sets were removed from both acknowledgments become less reliable. The Server, to maximize
distributions using the five number summary method [30]. efficiency, begins to stack acknowledgements which increases the
Though the propagation delay of IRTT is different in time at the difficulty of accurately measuring delays. QoS-1 with
nodes, the distribution over the median yields a similar curve from asynchronous publication can yield similar results below the
both locations; however, the spread of the data collected at the IRTT threshold, though reliable data can be gathered due to the
Pink Box location was slightly larger than that of the TSERI Labs MQTT acknowledgement requirement.
location. A deviation calculation was performed on the data to For this test, quality of service levels examined were
justify the use of the TSERI Labs node over that of the Pink Box published at an interval of 65ms. This interval was chosen for
node for the remaining tests as a more stable connection could reasons previously discussed in sections 5.2.1 and 5.3.1. QoS-0
reduce error in delay interpretation and calculation. Median and QoS-1 with asynchronous publication display the stacking
absolute deviation was used as it is considered a more robust behavior detailed in section 5.2.1 due to contributory increases in
method for handling outliers in a univariate data set [31]. Table both Dtransmission and Dqueuing. In this state, instability increases
1 shows the median absolute deviation along with the median for producing variations in the delay of the system. This pattern
each location. continues until the TSERI Labs MSS is exceeded at which point
the RTT stabilizes due to the delay in the system reaching a level
TABLE I. Robust measure of variability in IRTT of process equilibrium as seen in Figure 12.
QoS-1 with synchronous publication was held to the same
publishing interval of 65ms, though publishing interval in this
Median and Deviation Table of IRTT situation only sets the minimum as the next MQTT packet will
not be published until the previous packet has been
Median Median Absolute acknowledged. This eliminates the variable delay patterns caused
Client IRTT (s) Deviation by increases to Dqueuing since the queue never exceeds one MQTT
Pink Box 0.08911979 0.007440069 packet.
In this circumstance, delay for QoS-1 with synchronous
TSERI Labs 0.06247810 0.000901661
publication remains remarkably stable while the MQTT packet is
kept below the MSS as seen by the RTT distribution in Fig. 13
(top). As the packet length exceeds the MSS, the distribution of
Published Packet Length Trial delay shifts to a less predictable pattern shown in Fig. 13 (bottom).
The packet length test involves changing the published packet This is due in large part to the processing of the packets at the
size from 40 Bytes to roughly 9 KBytes. While the MQTT Server. While the MQTT packet length is held below the TSERI
standard allows control packets of up to 256MB in length, the Lab’s MSS, the TCP and MQTT acknowledgements are
Ethernet standard breaks this down even further to a maximum combined into a single ACK; however, packet inspection reveals
transmission unit (MTU) at 1500 Octets [32]. The AWS Server a separation of the TCP and MQTT acknowledgements when the
MQTT packet length exceeds the MSS. This is caused by the measured at the Server. Figure 14 (top) shows the distribution of
increased processing time required by the MQTT broker to the delay before the increased traffic, while Fig. 14 (bottom)
examine and acknowledge the receipt of the larger MQTT displays the shifted delay distribution recorded as the network
packets. In this scenario, the TCP ACK is followed by the MQTT traffic was increased.
PUBACK reducing efficiency at the Server and increasing traffic The results of the network traffic test are promising in that
in the channel. they display a perceived shift in the established delay pattern.
The packet length test revealed a good candidate for Using a combination of MSS load balancing, IRTT, and expected
establishing a predictable delay pattern that can be used to detect deviations, one could conceivably create a reactive monitoring
shifts in delay during live sessions. QoS-1 with synchronous system used to report unexpected behavior based on an expected
publication (a sliding window set to size one) and a MQTT packet distribution.
length set below the smallest established MSS results in a stable
and controllable system that may allow for reactive monitoring of Conclusion and future work
the delay. This paper presents an approach to establish an expected
Network Traffic Trial delay pattern for MQTT based communications which could be
used to enable live reactive monitoring of an MQTT connection.
Network traffic tests were performed using multiple nodes to
Through deep packet inspection the relationships between data
generate traffic to the server. The test involved publishing a fixed
payload to the Server from a single node, and then gradually size, data collection intervals, network traffic, and its effect on
adding traffic to the server. Packets were captured at the Client delay were examined. It was shown that the initial round trip time
(IRTT) established during the TCP three-way hand shake can give
of interest, as well as the Server. This method allows a
a reliable estimation for the propagation delay of the connection,
comparison of delay measured at the Client, to traffic (in Bytes)
which in turn can be used to establish a baseline for expected delay
Figure 13 QoS-1 RTT for Synchronous Publication; Packet Length<MSS (top), Packet Length >MSS (bottom)
in a connection. Through experimentation we demonstrated that [3] OpenFMB. 2016 [cited 2016 02 November]; Available from:
shifts in the distribution of the expected delay are measurable using http://www.sgip.org/openfmb/
the combined application of MSS load balancing, IRTT, and
[4] Idell Hamilton, T. “CPS Energy seeking partners to test “grid of
expected deviations. These shifts may indicate session integrity,
the future” and bring more value to customers.” 2014 [cited 2016
security, as well as generalize the overall health of the connection. 02 November]; Available from:
Use of this proposed method to improve sensor network http://newsroom.cpsenergy.com/grid-of-the-future/.
designs in a publish/subscribe communication environment was a
goal of this project. We hope that this research provides some [5] Al-Fuqaha, A., Mohsen, G., Mohammadi, M., “Internet of Things:
insight into the development of Smart Grid IoT communications A Survey on Enabling Technologies, Protocols, and Applications.”
in situations where MQTT and sensor networks play an important IEEE Communications Surveys & Tutorials, 2015. 17(4): p. 2347-
role. 2376.
Further research into nodal behavior regarding the processing [6] Al-Fuqaha, A., Mohsen, G., Mohammadi, M., "Toward better
of MQTT packets and delay effects caused by transport protocol horizontal integration among IoT services." IEEE Communications
behavior at the node would be a future goal. This requires a more Magazine, 2015. 53(9): p. 72-79.
detailed investigation of individual MQTT packets at both the
Client and the Server nodes. We believe a thorough study on [7] Beckmann, K. and O. Dedi. "sDDS: A portable data distribution
recovering from packet loss, and the impact the recovery has on service implementation for WSN and IoT platforms." in Intelligent
delay and throughput would provide a useful comparison of Solutions in Embedded Systems (WISES), 2015 12th International
MQTT to other IoT protocols for use in large-scale senor Workshop on. 2015.
networks. We would also like to further investigate modeling [8] Fernandes, J.L., Lopes, I.C., Rodrigues, J., Ullah, S., "Performance
ideal, scalable, remote sensor network designs for the MQTT evaluation of RESTful web services and AMQP protocol." 2013
protocol to optimize performance and reduce data loss. Fifth International Conference on Ubiquitous and Future Networks
(ICUFN), 2013: p. 810-815.
Acknowledgment [9] Lee, S., Kim, H., Hong, D., Ju, H., "Correlation analysis of MQTT
This project and the preparation of this paper were funded in part loss and delay according to QoS level." The International
by monies provided by CPS Energy through an agreement with Conference on Information Networking 2013 (ICOIN), 2013: p.
the University of Texas at San Antonio. 714-717.
© CPS Energy and the University of Texas at San Antonio
[10] Luzuriaga, J.E., Perez, M., Boronat, P., Cano, J.C., Calafate, C.,
Support for this project was also provided in part by Texas Manzoni, P., "A comparative evaluation of AMQP and MQTT
Sustainable Energy Research Institute. protocols over unstable and mobile networks." 2015 12th Annual
IEEE Consumer Communications and Networking Conference
(CCNC), 2015: p. 931-936.
References
[1] Goel, S., Bush, S., Bakken, D, “IEEE Vision for Smart Grid [11] Thangavel, D., Ma, X., Valera, A., Tan, H.X., Tan, C.K.Y.,
Communications: 2030 and Beyond.” 2013. "Performance evaluation of MQTT and CoAP via a common
middleware." Intelligent Sensors, Sensor Networks and
[2] Laval, S. and B. Godwin, “Distributed Intelligence Platform (DIP)
Information Processing (ISSNIP), 2014 IEEE Ninth International
Reference Architecture, in Vision Overview”, S. Laval, Editor.
Conference on, 2014: p. 1-6.
2015, Duke Energy.