GSMCode.PRO
Engineering Documentation
Back to All Guides

Android Debug Bridge (ADB) Architecture: Transport Protocol, Server-Daemon Sockets & Authorization State Machine

GSMCode.PRO Core Systems Team • November 2026 • 7 min read • Protocol Internals
Sponsored Advertisement
Responsive In-Article Display Ad Slot (Top Article Placement)

The Android Debug Bridge (ADB) is the universal control plane for Android hardware diagnostics, automated testing, and recovery servicing. Behind the command-line adb utility lies a multi-component distributed system consisting of client applications, a long-lived local server daemon running on TCP port 5037, and the device-resident adbd daemon.

1. Three-Tier Architectural Hierarchy

2. Low-Level Transport Packet Framing

Every message over the physical USB bulk pipe starts with a fixed 24-byte header:

ADB Message Header Structure (24 Bytes) AOSP Transport Layer
struct amessage {
    uint32_t command;       /* Command identifier (e.g. A_CNXN, A_OPEN, A_OKAY) */
    uint32_t arg0;          /* First argument (e.g. local stream ID) */
    uint32_t arg1;          /* Second argument (e.g. remote stream ID) */
    uint32_t data_length;   /* Length of payload payload in bytes */
    uint32_t data_check;    /* Checksum of data payload (sum of all bytes) */
    uint32_t magic;         /* Command ^ 0xFFFFFFFF for integrity validation */
};
Sponsored Advertisement
Mid-Article Technical Documentation Banner Slot

3. The RSA Keypair Authorization State Machine

Since Android 4.2.2, all ADB connections require cryptographic mutual authentication. When a diagnostic client opens an ADB connection:

  1. Host sends A_CNXN (Connect).
  2. Device responds with an A_AUTH challenge containing a random 20-byte token.
  3. Host signs the token with its private RSA key (~/.android/adbkey) and returns the signature.
  4. If the host public key exists in /data/misc/adb/adb_keys, the device grants access (A_CNXN device).
  5. If unrecognized, the device displays the interactive "Allow USB debugging?" trust prompt on the touchscreen.

Diagnostic Tip: Resolving "Offline" Device States

A device listed as offline indicates that the USB transport handshake completed, but the higher-level socket stream timed out or failed RSA key validation. Killing the host server via adb kill-server && adb start-server and refreshing USB power re-triggers the full authentication state machine cleanly.

Previous: C# Desktop Diagnostic Architecture Back to Documentation Hub