Fleets: Connectivity, Telemetry and Trace Correlation

A robot that loses its Wi-Fi can find its own root cause, fail over to cellular and keep reporting, where a monitoring alert can only page a human at 2 a.m.

Learn how a fleet of robots stays reachable on networks you do not own, what it should send home, how to update it without bricking it, and how to line up events from many machines whose clocks disagree.

Pick a fault, then turn the detection timer. Watch the robot find the cause and move to cellular. Then we build, piece by piece, every part of that state machine.

You need a rough idea of what Wi-Fi and a server are. We build the rest from zero: sockets, timers, clocks, rollouts.

Built from primary sources, listed in the Field Guide: the Linux kernel documentation, the MQTT 5.0 specification, W3C Trace Context, OpenTelemetry, Lamport’s 1978 paper and the Google SRE Workbook.

Break the robot’s network

3

A model, not a real robot. Timers are illustrative: one heartbeat every 2 s, 6 s to bring the cellular modem up, 1.5 s for the VPN handshake, a human paged if recovery takes over 30 s.

Chapter 0

The 2 a.m. Page to Run tcpdump On-Site

See why a robot must diagnose its own dropped connection, and how a small state machine turns an outage into a log line

It is 2 a.m. in a warehouse two hours away. Robot 17 has stopped sending data. On your dashboard the robot’s dot turned grey at 01:52. A monitoring tool paged you. The page says one thing: robot-17 offline.

You open a terminal. You try to log in to the robot. The robot is offline, so the login fails. You cannot see its Wi-Fi signal, its error logs or its last packets. Every clue is inside the machine you cannot reach.

So someone drives to the site with a laptop. They plug into the robot. They run tcpdump, a tool that prints every network packet a machine sends and receives. After 20 minutes they find the cause: the customer’s IT team closed an outbound port at midnight. The robot was healthy. The network around it changed.

This lesson is about not making that drive. The fix is not a better dashboard. The evidence was on the robot the whole time. The robot must read it, name the cause, switch to a backup link and report all of that when it can.

Three words before we start

A fleet is a group of robots that one team runs from one place. Think of a taxi company: the dispatcher cannot sit in every car, so each car must report in and fix small things alone.

Telemetry is the data a machine sends home about itself: its speed, its temperature, its errors. The word comes from Greek roots meaning “measure from afar”.

A root cause is the first thing that went wrong in a chain of failures. “The robot is offline” is a symptom. “TCP port 443 is blocked at the customer’s firewall” is a root cause. A symptom tells you to worry. A root cause tells you what to do.

The robot watches its own link

The robot sends a tiny message to the server every few seconds. That message is a heartbeat. If the server answers, the link is alive. If the answers stop, something broke.

One missed heartbeat proves little. Wi-Fi drops a packet now and then. So the robot counts. After K misses in a row it decides the link is down. The wait before it decides is the detection time:

detection time = K × heartbeat interval

In the instrument above, the interval is 2 s and K is 3. So detection takes 6 s. If you set K to 1, the robot reacts in 2 s but also reacts to every single lost packet. If you set K to 10, it never overreacts but stays blind for 20 s. K is a trust slider: how much silence the robot needs before it believes the link is gone.

Once the robot believes the link is down, it does two jobs at the same time. First it runs a ladder of six probes. A probe is a small test of one step on the path to the server: is the Wi-Fi link up, did it get an IP address, can it look up the server’s name, can it open a TCP connection on port 443, does the TLS handshake finish, does a heartbeat arrive. The first probe that fails is the root cause. You saw the ladder light up in the hero.

Second, the robot starts a backup link. It powers up the cellular modem and, if the network rules demand it, opens a VPN (a private tunnel to your servers; Chapter 1 explains it). The time from the fault to a working link is the recovery time:

recovery time = detection time + modem bring-up + VPN handshake

Worked example with the hero’s illustrative numbers: 6 s to detect, 6 s for the modem, 1.5 s for the VPN handshake. The robot is back on the cloud after 13.5 s. It also holds a note that says which probe failed.

The state machine. A state machine is a program that is always in exactly one named state, such as Wi-Fi up, suspect, probing or on cellular. A timer or an event moves it to the next state. It is simple on purpose: a robot at 2 a.m. has no one to ask. Chapter 9 gives the whole thing as C code.

Compare the two endings

The device below puts the two outages side by side. The numbers on the human path are made up for the exercise, so change them to match your own site. The point is the scale: minutes and hours against seconds.

Count the cost of one outage

Each bar is one outage in one site. The top bar is the human path, step by step. The bottom bar is the robot’s own recovery. Drag the drive time and the robot count.

90
6

Illustrative numbers: 5 min until the alert fires, 10 min for the on-call engineer to wake and read it, 20 min of tcpdump on site. The robot path uses the hero’s 13.5 s.

Notice what the robot path does not do. It does not make the customer’s firewall rule go away. The firewall is still wrong. The robot only moves traffic to a link that works and writes down the evidence. A person still fixes the firewall, but at 09:00, with the cause already named, on a ticket that says “TCP 443 blocked at egress, first seen 01:52:06”.

Two numbers to track

A fleet team should watch two numbers per incident. Time to detect is how long from the fault to the robot knowing. Time to recover is how long from the fault to a working link. Both have a unit (seconds) and a target. If you cannot measure them, you cannot improve them. Chapter 3 returns to this when we look at what the robot sends home, and Chapter 8 shows the same idea for reboots.

This lesson follows the fleet from one link to many machines. Chapter 1 maps the networks you do not own. Chapter 2 opens the cellular and Wi-Fi stacks. Then we look at what to send, how to update, how to patch and how to line up events across clocks that disagree.

The road

  1. Networks you do not own: Wi-Fi dead zones, cellular, VPN gates and firewalls you cannot change.
  2. Cellular and Wi-Fi stacks: whose bug is it, the host’s or the modem vendor’s.
  3. Telemetry: what to send, how often, at what cost.
  4. Staged OTA rollout: canary, cohorts, health gates, rollback.
  5. CVE remediation: patching fielded units against the kernel’s long-term cycle.
  6. Cross-machine traces: one request, many clocks.
  7. Fleet ordering: why wall clocks lie and Lamport clocks do not.
  8. Reboot reasons: ramoops, reset flags and the field debug loop.
  9. Field guide: the numbers, the checklist, the FSM as code.

Related lessons: Linux networking for robots covers sockets and routes in depth, and secure boot and OTA covers the on-device update mechanism. This lesson stays at fleet scale.

On real hardware: on a Raspberry Pi with Wi-Fi, run a loop that opens a TCP connection to your server port once a second with nc -vz. Block that port with a firewall rule on a second machine and note how many seconds pass before your loop notices. That gap is your detection time.

The robot’s link drops and the cloud sees silence. Why can a cloud-side alert not name the root cause?

Chapter 1

Networks You Do Not Own: Wi-Fi, Cellular, VPN, Firewalls

Walk a robot through five zones and learn which links and transports survive each one

A robot rolls out of the office, down a corridor, past the loading dock and into a cold room. In the office the Wi-Fi is strong. In the corridor it fades. At the dock the Wi-Fi works but the customer’s firewall lets almost nothing out. In the cold room there is no signal at all. The robot has one job in all five places: keep talking to your server.

You own the robot. You do not own any of these networks. A customer’s IT team owns the Wi-Fi and the firewall. A mobile carrier owns the cellular link. They change rules at midnight and they do not ask you. So the design rule for a fleet is: assume the network is hostile and unchanging only by luck.

Four things that go wrong

A dead zone is a place with no usable signal. Wi-Fi radio waves fade with distance and metal shelving blocks them. A robot that drives through one loses its link for seconds or minutes. Moving from one access point (a Wi-Fi radio) to the next is called roaming. During a roam the link can drop for a moment even in a well-covered building.

A firewall is a gatekeeper that allows or blocks network traffic by rule. Rules often say: which direction, which protocol, which port. A port is a numbered door on a machine. Port 443 is the door for HTTPS, so almost every firewall leaves it open. Many other doors are shut.

Egress means traffic that leaves a network. Ingress means traffic that arrives. Customers usually block ingress completely and allow only some egress. A device behind NAT (network address translation, a trick that lets many machines share one public address) cannot be reached from outside unless it first reaches out. So your robot must always be the one that dials out. Your server never dials in.

A VPN (virtual private network) is a tunnel that wraps your traffic in an encrypted envelope and delivers it to a private network. Some customers only allow robots to reach their systems through a VPN. WireGuard is one VPN protocol. It sends everything over UDP, a connection-less transport that has no built-in retries. The WireGuard protocol page states it directly: all packets are sent over UDP. A network that blocks UDP therefore blocks WireGuard.

The design that survives

Three choices follow from this. First, robots dial out only. Second, the main transport is something that looks like ordinary web traffic: TLS (encryption) over TCP on port 443. MQTT, a small publish and subscribe protocol many fleets use, can run inside TLS or inside a WebSocket on that port. Third, the robot carries a second physical link, a cellular modem, that does not depend on the customer at all.

The interactive below lets you test this. Slide the robot along the corridor. Pick a transport. The device shows which link, if any, carries your traffic in each zone.

Walk the robot through five zones

Drag the robot along the corridor. Choose a transport. The bars show Wi-Fi and cellular, and the sentence says which link carries traffic.

35

An invented site. Office: Wi-Fi, all ports out. Dead zone: no Wi-Fi. Dock: Wi-Fi, only TCP 443 allowed out. Yard: no Wi-Fi, good cellular. Cold room: no Wi-Fi, no cellular.

Try the dock with plain MQTT: the Wi-Fi is up and every probe on the link layer passes, yet the data goes nowhere. This is the nastiest failure for a human to find, because the signal-strength bar is full. The robot’s probe ladder from Chapter 0 finds it in one step: TCP connect to the broker port fails while the Wi-Fi link probe passes.

Detection timers you set yourself

A dead link does not announce itself. The robot must notice. Linux gives a default, and the default is slow. The tcp(7) manual page lists three keepalive settings that apply only when the program turns keepalive on: wait 7200 s of silence, then send a probe every 75 s, and give up after 9 probes. The total is 7200 + 9 × 75 = 7875 s, about 2 hours 11 minutes. For a robot that is far too long.

You can tighten every number. Set the idle wait to 20 s, the interval to 5 s and the probe count to 3, and a dead TCP connection is found after 20 + 3 × 5 = 35 s. A second option is the TCP_USER_TIMEOUT socket option, in milliseconds. It forces the connection closed with an error when sent data stays unacknowledged for that long.

MQTT adds its own timer. The client states a Keep Alive period. The MQTT 5.0 specification (section 3.1.2.10) says the server closes the connection if it hears nothing for 1.5 times that period. With Keep Alive at 30 s, the server drops a silent robot after 45 s. The client sends a small PINGREQ message when it has nothing else to say, so a quiet robot is not mistaken for a dead one.

MQTT also has a Will Message: a note the robot hands the server when it connects. If the connection dies without a clean goodbye, the server publishes the note for it, for example “robot-17 went offline”. That gives the cloud an immediate, structured event instead of a mystery.

Why the order of timers matters. The robot’s own heartbeat must fire before the server gives up and before the operating system notices. If the robot waits 7875 s for TCP to tell it, it fails over two hours late.

Failure mode and fix

Symptom: robots at one customer go grey at the same minute and stay grey. Measurement: the probe ladder on each robot says the link, the IP address and DNS all pass, and TCP connect to your port fails. Fix: move the main path to 443 so one allowed port carries everything, keep WireGuard as an option where UDP is allowed, and keep the cellular modem as a path the customer cannot close. Then add the on-robot probe so the next change is named in seconds.

The wireless link in each robot is not the only part you cannot see into. Chapter 2 opens up the cellular and Wi-Fi stacks to show who owns each layer.

On real hardware: take a Raspberry Pi or a laptop on a phone hotspot. Run nc -vz your-server 443 and nc -vz your-server 8883 from a guest network that filters ports, and write down which ones connect. That is a probe by hand.

A robot shows full Wi-Fi bars at the loading dock, yet no data arrives. The probes show DNS passes and TCP to port 8883 fails. What is the likeliest cause and the best design response?

Chapter 2

Cellular and Wi-Fi Stack Integration

Open the modem, name its layers, and decide in two experiments whether a bug belongs to your host or to the vendor

Your team adds a cellular module to the robot. It works on the bench. In the field, 4 robots out of 200 lose their data session after a few hours and never get it back until a reboot. You blame the Linux driver. The module vendor blames your power supply. Both could be right. Neither has proof.

To argue with proof you must know what is inside the radio link. A modem is not a wire. It is a small computer that runs its own firmware, a program stored in the module, and that firmware runs a tall stack of protocols. Your Linux machine sees a network interface, but behind it sits a second operating system you cannot read.

The layers of the cellular link

A protocol stack is a pile of layers. Each layer does one job and talks to the layer above and below. Think of mailing a parcel: you pack it, the post office sorts it, a truck drives it, a plane flies it. Each step trusts the step beneath.

The LTE stack, from top to bottom, has these layers. NAS (non-access stratum) talks to the carrier’s core network: it registers your SIM and sets up a data session. RRC (radio resource control) opens and closes the radio connection to the nearest tower. Wikipedia’s summary of the 3GPP specification (TS 36.331 for LTE, TS 38.331 for 5G) lists connection setup and release, mobility and paging among its jobs, and notes that RRC messages travel over the next layer down, PDCP, which handles compression and encryption of the data. RLC cuts data into pieces and resends lost pieces. MAC decides who may transmit when. PHY, the physical layer, turns bits into radio waves.

All six live inside the modem on most IoT modules. Your robot sees only the result: an interface, usually named something like wwan0, plus a control channel.

The host half

The host half is your Linux machine. It has four parts you can inspect. A bus (USB or PCIe) carries bytes to the module. A kernel driver turns those bytes into a network interface; the kernel documentation has a WWAN section and drivers such as cdc_mbim for MBIM modems. A manager program such as ModemManager tracks modem state (initializing, enabled, connecting, connected) and exposes it on D-Bus, the Linux message bus. And the normal IP stack runs on top, with DHCP, routes and DNS.

Wi-Fi has the same two halves. The chip runs firmware that the kernel loads at boot from a file. A kernel driver and the 802.11 subsystem sit above it, and a user program such as wpa_supplicant does the login (authentication) to the access point. A bug can sit in any of those parts.

Two experiments that sort the blame

Staring at logs does not tell you which half is wrong. Two controlled swaps do. Run each one and write down yes or no.

  1. Experiment A. Put the same module on a known-good reference host, such as a laptop with a vendor evaluation kit. Does the fault still happen?
  2. Experiment B. Put a different module on this robot. Does the fault still happen?

The answers form a small table. Use the device to read it.

Run the two swap experiments

Switch each experiment between yes and no. The stack on the canvas lights up the half that owns the bug.

The four-way table is a reasoning aid, not a proof: a fault that depends on timing or on heat can hide in both swaps. Layer names follow the 3GPP LTE stack.

Look at the combinations. If the fault follows the modem to the reference host (A yes) but vanishes with another modem (B no), the modem firmware is the owner. If it stays on your robot with every modem (B yes) but the reference host is fine (A no), your host owns it: the driver, the power supply, the heat, or the configuration. If both stay failing, the cause is outside both: the carrier network or the test place itself. If neither fails, you have not reproduced it, and the next step is more logging.

Tools on each side

On the host you have normal tools. Wireshark reads packet captures made with tcpdump and shows every field. The kernel log shows driver messages. ModemManager’s own command shows the modem’s state.

On the modem side you need the vendor’s diagnostics. Qualcomm sells QXDM Professional, a tool that captures proprietary diagnostic logs from Qualcomm-based modems and shows RRC and NAS signalling, such as attach, bearer set-up and handover. It needs a commercial licence. Other vendors ship their own equivalents. These logs tell you if the tower released the radio connection (an RRC event) or if the core network refused your session (a NAS event). No host-side tool can see that.

The modem also reports numbers about the radio. Examples are signal power and signal quality. Teams call these KPIs (key performance indicators). If robots in one hall all lose data when many machines share a tower, the KPIs show the congestion before any log does.

Failure mode and fix

Symptom: 4 of 200 robots lose the data session after hours. Measurement: run Experiment A on one failing robot’s module. Suppose it fails again on the reference host with the vendor log running, and the log shows the network released the radio connection and the module never re-registered. Fix: that is a firmware defect. Send the vendor the log and the timing, and meanwhile have the robot’s state machine power-cycle the modem when the data session stays down for a set time. Chapter 0’s state machine gets one more state: reset modem.

The lesson on bench work and root cause goes deeper on building a reproducer. This chapter only needs its core rule: make the same failure happen on both sides, then change one side at a time.

On real hardware: if you own a USB LTE dongle and a Raspberry Pi, list the interface with ip link and read the modem state with ModemManager’s mmcli. Unplug the dongle in the middle of a transfer, and record how long the manager takes to report the loss.

Why the modem matters to a fleet. A module you integrate is a second computer you do not control. Treat its firmware version as part of your fleet inventory, next to your own software version. Chapter 3 shows how to report both.
The same modem fails on a reference host. A different modem works on your robot. Who most likely owns the bug?

Chapter 3

Telemetry: What to Send, How Often, at What Cost

Price each kind of data a robot can send home, and learn why a ring buffer beats streaming everything

A robot arm has a motor, a gearbox and a temperature sensor. An engineer says: “Send me everything, in case we need it.” The robot logs 50 lines every second at debug level and ships them over a cellular link. A month later the cellular bill is ten times the plan, and the one log line you needed was buried in a queue that was still draining.

The robot can measure far more than the link can carry. So telemetry is a budgeting problem. You decide what is worth sending, how often, and over which link.

Four kinds of data

A metric is a number sampled over time, such as motor temperature once a second. It is small and easy to chart. A fleet can send thousands of them cheaply. A log is a line of text a program writes, such as “gripper retry 3”. It is rich but large. An event is a structured record that something happened, such as “watchdog reset at 01:52:06, firmware 1.4.2”. It is rare and very useful. A trace follows one request through several machines; Chapter 6 covers it. OpenTelemetry, a common standard for this data, treats traces, metrics and logs as three signal types.

Rule of thumb: metrics tell you something is wrong, events tell you what happened, logs tell you why. You pay most for logs.

Counting the bytes

Every upload has a size you can compute. Take a robot with 50 metric series, each sampled once a second, with each sample taking 16 bytes (a timestamp, an id and a value). That is 50 × 16 = 800 bytes per second. One day has 86,400 seconds, so the robot sends 800 × 86,400 = 69.1 MB a day. At 0.1 Hz the same set costs 6.9 MB.

Now logs. Say each line is 100 bytes. At debug level the robot writes 50 lines a second: 5,000 bytes per second, or 432 MB a day. At info level, 5 lines a second gives 43.2 MB. At errors only, 0.05 lines a second gives about 0.4 MB. One setting, the log level, changes the bill by a factor of 1000.

Compare that with a plan. Suppose each robot has a cellular allowance of 3 GB a month, which is 100 MB a day. Debug logs alone use 432%. The numbers in this section are made up to show the arithmetic, so replace them with the ones from your own robot.

Three ways to cut the bill

First, sample less. Most metrics do not need 1 Hz upload. You can keep the fast rate on the robot for its own control loops and send a slower or summarized version. A summary, such as the minimum, maximum and mean per minute, keeps the spikes that a plain average hides.

Second, send bulk data over the cheap link. A robot that is often on the customer’s Wi-Fi can hold big uploads (full logs, camera clips) until then. Cellular carries only what must arrive now: metrics, events and heartbeats. This is a priority rule: tag each message urgent or bulk.

Third, capture on a trigger. A ring buffer is a fixed block of memory that overwrites its oldest data when full, like a security camera that keeps the last hour. The robot writes debug logs into a ring buffer all the time, which costs no network. When an event fires, for example a watchdog reset or a failover, the robot freezes the buffer and uploads the 30 seconds before and after. You get debug detail exactly where it matters. The lesson on logging and deterministic replay (a planned lesson in this track) goes deeper into this method.

Fit the telemetry in the plan

Choose a log level, slide the metric rate, and switch the rules. The bar is one robot’s cellular bytes for one day. The line is its 100 MB allowance.

1.0
200

Illustrative: 50 metric series at 16 bytes a sample, 100-byte log lines at 0.05, 5 or 50 lines a second, 200 events a day at 200 bytes, 6 incidents a day with a 60 s capture window, a 100 MB a day allowance. No compression.

Try debug with everything on: the bar runs far past the line. Now switch on trigger capture. The 432 MB of steady logs shrinks to 6 incidents × 60 s × 5,000 bytes per second = 1.8 MB, because only the windows around incidents leave the robot. The debug detail you need is still on the robot at the moment you need it.

Failure mode and fix

Symptom: the cloud shows telemetry that is hours old, and the bill is high. Measurement: compare bytes sent per robot per day against the allowance, and look at the upload queue depth on the robot. Fix: cut the log level for steady state, move bulk to Wi-Fi, and use trigger capture. Add one more rule: when the link is down, the robot stores data on its flash and drops the oldest first, so a long outage cannot fill the disk.

Also report what the fleet is made of. Each robot should send its software version, its hardware revision and its modem firmware version once, as an event. When a problem shows up in one cohort (one firmware version, one site), you can see it only if the data carries those labels.

On real hardware: on a Raspberry Pi or Jetson, run vnstat or read /proc/net/dev before and after an hour of your logging setup. Divide by 3,600 and multiply by 86,400 to get the daily figure. Compare it with the model.

A robot must keep debug-level detail for rare faults, but its cellular allowance is small. Which design fits best?

Chapter 4

Staged OTA Rollout at Fleet Scale

Compute how many units a bad update bricks with and without a canary, and why a gate that does not look protects nothing

Friday, 16:40. A new firmware build passed every test in the lab. You press “update all 1,000 robots”. By 17:10, 140 robots sit dead in warehouses across three countries. A bug that only appears on one motor-driver revision slipped past the lab, which had none. Each dead robot needs a person with a cable. Your weekend is gone.

A software bug on a phone is annoying. A firmware regression on a fielded robot is a physical unit someone must visit and service. That cost is why fleets do not update everything at once.

Some words first

An OTA update (over-the-air) sends new software to a device through the network, with no cable. The mechanics on one robot, such as two flash slots (A and B), signature checks and rollback to the old slot, belong to the lesson on secure boot and OTA. Here we study the fleet side: who gets the update, in what order, and who decides to continue.

A canary is a small group that gets the update first. The name comes from canaries that miners carried to detect gas: if the bird fell sick, the miners left. A cohort is a named group of devices, such as “lab units” or “site 7”. A staged rollout moves the update through waves: a small canary, then a bigger cohort, then everyone. A health gate is a check between waves. It looks at numbers from the robots that already updated and decides to go on or to halt.

The Google SRE Workbook explains canarying with an example worth keeping in mind. A canary that is 5% of traffic and fails 20% of its requests produces only a 1% error rate overall. The harm scales with how much of the fleet you exposed, so small first waves keep failures cheap.

The arithmetic of a bad build

Say a fraction p of the units that get a bad build will brick. Take p = 2% and a fleet of 1,000. Push to everyone and you brick 0.02 × 1,000 = 20 units.

Now use waves of 1%, then 10%, then 100% (cumulative). Wave 1 is 10 units; wave 2 adds 90; wave 3 adds 900. A gate stops the rollout if it sees at least one bricked unit. The chance that wave 1 shows no failure is (1 − 0.02)10 = 0.817. The chance that waves 1 and 2 together (100 units) show none is 0.98100 = 0.133.

Expected bricks = p × [10 + 90 × 0.817 + 900 × 0.133] = 0.02 × [10 + 73.5 + 119.3] = 4.1 units. A canary cuts the damage from 20 to about 4 on average. Look at the 13% chance that no failure appears in 100 units: a small canary can miss a rare bug. Rare bugs need a bigger first wave or a longer soak, and they need good metrics, not just “did anything brick?”.

Roll out a bad build

Each square is 10 robots. Choose the waves, set the share of units a bad build bricks, and press Roll. Red squares hold a bricked robot.

2.0%

A model of 1,000 identical units. The gate halts after any wave that shows at least one failure. Real gates watch rates and compare to a control group, and soak time matters. The expected number is exact; the dice give one possible run.

Switch the gate off. The waves still go out in order, but nobody looks between them, so the expected damage jumps back to the full 20. A canary without a gate is only a slower way to push to everyone.

What a good gate looks at

The SRE Workbook gives advice that carries over to robots. Pick a few metrics that reflect real health, not a dozen noisy ones. For a robot fleet that means: boot success, crash-free hours, heartbeat rate, time to reconnect, and the fault events from Chapter 8. Compare the canary against a control group of robots that did not update, because fleet-wide noise (a bad day at a customer site) would otherwise look like the canary’s fault.

The wave must be large enough and last long enough to be representative. A robot that runs a shift once a day needs at least a day of soak, not 20 minutes. Run one canary at a time, or the signals mix. Also spread the start times, with random delay on each robot’s check-in, so thousands of units do not all download at once. Memfault’s OTA documentation describes staged rollouts that apply to a random subset of a cohort and an abort control for each activation, which are the same ideas in a product.

Rollback at fleet level

Two kinds of rollback exist. On the robot, the boot loader returns to the old slot when the new image fails to boot or never reports healthy (see the OTA lesson). At fleet level, you halt the rollout so no more robots take the build, and you retarget the cohort back to the last good version. Test this before you need it. A rollback you have never run is a guess.

Failure mode and fix

Symptom: a fleet-wide push ends with a fleet-wide brick. Measurement: the update log shows all 1,000 robots took the build within one hour and the first failure reports arrived after the last download started. Fix: waves with a soak time longer than your slowest failure signal, a gate with real metrics, a control group, and a halt button that works.

On real hardware: with two nRF52840 DKs or two STM32 Nucleo boards, flash one with a deliberately bad build that never sets its “healthy” flag. Watch the bootloader switch back after its retry count, and time it. That is the single-robot half of the story.

You roll out in waves of 1%, 10% and 100%, but nobody checks any metric between waves. What is the expected damage compared with pushing to everyone at once?

Chapter 5

CVE Remediation on Fielded Units

Walk a kernel security fix from disclosure to the last robot, and see which stage you can shorten without raising the risk

On a Monday a security researcher publishes a flaw in the Linux network stack. An attacker on the same Wi-Fi could crash a robot or take it over. A customer’s security team emails you: “Are your robots affected? When will they be patched?” The honest answer needs a plan with days in it.

A CVE (Common Vulnerabilities and Exposures) is a public ID for one known security flaw, such as CVE-2026-12345. Anyone can look it up. Your robots run a kernel, a C library, a web server and a hundred packages, so new CVEs that touch your image arrive every week. Fixing them on a phone is easy. Fixing them on robots in warehouses is a pipeline.

The four stages

Triage asks three questions. Is the vulnerable code in our build at all (a kernel feature may be switched off in our configuration)? Can an attacker reach it (a flaw in a network driver we ship matters more than one in a USB gadget we never plug in)? How bad is it (CVE records carry a severity score)? Most CVEs end here with the answer “not affected”, and you write that down so the customer can read it.

Backport means taking a fix written for a newer version and fitting it to the older version you ship. Your robots do not run the latest kernel. They run one release line, such as 6.12, and receive fixes as point releases (6.12.1, 6.12.2 and so on). When the fix is in the next point release, you rebase. When it is not, a person adapts the patch by hand.

Test on HIL comes next. HIL (hardware in the loop) means a rack of real boards and robots that run your image and your test suite automatically. Kernel patches break drivers and timing in ways that only real hardware shows. The real-time lesson on real-time Linux shows why a latency regression after a kernel change is plausible.

Finally comes the staged rollout from Chapter 4: canary, soak, waves.

How long are the robots exposed?

The number that matters to the customer is the time from disclosure until each robot has the fix. Put sample durations on the stages: triage 2 days, backport 3, HIL 4. The build is ready on day 2 + 3 + 4 = 9. Say the canary (10 robots) updates on day 9. After a 3-day soak the second wave (90 robots) goes on day 12. The last 900 robots finish on day 19. These durations are made up for the exercise.

Average exposure across 1,000 robots = (10 × 9 + 90 × 12 + 900 × 19) / 1,000 = (90 + 1,080 + 17,100) / 1,000 = 18.3 days. Every day added before the canary costs all 1,000 robots one day. A day added to the final wave costs the 900 robots in it. So the best saving comes from the stage with the most days you can cut. The 900 robots of wave 3 account for 93.6% of the total exposure, 17,100 of 18,270 robot-days.

Shorten the exposure window

Each block is one stage. Drag the durations. The read-out gives the average days a robot stays exposed after the disclosure.

3
4
7

Illustrative durations. Triage is fixed at 2 days and the canary soak at 3 days. Waves hold 1%, 9% and 90% of 1,000 robots. Skipping the soak ships the whole fleet on HIL evidence alone, which is the risk Chapter 4 priced.

Try the toggles. Automating the HIL rack (a one-time investment) cuts days from every patch ever after. Skipping the soak cuts exposure further but removes the only check on real robots in the field. For an actively exploited flaw you may accept that trade; for a theoretical one you should not.

The kernel’s long-term cycle

A long-term support (LTS) kernel is a release line that receives bug and security fixes for years. The kernel.org releases page lists 6.12 (released 17 November 2024) and 6.18 (released 30 November 2025) as longterm, both with a projected end of life in December 2028. The page notes these dates are projections and can change.

That gives a rhythm. A robot line on 6.12 gets about four years of fixes from its release. A product that ships in 2027 may start on 6.18 and have under two years of runway before its next move. Plan to move the fleet between LTS lines, because the last fix will not arrive after the end of life.

The move is where patch stacks hurt. If your build carries 40 out-of-tree patches (your own driver changes) and each needs 2 hours to rebase and retest, that is 80 hours, 10 working days, every time. Patches that you upstream (send to the kernel project and get accepted) disappear from your stack. The lesson on secure boot and OTA picks up this theme in its chapter on keeping a patch stack movable.

Failure mode and fix

Symptom: a customer asks for a CVE status and the team needs a week to answer. Measurement: record for every CVE the dates of triage, fix ready, HIL pass, canary and last robot. Fix: a software bill of materials (a list of every package and version in each image) so triage is a lookup, an automated HIL rack so testing is days not weeks, and a patch stack small enough to carry to the next LTS.

On real hardware: on any Linux board, run uname -r and compare it with the stable series on kernel.org. Count how many point releases behind you are. That count is your backlog.

You can cut the final wave from 7 days to 3, or cut triage from 2 days to 1. Which saves more average exposure across 1,000 robots?

Chapter 6

Cross-Machine Trace Correlation

Follow one command across three computers, find why its spans end before they start, and put them back in true order

The cloud planner sends a command: “grasp the box”. A computer on the robot plans the grasp. A small microcontroller in the gripper closes the fingers. The whole job took 210 ms and the customer says it is too slow. You open the traces. The robot’s span starts 75 ms before the cloud sent the command. The gripper’s span starts after the robot’s span has already ended. The data is impossible, so you cannot tell which step is slow.

Nothing is broken in the code. Each machine kept its own clock, and the clocks disagree. This chapter shows how to find a trace through machines you cannot sync perfectly.

Spans, traces and the header that links them

A span is one unit of work with a name, a start time and an end time. The OpenTelemetry documentation says a span represents “a unit of work or operation” and carries a parent span ID, so spans nest. A trace is the whole tree of spans for one request. Every span in it shares one trace ID.

To join spans from different machines, each message must carry the IDs. This is context propagation. The W3C Trace Context standard fixes the format of one HTTP header, traceparent: four fields joined by dashes. The version (2 hex characters, now 00), the trace ID (32 hex characters, 16 bytes), the parent span ID (16 hex characters, 8 bytes) and flags (2 hex characters; bit 0 means “sampled”). The standard’s own example is:

httptraceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
# 2 + 1 + 32 + 1 + 16 + 1 + 2 = 55 characters, every time

On a robot, the same ID travels in your own message headers: a ROS message field, an MQTT user property, a CAN frame tag. The rule is: create the ID at the first hardware stamp. If a camera captures a frame and its sensor timer stamps it, that moment is the start of the trace. The ID follows the frame through inference and into the command to the gripper. If you create the ID later, in software, you have already lost the beginning.

Why the times disagree

A clock is a counter that a crystal oscillator drives. Two things go wrong. The offset is how far one clock reads from another at one moment. The drift is how fast that offset grows because the crystals run at slightly different speeds. A crystal is rated in ppm (parts per million). A 50 ppm crystal gains or loses 50 microseconds every second: 50 × 10−6 × 60 s = 3 ms per minute, which is 180 ms per hour and 4.32 s per day.

Network time sync cuts the offset but not to zero. The ntp.org FAQ says the typical accuracy on the Internet is about 5 ms to 100 ms, and that machines on one quiet subnet can stay within 1 ms. PTP (IEEE 1588), implemented on Linux by ptp4l, takes timestamps in the network hardware, which removes software delay from the measurement. The linuxptp documentation says hardware timestamping is its default mode.

The sync tool can also step a clock (jump it) instead of slewing it (changing its speed a little). The chrony manual describes makestep as forcing an immediate jump when the offset passes a threshold. A jump in the middle of a span makes it negative.

Two clocks per machine

Linux offers several. The clock_gettime manual page says CLOCK_REALTIME is settable and is hit by jumps when someone sets the time. CLOCK_MONOTONIC cannot be set and does not jump, though NTP slewing still adjusts its speed. So measure durations with the monotonic clock. Use real time to give a span a place on a calendar.

Log both at once. At start-up, and every few minutes, write one pair: (monotonic, real). Later you can detect a jump (the real clock moved but the monotonic did not) and convert every monotonic stamp to calendar time.

Estimating the offset

A machine can measure its offset to another with four timestamps. The client stamps T1 when it sends a request. The server stamps T2 on arrival and T3 on reply. The client stamps T4 on arrival. RFC 5905 gives the offset θ = ½ [(T2 − T1) + (T3 − T4)] and the round-trip delay δ = (T4 − T1) − (T3 − T2).

Worked example: T1 = 10.000 s, T2 = 10.150, T3 = 10.151, T4 = 10.040. Then θ = ½ [0.150 + 0.111] = 0.1305 s and δ = 0.040 − 0.001 = 0.039 s. The server’s clock is about 130.5 ms ahead. If the path is lopsided, the true offset can differ by up to half the delay, 19.5 ms. Record the offset and its uncertainty beside every span.

Line the spans back up

Each lane is one machine, drawn with its own clock. A child span must sit inside its parent. Set the clock errors, then switch on correction.

-120
60
0

Illustrative true times: cloud span 0 to 210 ms, robot span 45 to 180 ms, gripper span 110 to 160 ms. The robot clock gains 3 ms per minute (a 50 ppm crystal). Correction leaves a 2 ms residual.

With the defaults the robot span begins 75 ms before its parent, and the gripper span starts after the robot span has already ended. Turn on the correction and all three fit. Now push the sync age to 60 minutes: the robot clock has gained another 180 ms, so a correction that was measured an hour ago would be wrong. Offsets must be measured often and stored with a time.

pythonimport time, secrets

def clock_pair():
    # log this pair at boot and every few minutes
    return {"mono_ns": time.clock_gettime_ns(time.CLOCK_MONOTONIC),
            "real_ns": time.clock_gettime_ns(time.CLOCK_REALTIME)}

def new_traceparent():
    return f"00-{secrets.token_hex(16)}-{secrets.token_hex(8)}-01"

Failure mode and fix

Symptom: spans that end before they start, or children outside parents. Measurement: count nesting violations per trace and plot the recorded offset against time. Fix: PTP or well-run NTP on every machine, a recorded offset with its uncertainty next to each span, durations from the monotonic clock, and one trace ID created at the first hardware stamp and sent with every message. Where you cannot trust time at all, Chapter 7 shows an order that needs no clock.

On real hardware: on two Raspberry Pi boards on one switch, run chronyc tracking on each and read the reported offset. Then send 100 requests between them with four timestamps and compare your θ with the tool’s.

A 50 ppm crystal is synced once, then left alone. By how much does it drift in 10 minutes?

Chapter 7

Fleet Ordering and Time

Sort events from three robots by wall clock and by Lamport counter, and see which order never contradicts cause and effect

Robot A drops a box on a conveyor. Robot B picks it up at the other end. The fleet log shows B’s line “box received” at 10:00:00.010 and A’s line “box released” at 10:00:00.040. The box arrived 30 ms before it was sent. An engineer opens a ticket for a time-travelling box.

No box travelled in time. Robot B’s clock is 50 ms behind Robot A’s. Chapter 6 showed how clocks drift. In a fleet the problem grows: robots sync to different time servers, at different ages, at different customer sites. Some use a site NTP server. Some use a public pool. Some have no network for hours. Their errors are all different, and you cannot assume any pair agrees to better than tens of milliseconds.

Cause before effect

What you want from a merged log is one thing: if event X caused event Y, X must come first. Leslie Lamport’s 1978 paper “Time, Clocks, and the Ordering of Events” builds this from one idea. Event X happened before event Y (written X → Y) if one of three things holds. They are the same machine and X came first. X is the sending of a message and Y is its receipt. Or there is a chain of such steps from X to Y.

If neither X → Y nor Y → X, the two events are concurrent. They could not have influenced each other. For concurrent events, any order is honest.

Lamport then asks for a counter that respects this. His Clock Condition says: if a → b, then the counter value of a is less than the counter value of b. He gets it with two rules, called IR1 and IR2 in the paper:

  1. Rule 1. Each machine adds 1 to its counter between any two of its events.
  2. Rule 2. A message carries the sender’s counter. On receipt, the receiver sets its counter to more than both its own value and the message’s value.

The counter is called a Lamport clock. It counts events, not seconds, so it needs no time server. The lesson on Lamport clocks derives it in full, and failure and time in distributed systems and the trouble with distributed systems put it in context.

ctypedef struct { uint64_t t; } lclock_t;

/* local event or send: tick, then stamp the message with the result */
uint64_t lc_tick(lclock_t *c) { return ++c->t; }

/* receive: jump past the sender's value, then count the receive itself */
uint64_t lc_recv(lclock_t *c, uint64_t m) {
    c->t = (m > c->t ? m : c->t) + 1;
    return c->t;
}

A worked example

Take the eight events in the device below. Robot A has a local event (a1) and then sends the box message m1 (a2). Robot B has a local event (b1), receives m1 (b2) and sends m2 to Robot C (b3). Robot C has a local event (c1), receives m2 (c2) and has another local event (c3).

Counters, step by step. A: a1 = 1, a2 = 2, and m1 carries 2. B: b1 = 1. At b2, B takes max(1, 2) + 1 = 3. Then b3 = 4, and m2 carries 4. C: c1 = 1. At c2, C takes max(1, 4) + 1 = 5. Then c3 = 6. Sort by counter and break ties by robot name: a1, b1, c1, a2, b2, b3, c2, c3. Every send sits before its receive.

Sort the fleet log two ways

The canvas shows the true story: arrows are messages. Give each robot a clock error. The two lists show the merged log, sorted by wall clock and by Lamport counter.

0
-50
40

Sorted by wall clock

    Sorted by Lamport counter

      Illustrative true times in ms: a1 10, a2 40, b1 35, b2 60, b3 70, c1 20, c2 95, c3 110. A red line marks a receive that the sort places before its own send.

      At the defaults, B is 50 ms behind. The wall-clock sort puts b2 (stamped 10) before a2 (stamped 40): the box is received before it is sent. The Lamport sort does not, for any clock error you pick, because it ignores the clocks entirely. Move the sliders to try to break it.

      What the counter cannot do

      A Lamport counter respects cause and effect, but the reverse is false. Two events with counter 1 (a1, b1, c1) may be unrelated, and a smaller counter does not prove a cause. It also says nothing about how much real time passed. Vector clocks fix the first problem at a higher storage cost; the Lamport lesson explains them. Only a good physical clock answers the second.

      So a fleet logs both. Every event gets: the robot ID, a Lamport counter, the monotonic and real timestamps from Chapter 6, and the latest offset estimate with its uncertainty. The counter travels in a header with each message. The W3C tracestate header exists for this kind of vendor key-value data beside the trace ID. In the cloud, order events by the causal edges first, then by corrected time inside each concurrent group.

      Failure mode and fix

      Symptom: the merged log shows effects before causes, and engineers argue about which robot is lying. Measurement: count messages whose receive stamp is earlier than the send stamp, per robot pair. That count is a free estimate of how far the clocks disagree. Fix: carry a Lamport counter in every cross-robot message, use PTP or a shared time source where timing matters, and store offsets so you can correct old logs.

      On real hardware: run two processes on one board with two sockets. Add a fake 80 ms offset to one process’s wall time. Log both stamp types, merge the files, and count the contradictions each sort produces.

      Robot X sends a message with counter 7. Robot Y has counter 12 when it receives it. What is Y’s counter after the receive?

      Chapter 8

      Reboot Reasons, Crash Capture and the Field Debug Loop

      Capture why a robot restarted, group the reasons across the fleet, and see one bad firmware version stand out

      On Tuesday morning the dashboard shows 45 robots with an uptime of under 6 hours. They all restarted overnight. Nobody was there. The logs from before each restart end in the middle of a line. A restart is a symptom with no story: was it a power cut, a software crash, a watchdog, a person pressing a button?

      Without the reason, the only fix is to guess. This chapter builds the habit of capturing a reason at every restart and then reading the fleet-wide pattern.

      Two places a reason hides

      The chip remembers. Most microcontrollers keep a few flag bits that say what caused the last reset. On many STM32 parts they sit in a register called RCC_CSR. The flags separate causes such as a power-on or brown-out (the supply voltage dipped), a pin reset, a software-requested reset, and a watchdog. A watchdog is a timer that resets the chip if the program forgets to “pet” it in time. It catches hangs.

      Two traps appear in practice, both reported by developers who use Memfault’s STM32 reboot-tracking code and in ST’s community forum. First, the flags are a bitmask, so more than one can be set at once. Memfault’s code checks them in a fixed priority order to pick one reason. Second, something may clear them before your code looks: a boot loader that calls the HAL de-init function wipes the flags. The fix is to read the register at the very start of main(), save the value, and then clear the flags so the next reset reports cleanly. Some parts also cannot tell a power-on reset from a brown-out; on the STM32L4 port both map to power-on.

      c/* first lines of main(): read, keep, clear (STM32, CMSIS names vary by part) */
      uint32_t reset_flags = RCC->CSR;      /* a bitmask: several bits can be set */
      RCC->CSR |= RCC_CSR_RMVF;            /* clear them for the next reset */
      boot_log_reason(classify(reset_flags));  /* store in noinit RAM or flash */

      The RAM remembers. On Linux, a kernel panic prints a message and then the machine restarts, and the message is gone. pstore is a file system that keeps such records across a restart, and ramoops is a pstore back end that writes them into a reserved block of RAM. The kernel documentation says ramoops needs a system with persistent RAM, so the content survives a restart, and that after a hardware reset such as a watchdog the memory “may be somewhat corrupt, but usually it is restorable”. A power cut erases RAM, so ramoops tells you nothing about it. The absence of a record, together with a power-on flag, is itself the clue.

      You reserve the block with parameters: mem_address and mem_size for where and how big, record_size for the size of each dump, and optional ecc for error-correcting data. After the reboot, each stored dump appears as a file named dmesg-ramoops-0, dmesg-ramoops-1 and so on.

      sh# kernel command line (addresses are examples: reserve real RAM on your board)
      ramoops.mem_address=0x8f000000 ramoops.mem_size=0x100000 ramoops.record_size=0x4000 ramoops.ecc=1
      
      # after the reboot
      mount -t pstore pstore /mnt
      cat /mnt/dmesg-ramoops-0      # the last panic text, then upload it with the reboot event

      From one robot to the fleet

      At every boot, the robot builds one reboot event: the chip’s reset flags, whether a pstore record exists, a marker that says whether the last shutdown was clean (planned update, user command), the firmware version, the hardware revision, the uptime before the reset, and the last heartbeat time. That event is small, a few hundred bytes, and rare, so it fits the telemetry budget from Chapter 3.

      The cloud then groups the events by reason and by cohort. The device below holds a made-up week for 200 robots: 120 on firmware 1.4.1 and 80 on 1.4.2. Choose a view and compare.

      Read the reboot dashboard

      Bars show reboots per 100 robots in one week, by reason. The line is a target for unplanned reboots. Switch the firmware, then switch reason capture off.

      Synthetic counts, one week. 1.4.1 (120 robots): planned 14, watchdog 6, panic 4, brown-out 5, power loss 9, unknown 2. 1.4.2 (80 robots): planned 9, watchdog 31, panic 3, brown-out 4, power loss 6, unknown 1. Target: at most 25 unplanned reboots per 100 robots per week.

      On 1.4.2, the watchdog accounts for 31 of the 45 unplanned reboots: 38.8 per 100 robots, against 5.0 on 1.4.1, which is 7.8 times higher. The panic count is flat, so the bug is a hang and not a crash. Together the numbers point the engineer at one firmware change. The panic records, when they exist, then name the function.

      Now switch capture off. Every unplanned reboot lands in one bar called unknown, and the 1.4.2 regression disappears into noise. That is the whole case for this chapter.

      From a module metric to a fleet target

      A service level indicator (SLI) is a measured number about health. A service level objective (SLO) is the target you promise for it. Here the SLI is unplanned reboots per 100 robots per week, and the SLO is 25. The metrics ladder lesson shows how a measure on one module climbs to a number the whole company can track. Check the SLI per firmware cohort, not only for the whole fleet: 1.4.2 scores 56.3 and breaches the target while 1.4.1 scores 21.7 and does not. This number is also the health signal for the rollout gate in Chapter 4.

      The field debug loop

      1. Robots send reboot events with reasons.
      2. The dashboard groups them by reason, firmware and hardware revision.
      3. A cohort breaches its target, and the gate halts the rollout.
      4. An engineer reads the attached panic text or the watchdog context.
      5. A fix is built, tested on the bench (see bench and root cause) and rolled out in waves.
      6. The same chart confirms the fix: the bar shrinks.

      On real hardware: on an STM32 Nucleo, write the reset flags to the serial port at boot. Then force each cause in turn: press the reset pin, call the software reset, and stop petting the watchdog. Record which flag set each time.

      Robots lose power, so RAM is wiped, then boot again. What does ramoops show on the next boot?

      Chapter 9

      Field Guide

      Keep the numbers, the checklist and the failover state machine in one place, and pick where to go next

      The one-paragraph summary

      A fleet runs on networks it does not own, so each robot carries its own evidence. A state machine watches heartbeats, probes the path in order, names the first failing step and moves to a backup link (Chapters 0 and 1). The modem is a second computer, and two swap experiments say whose bug it is (Chapter 2). Telemetry is a budget: metrics always, events when something happens, logs only around a trigger (Chapter 3). Updates and patches go out in waves behind a gate that actually looks (Chapters 4 and 5). Spans across machines need a trace ID from the first hardware stamp and recorded clock offsets (Chapter 6). Order that must hold under bad clocks uses a Lamport counter (Chapter 7). Every restart records its reason, and the fleet reads the pattern (Chapter 8).

      The numbers that matter

      WhatNumberSource or note
      Linux TCP keepalive defaults7200 s idle, 75 s interval, 9 probes = 7875 s (about 2 h 11 min)tcp(7) manual page; tune all three on a robot
      MQTT server timeout1.5 × Keep Alive; 30 s becomes 45 sMQTT 5.0, section 3.1.2.10
      Detection and recovery (model)3 × 2 s + 6 s modem + 1.5 s VPN = 13.5 sThis lesson, illustrative timers
      Crystal drift50 ppm = 3 ms a minute, 180 ms an hour, 4.32 s a dayArithmetic: 50 × 10−6 × seconds
      NTP accuracyabout 5 to 100 ms over the Internet; within 1 ms on a quiet subnetntp.org FAQ
      Offset and delayθ = ½[(T2−T1)+(T3−T4)], δ = (T4−T1)−(T3−T2)RFC 5905, section 8
      traceparent header00 - 32 hex - 16 hex - 2 hex = 55 charactersW3C Trace Context
      Canary arithmetic5% canary failing 20% of requests = 1% overallGoogle SRE Workbook, canarying releases
      Bad build, 1,000 robots, p = 2%20 bricked at once; 4.1 expected with 1%, 10%, 100% waves and a gateThis lesson, exact expectation
      Telemetry (model)50 series at 1 Hz, 16 bytes = 69.1 MB a day; debug logs 432 MB a dayThis lesson, illustrative sizes
      Kernel LTS lines6.12 (17 Nov 2024) and 6.18 (30 Nov 2025), projected end Dec 2028kernel.org releases page; dates can change
      Lamport receive rulecounter = max(own, message) + 1Lamport 1978, rules IR1 and IR2
      ramoops parametersmem_address, mem_size, record_size, ecc; files dmesg-ramoops-NLinux kernel documentation, ramoops
      5G RedCap3GPP Release 17; up to 20 MHz in FR1Secondary industry sources; check TR 38.875

      The failover state machine as code

      This is Chapter 0 as a small C program. It runs once a second, owns no threads and does only the decision. The probes and the modem control are functions you provide.

      ctypedef enum { WIFI_OK, SUSPECT, PROBING, MODEM_UP, VPN_UP, CELL_OK } state_t;
      
      typedef struct {
          state_t state;
          int missed;            /* heartbeats missed in a row */
          int k;                 /* trust slider: misses before failover (3) */
          int vpn_required;
          uint32_t t_state;       /* monotonic seconds when we entered the state */
          int failed_probe;      /* index of the first failing probe, -1 if none */
      } fsm_t;
      
      static void enter(fsm_t *f, state_t s, uint32_t now) { f->state = s; f->t_state = now; }
      
      void fsm_tick(fsm_t *f, uint32_t now, int heartbeat_ok) {
          switch (f->state) {
          case WIFI_OK:
              f->missed = heartbeat_ok ? 0 : f->missed + 1;
              if (f->missed >= f->k) enter(f, PROBING, now);
              break;
          case PROBING:
              f->failed_probe = run_probe_ladder();      /* link, dhcp, dns, tcp:443, tls, app */
              log_event("root_cause", f->failed_probe, now);   /* the evidence stays on the robot */
              modem_power_on();
              enter(f, MODEM_UP, now);
              break;
          case MODEM_UP:
              if (modem_has_ip()) enter(f, f->vpn_required ? VPN_UP : CELL_OK, now);
              else if (now - f->t_state > 30) { modem_reset(); enter(f, MODEM_UP, now); }
              break;
          case VPN_UP:
              if (vpn_handshake_done()) enter(f, CELL_OK, now);
              break;
          case CELL_OK:
              if (wifi_probe_ladder_passes()) enter(f, WIFI_OK, now);   /* go back when Wi-Fi heals */
              break;
          default: break;
          }
      }

      The fleet checklist

      Where this sits

      The tools here have standard homes. OpenTelemetry defines traces, metrics and logs as signals and the context that joins them. eBPF runs small checked programs inside the Linux kernel, and its own site lists tracing, networking and security as uses, which makes it a candidate for light on-robot observability. Zenoh describes itself as a pub/sub/query protocol that unifies data in motion, data at rest and computation, and says it runs on very constrained hardware and networks. 5G RedCap is a reduced-capability 3GPP Release 17 device class for mid-tier IoT, with a narrower bandwidth (20 MHz in FR1 in the sources I read) and so a cheaper modem. These are options, not requirements: budget the link first, then pick the tool that fits it. Cloud observability products assume a fat, steady pipe; a robot on cellular does not have one.

      Keep going

      Sources I opened

      The takeaway. At fleet scale the network, the clocks and the patch cycle are not yours. What is yours is the evidence a robot keeps about itself and the discipline of releasing in waves. Capture the reason, send it cheaply, and let a gate decide.

      Now press Teach and explain one outage out loud, from memory: how the robot detects it, which probe names the cause, how traffic moves to cellular, and what the robot writes down. Then go back to the instrument at the top, set the detection timer to 10, and say what you would give up.

      Fleets: Connectivity, Telemetry, OTA Rollout and Trace Correlation
      Physical AI Systems, networking track · Back to Gleams