Inspirel banner

100kB Message Broker

Embedded systems want to be distributed, too

The C programming language is not (yet) dead.

This is the lesson that we have learned when a user wanted to use YAMI4 in his embedded system. This idea is not entirely new and we have already seen YAMI4 working on Raspberry Pi, for example. It is just more and more obvious that embedded systems want to be distributed, too. There are plenty of reasons to do it, from measurement acquisition to collaborative decision making - whatever the use-case, embedded systems can benefit from the ability to exchange messages and the network-related features that are more and more prevalent on such platforms just make it more and more feasible and appealing.

The problem is that not all embedded platforms are equally comfortable with regard to development environment - in particular, there exist platforms that have limited support for the C++ compiler toolchain. The bare availability of C++ compiler is not enough for the software that operates on the border between user code and system API and YAMI4 belongs to this category expecting at least properly defined POSIX header files. What if these are not available? What if the vendor still believes that C is the only programming language and provides header files that are more or less OK with regard to the API that they provide, but fail to comply with expectations of C++ users? Proper definitions of NULL or some standard types like size_t is what can make or break the compilation of C++ software, even if the software itself is written to the highest standards of quality.

Sadly, there is usually no chance to get the fix from the platform vendor in a reasonable time. In addition to the problems with C++ there were also challenges related to the use of Ada in the broker implementation. The solution to all those issues was to... translate the codebase (well, at least the parts that are relevant for the message broker) to C.



The effect of translating the message broker with the underlying core library to C is an additional YAMI4 package, available for download from the project homepage. There is nothing special about the fact that it just works, but after doing all the translation work we have realised that the resulting binary is quite small. It was not surprising - the fact that no C++ nor Ada run-time support code was referenced meant that the binary had to be smaller than original. But what was nice to see is that the complete YAMI4 broker could fit in a single, statically linked 100kB file.

Yes, just 100kB. The exact value on the target platform will of course depend on the compiler that is used, but this is the range of size that is achievable on a typical Linux or Mac machine. Stripping can push the limits even further, down to 80kB. Check on your target platform for the actual value.

... and functionally complete

Is such a small message broker useful?

Yes, there is no cheating, this is a complete reimplementation of the original broker, which offers the following features:

Since the broker was built on top of the core library, some fundamental features of the core are available in the broker as well:

This last feature is a strong point of the YAMI4 core library and was meant from the very beginning to support the development of embedded distributed systems as well as those systems where high reliability is the requirement. This feature is ready to be used, although its activation will need a minor and local modification of the broker source code.

Is it the smallest message broker on the market?

We have no idea :-) but if you are designing your next embedded system with distribution in mind then the YAMI4 C package should be on your radar. Are you looking for a small and lightweight messaging solution with the message broker that was actually made for such deployments? Let's talk.

Did you find this article interesting? Share it!

Bookmark and Share