mudRPC, gRPC for unstable networks

gRPC for the Internet of Things

gRPC for the Internet of Things is gRPC’s service model on devices that cannot hold a connection, cannot afford an HTTP/2 stack and may be a week between contacts: sensors, meters, trackers and gateways, each a .proto with calls and events.

An IoT device is defined by what it lacks: memory for a TLS and HTTP/2 stack, a link that is up when the service wants it, a clock that is right. mudRPC’s peer is built for those constraints. It is a no_std library with no allocation and no crates, measured by the gate as a Cortex-M firmware links it and run on two boards under QEMU; its block is fourteen kilobytes on a leaf, the device’s own, saved to flash and restored with an epoch the device raises on every boot, so a reboot, a clone or a re-flash is a provisioning event the fleet can see, not a replay it can suffer. Time is an input: the device gives its uptime in seconds, and no wall clock is needed for any of the security.

Messages fit the links devices have: a sealed packet of at most 512 bytes over UDP, a cellular datagram, a LoRa frame or a serial line to a gateway. A call carries a ttl of up to a week, so a sensor that wakes once a day answers the calls that waited for it and sees the ones that did not; an event is a publish to a topic, no reply, for telemetry the gateway listens to. A gateway is a peer like any other, a hub shape that believes a fleet of 256 signed senders, and the operator’s counters, rollbacks, floods, dropped and managed, saturate and survive restores, so the fleet’s health is readable without a connection to each device.

The cloud side is a product in whatever language the service already is, with the generated gRPC code unchanged and the channel line swapped, as From gRPC shows per language; the device side is C over mudrpc.h, C++, Rust or a board’s firmware, with mud gen writing thin stubs from the same .proto where protoc is too heavy. Over the air it is gRPC over LoRa and mesh radio; on a site network, gRPC over UDP. demos/sensors is this page’s program in every language: two sensors publishing readings to a gateway that calibrates one.

This page belongs to gRPC without HTTP/2; the home page has the five-minute start.