# SoundGrid Protocol: Byte-Level Map
This map was reverse-engineered from network captures of real SoundGrid devices (the captures aren't in this repository). Every SoundGrid frame in the 21 original captures decodes with **zero unexplained bytes** using `tools/sg_decode.py`. That means every byte belongs to a named field. Some fields still have only a provisional name, and the confidence column marks those.
- `decoded_examples.md`: one real frame of each of the 65 message types, decoded field by field.
- `tools/sg_decode.py`: the decoder (`--summary` shows coverage, `--filter` and `--hex` show frames).
- `wireshark/soundgrid.lua`: a Wireshark dissector that uses the same rules.
- `tools/fake_d.py`: a control-plane emulator of a DiGiGrid D that runs as clock slave. It is checked byte for byte against the captures (§13), and live it syncs to the IOC and is claimed by the controller. **It encodes every rule in this map that a device needs, so treat it as the reference implementation for the FPGA.**
- [`FPGA_control_spec.md`](FPGA_control_spec.md): the control-plane specification for the bridge's FPGA, written from this map and `fake_d.py` (interim D identity, every borrowed value marked).
- `tools/fake_d16.py`: the same fake reporting 16 × 16 channels (it was still shown as 4 × 4, §5.6).
- `tools/scan_models.py`: steps the fake through firmware model numbers and records how the controller treats each (§10.4).
- `screenshots/`: the controller UI for each model number the scan made visible (`model13_D.png` etc.).
- Captures added later: the D-as-slave capture (port mirror of the real D as clock slave: attach, sync, routed audio, unplug; §10.2), the IOC-session capture (IOC added to a session, routed, identified, removed; §10.3), the IOC power-on capture (IOC from power-on; §10.4). All three also decode with zero unexplained bytes.
**Key results so far:**
- A slave syncs to the clock master with 10 `sync.unicast` → `sync.03` timestamp exchanges, reporting `clock_state` 2 (syncing), then 1 (locked) in the master's timebase (§10.2). Without this the UI shows the device as not synced; with it, green "SOE". It re-syncs whenever the controller sends `announce_master` (new rate or new master); if the master disappears it stays locked and free-runs until the controller fails over (§10.6–10.9).
- **The device model is the firmware reply's words 3 and 7** (13 = DiGiGrid D, 9 = IOC, 1–13 all registered, §10.4). It alone sets the manufacturer, model name, picture and I/O in the UI and the model-specific `clock.property` the controller reads; a device only syncs and appears after that property is answered correctly. The reported channel counts have no visible effect; the presence name is only used as the label for an unknown model.
- **A device whose model is a master candidate must be able to become master.** When the master fails, the controller retries `set_master`/`announce_master` on the candidate about 5 times a second forever; a slave-only device that refuses stalls the system (§10.11).
- **A new device needs a registered model number *and* a device module installed in the controller.** Model numbers this SoundGrid Studio (14.9) has no module for (16 and up) are rejected with an "incompatible device" dialog (§10.4).
This file has been truncated. show original