MAVLink

On this page 7

MAVLink (Micro Air Vehicle Link) is a lightweight binary messaging protocol that carries telemetry, commands, missions and parameters between an unmanned vehicle and the software around it. In drone software & autonomy it is the common language of open autopilots such as ArduPilot and PX4, of ground control stations such as Mission Planner and QGroundControl, and of companion computers that run autonomous behaviors.

The protocol was first released in 2009 and is now maintained as an open project within the Dronecode ecosystem. It is deliberately simple: messages are defined in XML files, turned into source code by a generator, and exchanged as compact packets over almost any link, from a 57,600 baud telemetry radio to a UDP socket on a flight-test laptop.

A MAVLink packet is a small, self-delimiting frame that wraps one message with addressing and integrity data. Each frame starts with a magic start byte, carries the sender’s system ID and component ID, a sequence number for detecting lost packets, a message ID and a 16-bit checksum.

The checksum is not computed over the bytes alone. Each message definition contributes a CRC_EXTRA seed derived from its field layout, so two endpoints that were built from mismatched XML definitions reject each other’s packets instead of silently misreading them. This guard is the most common reason a new custom message appears to vanish on the receiving side.

The following table compares the two protocol versions found in the field today.

PropertyMAVLink 1MAVLink 2
Start byte0xFE0xFD
Header and checksum overhead8 bytes12 bytes
Message ID range0 to 255Up to about 16.7 million (24 bits)
Maximum payload255 bytes255 bytes, with trailing zero truncation
Extension fieldsNot supportedSupported without breaking old receivers
Packet signingNot availableOptional 13-byte signature
MAVLink 1 and MAVLink 2 frame properties

MAVLink 2 is the current default in both major autopilot stacks. Its payload truncation drops trailing zero bytes before transmission, which offsets much of the larger header on slow radio links.

Message sets and microservices

MAVLink content is organized into dialects, which are XML files that list messages and enumerations. The common.xml dialect holds messages that every compliant system should understand, while files such as ardupilotmega.xml add autopilot-specific extensions. Code generators such as mavgen produce libraries in C, Python, C++, Java and other languages.

Higher-level behavior is defined as microservices, which are small conversations built from several messages with defined handshakes, retries and acknowledgments. The table lists the microservices that matter most in daily operations.

MicroserviceKey messagesPurpose
HeartbeatHEARTBEATAnnounces presence, vehicle type and mode, usually at 1 Hz
Mission protocolMISSION_COUNT, MISSION_ITEM_INT, MISSION_ACKUploads and downloads waypoint missions, fences and rally points
Parameter protocolPARAM_REQUEST_LIST, PARAM_VALUE, PARAM_SETReads and changes autopilot configuration values
Command protocolCOMMAND_LONG, COMMAND_INT, COMMAND_ACKArms, takes off, changes mode, triggers cameras
File transfer protocolFILE_TRANSFER_PROTOCOLMoves logs and parameter files over the link
Offboard setpointsSET_POSITION_TARGET_LOCAL_NEDLets a companion computer steer the vehicle
Core MAVLink microservices

Telemetry streams such as ATTITUDE, GLOBAL_POSITION_INT and SYS_STATUS are sent periodically. A ground station requests the rate of each stream with the MAV_CMD_SET_MESSAGE_INTERVAL command, which replaced the older and coarser data stream requests.

Addressing, routing and transports

Every MAVLink node has a system ID from 1 to 255 that identifies the vehicle or station, and a component ID that identifies a part of it, such as the autopilot, a camera or a gimbal. Ground control stations conventionally use system ID 255, and each vehicle in a fleet needs a unique system ID to avoid confused telemetry.

Because MAVLink is transport-agnostic, routers such as mavlink-router or MAVProxy forward packets between serial ports and network endpoints. The autopilot itself also routes messages between its links, so a camera on one serial port can be commanded from a ground station on another.

The following table shows typical transports and where each is used.

TransportTypical settingTypical use
Serial telemetry radio57,600 baud, 433 or 915 MHzLong-range link to a ground station
Companion computer UART921,600 baudHigh-rate data to onboard computers
UDPPort 14550 for ground stationsSimulation, Wi-Fi and cellular links
TCPConfigurable portReliable links to tools and log servers
USBVirtual serial portBench configuration and firmware setup
Common MAVLink transports

MAVLink is a wire protocol, not an application programming interface, which is why several layers are built on top of it. MAVSDK wraps MAVLink in a high-level API for missions and offboard control, while MAVROS bridges MAVLink to the Robot Operating System. Proprietary ecosystems take another path: the DJI Mobile SDK exposes vehicle functions through a closed vendor interface instead of an open protocol.

InterfaceLayerMain audience
MAVLinkBinary wire protocolAutopilot and ground station developers
MAVSDKHigh-level library over MAVLinkApplication and integration developers
MAVROSROS bridge over MAVLinkRobotics and research teams
DJI Mobile SDKProprietary vendor APIApps for DJI aircraft
Where MAVLink sits among drone interfaces

Inside the onboard flight software, PX4 uses its own uORB publish and subscribe bus for internal data. MAVLink is used only at the boundary of the vehicle, where messages leave for the ground station, payloads or a companion computer.

Security limits and common integration mistakes

MAVLink provides no encryption. Any receiver on the same frequency or network can read telemetry, and without protection any sender can inject commands. MAVLink 2 signing adds authentication with a 32-byte shared secret key, a timestamp and a truncated SHA-256 signature, which blocks spoofed and replayed packets but does not hide content.

Operators who need confidentiality therefore run MAVLink inside an encrypted transport, such as a VPN over a cellular modem or an encrypted radio. Signing also requires careful key distribution, because a vehicle that rejects unsigned packets cannot be reached by a ground station with a missing or wrong key.

The table summarizes problems that integrators meet most often.

SymptomLikely causeFix
Custom message never arrivesCRC_EXTRA mismatch from different XML filesRegenerate code on both ends from one dialect
Two vehicles appear as oneDuplicate system IDsAssign a unique ID to every vehicle
Telemetry lags or dropsStream rates exceed link bandwidthLower message intervals on slow radios
Commands ignoredWrong target system or componentCheck addressing and COMMAND_ACK results
Unknown sender takes controlUnsigned link exposed to a networkEnable signing and an encrypted transport
Typical MAVLink problems and fixes

A plain-language summary

MAVLink is the shared language that a drone and its controllers speak. The drone keeps reporting short status notes, such as where it is, how fast it moves and how full its battery is. The pilot’s software answers with short instructions, such as take off, fly to this point or come home.

Think of it as a standard set of postcards with fixed boxes to fill in. Because everyone uses the same postcards, a drone built by one team can talk to planning software written by another. The main caution is that these postcards are readable by anyone listening unless extra protection is added.

An example from practice

A survey company flies a PX4-based quadcopter over a quarry. A SiK telemetry radio at 57,600 baud links the aircraft to QGroundControl on a field laptop, while a small companion computer on the drone talks to the autopilot over a 921,600 baud serial link. Both connections carry MAVLink, and mavlink-router on the companion computer merges them.

Before takeoff, the operator uploads a 42-waypoint mission with the mission protocol, and the ground station confirms each item with an acknowledgment. During flight, the companion computer reads GLOBAL_POSITION_INT at 10 Hz to geotag images and sends a camera trigger command at each survey line.

When a second drone joins later in the day, the team gives it system ID 2 and enables signing on both aircraft. The result is two vehicles monitored from one screen, with no confused telemetry and no accepted commands from unknown senders.