Networking

IoT Architecture

"IoT" isn't one protocol or one product — it's a handful of layers working together: a device, optionally a gateway, a cloud platform, and the applications built on top. Everything else in this notebook — sensors, protocols, security — is a piece that slots into one of these layers.

Quick reference
What it is
A layered system: device → (gateway) → cloud platform → application, with telemetry flowing up and commands flowing down.
Mental model
Not "a protocol" — a supply chain for data, where each layer's job is to move it one step closer to something a human or another system can act on.
Key numbers
4 layers typically; two data directions (telemetry up, commands down) that need separate thinking.
Reach for it when
Designing anything beyond a single standalone device — the moment more than one device needs to be seen or managed centrally.

The layered architecture

Device, gateway, cloud platform, and application layers, with telemetry flowing up toward the application and commands flowing back down toward the device telemetry (device → cloud) commands (cloud → device) Device sensors, actuators, MCU Gateway edge compute (optional) Cloud Platform registry, broker, rules Application dashboards, analytics A gateway aggregates several devices, translates protocols, and can run inference locally — see Snap → Ubuntu Core's inference-snap pattern.
Not every system needs a gateway layer — plenty of devices connect straight to the cloud platform — but the telemetry-up / commands-down split applies either way.

The device layer is everything covered in Electronics, Sensors, and Embedded — this page picks up where those leave off, once the device is ready to talk to the outside world.

Device provisioning and identity

Before a device can participate in any of this, it needs a unique, cryptographically verifiable identity — otherwise the cloud platform has no way to know which physical device a given message came from.

Factory provisioning
A unique certificate/key is generated and installed during manufacturing — the most secure option, since the credential never travels over an untrusted channel after that point.
Just-in-time provisioning
A device authenticates with a shared "bootstrap" credential on first connect, and the platform issues it a unique certificate at that point — lower manufacturing complexity, but the bootstrap credential itself becomes something worth protecting.

OTA updates

Over-the-air firmware updates are usually the single most operationally important piece of a fleet's software lifecycle — see The Complete Boot Process for the bootloader-level mechanics (A/B partitions, bootargs pointing at whichever is current) and Snap types & Ubuntu Core for a full OS built around exactly this update model. At the fleet level, the concerns are different: staged rollouts (update 1% of devices before 100%), the ability to halt a bad rollout mid-flight, and bandwidth-conscious delta updates rather than shipping a full firmware image to every device on every change.

Telemetry vs. commands

It's worth treating these as genuinely separate design problems, not one "communication channel":

Device shadows / digital twins

A device shadow (AWS IoT's term) or digital twin (the more general term) is a cloud-side cached copy of a device's last-known state and desired state. It matters because devices aren't always connected: an application can read or even set the "desired" state of an offline device against its shadow, and the device applies that desired state the next time it reconnects — without the application ever needing to know or care whether the device was online at the moment the request was made.

Choosing a protocol at each layer

ProtocolBest fit here
CoAPIndividually constrained devices talking to a gateway, or directly to a CoAP-aware backend
MQTTDevice-to-cloud telemetry and command fan-out at fleet scale — the most common device-to-cloud choice
AMQPBehind the cloud platform itself, routing ingested device data to the right internal services
HTTPSApplication-layer APIs, dashboards, and anything device-to-cloud that isn't latency- or power-sensitive

Security, end to end

A real IoT deployment needs security at every layer, not just one: TLS/mTLS for the connection itself, unique per-device identity (above) so a compromised device can be individually revoked, and secure/verified boot so the device's own firmware can't be silently replaced by something malicious in the first place. Any one of these alone is a partial defense — a stolen shared credential defeats TLS just as completely as no TLS at all.

Real-world applications

For this same layering traced through one real device — two independent protocol adapters, a shared local bus, and a single cloud uplink — see Project-Based Example.

Gotchas

Field notes