GNU Radio ZeroMQ Block Enhancements

Since some time this summer, GNU Radio has merged gr-zeromq into the mainline master branch, these handy I/O blocks have since then provided nice mappings to allow GNU Radio stream ports to use a library called ZeroMQ as a network transport layer for distributing stream items between processes, or between separate processing nodes over a network layer. This is a great addition beyond the original GNU Radio socket based blocks as it provides additional features such as session re-establishment, point to multi-point distribution, and some other message passing models for I/O.
Over this winter break I finally had a bit of free time to finishing working on some enhancements for these blocks which I started working on this year at the GNU Radio Conference 2014 hack-fest. These are elaborated below.

Stream Tag Passing Support

The first major addition to these blocks was the ability to transport stream-tags over ZMQ connections along with the raw stream item contents. This is a major help when working with distribution of GNU Radio flowgraphs as it allows stream tags to be preserved over network connections or between processes with minimal effort allowing them to be generated in one application, and referenced or consumed in a completely separate application elsewhere. In order to introduce stream tag passing support for ZMQ stream connections in GNU Radio, we introduce a new ZMQ message header which encodes a small header, stream offset, and any stream tags within the relevant range. The PMT library’s serialization capability is used to map it into a raw buffer and to recover the PMT data structure upon reception. As can be seen in the simple example below, this successfully allows for tags to be preserved as expected.

The two example graphs below show one flowgraph generating a stream with a sinuoid, a stream to tagged stream block appending a “packet_len” tag to this stream every 1024 items, and then a ZeroMQ Publish sink block to end the waveform.   The second waveform begins with a ZeroMQ Subscribe source block which receives the stream and tags from the other waveform, and sends the output to a QTGui frequency plot sink where we can see the sine wave is in tact, and a tag debug block where we can see the tags are making it through the connection ok!

Stream Tags over ZMQ Connection
GNU Radio ZeroMQ Tagged Stream + Sinusoid Passing Example

Message Passing Support

The second new addition was simply to introduce a new set of message passing blocks which simply allowed the transport of GNU Radio message connections over the primitive ZeroMQ transport interfaces. In contrast to the stream port versions of these blocks, the implementation is quite trivial involving simply the serialization of a single GR Message PMT type into a ZMQ message and the inverse operation upon reception. No additional buffers or context is required since a single PMT constitutes a message between GNU Radio blocks.

The simple example below shows a message strobe block sending a single pmt string/symbol containing “TEST” through a ZeroMQ publish/subscribe message block to a message debug block once every second.

GNU Radio ZMQ Message Passing Example
GNU Radio ZeroMQ Message Passing Example

Until this work is approved and merged, it is available from my github branch at