Skip to content

Discovery Protocol

GhostTypes edited this page Mar 16, 2026 · 3 revisions

Discovery Protocol

FlashForge printers use UDP-based discovery protocols to announce their presence on the network. A robust client implementation must handle both modern and legacy protocols to support the full printer fleet.

Protocol Overview

Family Protocol Type Ports Packet Size Key Identifier
Modern (5M / 5M Pro / AD5X) UDP Broadcast & Multicast 19000 (Multi), 48899 (Broad) 276 bytes Serial Number (Offset 0x92)
Legacy (A3 / A4 Pro) UDP Multicast 8899 140 bytes Machine Name (Offset 0x00)

Multicast Group: 225.0.0.9

Modern Protocol (5M / 5M Pro / AD5X)

Discovery Mechanism

Modern printers listen on both multicast and broadcast addresses:

Type Address Port
Multicast 225.0.0.9 19000
Broadcast 255.255.255.255 48899

Probe: Send any UDP packet (payload ignored) to either address.

Response: Fixed-size binary packet (276 bytes).

Packet Structure

Total Size: 276 bytes (0x114) (Big Endian)

Offset Size Type Description
0x00 128 char[] Machine Name (null-terminated)
0x80 4 bytes Padding (zeroed)
0x84 2 uint16 Command Port (TCP) - typically 8899
0x86 2 uint16 VID - typically 0x2B71
0x88 2 uint16 PID - 0x0024 or 0x0026
0x8A 2 uint16 Status Code (0=Ready, 1=Busy, 2=Error)
0x8C 2 uint16 Product Type (e.g., 0x5A02)
0x8E 2 uint16 HTTP/Event Port - typically 8898
0x90 1 uint8 LAN Mode flag (0=cloud, 1=LAN-only)
0x91 1 uint8 Reserved
0x92 128 char[] Serial Number (null-terminated)
0x112 2 bytes Padding (zeroed)

Detection Logic

Packets with length >= 196 bytes (0xC4) should be parsed as modern protocol.

Legacy Protocol (Adventurer 3 / 4 Pro)

Discovery Mechanism

Legacy printers listen on multicast only:

Type Address Port
Multicast 225.0.0.9 8899

Probe: Send any UDP packet to the multicast address.

Response: Fixed-size binary packet (140 bytes).

Packet Structure

Total Size: 140 bytes (Big Endian)

Offset Size Type Description
0x00 128 char[] Machine Name (null-terminated)
0x80 4 bytes Padding (zeroed)
0x84 2 uint16 Command Port (TCP) - typically 8899
0x86 2 uint16 Vendor ID - typically 0x2B71
0x88 2 uint16 Product ID - e.g., 0x001D
0x8A 2 uint16 Status Code (0=Ready)

Detection Logic

Packets with length == 140 bytes should be parsed as legacy protocol.

Important Limitation

The legacy packet does not contain the Serial Number. To retrieve the SN for unique identification, you must:

  1. Connect via TCP to port 8899
  2. Send ~M115
  3. Parse the Serial Number from the response

Unified Implementation Strategy

To auto-discover any FlashForge printer:

1. Create UDP Socket

Bind a UDP socket capable of receiving from multiple interfaces.

2. Send Probes

Send discovery probes to all known addresses:

225.0.0.9:19000   (Modern Multicast)
255.255.255.255:48899   (Modern Broadcast)
225.0.0.9:8899    (Legacy Multicast)

3. Parse Responses

Parse responses based on packet length:

Packet Length >= 196  --> Modern Protocol
Packet Length == 140  --> Legacy Protocol

4. Handle Legacy Printers

For legacy printers, initiate a TCP connection to retrieve the serial number.

Discovery Response Summary

Field Modern (276 bytes) Legacy (140 bytes)
Machine Name Yes (offset 0x00, 128B + 4B pad) Yes (offset 0x00, 128B + 4B pad)
Serial Number Yes (offset 0x92, 128B + 2B pad) No (requires TCP)
Command Port Yes (offset 0x84) Yes (offset 0x84)
HTTP/Event Port Yes (offset 0x8E) No
Status Code Yes (offset 0x8A) Yes (offset 0x8A)
VID/PID Yes (offsets 0x86, 0x88) Yes (offsets 0x86, 0x88)
Product Type Yes (offset 0x8C) No
LAN Mode Yes (offset 0x90, 1 byte) No

Troubleshooting

No Responses Received

  1. Verify the printer is powered on and connected to the network
  2. Check firewall settings allow UDP traffic on discovery ports
  3. Ensure the client is on the same network segment as the printer
  4. Try direct IP connection if discovery fails

Multiple Responses

A single printer may respond to multiple probe addresses. Use the IP address or serial number to deduplicate responses.

Legacy Printer Identification

For legacy printers, always fetch the serial number via TCP ~M115 before caching or displaying printer details. The machine name alone may not be unique across multiple printers.

Clone this wiki locally