Google protobuf at run-time deserialization example in C++

Lately I have been looking at Google’s format for interchanging data between multiple processes or Protocol Buffers. As you would expect for an inter-process data format Protocol Buffers are supported on different platforms and implementations are available for most popular programming languages. An interesting example of such a platform is the stm32l1 micro controller, which is supported by a third party protobuf implementation named nano pb.

One of the interesting feats of Google’s C++ protobuf implementation is that it supports deserializing arbitrary protobuf objects at run-time. As long as the proto definition is known at run time, the library is capable of parsing any message back into the individual fields from the proto definition. This is especially useful in situations where a program has to be able to handle proto definitions that are unknown at compile time. In this case the standard approach of using the proto compiler (protoc) to construct C++ class definitions, writing (de)serialization code and linking the resulting program with these definitions is obviously not possible.

This post addresses the lack of examples that demonstrate this ‘at run-time deserialization’ feature of Google’s C++ protobuf implementation. The example below was constructed by combining the protobuf unit tests with this example provided by . It has been tested with the v3.0.0-beta-3 from Google’s github repo. Use at your own discretion. The example should be self explanatory.
Continue reading “Google protobuf at run-time deserialization example in C++”

Cross compiling C projects with external dependencies: Click modular router and the Raspberry PI


At IBCN – my research group – we rely on Click router for implementing and evaluating various Internet communication protocols. Click is a modular software router in C++ that was developed at the end of the last century by Eddie Kohler and others at MIT (the original research paper is available here). Apart from the IP routing functionality that ships with Click, we’ve added a CoAP implementation that has been widely tested at ETSI Plugtest interoperability events. We also have a working 6LoWPAN implementation that was tested inĀ  at last year’s summer IETF in Berlin. Lately, we’ve also added DTLS integration via CyaSSL. Continue reading “Cross compiling C projects with external dependencies: Click modular router and the Raspberry PI”