Link loss and failsafes
UAT 207 Communication and Data Network Systems
Lesson
By the end of this module you will be able to
- Distinguish telemetry loss, GCS failsafe and RC failsafe
- Explain ArduPilot and PX4 failsafe parameters and the defaults to check
- Build a link state machine from heartbeat arrival times
- Choose a timeout by computing the chance of a false failsafe from packet loss
- Distinguish encryption from authentication and explain how MAVLink 2 signing blocks forged and replayed commands
Why this matters
Link loss is one of the most common events in flight, and the system must decide on its own what to do. Set it too sensitive and the drone returns home mid-mission every time the signal stutters; too slow and the drone flies on with nobody able to control it. Lab L10 and the knowledge base’s C2 simulation unit warn that telemetry loss, GCS failsafe and RC loss are different events, and not every case should end in a return home.
Different kinds of failsafe
- Heartbeat: the MAVLink guide says that on RF links components typically send heartbeats at 1 Hz and consider another system disconnected after four or five are missed, while stressing the numbers depend on the channel.
- ArduPilot GCS failsafe: triggers when no GCS heartbeat arrives for
FS_GCS_TIMEOUT(default 5 s), butFS_GCS_ENABLEis disabled by default; you must enable it and choose an action such as RTL or land. - ArduPilot radio (RC) failsafe:
FS_THR_ENABLEdefaults to RTL, andFS_THR_VALUE975 PWM is the throttle level treated as loss of the transmitter signal. - PX4:
COM_DL_LOSS_T(default 10 s) withNAV_DLL_ACT, disabled by default, for the data link;COM_RC_LOSS_T(0.5 s) withNAV_RCL_ACT(default Return) for the RC link.
These defaults come from the documentation and source of the versions checked; always verify them against the firmware actually in use. RTCA DO-400 on lost-C2 procedures gives the overall picture of how to plan ahead.
A link state machine
Example 1 Link state from heartbeat times
Times at which the station received heartbeats (seconds). Warn after 2.5 s without one and declare the link lost after 5 s, matching the default FS_GCS_TIMEOUT.
beats = [0, 1, 2, 3, 4, 5, 6, 12, 13, 14, 15, 16, 17, 18, 19]
WARN_S, LOST_S, DT = 2.5, 5.0, 0.5
state, events = "connected", []
t = 0.0
while t <= 20:
last = max(b for b in beats if b <= t)
age = t - last
new = "lost" if age > LOST_S else "warning" if age > WARN_S else "connected"
if new != state:
events.append((t, state, new, age))
state = new
t += DT
for t, old, new, age in events:
print(f"t = {t:4.1f} s: {old:<9} -> {new:<9} (last heartbeat {age:.1f} s ago)")
t = 9.0 s: connected -> warning (last heartbeat 3.0 s ago)
t = 11.5 s: warning -> lost (last heartbeat 5.5 s ago)
t = 12.0 s: lost -> connected (last heartbeat 0.0 s ago)
When the link returns, the system should not always resume the old mission automatically; that depends on the settings and the team’s procedure. Check in the log how the mode changed.
Choosing a timeout with numbers
If each heartbeat is lost independently with probability , a run of consecutive losses occurs with probability at any given point. But a flight contains thousands of such points, so the chance of meeting at least one is far higher.
Example 2 Chance of a false failsafe per flight
Heartbeats at 1 Hz over a 30-minute flight (1,800 beats); the chance of at least one run of N consecutive losses, computed by tracking the current run length.
def false_failsafe(p, n_timeout, n_beats=1800):
run = [1.0] + [0.0] * n_timeout # run[r] = chance of currently having r consecutive losses
for _ in range(n_beats):
new = [0.0] * (n_timeout + 1)
for r in range(n_timeout):
new[0] += run[r] * (1 - p)
new[r + 1] += run[r] * p
new[n_timeout] += run[n_timeout]
run = new
return run[n_timeout]
print("loss p | N=3 N=5 N=10")
for p in (0.05, 0.1, 0.2, 0.3):
print(f"{p:6.2f} | " + " ".join(f"{false_failsafe(p, n):9.2e}" for n in (3, 5, 10)))
loss p | N=3 N=5 N=10
0.05 | 1.92e-01 5.33e-04 1.66e-10
0.10 | 8.03e-01 1.60e-02 1.61e-07
0.20 | 1.00e+00 3.69e-01 1.47e-04
0.30 | 1.00e+00 9.54e-01 7.38e-03
With 10% packet loss, a 3-second timeout gives about an 80% chance of a false failsafe in a half-hour flight; 5 seconds brings it to about 2%, and 10 seconds makes it negligible. But a long timeout means the drone flies on longer when the link really is lost, so both sides must be weighed. This model assumes independent losses, which is often untrue because losses come in bursts, so check against real logs.
Data security and MAVLink 2 message signing
A link can be lost by accident, but it can also be attacked on purpose: someone listens to the telemetry, sends a fake command, or records a real command and plays it back later (a replay attack). Data security has three separate goals, and each needs its own tool.
- Confidentiality: only the intended people can read the data. The tool is encryption, which scrambles data with a secret key; for example AES in GCM mode, which NIST SP 800-38D specifies and which protects both confidentiality and authenticity at once.
- Integrity and authentication: the data has not been changed and really comes from who it claims to. The tool is a message authentication code, a short tag computed from the message and a secret key; anyone without the key cannot produce a correct tag.
- Availability: the link keeps working. Encryption cannot stop jamming, so this goal relies on failsafes and backup links (the first half of this module).
MAVLink 2 message signing serves the second goal. The MAVLink guide specifies that a signed frame sets bit 0x01 of the incompat_flags header field and appends 13 bytes: a link ID (1 byte), a timestamp (6 bytes, in units of 10 µs since 1 January 2015 GMT) and a signature (6 bytes), which is the first 48 bits of a SHA-256 hash of the 32-byte secret key followed by the whole frame up to and including the timestamp. Both ends hold the same key. Every new timestamp must be greater than the last one on the same link, so the receiver rejects a frame whose timestamp is not newer, which blocks replays. The guide also says plainly that signing does not encrypt anything.
In ArduPilot, keys are created and loaded through Mission Planner (SETUP > Advanced > MAVLink Signing), and the port must use MAVLink 2. The documentation states that once signing is on, non-USB serial ports ignore unsigned commands, while USB is unaffected and telemetry downlink data is unaffected: an eavesdropper within range can still read everything the drone sends.
Field networks have the same gaps. Meshtastic encrypts each packet’s payload with AES256-CTR using the channel key, but headers stay readable, and the primary channel ships with a known default key, so it is effectively public until the team changes it. The Meshtastic documentation itself states that channel (group) encryption provides no integrity check, no sender authentication and no forward secrecy, and is not equivalent to WPA3 or TLS 1.3; since firmware 2.5, direct messages between updated nodes use public-key cryptography with an integrity check, but group traffic still depends on the shared channel key. On IP links over 4G or the internet, put MAVLink and video inside an encrypted tunnel or TLS (RFC 9846, which replaced RFC 8446 in 2026) instead of opening ports (Module 3).
Example 3 Signing a command and catching forgeries
The GCS (system 255, component 190) sends a signed Return to Launch command (COMMAND_LONG, message 76, CRC_EXTRA 152, MAV_CMD 20). The frame builder follows the same structure as Module 3 Example 2. The key is made from a team passphrase (assumed). Then we test three attacks: changing the command to disarm (MAV_CMD 400) and recomputing the CRC, replaying the old frame, and signing with a guessed key.
import hashlib
import struct
def crc_x25(data, crc=0xFFFF):
for b in data:
tmp = b ^ (crc & 0xFF)
tmp = (tmp ^ (tmp << 4)) & 0xFF
crc = ((crc >> 8) ^ (tmp << 8) ^ (tmp << 3) ^ (tmp >> 4)) & 0xFFFF
return crc
KEY = hashlib.sha256(b"mangrove team passphrase").digest() # 32-byte shared secret (assumed)
T2015 = 1420070400 # 1 Jan 2015 00:00 UTC in Unix seconds
def command_long(cmd, p1=0.0): # COMMAND_LONG (msgid 76, CRC_EXTRA 152) to system 1
return struct.pack("<7fHBBB", p1, 0, 0, 0, 0, 0, 0, cmd, 1, 1, 0)
def signed_frame(seq, payload, unix_s, key=KEY, link_id=0):
hdr = bytes([0xFD, len(payload), 0x01, 0, seq, 255, 190]) + (76).to_bytes(3, "little")
body = hdr + payload + struct.pack("<H", crc_x25(hdr[1:] + payload + bytes([152])))
stamp = round((unix_s - T2015) * 100_000) # units of 10 microseconds
body += bytes([link_id]) + stamp.to_bytes(6, "little")
return body + hashlib.sha256(key + body).digest()[:6]
last = {}
def check(frame):
body, sig = frame[:-6], frame[-6:]
if hashlib.sha256(KEY + body).digest()[:6] != sig:
return "REJECT bad signature"
stream = (frame[-13], frame[5], frame[6]) # link id, system id, component id
stamp = int.from_bytes(frame[-12:-6], "little")
if stamp <= last.get(stream, -1):
return "REJECT old timestamp (replay)"
last[stream] = stamp
return "accept"
rtl = signed_frame(7, command_long(20), 1790000000.0) # MAV_CMD_NAV_RETURN_TO_LAUNCH
print(f"frame {len(rtl)} bytes = 12 header/CRC + {len(rtl) - 25} payload + 13 signature")
print("1 genuine RTL :", check(rtl))
forged = bytearray(rtl)
forged[10 + 28:10 + 30] = (400).to_bytes(2, "little") # change the command to ARM_DISARM
forged[10 + 33:10 + 35] = struct.pack("<H", crc_x25(bytes(forged[1:43]) + bytes([152])))
print("2 command altered :", check(bytes(forged)))
print("3 old frame replayed :", check(rtl))
print("4 attacker's own key :", check(signed_frame(8, command_long(400), 1790000001.0, key=bytes(32))))
frame 58 bytes = 12 header/CRC + 33 payload + 13 signature
1 genuine RTL : accept
2 command altered : REJECT bad signature
3 old frame replayed : REJECT old timestamp (replay)
4 attacker's own key : REJECT bad signature
In case 2 the attacker recomputed the CRC, so the CRC check of Module 3 passes; only the signature catches the change, because the CRC protects against noise, not against people. The instructor checked that pymavlink 2.4.50, loaded with the same key, accepts the genuine frame. Signing adds 13 bytes to each frame, little for commands. Keep the key secret and change it if a GCS laptop is lost, and remember that the telemetry itself is still readable.
Module lab
Lab: cutting and restoring the link in SITL (L10)
- Start SITL and a GCS, recording all failsafe parameters before starting.
- Enable the GCS failsafe with the action the team chose and set the timeout from your calculation.
- Stop MAVProxy forwarding, recording when you stopped it and when the mode changed.
- Restore it and record the behaviour, comparing with the code from Example 1.
- Separate the results for telemetry loss, GCS failsafe and RC loss in the report.
Common mistakes
Watch out
- Assuming the failsafe is enabled by default.
- A timeout too short, causing frequent returns.
- A timeout too long without considering how far the drone flies on.
- Not testing failsafes in simulation first.
- Using documented defaults without checking the real firmware.
- Believing signing encrypts the data, or leaving Meshtastic on its default key.
Summary
- Telemetry loss, GCS failsafe and RC loss are different events that need separate settings.
- ArduPilot: FS_GCS_TIMEOUT 5 s but FS_GCS_ENABLE off by default · PX4: COM_DL_LOSS_T 10 s with NAV_DLL_ACT off by default.
- A link state machine uses the age of the latest heartbeat to set the state.
- Choose the timeout from the false failsafe chance and the distance flown on a real loss.
- Encryption keeps data secret, authentication proves who sent it; MAVLink 2 signing adds 13 bytes (link ID, timestamp, 48-bit SHA-256 signature) and rejects forged and replayed commands but does not encrypt.
Check your understanding
- According to the MAVLink guide, when is a system usually considered disconnected on a radio link?
- Heartbeats are lost with probability 0.1. What is the chance of three consecutive losses at one point?
- Why is the false failsafe chance per flight much higher than ?
- An attacker changes a MAVLink command and recomputes the CRC. Why does MAVLink 2 signing still catch it?
- A drone flies at 20 m/s with a 10 s timeout. How far does it fly after a real link loss before the failsafe starts?
Answers
- After four or five missed heartbeats (at 1 Hz).
- A flight has thousands of time points, each a chance for it to happen.
- The attacker does not have the secret key, so cannot compute the matching signature over the changed frame; the CRC only guards against noise.
- m
Key formulas
| Chance of N consecutive losses at one point | |
| Time the link is declared lost |
Key references
- MAVLink Development Team. Heartbeat/connection protocol. MAVLink developer guide. link
- ArduPilot Dev Team. GCS failsafe. ArduPilot Copter documentation. link
- ArduPilot Dev Team. Radio failsafe. ArduPilot Copter documentation. link
- PX4 Autopilot. Safety (failsafe) configuration. PX4 user guide (main). link
- RTCA. (2023). Guidance material: Lost C2 link procedures (DO-400). link
- MAVLink Development Team. Message signing (authentication). MAVLink developer guide. link
- ArduPilot Dev Team. MAVLink2 signing. ArduPilot Copter documentation. link
- Meshtastic. Encryption. Meshtastic documentation. link
- Dworkin, M. (2007). Recommendation for block cipher modes of operation: Galois/Counter Mode (GCM) and GMAC (NIST SP 800-38D). National Institute of Standards and Technology. link
- Rescorla, E. (2026). The Transport Layer Security (TLS) protocol version 1.3 (RFC 9846). RFC Editor. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
In class / field
Lab or field practice from worksheets with a safety checklist
Learning evidence: Checked worksheets and quiz results