MQTT-SN Performance Measurement in OMNeT++ and INET

MQTT-SN network diagram showing two publishers, a central broker, three subscribers, tags, and performance metrics.

MQTT-SN performance measurement involved two challenges: preserving packet metadata and collecting message statistics.

A Master’s Thesis Challenge

Several years have passed since my master’s thesis, yet some details of the project are still imprinted in my memory. One of the problems I faced at the time turned out to be harder than expected, and solving it allowed me to move forward with the work.

The interesting thing is that, after all this time, another person ran into the exact same difficulty and reached out to me on LinkedIn to ask for clarification. Without getting too long-winded, I would first like to tell you about the context.

MQTT-SN Performance Metrics

The thesis was about implementing the MQTT-SN protocol in C++ using the OMNeT++ simulator and the INET framework. After verifying that the application was working correctly, the goal was to evaluate the QoS levels provided by the protocol and measure performance in a simulated wireless network through specific metrics.

In this model, one or more publishers sent messages to the broker, which forwarded them to interested subscribers following the publish-subscribe pattern. For simplicity, I will focus on just two metrics: the end-to-end delay, i.e., the time elapsed between sending and receiving, and the share of messages actually received at the destination, referred to in the project as the Hit Rate.

The requirement was to keep the behavior of the protocol separate from the collection of measurements. In particular, I needed to attach additional information to each packet in transit across the network, such as the timestamp of sending or a unique identifier, without altering the format of the messages or affecting their size. Furthermore, it was necessary to maintain counters to perform final aggregations.

Although tied to the same goal, I tackled the two issues separately, adopting a distinct approach for each.

INET Region Tags for Packet Metadata

Let’s start now with the first problem: finding a way to attach metadata to MQTT-SN messages, all without altering how the protocol operates.

INET’s tags fully met this need. I chose this exact solution because it was a feature already available in the framework, well documented, and established.

Going into more detail, the official guide distinguishes between two types of tags: packet tags and region tags.

The former are associated with the packet as a whole and are used, among other things, to pass information between network stack layers. The issue is that these tags do not cross node boundaries, since they are removed prior to transmission. In my case, this was a limitation: I needed the metadata to stay associated with the messages along the entire path from the publisher to the subscriber.

The second type of tag solved this exact problem. In fact, region tags can associate information with the data contained inside the packet and, most importantly, maintain that association along the simulated path. INET itself documents this solution for measuring end-to-end delay.

I want to emphasize that, in both cases, tags are not transmitted as part of the bytes actually sent over the network. Between the two, what changes is simply how INET manages this metadata at the simulation level.

That said, to apply this solution I used both tags already available in INET and a custom tag. For the timestamp I used CreationTimeTag, while for the unique identifier I defined IdentifierTag, extending the base class inet::TagBase. To learn more, you can check the tag attachment code in my GitHub repository.

Message Counters and OMNeT++ Signals

As mentioned earlier, the other issue concerned counting the MQTT-SN messages sent by publishers and received by subscribers. In this case, it was necessary to distinguish between local counters, which tracked messages for each instance, and global counters, which considered all instances. For the latter, I used static member variables in the MqttSNClient base class, accessible to derived classes like publishers and subscribers.

It was a simple and effective solution that, considering the time constraints back then, I decided to adopt. I remember, however, having also evaluated OMNeT++ signals, a publish-subscribe mechanism that lets modules emit information to interested listeners, separating who produces the information from who collects it.

The adopted solution carried a tighter coupling between protocol logic and metric collection. Signals, on the other hand, would have allowed for a more flexible and reusable solution, although they would have required a different approach to managing statistics. As often happens, this choice was also a compromise: in hindsight, I would probably choose the second solution today, precisely for the greater decoupling it offers.

References

To conclude, I’ll leave you with a few references to dive deeper into the project and technologies used:

Thanks for reading!